diff --git a/.clang-format b/.clang-format index a90689185b665d6abd00a2ba5b81d714456e3dcb..51624c6077217649770cddf9405b4d95970e8946 100644 --- a/.clang-format +++ b/.clang-format @@ -4,7 +4,7 @@ AllowAllConstructorInitializersOnNextLine: true AllowShortFunctionsOnASingleLine: Inline AllowShortIfStatementsOnASingleLine: false BreakBeforeBinaryOperators: NonAssignment -BreakBeforeBraces: Linux +BreakBeforeBraces: Attach BreakConstructorInitializers : BeforeComma ColumnLimit: 100 ConstructorInitializerAllOnOneLineOrOnePerLine: true diff --git a/Base/Axis/Bin.cpp b/Base/Axis/Bin.cpp index 993a04d0fa53f65526d2d2b36ceeb51fce1554ab..a407344afedf45f632dfb0b2cdec2c8c517a1e83 100644 --- a/Base/Axis/Bin.cpp +++ b/Base/Axis/Bin.cpp @@ -14,8 +14,7 @@ #include "Base/Axis/Bin.h" -bool BinContains(const Bin1D& bin, double value) -{ +bool BinContains(const Bin1D& bin, double value) { if (bin.binSize() == 0.0) return false; double coordinate = (value - bin.m_lower) / bin.binSize(); @@ -28,16 +27,14 @@ bool BinContains(const Bin1D& bin, double value) //! creation on Bin1DKVector from alpha and phi bins Bin1DKVector::Bin1DKVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin) - : m_q_lower(), m_q_upper() -{ + : m_q_lower(), m_q_upper() { m_q_lower = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower); m_q_upper = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper); } //! creation on Bin1DCVector from alpha and phi bins Bin1DCVector::Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin) - : m_q_lower(), m_q_upper() -{ + : m_q_lower(), m_q_upper() { m_q_lower = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower).complex(); m_q_upper = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper).complex(); } diff --git a/Base/Axis/Bin.h b/Base/Axis/Bin.h index e3c607c179c220108d6f5882a69812538532fd4a..b62a18d0a3b6728b51d58925bcb0a473bef2a11c 100644 --- a/Base/Axis/Bin.h +++ b/Base/Axis/Bin.h @@ -35,9 +35,8 @@ bool BinContains(const Bin1D& bin, double value); struct Bin1DKVector { Bin1DKVector() : m_q_lower(), m_q_upper() {} - Bin1DKVector(const kvector_t lower, const kvector_t upper) : m_q_lower(lower), m_q_upper(upper) - { - } + Bin1DKVector(const kvector_t lower, const kvector_t upper) + : m_q_lower(lower), m_q_upper(upper) {} Bin1DKVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin); kvector_t center() const { return (m_q_lower + m_q_upper) / 2.0; } @@ -49,8 +48,7 @@ struct Bin1DKVector { //! An one-dimensional range of cvector_t's. //! @ingroup tools_internal -class Bin1DCVector -{ +class Bin1DCVector { public: Bin1DCVector() : m_q_lower(), m_q_upper() {} Bin1DCVector(cvector_t lower, cvector_t upper) : m_q_lower(lower), m_q_upper(upper) {} diff --git a/Base/Axis/ConstKBinAxis.cpp b/Base/Axis/ConstKBinAxis.cpp index 3039de0b2fc0a63d35b9ec666a64fae8ec01663d..546bdb3e4c078fe4f684bc344d65e272c02426e4 100644 --- a/Base/Axis/ConstKBinAxis.cpp +++ b/Base/Axis/ConstKBinAxis.cpp @@ -18,13 +18,10 @@ #include <iomanip> ConstKBinAxis::ConstKBinAxis(const std::string& name, size_t nbins) - : VariableBinAxis(name, nbins), m_start(0), m_end(0) -{ -} + : VariableBinAxis(name, nbins), m_start(0), m_end(0) {} ConstKBinAxis::ConstKBinAxis(const std::string& name, size_t nbins, double start, double end) - : VariableBinAxis(name, nbins), m_start(start), m_end(end) -{ + : VariableBinAxis(name, nbins), m_start(start), m_end(end) { if (m_start >= m_end) throw Exceptions::LogicErrorException( "ConstKBinAxis::ConstKBinAxis() -> Error. start >= end is not allowed."); @@ -41,13 +38,11 @@ ConstKBinAxis::ConstKBinAxis(const std::string& name, size_t nbins, double start setBinBoundaries(bin_boundaries); } -ConstKBinAxis* ConstKBinAxis::clone() const -{ +ConstKBinAxis* ConstKBinAxis::clone() const { return new ConstKBinAxis(getName(), m_nbins, m_start, m_end); } -ConstKBinAxis* ConstKBinAxis::createClippedAxis(double left, double right) const -{ +ConstKBinAxis* ConstKBinAxis::createClippedAxis(double left, double right) const { if (left >= right) throw Exceptions::LogicErrorException( "ConstKBinAxis::createClippedAxis() -> Error. 'left'' should be smaller than 'right'"); @@ -74,8 +69,7 @@ ConstKBinAxis* ConstKBinAxis::createClippedAxis(double left, double right) const return result; } -bool ConstKBinAxis::equals(const IAxis& other) const -{ +bool ConstKBinAxis::equals(const IAxis& other) const { if (!IAxis::equals(other)) return false; if (const ConstKBinAxis* otherAxis = dynamic_cast<const ConstKBinAxis*>(&other)) { @@ -90,8 +84,7 @@ bool ConstKBinAxis::equals(const IAxis& other) const return false; } -void ConstKBinAxis::print(std::ostream& ostr) const -{ +void ConstKBinAxis::print(std::ostream& ostr) const { ostr << "ConstKBinAxis(\"" << getName() << "\", " << size() << ", " << std::setprecision(std::numeric_limits<double>::digits10 + 2) << m_start << ", " << m_end << ")"; diff --git a/Base/Axis/ConstKBinAxis.h b/Base/Axis/ConstKBinAxis.h index 73e895e4b9e85d5ffb5995792b33bb4036554514..90a616fa5896c009072ba3fa61fc0482af06c130 100644 --- a/Base/Axis/ConstKBinAxis.h +++ b/Base/Axis/ConstKBinAxis.h @@ -20,8 +20,7 @@ //! Axis with fixed bin size in sin(angle) space. //! @ingroup tools -class ConstKBinAxis : public VariableBinAxis -{ +class ConstKBinAxis : public VariableBinAxis { public: //! ConstKBinAxis constructor. //! @param name Axis name diff --git a/Base/Axis/CustomBinAxis.cpp b/Base/Axis/CustomBinAxis.cpp index 97e4d58369b828307a49c10e60aced63cfa90b00..4812cfaef637b3e4d9459d4c98dbdfb66a9e48a7 100644 --- a/Base/Axis/CustomBinAxis.cpp +++ b/Base/Axis/CustomBinAxis.cpp @@ -19,8 +19,7 @@ #include <limits> CustomBinAxis::CustomBinAxis(const std::string& name, size_t nbins, double start, double end) - : VariableBinAxis(name, nbins), m_start(start), m_end(end) -{ + : VariableBinAxis(name, nbins), m_start(start), m_end(end) { if (m_start >= m_end) throw Exceptions::LogicErrorException("CustomBinAxis::CustomBinAxis() -> Error." " start >= end is not allowed."); @@ -42,13 +41,11 @@ CustomBinAxis::CustomBinAxis(const std::string& name, size_t nbins, double start setBinBoundaries(bin_boundaries); } -CustomBinAxis* CustomBinAxis::clone() const -{ +CustomBinAxis* CustomBinAxis::clone() const { return new CustomBinAxis(getName(), m_nbins, m_start, m_end); } -Bin1D CustomBinAxis::bin(size_t index) const -{ +Bin1D CustomBinAxis::bin(size_t index) const { if (index >= m_nbins) throw Exceptions::OutOfBoundsException("CustomBinAxis::bin() -> Error. Wrong index."); @@ -56,26 +53,22 @@ Bin1D CustomBinAxis::bin(size_t index) const return result; } -std::vector<double> CustomBinAxis::binCenters() const -{ +std::vector<double> CustomBinAxis::binCenters() const { return m_bin_centers; } -CustomBinAxis* CustomBinAxis::createClippedAxis(double /* left */, double /* right */) const -{ +CustomBinAxis* CustomBinAxis::createClippedAxis(double /* left */, double /* right */) const { throw Exceptions::NotImplementedException("VariableBinAxis::CustomBinAxis() -> Error." " Not implemented."); } -void CustomBinAxis::print(std::ostream& ostr) const -{ +void CustomBinAxis::print(std::ostream& ostr) const { ostr << "CustomBinAxis(\"" << getName() << "\", " << size() << ", " << std::setprecision(std::numeric_limits<double>::digits10 + 2) << m_start << ", " << m_end << ")"; } -bool CustomBinAxis::equals(const IAxis& other) const -{ +bool CustomBinAxis::equals(const IAxis& other) const { if (!IAxis::equals(other)) return false; if (const CustomBinAxis* otherAxis = dynamic_cast<const CustomBinAxis*>(&other)) { diff --git a/Base/Axis/CustomBinAxis.h b/Base/Axis/CustomBinAxis.h index 15ccf6c945af81d7a44296f3fa9b18f65b56dc69..09cbbcbaeb6c021b3f94fe5cb583db19af461493 100644 --- a/Base/Axis/CustomBinAxis.h +++ b/Base/Axis/CustomBinAxis.h @@ -21,8 +21,7 @@ //! The main feature of the axis is that it produces zero bin sizes. //! @ingroup tools -class CustomBinAxis : public VariableBinAxis -{ +class CustomBinAxis : public VariableBinAxis { public: //! CustomBinAxis constructor. //! @param name Axis name diff --git a/Base/Axis/FixedBinAxis.cpp b/Base/Axis/FixedBinAxis.cpp index 23c342633a5c4e9d4e6c9ef2746187955d47045b..9a25c492220c3af333221675f2e5496b4e650357 100644 --- a/Base/Axis/FixedBinAxis.cpp +++ b/Base/Axis/FixedBinAxis.cpp @@ -20,18 +20,14 @@ #include <limits> FixedBinAxis::FixedBinAxis(const std::string& name, size_t nbins, double start, double end) - : IAxis(name), m_nbins(nbins), m_start(start), m_end(end) -{ -} + : IAxis(name), m_nbins(nbins), m_start(start), m_end(end) {} -FixedBinAxis* FixedBinAxis::clone() const -{ +FixedBinAxis* FixedBinAxis::clone() const { FixedBinAxis* result = new FixedBinAxis(getName(), m_nbins, m_start, m_end); return result; } -double FixedBinAxis::operator[](size_t index) const -{ +double FixedBinAxis::operator[](size_t index) const { if (index >= m_nbins) throw Exceptions::OutOfBoundsException("FixedBinAxis::operator[] -> Error. Wrong index."); @@ -39,8 +35,7 @@ double FixedBinAxis::operator[](size_t index) const return m_start + (index + 0.5) * step; } -Bin1D FixedBinAxis::bin(size_t index) const -{ +Bin1D FixedBinAxis::bin(size_t index) const { if (index >= m_nbins) throw Exceptions::OutOfBoundsException("FixedBinAxis::bin() -> Error. Wrong index."); @@ -49,8 +44,7 @@ Bin1D FixedBinAxis::bin(size_t index) const return result; } -size_t FixedBinAxis::findClosestIndex(double value) const -{ +size_t FixedBinAxis::findClosestIndex(double value) const { if (value < lowerBound()) { return 0; } else if (value >= upperBound()) { @@ -61,8 +55,7 @@ size_t FixedBinAxis::findClosestIndex(double value) const return int((value - m_start) / step); } -std::vector<double> FixedBinAxis::binCenters() const -{ +std::vector<double> FixedBinAxis::binCenters() const { std::vector<double> result; result.resize(size(), 0.0); for (size_t i = 0; i < size(); ++i) { @@ -71,8 +64,7 @@ std::vector<double> FixedBinAxis::binCenters() const return result; } -std::vector<double> FixedBinAxis::binBoundaries() const -{ +std::vector<double> FixedBinAxis::binBoundaries() const { std::vector<double> result; result.resize(size() + 1, 0.0); for (size_t i = 0; i < size(); ++i) { @@ -82,8 +74,7 @@ std::vector<double> FixedBinAxis::binBoundaries() const return result; } -FixedBinAxis* FixedBinAxis::createClippedAxis(double left, double right) const -{ +FixedBinAxis* FixedBinAxis::createClippedAxis(double left, double right) const { if (left >= right) throw Exceptions::LogicErrorException("FixedBinAxis::createClippedAxis() -> Error. " "'left' should be smaller than 'right'"); @@ -99,15 +90,13 @@ FixedBinAxis* FixedBinAxis::createClippedAxis(double left, double right) const return new FixedBinAxis(getName(), nbin2 - nbin1 + 1, bin(nbin1).m_lower, bin(nbin2).m_upper); } -void FixedBinAxis::print(std::ostream& ostr) const -{ +void FixedBinAxis::print(std::ostream& ostr) const { ostr << "FixedBinAxis(\"" << getName() << "\", " << size() << ", " << std::setprecision(std::numeric_limits<double>::digits10 + 2) << lowerBound() << ", " << upperBound() << ")"; } -bool FixedBinAxis::equals(const IAxis& other) const -{ +bool FixedBinAxis::equals(const IAxis& other) const { if (!IAxis::equals(other)) return false; if (const FixedBinAxis* otherAxis = dynamic_cast<const FixedBinAxis*>(&other)) { @@ -122,8 +111,7 @@ bool FixedBinAxis::equals(const IAxis& other) const return false; } -std::string FixedBinAxis::pyString(const std::string& units, size_t) const -{ +std::string FixedBinAxis::pyString(const std::string& units, size_t) const { std::ostringstream result; result << "ba.FixedBinAxis(" << pyfmt::printString(getName()) << ", " << size() << ", " << pyfmt::printValue(lowerBound(), units) << ", " diff --git a/Base/Axis/FixedBinAxis.h b/Base/Axis/FixedBinAxis.h index 32ffbdfb793da9150fb7703abed1f4e99fa08201..54e70ab995a9c3a5d65fbd589e2401722cba6ab7 100644 --- a/Base/Axis/FixedBinAxis.h +++ b/Base/Axis/FixedBinAxis.h @@ -20,8 +20,7 @@ //! Axis with fixed bin size. //! @ingroup tools -class FixedBinAxis : public IAxis -{ +class FixedBinAxis : public IAxis { public: //! FixedBinAxis constructor. //! @param name Axis name diff --git a/Base/Axis/IAxis.cpp b/Base/Axis/IAxis.cpp index b69143e1bad2a145c82bbcd0acd6780b99b68d55..0a508d3f9b1646c886c2d493bdb4df2f0b525500 100644 --- a/Base/Axis/IAxis.cpp +++ b/Base/Axis/IAxis.cpp @@ -15,33 +15,27 @@ #include "Base/Axis/IAxis.h" #include "Base/Types/Exceptions.h" -bool IAxis::equals(const IAxis& other) const -{ +bool IAxis::equals(const IAxis& other) const { return getName() == other.getName(); } -std::vector<double> IAxis::binCenters() const -{ +std::vector<double> IAxis::binCenters() const { throw Exceptions::NotImplementedException("IAxis::binCenters() -> Error. Not implemented."); } -std::vector<double> IAxis::binBoundaries() const -{ +std::vector<double> IAxis::binBoundaries() const { throw Exceptions::NotImplementedException("IAxis::binBoundaries() -> Error. Not implemented."); } -IAxis* IAxis::createClippedAxis(double /* left */, double /* right */) const -{ +IAxis* IAxis::createClippedAxis(double /* left */, double /* right */) const { throw Exceptions::NotImplementedException( "IAxis::createClippedAxis() -> Error. Not implemented."); } -bool IAxis::contains(double value) const -{ +bool IAxis::contains(double value) const { return value >= lowerBound() && value < upperBound(); } -double IAxis::span() const -{ +double IAxis::span() const { return upperBound() - lowerBound(); } diff --git a/Base/Axis/IAxis.h b/Base/Axis/IAxis.h index c91b00a05aaf7ecf5ec0746c21cc9938e169ab0b..96a5090d8b2aa29c808824fa78b6f2ded0e569af 100644 --- a/Base/Axis/IAxis.h +++ b/Base/Axis/IAxis.h @@ -21,8 +21,7 @@ //! Interface for one-dimensional axes. //! @ingroup tools_internal -class IAxis -{ +class IAxis { public: //! constructors IAxis(const std::string& name) : m_name(name) {} @@ -66,8 +65,7 @@ public: bool operator==(const IAxis& right) const { return equals(right); } bool operator!=(const IAxis& right) const { return !(*this == right); } - friend std::ostream& operator<<(std::ostream& ostr, const IAxis& m) - { + friend std::ostream& operator<<(std::ostream& ostr, const IAxis& m) { m.print(ostr); return ostr; } @@ -96,8 +94,7 @@ private: }; //! global helper function for comparison of axes -inline bool HaveSameNameAndShape(const IAxis& left, const IAxis& right) -{ +inline bool HaveSameNameAndShape(const IAxis& left, const IAxis& right) { return left == right; } diff --git a/Base/Axis/PointwiseAxis.cpp b/Base/Axis/PointwiseAxis.cpp index 0e0cc1181c026d27b5a9d9680e539a6ce37fb091..f8d578c9539b5809c1e71f8e88c321b48abb1541 100644 --- a/Base/Axis/PointwiseAxis.cpp +++ b/Base/Axis/PointwiseAxis.cpp @@ -20,35 +20,29 @@ const size_t min_axis_size = 2; -PointwiseAxis* PointwiseAxis::clone() const -{ +PointwiseAxis* PointwiseAxis::clone() const { return new PointwiseAxis(getName(), m_coordinates); } -Bin1D PointwiseAxis::bin(size_t index) const -{ +Bin1D PointwiseAxis::bin(size_t index) const { checkIndex(index); return Bin1D(lowerBoundary(index), upperBoundary(index)); } -double PointwiseAxis::lowerBound() const -{ +double PointwiseAxis::lowerBound() const { return lowerBoundary(0); } -double PointwiseAxis::upperBound() const -{ +double PointwiseAxis::upperBound() const { return upperBoundary(m_coordinates.size() - 1); } -double PointwiseAxis::binCenter(size_t index) const -{ +double PointwiseAxis::binCenter(size_t index) const { checkIndex(index); return m_coordinates[index]; } -size_t PointwiseAxis::findClosestIndex(double value) const -{ +size_t PointwiseAxis::findClosestIndex(double value) const { if (value <= m_coordinates.front()) return 0; if (value >= m_coordinates.back()) @@ -60,8 +54,7 @@ size_t PointwiseAxis::findClosestIndex(double value) const return value < lowerBoundary(index) ? index - 1 : index; } -std::vector<double> PointwiseAxis::binBoundaries() const -{ +std::vector<double> PointwiseAxis::binBoundaries() const { std::vector<double> result; const size_t v_size = m_coordinates.size(); result.reserve(v_size + 1); @@ -71,8 +64,7 @@ std::vector<double> PointwiseAxis::binBoundaries() const return result; } -PointwiseAxis* PointwiseAxis::createClippedAxis(double left, double right) const -{ +PointwiseAxis* PointwiseAxis::createClippedAxis(double left, double right) const { if (left >= right) throw std::runtime_error("Error in PointwiseAxis::createClippedAxis: " "'left' should be smaller than 'right'"); @@ -84,8 +76,7 @@ PointwiseAxis* PointwiseAxis::createClippedAxis(double left, double right) const return new PointwiseAxis(getName(), std::vector<double>(begin, end)); } -std::string PointwiseAxis::pyString(const std::string& units, size_t offset) const -{ +std::string PointwiseAxis::pyString(const std::string& units, size_t offset) const { std::ostringstream result; const std::string py_def_call = "numpy.asarray(["; const size_t total_offset = offset + py_def_call.size(); @@ -99,8 +90,7 @@ std::string PointwiseAxis::pyString(const std::string& units, size_t offset) con return result.str(); } -void PointwiseAxis::print(std::ostream& ostr) const -{ +void PointwiseAxis::print(std::ostream& ostr) const { auto precision = std::setprecision(std::numeric_limits<double>::digits10 + 2); ostr << "PointwiseAxis(\"" << getName() << "\", " << ", ["; @@ -109,8 +99,7 @@ void PointwiseAxis::print(std::ostream& ostr) const ostr << precision << m_coordinates.back() << "])"; } -bool PointwiseAxis::equals(const IAxis& other) const -{ +bool PointwiseAxis::equals(const IAxis& other) const { if (!IAxis::equals(other)) return false; if (const PointwiseAxis* otherAxis = dynamic_cast<const PointwiseAxis*>(&other)) @@ -118,22 +107,19 @@ bool PointwiseAxis::equals(const IAxis& other) const return false; } -double PointwiseAxis::lowerBoundary(size_t index) const -{ +double PointwiseAxis::lowerBoundary(size_t index) const { if (index == 0) return m_coordinates.front(); return 0.5 * (m_coordinates[index] + m_coordinates[index - 1]); } -double PointwiseAxis::upperBoundary(size_t index) const -{ +double PointwiseAxis::upperBoundary(size_t index) const { if (index + 1 == m_coordinates.size()) return m_coordinates.back(); return 0.5 * (m_coordinates[index] + m_coordinates[index + 1]); } -void PointwiseAxis::checkIndex(size_t index) const -{ +void PointwiseAxis::checkIndex(size_t index) const { if (m_coordinates.size() > index) return; std::string message = "Error in PointwiseAxis::binCenter: passed index "; @@ -142,8 +128,7 @@ void PointwiseAxis::checkIndex(size_t index) const throw std::runtime_error(message); } -void PointwiseAxis::sanityCheck() const -{ +void PointwiseAxis::sanityCheck() const { if (m_coordinates.size() < min_axis_size) throw std::runtime_error( "Error in PointwiseAxis::PointwiseAxis: the size of passed coordinate array is " diff --git a/Base/Axis/PointwiseAxis.h b/Base/Axis/PointwiseAxis.h index 8a8f2aa6428dd0e4eeaddb72c3ec703b27c4d9d4..bc6265cdc07b9183fa8e303b589f2e29c98338b2 100644 --- a/Base/Axis/PointwiseAxis.h +++ b/Base/Axis/PointwiseAxis.h @@ -29,13 +29,12 @@ //! values passed to the constructor. //! @ingroup tools -class PointwiseAxis : public IAxis -{ +class PointwiseAxis : public IAxis { public: template <class String, class Vector> PointwiseAxis(String&& name, Vector&& coordinate_values) - : IAxis(std::forward<String>(name)), m_coordinates(std::forward<Vector>(coordinate_values)) - { + : IAxis(std::forward<String>(name)) + , m_coordinates(std::forward<Vector>(coordinate_values)) { sanityCheck(); } diff --git a/Base/Axis/VariableBinAxis.cpp b/Base/Axis/VariableBinAxis.cpp index 047da40fe04cb988bd5668ebbcc170deb7994107..cef438eb988c2a2fa152fbb7e38b8a9dda88bdb0 100644 --- a/Base/Axis/VariableBinAxis.cpp +++ b/Base/Axis/VariableBinAxis.cpp @@ -20,8 +20,7 @@ VariableBinAxis::VariableBinAxis(const std::string& name, size_t nbins, const std::vector<double>& bin_boundaries) - : IAxis(name), m_nbins(nbins) -{ + : IAxis(name), m_nbins(nbins) { if (m_nbins != bin_boundaries.size() - 1) throw Exceptions::LogicErrorException( "VariableBinAxis::VariableBinAxis() -> Error! " @@ -31,23 +30,18 @@ VariableBinAxis::VariableBinAxis(const std::string& name, size_t nbins, } VariableBinAxis::VariableBinAxis(const std::string& name, size_t nbins) - : IAxis(name), m_nbins(nbins) -{ -} + : IAxis(name), m_nbins(nbins) {} -VariableBinAxis* VariableBinAxis::clone() const -{ +VariableBinAxis* VariableBinAxis::clone() const { VariableBinAxis* result = new VariableBinAxis(getName(), m_nbins, m_bin_boundaries); return result; } -double VariableBinAxis::operator[](size_t index) const -{ +double VariableBinAxis::operator[](size_t index) const { return bin(index).center(); } -Bin1D VariableBinAxis::bin(size_t index) const -{ +Bin1D VariableBinAxis::bin(size_t index) const { if (index >= m_nbins) throw Exceptions::OutOfBoundsException("VariableBinAxis::bin() -> Error. Wrong index."); @@ -55,23 +49,19 @@ Bin1D VariableBinAxis::bin(size_t index) const return result; } -double VariableBinAxis::lowerBound() const -{ +double VariableBinAxis::lowerBound() const { return m_bin_boundaries.front(); } -double VariableBinAxis::upperBound() const -{ +double VariableBinAxis::upperBound() const { return m_bin_boundaries.back(); } -double VariableBinAxis::binCenter(size_t index) const -{ +double VariableBinAxis::binCenter(size_t index) const { return bin(index).center(); } -size_t VariableBinAxis::findClosestIndex(double value) const -{ +size_t VariableBinAxis::findClosestIndex(double value) const { if (m_bin_boundaries.size() < 2) throw Exceptions::ClassInitializationException( "VariableBinAxis::findClosestIndex() -> Error! " @@ -90,8 +80,7 @@ size_t VariableBinAxis::findClosestIndex(double value) const return nbin; } -std::vector<double> VariableBinAxis::binCenters() const -{ +std::vector<double> VariableBinAxis::binCenters() const { std::vector<double> result; result.resize(size(), 0.0); for (size_t i = 0; i < size(); ++i) { @@ -100,8 +89,7 @@ std::vector<double> VariableBinAxis::binCenters() const return result; } -VariableBinAxis* VariableBinAxis::createClippedAxis(double left, double right) const -{ +VariableBinAxis* VariableBinAxis::createClippedAxis(double left, double right) const { if (left >= right) throw Exceptions::LogicErrorException("VariableBinAxis::createClippedAxis() -> Error. " @@ -124,13 +112,11 @@ VariableBinAxis* VariableBinAxis::createClippedAxis(double left, double right) c return new VariableBinAxis(getName(), new_nbins, new_boundaries); } -std::string VariableBinAxis::pyString(const std::string&, size_t) const -{ +std::string VariableBinAxis::pyString(const std::string&, size_t) const { throw std::runtime_error("VariableBinAxis::pyString not yet implemented"); // TODO } -void VariableBinAxis::print(std::ostream& ostr) const -{ +void VariableBinAxis::print(std::ostream& ostr) const { ostr << "VariableBinAxis(\"" << getName() << "\", " << size() << ", ["; for (size_t i = 0; i < m_bin_boundaries.size(); ++i) { ostr << std::setprecision(std::numeric_limits<double>::digits10 + 2) << m_bin_boundaries[i]; @@ -140,8 +126,7 @@ void VariableBinAxis::print(std::ostream& ostr) const ostr << "])"; } -bool VariableBinAxis::equals(const IAxis& other) const -{ +bool VariableBinAxis::equals(const IAxis& other) const { if (!IAxis::equals(other)) return false; if (const VariableBinAxis* p_other_cast = dynamic_cast<const VariableBinAxis*>(&other)) { @@ -157,8 +142,7 @@ bool VariableBinAxis::equals(const IAxis& other) const return false; } -void VariableBinAxis::setBinBoundaries(const std::vector<double>& bin_boundaries) -{ +void VariableBinAxis::setBinBoundaries(const std::vector<double>& bin_boundaries) { // checking that values are sorted std::vector<double> vec_sorted = bin_boundaries; std::sort(vec_sorted.begin(), vec_sorted.end()); diff --git a/Base/Axis/VariableBinAxis.h b/Base/Axis/VariableBinAxis.h index f86f62ade886d1d371efb4770fff33529193f10c..f43e1c8ae9e0f70904d6e0f7bebc878267b2f457 100644 --- a/Base/Axis/VariableBinAxis.h +++ b/Base/Axis/VariableBinAxis.h @@ -20,8 +20,7 @@ //! Axis with variable bin size. //! @ingroup tools -class VariableBinAxis : public IAxis -{ +class VariableBinAxis : public IAxis { public: //! VariableBinAxis constructor. //! @param name Axis name diff --git a/Base/Const/PhysicalConstants.h b/Base/Const/PhysicalConstants.h index 557c8366ee46b3ef79ab7c44970cf59fd8bb10fb..57ffbf941a84420472b682422040a849deee5616 100644 --- a/Base/Const/PhysicalConstants.h +++ b/Base/Const/PhysicalConstants.h @@ -17,8 +17,7 @@ //! Physical constants. -namespace PhysConsts -{ +namespace PhysConsts { constexpr double m_n = 1.67492749804e-27; //!< Neutron mass, kg constexpr double h_bar = 1.054571817e-34; //!< Reduced Plank constant, J s diff --git a/Base/Const/Units.h b/Base/Const/Units.h index d7ed6454f0120b4132a5c4908bd4844355f9a5f2..b8ce27bb73ea5950d1502f5e409e5bb90d9c75bc 100644 --- a/Base/Const/Units.h +++ b/Base/Const/Units.h @@ -17,8 +17,7 @@ //! Constants and functions for physical unit conversions. -namespace Units -{ +namespace Units { // Length static constexpr double nanometer = 1.; @@ -40,12 +39,10 @@ static constexpr double milliradian = 1.e-3 * radian; static constexpr double degree = (3.1415926535897932 / 180.0) * radian; static constexpr double steradian = 1.; -inline double rad2deg(double angle) -{ +inline double rad2deg(double angle) { return angle / degree; } -inline double deg2rad(double angle) -{ +inline double deg2rad(double angle) { return angle * degree; } diff --git a/Base/Math/Bessel.cpp b/Base/Math/Bessel.cpp index 3c9c35622c53e169b5df531ce32cbd70a1f3366c..278454d86b95f1a744f751588c83bb0717dfa111 100644 --- a/Base/Math/Bessel.cpp +++ b/Base/Math/Bessel.cpp @@ -16,16 +16,14 @@ #include "Base/Math/Constants.h" #include <gsl/gsl_sf_bessel.h> -namespace -{ +namespace { //! Computes the complex Bessel function J0(z), using power series and asymptotic expansion. //! //! Forked from unoptimized code at http://www.crbond.com/math.htm, //! who refers to "Computation of Special Functions", Zhang and Jin, John Wiley and Sons, 1996. -complex_t J0_PowSer(const complex_t z) -{ +complex_t J0_PowSer(const complex_t z) { complex_t cj0; static const double eps = 1e-15; static double a[] = {-7.03125e-2, 0.112152099609375, -0.5725014209747314, @@ -84,8 +82,7 @@ complex_t J0_PowSer(const complex_t z) //! //! Forked from same source as for J0_PowSer -complex_t J1_PowSer(const complex_t z) -{ +complex_t J1_PowSer(const complex_t z) { complex_t cj1; static const double eps = 1e-15; @@ -160,42 +157,35 @@ complex_t J1_PowSer(const complex_t z) // Bessel functions // ************************************************************************************************ -double Math::Bessel::J0(double x) -{ +double Math::Bessel::J0(double x) { return gsl_sf_bessel_J0(x); } -double Math::Bessel::J1(double x) -{ +double Math::Bessel::J1(double x) { return gsl_sf_bessel_J1(x); } -double Math::Bessel::J1c(double x) -{ +double Math::Bessel::J1c(double x) { return x == 0 ? 0.5 : gsl_sf_bessel_J1(x) / x; } -double Math::Bessel::I0(double x) -{ +double Math::Bessel::I0(double x) { return gsl_sf_bessel_I0(x); } -complex_t Math::Bessel::J0(const complex_t z) -{ +complex_t Math::Bessel::J0(const complex_t z) { if (std::imag(z) == 0) return gsl_sf_bessel_J0(std::real(z)); return J0_PowSer(z); } -complex_t Math::Bessel::J1(const complex_t z) -{ +complex_t Math::Bessel::J1(const complex_t z) { if (std::imag(z) == 0) return gsl_sf_bessel_J1(std::real(z)); return J1_PowSer(z); } -complex_t Math::Bessel::J1c(const complex_t z) -{ +complex_t Math::Bessel::J1c(const complex_t z) { if (std::imag(z) == 0) { double xv = std::real(z); return xv == 0 ? 0.5 : gsl_sf_bessel_J1(xv) / xv; diff --git a/Base/Math/Bessel.h b/Base/Math/Bessel.h index 84f4745548f22f0eb7e1b7e1c927a64d51ae82c5..12382765e8b1126fea0a4f899137d8d748e16f4e 100644 --- a/Base/Math/Bessel.h +++ b/Base/Math/Bessel.h @@ -18,12 +18,10 @@ #include "Base/Types/Complex.h" #include <vector> -namespace Math -{ +namespace Math { //! Real and complex Bessel functions -namespace Bessel -{ +namespace Bessel { //! Bessel function of the first kind and order 0 double J0(double x); diff --git a/Base/Math/Functions.cpp b/Base/Math/Functions.cpp index 4a77f64da35f694db33fc296f4aa87b862427fb6..b50457a2609aa3dedcf85d7b8ac45c504b9e5fd7 100644 --- a/Base/Math/Functions.cpp +++ b/Base/Math/Functions.cpp @@ -28,25 +28,21 @@ // Various functions // ************************************************************************************************ -double Math::StandardNormal(double x) -{ +double Math::StandardNormal(double x) { return std::exp(-x * x / 2.0) / std::sqrt(M_TWOPI); } -double Math::Gaussian(double x, double average, double std_dev) -{ +double Math::Gaussian(double x, double average, double std_dev) { return StandardNormal((x - average) / std_dev) / std_dev; } -double Math::IntegratedGaussian(double x, double average, double std_dev) -{ +double Math::IntegratedGaussian(double x, double average, double std_dev) { double normalized_x = (x - average) / std_dev; static double root2 = std::sqrt(2.0); return (gsl_sf_erf(normalized_x / root2) + 1.0) / 2.0; } -double Math::cot(double x) -{ +double Math::cot(double x) { return tan(M_PI_2 - x); } @@ -73,8 +69,7 @@ complex_t Math::tanhc(const complex_t z) // tanh(x)/x return std::tanh(z) / z; } -double Math::Laue(const double x, size_t N) -{ +double Math::Laue(const double x, size_t N) { static const double SQRT6DOUBLE_EPS = std::sqrt(6.0 * std::numeric_limits<double>::epsilon()); auto nd = static_cast<double>(N); if (std::abs(nd * x) < SQRT6DOUBLE_EPS) @@ -84,8 +79,7 @@ double Math::Laue(const double x, size_t N) return num / den; } -double Math::erf(double arg) -{ +double Math::erf(double arg) { if (arg < 0.0) throw std::runtime_error("Error in Math::erf: negative argument is not allowed"); if (std::isinf(arg)) diff --git a/Base/Math/Functions.h b/Base/Math/Functions.h index 0a836345e551fd1493e7943b78817c9ee2c96ae1..7fe8560926673b03a9988e585cde02500323eb5c 100644 --- a/Base/Math/Functions.h +++ b/Base/Math/Functions.h @@ -20,8 +20,7 @@ //! Various mathematical functions. -namespace Math -{ +namespace Math { // ************************************************************************************************ // Various functions diff --git a/Base/Math/Integrator.cpp b/Base/Math/Integrator.cpp index e63b01b51930a30744687ba8047ade9e4089d359..eecfa02a1400549d2c57123600fd57c4d1c40b19 100644 --- a/Base/Math/Integrator.cpp +++ b/Base/Math/Integrator.cpp @@ -15,17 +15,13 @@ #include "Base/Math/Integrator.h" RealIntegrator::RealIntegrator() - : m_gsl_f{m_Cfunction, nullptr}, m_workspace{gsl_integration_workspace_alloc(200)} -{ -} + : m_gsl_f{m_Cfunction, nullptr}, m_workspace{gsl_integration_workspace_alloc(200)} {} -RealIntegrator::~RealIntegrator() -{ +RealIntegrator::~RealIntegrator() { gsl_integration_workspace_free(m_workspace); } -double RealIntegrator::integrate(const std::function<double(double)>& f, double lmin, double lmax) -{ +double RealIntegrator::integrate(const std::function<double(double)>& f, double lmin, double lmax) { m_gsl_f.params = (void*)&f; double result, error; gsl_integration_qag(&m_gsl_f, lmin, lmax, 1e-9, 1e-7, 200, 3, m_workspace, &result, &error); @@ -34,8 +30,7 @@ double RealIntegrator::integrate(const std::function<double(double)>& f, double } complex_t ComplexIntegrator::integrate(const std::function<complex_t(double)>& f, double lmin, - double lmax) -{ + double lmax) { return {realPart.integrate([f](double x) { return f(x).real(); }, lmin, lmax), imagPart.integrate([f](double x) { return f(x).imag(); }, lmin, lmax)}; } diff --git a/Base/Math/Integrator.h b/Base/Math/Integrator.h index 1146aa2d25104569a177920df7a08a4b87835a1d..a8b05aa3c8ffb1649ad9a11354bfe5ed06d12402 100644 --- a/Base/Math/Integrator.h +++ b/Base/Math/Integrator.h @@ -20,16 +20,14 @@ #include <gsl/gsl_integration.h> //! To integrate a real function of a real variable. -class RealIntegrator -{ +class RealIntegrator { public: RealIntegrator(); ~RealIntegrator(); double integrate(const std::function<double(double)>& f, double lmin, double lmax); private: - static double m_Cfunction(double x, void* p) - { + static double m_Cfunction(double x, void* p) { return (*(const std::function<double(double)>*)(p))(x); }; gsl_function m_gsl_f; @@ -37,8 +35,7 @@ private: }; //! To integrate a complex function of a real variable. -class ComplexIntegrator -{ +class ComplexIntegrator { public: complex_t integrate(const std::function<complex_t(double)>& f, double lmin, double lmax); diff --git a/Base/Math/IntegratorMCMiser.h b/Base/Math/IntegratorMCMiser.h index f3c55f1a6873e92758463dd9734027c5642bedde..a5f78213c718a348da4f08c3ceb4658eba3d2641 100644 --- a/Base/Math/IntegratorMCMiser.h +++ b/Base/Math/IntegratorMCMiser.h @@ -31,8 +31,7 @@ template <class T> using miser_integrand = double (T::*)(double*, size_t, void*) //! - Call: 'integrator.integrate(lmin, lmax, data, nbr_points)' //! @ingroup tools_internal -template <class T> class IntegratorMCMiser -{ +template <class T> class IntegratorMCMiser { public: //! structure holding the object and possible extra parameters struct CallBackHolder { @@ -50,8 +49,7 @@ public: private: //! static function that can be passed to gsl integrator - static double StaticCallBack(double* d_array, size_t dim, void* v) - { + static double StaticCallBack(double* d_array, size_t dim, void* v) { CallBackHolder* p_cb = static_cast<CallBackHolder*>(v); auto mf = static_cast<miser_integrand<T>>(p_cb->m_member_function); return (p_cb->m_object_pointer->*mf)(d_array, dim, p_cb->m_data); @@ -71,8 +69,7 @@ template <class T> using P_integrator_miser = std::unique_ptr<IntegratorMCMiser< template <class T> P_integrator_miser<T> make_integrator_miser(const T* object, miser_integrand<T> mem_function, - size_t dim) -{ + size_t dim) { P_integrator_miser<T> P_integrator(new IntegratorMCMiser<T>(object, mem_function, dim)); return P_integrator; } @@ -84,8 +81,10 @@ P_integrator_miser<T> make_integrator_miser(const T* object, miser_integrand<T> template <class T> IntegratorMCMiser<T>::IntegratorMCMiser(const T* p_object, miser_integrand<T> p_member_function, size_t dim) - : m_object(p_object), m_member_function(p_member_function), m_dim(dim), m_gsl_workspace{nullptr} -{ + : m_object(p_object) + , m_member_function(p_member_function) + , m_dim(dim) + , m_gsl_workspace{nullptr} { m_gsl_workspace = gsl_monte_miser_alloc(m_dim); const gsl_rng_type* random_type; @@ -94,16 +93,14 @@ IntegratorMCMiser<T>::IntegratorMCMiser(const T* p_object, miser_integrand<T> p_ m_random_gen = gsl_rng_alloc(random_type); } -template <class T> IntegratorMCMiser<T>::~IntegratorMCMiser() -{ +template <class T> IntegratorMCMiser<T>::~IntegratorMCMiser() { gsl_monte_miser_free(m_gsl_workspace); gsl_rng_free(m_random_gen); } template <class T> double IntegratorMCMiser<T>::integrate(double* min_array, double* max_array, void* params, - size_t nbr_points) -{ + size_t nbr_points) { CallBackHolder cb = {m_object, m_member_function, params}; gsl_monte_function f; diff --git a/Base/Math/Numeric.cpp b/Base/Math/Numeric.cpp index 2f0e69690c74220244bb9c95733eb356911feeda..412a59e61dd253cb30e3cd03bdfa188fa077140b 100644 --- a/Base/Math/Numeric.cpp +++ b/Base/Math/Numeric.cpp @@ -17,18 +17,15 @@ #include <cmath> #include <limits> -namespace Numeric -{ +namespace Numeric { //! Returns the absolute value of the difference between a and b. -double GetAbsoluteDifference(double a, double b) -{ +double GetAbsoluteDifference(double a, double b) { return std::abs(a - b); } //! Returns the safe relative difference, which is 2(|a-b|)/(|a|+|b|) except in special cases. -double GetRelativeDifference(double a, double b) -{ +double GetRelativeDifference(double a, double b) { constexpr double eps = std::numeric_limits<double>::epsilon(); const double avg_abs = (std::abs(a) + std::abs(b)) / 2.0; // return 0.0 if relative error smaller than epsilon @@ -39,8 +36,7 @@ double GetRelativeDifference(double a, double b) //! Returns the difference of the logarithm; input values are truncated at the minimum positive //! value -double GetLogDifference(double a, double b) -{ +double GetLogDifference(double a, double b) { double a_t = std::max(a, std::numeric_limits<double>::min()); double b_t = std::max(b, std::numeric_limits<double>::min()); return std::abs(std::log(a_t) - std::log(b_t)); diff --git a/Base/Math/Numeric.h b/Base/Math/Numeric.h index 5effb0950f52267148e27ad79f543d1dd9e74bb4..dbaec088c6eb1213416b545ef486cb8b31d7f5cf 100644 --- a/Base/Math/Numeric.h +++ b/Base/Math/Numeric.h @@ -19,8 +19,7 @@ //! Floating-point approximations. -namespace Numeric -{ +namespace Numeric { double GetAbsoluteDifference(double a, double b); diff --git a/Base/Math/Precomputed.h b/Base/Math/Precomputed.h index 8e48de2826127435cef900556fa99ad659b67f98..2cafed73754b4166b5119d2122dc481d81005953 100644 --- a/Base/Math/Precomputed.h +++ b/Base/Math/Precomputed.h @@ -19,32 +19,26 @@ #include <utility> #include <vector> -namespace Math::internal -{ +namespace Math::internal { template <size_t N> struct ReciprocalFactorial { static constexpr double value = ReciprocalFactorial<N - 1>::value / N; }; -template <> struct ReciprocalFactorial<0> { - static constexpr double value = 1.0; -}; +template <> struct ReciprocalFactorial<0> { static constexpr double value = 1.0; }; template <template <size_t> class F, size_t... I> -constexpr std::array<double, sizeof...(I)> generateArrayHelper(std::index_sequence<I...>) -{ +constexpr std::array<double, sizeof...(I)> generateArrayHelper(std::index_sequence<I...>) { return {F<I>::value...}; }; } // namespace Math::internal -namespace Math -{ +namespace Math { //! Returns a compile-time generated std::array of reciprocal factorials. template <size_t N, typename Indices = std::make_index_sequence<N>> -constexpr std::array<double, N> generateReciprocalFactorialArray() -{ +constexpr std::array<double, N> generateReciprocalFactorialArray() { return internal::generateArrayHelper<internal::ReciprocalFactorial>(Indices{}); }; } // namespace Math diff --git a/Base/Pixel/IPixel.h b/Base/Pixel/IPixel.h index a3e96a677b3a45eccb0441c300494c81aae8496d..b5bcb66b90affddc363cea42d3c765959d6cb851 100644 --- a/Base/Pixel/IPixel.h +++ b/Base/Pixel/IPixel.h @@ -21,8 +21,7 @@ //! Abstract base class for SphericalPixel and RectangularPixel. //! @ingroup detector -class IPixel -{ +class IPixel { public: virtual ~IPixel() {} diff --git a/Base/Pixel/PolarizationHandler.cpp b/Base/Pixel/PolarizationHandler.cpp index 31335130565335cb79280ab1b8469bd6f6349d5a..3e71f6ee9f7353ebb2090f299e2d3c15a4b2abdd 100644 --- a/Base/Pixel/PolarizationHandler.cpp +++ b/Base/Pixel/PolarizationHandler.cpp @@ -17,18 +17,13 @@ // corresponds to completely unpolarized beam and the absence of spin selection in the analyzer PolarizationHandler::PolarizationHandler() : m_polarization(Eigen::Matrix2cd::Identity() / 2.0) - , m_analyzer_operator(Eigen::Matrix2cd::Identity()) -{ -} + , m_analyzer_operator(Eigen::Matrix2cd::Identity()) {} PolarizationHandler::PolarizationHandler(const Eigen::Matrix2cd& polarization, const Eigen::Matrix2cd& analyzer) - : m_polarization(polarization), m_analyzer_operator(analyzer) -{ -} + : m_polarization(polarization), m_analyzer_operator(analyzer) {} -void PolarizationHandler::swapContent(PolarizationHandler& other) -{ +void PolarizationHandler::swapContent(PolarizationHandler& other) { std::swap(m_polarization, other.m_polarization); std::swap(m_analyzer_operator, other.m_analyzer_operator); } diff --git a/Base/Pixel/PolarizationHandler.h b/Base/Pixel/PolarizationHandler.h index d4d3e026e1d6221d71bde105b961572f3d9faf13..2c0df2cd0ba75c08b47e1c372bd454d46552387a 100644 --- a/Base/Pixel/PolarizationHandler.h +++ b/Base/Pixel/PolarizationHandler.h @@ -20,8 +20,7 @@ //! Convenience class for handling polarization density matrix and polarization analyzer operator //! @ingroup simulation -class PolarizationHandler -{ +class PolarizationHandler { public: PolarizationHandler(); PolarizationHandler(const Eigen::Matrix2cd& polarization, const Eigen::Matrix2cd& analyzer); diff --git a/Base/Pixel/SimulationElement.cpp b/Base/Pixel/SimulationElement.cpp index f61243bd09a5cb58c6f58ae9a469300699ae7395..abdd70be1570df2a77b486f01082892cd04fc77e 100644 --- a/Base/Pixel/SimulationElement.cpp +++ b/Base/Pixel/SimulationElement.cpp @@ -27,9 +27,7 @@ SimulationElement::SimulationElement(double wavelength, double alpha_i, double p , m_mean_kf(pixel->getK(0.5, 0.5, m_wavelength)) , m_pixel(std::move(pixel)) , m_is_specular(isSpecular_) - , m_intensity(0.0) -{ -} + , m_intensity(0.0) {} SimulationElement::SimulationElement(const SimulationElement& other) : m_polarization(other.m_polarization) @@ -40,16 +38,13 @@ SimulationElement::SimulationElement(const SimulationElement& other) , m_mean_kf(other.m_mean_kf) , m_pixel(std::move(other.m_pixel->clone())) , m_is_specular(other.m_is_specular) - , m_intensity(other.m_intensity) -{ -} + , m_intensity(other.m_intensity) {} SimulationElement::SimulationElement(SimulationElement&&) = default; SimulationElement::~SimulationElement() = default; -SimulationElement SimulationElement::pointElement(double x, double y) const -{ +SimulationElement SimulationElement::pointElement(double x, double y) const { return {m_wavelength, m_alpha_i, m_phi_i, @@ -59,51 +54,42 @@ SimulationElement SimulationElement::pointElement(double x, double y) const m_is_specular}; } -kvector_t SimulationElement::getKi() const -{ +kvector_t SimulationElement::getKi() const { return m_k_i; } -kvector_t SimulationElement::getMeanKf() const -{ +kvector_t SimulationElement::getMeanKf() const { return m_mean_kf; } //! Returns outgoing wavevector Kf for in-pixel coordinates x,y. //! In-pixel coordinates take values from 0 to 1. -kvector_t SimulationElement::getKf(double x, double y) const -{ +kvector_t SimulationElement::getKf(double x, double y) const { return m_pixel->getK(x, y, m_wavelength); } -kvector_t SimulationElement::meanQ() const -{ +kvector_t SimulationElement::meanQ() const { return getKi() - getMeanKf(); } //! Returns scattering vector Q, with Kf determined from in-pixel coordinates x,y. //! In-pixel coordinates take values from 0 to 1. -kvector_t SimulationElement::getQ(double x, double y) const -{ +kvector_t SimulationElement::getQ(double x, double y) const { return getKi() - m_pixel->getK(x, y, m_wavelength); } -double SimulationElement::getAlpha(double x, double y) const -{ +double SimulationElement::getAlpha(double x, double y) const { return M_PI_2 - getKf(x, y).theta(); } -double SimulationElement::getPhi(double x, double y) const -{ +double SimulationElement::getPhi(double x, double y) const { return getKf(x, y).phi(); } -double SimulationElement::integrationFactor(double x, double y) const -{ +double SimulationElement::integrationFactor(double x, double y) const { return m_pixel->integrationFactor(x, y); } -double SimulationElement::solidAngle() const -{ +double SimulationElement::solidAngle() const { return m_pixel->solidAngle(); } diff --git a/Base/Pixel/SimulationElement.h b/Base/Pixel/SimulationElement.h index d1b3df798602541780c0b48a3ce20e08dd6ea85f..ca16173a6ffab41f3f1907ff6b532bfdf5ca799d 100644 --- a/Base/Pixel/SimulationElement.h +++ b/Base/Pixel/SimulationElement.h @@ -25,8 +25,7 @@ class IPixel; //! Data stucture containing both input and output of a single detector cell. //! @ingroup simulation -class SimulationElement -{ +class SimulationElement { public: SimulationElement() = delete; SimulationElement(double wavelength, double alpha_i, double phi_i, diff --git a/Base/Progress/DelayedProgressCounter.cpp b/Base/Progress/DelayedProgressCounter.cpp index ec2e83c53969ad6642168fb0b55c7ea89831a415..d1c4acee70eddd2eed007870f0c73d36e29ca60a 100644 --- a/Base/Progress/DelayedProgressCounter.cpp +++ b/Base/Progress/DelayedProgressCounter.cpp @@ -16,12 +16,9 @@ #include "Base/Progress/ProgressHandler.h" DelayedProgressCounter::DelayedProgressCounter(ProgressHandler* p_progress, size_t interval) - : m_progress(p_progress), m_interval(interval), m_count(0) -{ -} + : m_progress(p_progress), m_interval(interval), m_count(0) {} -void DelayedProgressCounter::stepProgress() -{ +void DelayedProgressCounter::stepProgress() { ++m_count; if (m_count == m_interval) { m_progress->incrementDone(m_interval); diff --git a/Base/Progress/DelayedProgressCounter.h b/Base/Progress/DelayedProgressCounter.h index 6430289f9d613d1801a074768e6e240b7d465c97..c3aaa0cf1c41eb3a2cd7f34f1176bd2e156d2abc 100644 --- a/Base/Progress/DelayedProgressCounter.h +++ b/Base/Progress/DelayedProgressCounter.h @@ -21,8 +21,7 @@ class ProgressHandler; //! Counter for reporting progress (with delay interval) in a threaded computation. -class DelayedProgressCounter -{ +class DelayedProgressCounter { public: DelayedProgressCounter(ProgressHandler* p_progress, size_t interval); ~DelayedProgressCounter() {} diff --git a/Base/Progress/ProgressHandler.cpp b/Base/Progress/ProgressHandler.cpp index 95686b35d33c07d6773b9427a45b907d58ded26e..c683bd5733e2bb3c715b0a41d742a85be9dfcffa 100644 --- a/Base/Progress/ProgressHandler.cpp +++ b/Base/Progress/ProgressHandler.cpp @@ -16,8 +16,7 @@ #include <mutex> #include <stdexcept> -void ProgressHandler::subscribe(ProgressHandler::Callback_t inform) -{ +void ProgressHandler::subscribe(ProgressHandler::Callback_t inform) { if (m_inform) throw std::runtime_error("Invalid call of ProgressHandler::subscribe: " "currently, no more than one subscriber is allowed"); @@ -28,8 +27,7 @@ void ProgressHandler::subscribe(ProgressHandler::Callback_t inform) //! Performs callback (method m_inform) to inform the subscriber about //! the state of the computation and to obtain as return value a flag //! that indicates whether to continue the computation. -void ProgressHandler::incrementDone(size_t ticks_done) -{ +void ProgressHandler::incrementDone(size_t ticks_done) { static std::mutex single_mutex; std::unique_lock<std::mutex> single_lock(single_mutex); diff --git a/Base/Progress/ProgressHandler.h b/Base/Progress/ProgressHandler.h index 9ac51d9ea2afe6df4d295b69dbd4b2a74662341d..b44edef0e70f37ac18f7814e3866e29964a9e268 100644 --- a/Base/Progress/ProgressHandler.h +++ b/Base/Progress/ProgressHandler.h @@ -27,24 +27,21 @@ class MultiLayer; //! //! @ingroup algorithms_internal -class ProgressHandler -{ +class ProgressHandler { public: typedef std::function<bool(size_t)> Callback_t; ProgressHandler() - : m_inform(nullptr), m_expected_nticks(0), m_completed_nticks(0), m_continuation_flag(true) - { - } + : m_inform(nullptr) + , m_expected_nticks(0) + , m_completed_nticks(0) + , m_continuation_flag(true) {} ProgressHandler(const ProgressHandler& other) : m_inform(other.m_inform) // not clear whether we want multiple copies of this , m_expected_nticks(other.m_expected_nticks) - , m_completed_nticks(other.m_completed_nticks) - { - } + , m_completed_nticks(other.m_completed_nticks) {} void subscribe(ProgressHandler::Callback_t callback); - void reset() - { + void reset() { m_completed_nticks = 0; m_continuation_flag = true; } diff --git a/Base/Types/CloneableVector.h b/Base/Types/CloneableVector.h index 2cf6a2f78429a5680236385278b316888dfde266..3ebf585d1a77035259865fdc5b0aa2893c697014 100644 --- a/Base/Types/CloneableVector.h +++ b/Base/Types/CloneableVector.h @@ -27,14 +27,12 @@ //! The objects pointed to must posses a clone() function. -template <class T> class CloneableVector : public std::vector<std::unique_ptr<T>> -{ +template <class T> class CloneableVector : public std::vector<std::unique_ptr<T>> { using super = std::vector<std::unique_ptr<T>>; public: CloneableVector() : super() {} - CloneableVector(const CloneableVector& other) : super() - { + CloneableVector(const CloneableVector& other) : super() { super::reserve(other.size()); for (const std::unique_ptr<T>& t : other) super::emplace_back(t->clone()); diff --git a/Base/Types/Complex.h b/Base/Types/Complex.h index b5ea416015b28b543941b7927d8af1ffa6161f46..c854e0b4c99c5c0b017f7bfe0604c15d83f20778 100644 --- a/Base/Types/Complex.h +++ b/Base/Types/Complex.h @@ -21,14 +21,12 @@ using complex_t = std::complex<double>; constexpr complex_t I = complex_t(0.0, 1.0); //! Returns product I*z, where I is the imaginary unit. -inline complex_t mul_I(complex_t z) -{ +inline complex_t mul_I(complex_t z) { return complex_t(-z.imag(), z.real()); } //! Returns exp(I*z), where I is the imaginary unit. -inline complex_t exp_I(complex_t z) -{ +inline complex_t exp_I(complex_t z) { return std::exp(complex_t(-z.imag(), z.real())); } diff --git a/Base/Types/Exceptions.cpp b/Base/Types/Exceptions.cpp index dd5758d0cc3c1be52d05fd0f3995b0b95dbab145..e8f0339e8ced063e7b56320d310bd3c05c8fd1c1 100644 --- a/Base/Types/Exceptions.cpp +++ b/Base/Types/Exceptions.cpp @@ -15,65 +15,55 @@ #include "Base/Types/Exceptions.h" #include <iostream> -namespace Exceptions -{ +namespace Exceptions { -void LogExceptionMessage(const std::string&) -{ +void LogExceptionMessage(const std::string&) { // std::cerr << message << std::endl; } NotImplementedException::NotImplementedException(const std::string& message) - : std::logic_error(message) -{ + : std::logic_error(message) { LogExceptionMessage(message); } -NullPointerException::NullPointerException(const std::string& message) : std::logic_error(message) -{ +NullPointerException::NullPointerException(const std::string& message) : std::logic_error(message) { LogExceptionMessage(message); } -OutOfBoundsException::OutOfBoundsException(const std::string& message) : std::logic_error(message) -{ +OutOfBoundsException::OutOfBoundsException(const std::string& message) : std::logic_error(message) { LogExceptionMessage(message); } ClassInitializationException::ClassInitializationException(const std::string& message) - : std::runtime_error(message) -{ + : std::runtime_error(message) { LogExceptionMessage(message); } -LogicErrorException::LogicErrorException(const std::string& message) : std::logic_error(message) -{ +LogicErrorException::LogicErrorException(const std::string& message) : std::logic_error(message) { LogExceptionMessage(message); } RuntimeErrorException::RuntimeErrorException(const std::string& message) - : std::runtime_error(message) -{ + : std::runtime_error(message) { LogExceptionMessage(message); } -DomainErrorException::DomainErrorException(const std::string& message) : std::domain_error(message) -{ +DomainErrorException::DomainErrorException(const std::string& message) + : std::domain_error(message) { LogExceptionMessage(message); } FileNotIsOpenException::FileNotIsOpenException(const std::string& message) - : std::runtime_error(message) -{ + : std::runtime_error(message) { LogExceptionMessage(message); } -FileIsBadException::FileIsBadException(const std::string& message) : std::runtime_error(message) -{ +FileIsBadException::FileIsBadException(const std::string& message) : std::runtime_error(message) { LogExceptionMessage(message); } -FormatErrorException::FormatErrorException(const std::string& message) : std::runtime_error(message) -{ +FormatErrorException::FormatErrorException(const std::string& message) + : std::runtime_error(message) { LogExceptionMessage(message); } diff --git a/Base/Types/Exceptions.h b/Base/Types/Exceptions.h index 32f90f630d83215a8385f81d33cae771c5cacec4..2ed8ba761299055c0ee0d8c1d09300d7fbd40d0a 100644 --- a/Base/Types/Exceptions.h +++ b/Base/Types/Exceptions.h @@ -27,65 +27,54 @@ //! Different exceptions, all inheriting from std::exception. -namespace Exceptions -{ +namespace Exceptions { -class NotImplementedException : public std::logic_error -{ +class NotImplementedException : public std::logic_error { public: NotImplementedException(const std::string& message); }; -class NullPointerException : public std::logic_error -{ +class NullPointerException : public std::logic_error { public: NullPointerException(const std::string& message); }; -class OutOfBoundsException : public std::logic_error -{ +class OutOfBoundsException : public std::logic_error { public: OutOfBoundsException(const std::string& message); }; -class ClassInitializationException : public std::runtime_error -{ +class ClassInitializationException : public std::runtime_error { public: ClassInitializationException(const std::string& message); }; -class LogicErrorException : public std::logic_error -{ +class LogicErrorException : public std::logic_error { public: LogicErrorException(const std::string& message); }; -class RuntimeErrorException : public std::runtime_error -{ +class RuntimeErrorException : public std::runtime_error { public: RuntimeErrorException(const std::string& message); }; -class DomainErrorException : public std::domain_error -{ +class DomainErrorException : public std::domain_error { public: DomainErrorException(const std::string& message); }; -class FileNotIsOpenException : public std::runtime_error -{ +class FileNotIsOpenException : public std::runtime_error { public: FileNotIsOpenException(const std::string& message); }; -class FileIsBadException : public std::runtime_error -{ +class FileIsBadException : public std::runtime_error { public: FileIsBadException(const std::string& message); }; -class FormatErrorException : public std::runtime_error -{ +class FormatErrorException : public std::runtime_error { public: FormatErrorException(const std::string& message); }; diff --git a/Base/Types/ICloneable.h b/Base/Types/ICloneable.h index a64531f687244021c49068a1f46bedd7911e4f7e..825a117feb02e30331d98d71412c515fa57087a1 100644 --- a/Base/Types/ICloneable.h +++ b/Base/Types/ICloneable.h @@ -21,8 +21,7 @@ //! @ingroup tools_internal -class ICloneable -{ +class ICloneable { public: ICloneable() = default; virtual ~ICloneable() = default; diff --git a/Base/Types/SafePointerVector.h b/Base/Types/SafePointerVector.h index ea7395f3bbfefd4ec60e0fc571eac45b24069fef..dea4276ef9851776bf1d6ac22c7505a7d75d89d7 100644 --- a/Base/Types/SafePointerVector.h +++ b/Base/Types/SafePointerVector.h @@ -23,8 +23,7 @@ //! The objects pointed to must support the ICloneable interface. -template <class T> class SafePointerVector -{ +template <class T> class SafePointerVector { public: typedef typename std::vector<T*>::iterator iterator; typedef typename std::vector<T*>::const_iterator const_iterator; @@ -55,20 +54,17 @@ private: std::vector<T*> m_pointers; }; -template <class T> SafePointerVector<T>::SafePointerVector(const SafePointerVector<T>& other) -{ +template <class T> SafePointerVector<T>::SafePointerVector(const SafePointerVector<T>& other) { for (const_iterator it = other.begin(); it != other.end(); ++it) m_pointers.push_back((*it)->clone()); } template <class T> -SafePointerVector<T>::SafePointerVector(SafePointerVector<T>&& other) : m_pointers{other.m_pointers} -{ -} +SafePointerVector<T>::SafePointerVector(SafePointerVector<T>&& other) + : m_pointers{other.m_pointers} {} template <class T> -SafePointerVector<T>& SafePointerVector<T>::operator=(const SafePointerVector<T>& right) -{ +SafePointerVector<T>& SafePointerVector<T>::operator=(const SafePointerVector<T>& right) { if (this == &right) return *this; clear(); @@ -78,16 +74,14 @@ SafePointerVector<T>& SafePointerVector<T>::operator=(const SafePointerVector<T> } template <class T> -SafePointerVector<T>& SafePointerVector<T>::operator=(SafePointerVector<T>&& right) -{ +SafePointerVector<T>& SafePointerVector<T>::operator=(SafePointerVector<T>&& right) { clear(); m_pointers = std::move(right.m_pointers); right.m_pointers.clear(); return *this; } -template <class T> inline bool SafePointerVector<T>::deleteElement(T* pointer) -{ +template <class T> inline bool SafePointerVector<T>::deleteElement(T* pointer) { iterator it = std::find(m_pointers.begin(), m_pointers.end(), pointer); if (it == m_pointers.end()) return false; @@ -96,8 +90,7 @@ template <class T> inline bool SafePointerVector<T>::deleteElement(T* pointer) return true; } -template <class T> void SafePointerVector<T>::clear() -{ +template <class T> void SafePointerVector<T>::clear() { for (iterator it = begin(); it != end(); ++it) delete (*it); m_pointers.clear(); diff --git a/Base/Utils/Algorithms.h b/Base/Utils/Algorithms.h index 781b308543e5d18b1598cb515ea8cf44589e3ece..2e14d76e2c1b4b16f326d921717b4e1ae5777571 100644 --- a/Base/Utils/Algorithms.h +++ b/Base/Utils/Algorithms.h @@ -23,12 +23,10 @@ //! Some additions to standard library algorithms. -namespace algo -{ +namespace algo { //! Returns true if two doubles agree within machine epsilon. -inline bool almostEqual(double a, double b) -{ +inline bool almostEqual(double a, double b) { constexpr double eps = std::numeric_limits<double>::epsilon(); return std::abs(a - b) <= eps * std::max(eps, (std::abs(a) + std::abs(b)) / 2); } @@ -51,8 +49,7 @@ template <class T> std::vector<T> concat(const std::vector<T>& v1, const std::ve // ************************************************************************************************ template <typename Evaluator, typename Iterator> -double algo::min_value(const Iterator& begin, const Iterator& end, const Evaluator& evaluate) -{ +double algo::min_value(const Iterator& begin, const Iterator& end, const Evaluator& evaluate) { ASSERT(begin != end); double ret = evaluate(*begin); Iterator it = begin; @@ -62,8 +59,7 @@ double algo::min_value(const Iterator& begin, const Iterator& end, const Evaluat } template <typename Evaluator, typename Iterator> -double algo::max_value(const Iterator& begin, const Iterator& end, const Evaluator& evaluate) -{ +double algo::max_value(const Iterator& begin, const Iterator& end, const Evaluator& evaluate) { ASSERT(begin != end); double ret = evaluate(*begin); Iterator it = begin; @@ -72,8 +68,7 @@ double algo::max_value(const Iterator& begin, const Iterator& end, const Evaluat return ret; } -template <class T> std::vector<T> algo::concat(const std::vector<T>& v1, const std::vector<T>& v2) -{ +template <class T> std::vector<T> algo::concat(const std::vector<T>& v1, const std::vector<T>& v2) { std::vector<T> v = v1; v.insert(v.end(), v2.begin(), v2.end()); return v; diff --git a/Base/Utils/FileSystemUtils.cpp b/Base/Utils/FileSystemUtils.cpp index a76a81ae01f0ebc0285b77210f0927fa135f230e..8a330c9e52db7fc83002e496ae6ae4956d3feea4 100644 --- a/Base/Utils/FileSystemUtils.cpp +++ b/Base/Utils/FileSystemUtils.cpp @@ -21,20 +21,17 @@ #include <regex> #include <stdexcept> -std::string FileSystemUtils::extension(const std::string& path) -{ +std::string FileSystemUtils::extension(const std::string& path) { return boost::filesystem::extension(path.c_str()); } -std::string FileSystemUtils::extensions(const std::string& path) -{ +std::string FileSystemUtils::extensions(const std::string& path) { auto name = FileSystemUtils::filename(path); auto npos = name.find_first_of('.'); return npos != std::string::npos ? name.substr(npos, name.size() - npos) : std::string(); } -bool FileSystemUtils::createDirectory(const std::string& dir_name) -{ +bool FileSystemUtils::createDirectory(const std::string& dir_name) { #ifdef _WIN32 boost::filesystem::path path(convert_utf8_to_utf16(dir_name)); #else @@ -43,8 +40,7 @@ bool FileSystemUtils::createDirectory(const std::string& dir_name) return boost::filesystem::create_directory(dir_name); } -bool FileSystemUtils::createDirectories(const std::string& dir_name) -{ +bool FileSystemUtils::createDirectories(const std::string& dir_name) { #ifdef _WIN32 boost::filesystem::path path(convert_utf8_to_utf16(dir_name)); #else @@ -53,8 +49,7 @@ bool FileSystemUtils::createDirectories(const std::string& dir_name) return boost::filesystem::create_directories(path); } -std::vector<std::string> FileSystemUtils::filesInDirectory(const std::string& dir_name) -{ +std::vector<std::string> FileSystemUtils::filesInDirectory(const std::string& dir_name) { std::vector<std::string> ret; if (!boost::filesystem::exists(dir_name)) throw std::runtime_error("FileSystemUtils::filesInDirectory '" + dir_name @@ -69,8 +64,7 @@ std::vector<std::string> FileSystemUtils::filesInDirectory(const std::string& di return ret; } -std::string FileSystemUtils::jointPath(const std::string& spath1, const std::string& spath2) -{ +std::string FileSystemUtils::jointPath(const std::string& spath1, const std::string& spath2) { ASSERT(spath1 != ""); ASSERT(spath2 != ""); boost::filesystem::path path1(spath1); @@ -80,13 +74,11 @@ std::string FileSystemUtils::jointPath(const std::string& spath1, const std::str return full_path.string(); } -std::string FileSystemUtils::filename(const std::string& path) -{ +std::string FileSystemUtils::filename(const std::string& path) { return boost::filesystem::path(path).filename().string(); } -std::vector<std::string> FileSystemUtils::glob(const std::string& dir, const std::string& pattern) -{ +std::vector<std::string> FileSystemUtils::glob(const std::string& dir, const std::string& pattern) { std::vector<std::string> ret; for (const std::string& fname : filesInDirectory(dir)) if (std::regex_match(fname, std::regex(pattern))) @@ -94,26 +86,22 @@ std::vector<std::string> FileSystemUtils::glob(const std::string& dir, const std return ret; } -std::string FileSystemUtils::stem(const std::string& path) -{ +std::string FileSystemUtils::stem(const std::string& path) { return boost::filesystem::path(path).stem().string(); } -std::string FileSystemUtils::stem_ext(const std::string& path) -{ +std::string FileSystemUtils::stem_ext(const std::string& path) { auto name = FileSystemUtils::filename(path); auto npos = name.find_first_of('.'); return npos != std::string::npos ? name.substr(0, npos) : std::string(); } -std::wstring FileSystemUtils::convert_utf8_to_utf16(const std::string& str) -{ +std::wstring FileSystemUtils::convert_utf8_to_utf16(const std::string& str) { std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; return converter.from_bytes(str); } -bool FileSystemUtils::IsFileExists(const std::string& str) -{ +bool FileSystemUtils::IsFileExists(const std::string& str) { #ifdef _WIN32 boost::filesystem::path path(convert_utf8_to_utf16(str)); #else diff --git a/Base/Utils/FileSystemUtils.h b/Base/Utils/FileSystemUtils.h index 2307e75e13b3ef7989262dc1c579a3ecd220fea2..2a87943ffb51949f5e8b506e264655ff35dbdecf 100644 --- a/Base/Utils/FileSystemUtils.h +++ b/Base/Utils/FileSystemUtils.h @@ -20,8 +20,7 @@ //! Utility functions to deal with file system. -namespace FileSystemUtils -{ +namespace FileSystemUtils { //! Returns extension of given filename. //! "/home/user/filename.int" -> ".int", "/home/user/filename.int.gz" -> ".gz" diff --git a/Base/Utils/IFactory.h b/Base/Utils/IFactory.h index 80d1829f5d6005c8e13e1e3f124f76cd24c8a735..c33f0572fb38c8bc249f4826a0462f8dfef862b0 100644 --- a/Base/Utils/IFactory.h +++ b/Base/Utils/IFactory.h @@ -25,8 +25,7 @@ //! Base class for all factories. //! @ingroup tools_internal -template <class Key, class AbstractProduct> class IFactory -{ +template <class Key, class AbstractProduct> class IFactory { public: //! function which will be used to create object of AbstractProduct base type typedef typename std::function<AbstractProduct*()> CreateItemCallback; @@ -35,29 +34,25 @@ public: typedef std::map<Key, CreateItemCallback> CallbackMap_t; //! Creates object by calling creation function corresponded to given identifier - AbstractProduct* createItem(const Key& item_key) const - { + AbstractProduct* createItem(const Key& item_key) const { auto it = m_callbacks.find(item_key); assert(it != m_callbacks.end()); return (it->second)(); } #ifndef SWIG - std::unique_ptr<AbstractProduct> createItemPtr(const Key& item_key) const - { + std::unique_ptr<AbstractProduct> createItemPtr(const Key& item_key) const { return std::unique_ptr<AbstractProduct>{createItem(item_key)}; } #endif //! Registers object's creation function - bool registerItem(const Key& item_key, CreateItemCallback CreateFn) - { + bool registerItem(const Key& item_key, CreateItemCallback CreateFn) { assert(m_callbacks.find(item_key) == m_callbacks.end()); return m_callbacks.insert(make_pair(item_key, CreateFn)).second; } - bool contains(const Key& item_key) const - { + bool contains(const Key& item_key) const { return m_callbacks.find(item_key) != m_callbacks.end(); } @@ -74,8 +69,7 @@ protected: //! 'create_new<T>', with no function arguments supplied. Equivalently, we could //! use a lambda function '[](){return new T;}'. -template <class T> T* create_new() -{ +template <class T> T* create_new() { return new T(); } diff --git a/Base/Utils/PyEmbeddedUtils.cpp b/Base/Utils/PyEmbeddedUtils.cpp index 5b00c06a3d06727053097a0773537d38dea49137..04f39c01a04c019624dbcec7efc447f7172e80ce 100644 --- a/Base/Utils/PyEmbeddedUtils.cpp +++ b/Base/Utils/PyEmbeddedUtils.cpp @@ -21,8 +21,7 @@ #include <sstream> #include <stdexcept> -std::string PyEmbeddedUtils::toString(PyObject* obj) -{ +std::string PyEmbeddedUtils::toString(PyObject* obj) { std::string result; #if PY_MAJOR_VERSION >= 3 PyObject* pyStr = PyUnicode_AsEncodedString(obj, "utf-8", "Error ~"); @@ -35,8 +34,7 @@ std::string PyEmbeddedUtils::toString(PyObject* obj) return result; } -std::vector<std::string> PyEmbeddedUtils::toVectorString(PyObject* obj) -{ +std::vector<std::string> PyEmbeddedUtils::toVectorString(PyObject* obj) { std::vector<std::string> result; if (PyTuple_Check(obj)) { @@ -58,16 +56,14 @@ std::vector<std::string> PyEmbeddedUtils::toVectorString(PyObject* obj) return result; } -std::string PyEmbeddedUtils::toString(char* c) -{ +std::string PyEmbeddedUtils::toString(char* c) { if (c) return c; else return ""; } -std::string PyEmbeddedUtils::toString(wchar_t* c) -{ +std::string PyEmbeddedUtils::toString(wchar_t* c) { if (c) { std::wstring wstr(c); std::string result(wstr.begin(), wstr.end()); @@ -77,8 +73,7 @@ std::string PyEmbeddedUtils::toString(wchar_t* c) } } -void PyEmbeddedUtils::import_bornagain(const std::string& path) -{ +void PyEmbeddedUtils::import_bornagain(const std::string& path) { if (!Py_IsInitialized()) { Py_InitializeEx(0); @@ -106,8 +101,7 @@ void PyEmbeddedUtils::import_bornagain(const std::string& path) } } -std::string PyEmbeddedUtils::pythonRuntimeInfo() -{ +std::string PyEmbeddedUtils::pythonRuntimeInfo() { Py_InitializeEx(0); std::stringstream result; @@ -139,8 +133,7 @@ std::string PyEmbeddedUtils::pythonRuntimeInfo() // Attempt to retrieve Python stack trace // https://stackoverflow.com/questions/1796510/accessing-a-python-traceback-from-the-c-api -std::string PyEmbeddedUtils::pythonStackTrace() -{ +std::string PyEmbeddedUtils::pythonStackTrace() { std::stringstream result; if (PyErr_Occurred()) { diff --git a/Base/Utils/PyEmbeddedUtils.h b/Base/Utils/PyEmbeddedUtils.h index 32b25065e64eb80e6b01ce415c62fd359220a599..2df2648d1ed63a2fed08294ae21efb26c6c5164b 100644 --- a/Base/Utils/PyEmbeddedUtils.h +++ b/Base/Utils/PyEmbeddedUtils.h @@ -24,8 +24,7 @@ class MultiLayer; -namespace PyEmbeddedUtils -{ +namespace PyEmbeddedUtils { //! Converts PyObject into string, if possible, or throws exception. std::string toString(PyObject* obj); diff --git a/Base/Utils/PyFmt.cpp b/Base/Utils/PyFmt.cpp index a84b1e18d2968f2d404cf58de18e941be1d49760..3305797a1ce4bd0a14b86e2f9b1307b073364205 100644 --- a/Base/Utils/PyFmt.cpp +++ b/Base/Utils/PyFmt.cpp @@ -18,11 +18,9 @@ #include "Base/Utils/Algorithms.h" #include <iomanip> -namespace pyfmt -{ +namespace pyfmt { -std::string scriptPreamble() -{ +std::string scriptPreamble() { const std::string result = "import numpy\n" "import bornagain as ba\n" "from bornagain import deg, angstrom, nm, nm2, kvector_t\n\n\n"; @@ -30,18 +28,15 @@ std::string scriptPreamble() return result; } -std::string getSampleFunctionName() -{ +std::string getSampleFunctionName() { return "get_sample"; } -std::string printBool(double value) -{ +std::string printBool(double value) { return value ? "True" : "False"; } -std::string printDouble(double input) -{ +std::string printDouble(double input) { std::ostringstream inter; inter << std::setprecision(12); if (std::abs(input) < std::numeric_limits<double>::epsilon()) { @@ -54,16 +49,14 @@ std::string printDouble(double input) return inter.str(); } -std::string printNm(double input) -{ +std::string printNm(double input) { std::ostringstream inter; inter << std::setprecision(12); inter << printDouble(input) << "*nm"; return inter.str(); } -std::string printNm2(double input) -{ +std::string printNm2(double input) { std::ostringstream inter; inter << std::setprecision(12); inter << printDouble(input) << "*nm2"; @@ -71,8 +64,7 @@ std::string printNm2(double input) } // 1.000000e+07 -> 1.0e+07 -std::string printScientificDouble(double input) -{ +std::string printScientificDouble(double input) { std::ostringstream inter; inter << std::scientific; inter << input; @@ -91,8 +83,7 @@ std::string printScientificDouble(double input) return part1 + part2; } -std::string printDegrees(double input) -{ +std::string printDegrees(double input) { std::ostringstream inter; inter << std::setprecision(11) << Units::rad2deg(input); if (inter.str().find('e') == std::string::npos && inter.str().find('.') == std::string::npos) @@ -101,8 +92,7 @@ std::string printDegrees(double input) return inter.str(); } -std::string printValue(double value, const std::string& units) -{ +std::string printValue(double value, const std::string& units) { if (units == "rad") return printDegrees(value); else if (units == "nm") @@ -113,33 +103,28 @@ std::string printValue(double value, const std::string& units) throw std::runtime_error("pyfmt::printValue() -> Error. Unknown units '" + units + "'"); } -std::string printString(const std::string& value) -{ +std::string printString(const std::string& value) { std::ostringstream result; result << "\"" << value << "\""; return result.str(); } -bool isSquare(double length1, double length2, double angle) -{ +bool isSquare(double length1, double length2, double angle) { return length1 == length2 && algo::almostEqual(angle, M_PI_2); } -bool isHexagonal(double length1, double length2, double angle) -{ +bool isHexagonal(double length1, double length2, double angle) { return length1 == length2 && algo::almostEqual(angle, M_TWOPI / 3.0); } -std::string printKvector(const kvector_t value) -{ +std::string printKvector(const kvector_t value) { std::ostringstream result; result << "kvector_t(" << printDouble(value.x()) << ", " << printDouble(value.y()) << ", " << printDouble(value.z()) << ")"; return result.str(); } -std::string indent(size_t width) -{ +std::string indent(size_t width) { return std::string(width, ' '); } diff --git a/Base/Utils/PyFmt.h b/Base/Utils/PyFmt.h index c90edba26562dcd2a18fed65971c01e5eebbddc0..5dc8f17e09e1b8d3c4fdd857d8f763005f262d04 100644 --- a/Base/Utils/PyFmt.h +++ b/Base/Utils/PyFmt.h @@ -22,8 +22,7 @@ class RealLimits; //! Utility functions for writing Python code snippets. -namespace pyfmt -{ +namespace pyfmt { std::string scriptPreamble(); std::string getSampleFunctionName(); diff --git a/Base/Utils/StringUtils.cpp b/Base/Utils/StringUtils.cpp index 272a072c0c6c2499e34acd5827255e18b8caf53b..1dafb4815c1e97a71c529df7980505b4b7f72315 100644 --- a/Base/Utils/StringUtils.cpp +++ b/Base/Utils/StringUtils.cpp @@ -17,8 +17,7 @@ #include <regex> //! Returns true if text matches pattern with wildcards '*' and '?'. -bool StringUtils::matchesPattern(const std::string& text, const std::string& wildcardPattern) -{ +bool StringUtils::matchesPattern(const std::string& text, const std::string& wildcardPattern) { // escape all regex special characters, except '?' and '*' std::string mywildcardPattern = wildcardPattern; boost::replace_all(mywildcardPattern, "\\", "\\\\"); @@ -46,30 +45,26 @@ bool StringUtils::matchesPattern(const std::string& text, const std::string& wil } //! Returns string right-padded with blanks. -std::string StringUtils::padRight(const std::string& name, size_t length) -{ +std::string StringUtils::padRight(const std::string& name, size_t length) { std::string result = name; result.resize(length, ' '); return result; } //! Returns token vector obtained by splitting string at delimiters. -std::vector<std::string> StringUtils::split(const std::string& text, const std::string& delimiter) -{ +std::vector<std::string> StringUtils::split(const std::string& text, const std::string& delimiter) { std::vector<std::string> tokens; boost::split(tokens, text, boost::is_any_of(delimiter)); return tokens; } void StringUtils::replaceItemsFromString(std::string& text, const std::vector<std::string>& items, - const std::string& replacement) -{ + const std::string& replacement) { for (size_t i = 0; i < items.size(); ++i) boost::replace_all(text, items[i], replacement); } -std::string StringUtils::join(const std::vector<std::string>& joinable, const std::string& joint) -{ +std::string StringUtils::join(const std::vector<std::string>& joinable, const std::string& joint) { std::string result; size_t n = joinable.size(); if (n == 0) @@ -80,8 +75,7 @@ std::string StringUtils::join(const std::vector<std::string>& joinable, const st return result; } -std::string StringUtils::removeSubstring(const std::string& text, const std::string& substr) -{ +std::string StringUtils::removeSubstring(const std::string& text, const std::string& substr) { std::string result = text; for (std::string::size_type i = result.find(substr); i != std::string::npos; i = result.find(substr)) @@ -89,8 +83,7 @@ std::string StringUtils::removeSubstring(const std::string& text, const std::str return result; } -std::string StringUtils::to_lower(std::string text) -{ +std::string StringUtils::to_lower(std::string text) { boost::to_lower(text); return text; } diff --git a/Base/Utils/StringUtils.h b/Base/Utils/StringUtils.h index 91d2ffc99ffd26f9f559d6ff5d1b201a5ef91648..c4281a314ef68e40ffdbaa4c1ae1fc9103510dec 100644 --- a/Base/Utils/StringUtils.h +++ b/Base/Utils/StringUtils.h @@ -22,8 +22,7 @@ //! Utility functions to analyze or modify strings. -namespace StringUtils -{ +namespace StringUtils { //! Returns true if text matches pattern with wildcards '*' and '?'. bool matchesPattern(const std::string& text, const std::string& wildcardPattern); @@ -51,8 +50,7 @@ std::string to_lower(std::string text); } // namespace StringUtils -template <typename T> std::string StringUtils::scientific(const T value, int n) -{ +template <typename T> std::string StringUtils::scientific(const T value, int n) { std::ostringstream out; out << std::scientific << std::setprecision(n) << value; return out.str(); diff --git a/Base/Utils/SysUtils.cpp b/Base/Utils/SysUtils.cpp index 53d11454317e01ef57270dbca5fdeea6d46471f7..a02dacb4bf1516f2ffcc840ea212c119ae9f8014 100644 --- a/Base/Utils/SysUtils.cpp +++ b/Base/Utils/SysUtils.cpp @@ -19,8 +19,7 @@ #include <sstream> #include <stdexcept> -std::string SysUtils::getCurrentDateAndTime() -{ +std::string SysUtils::getCurrentDateAndTime() { using clock = std::chrono::system_clock; std::stringstream output; @@ -30,8 +29,7 @@ std::string SysUtils::getCurrentDateAndTime() } //! enables exception throw in the case of NaN, Inf -void SysUtils::enableFloatingPointExceptions() -{ +void SysUtils::enableFloatingPointExceptions() { #ifdef DEBUG_FPE #ifndef _WIN32 std::cout << "SysUtils::EnableFloatingPointExceptions() -> " @@ -45,16 +43,14 @@ void SysUtils::enableFloatingPointExceptions() #endif } -std::string SysUtils::getenv(const std::string& name) -{ +std::string SysUtils::getenv(const std::string& name) { if (char* c = std::getenv(name.c_str())) return c; else return ""; } -bool SysUtils::isWindowsHost() -{ +bool SysUtils::isWindowsHost() { #ifdef _WIN32 return true; #else diff --git a/Base/Utils/SysUtils.h b/Base/Utils/SysUtils.h index b1ff4d59eb8b2ae4291fcf1aa4b2066e44de103c..ea00e83d117befb4f664d843279df64a0d074b3e 100644 --- a/Base/Utils/SysUtils.h +++ b/Base/Utils/SysUtils.h @@ -19,8 +19,7 @@ //! Utility functions getCurrentDateAndTime, enableFloatingPointExceptions. -namespace SysUtils -{ +namespace SysUtils { std::string getCurrentDateAndTime(); diff --git a/Base/Vector/BasicVector3D.cpp b/Base/Vector/BasicVector3D.cpp index bc99e7794d854b7bdb919654873f575f07de41d0..de3d6f14525d3325c16199d319e5c49759767b3b 100644 --- a/Base/Vector/BasicVector3D.cpp +++ b/Base/Vector/BasicVector3D.cpp @@ -22,8 +22,7 @@ typedef std::complex<double> complex_t; // Quasi constructor // ----------------------------------------------------------------------------- -BasicVector3D<double> vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi) -{ +BasicVector3D<double> vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi) { double k = M_TWOPI / _lambda; return BasicVector3D<double>(k * std::cos(_alpha) * std::cos(_phi), -k * std::cos(_alpha) * std::sin(_phi), k * std::sin(_alpha)); @@ -34,68 +33,57 @@ BasicVector3D<double> vecOfLambdaAlphaPhi(double _lambda, double _alpha, double // ----------------------------------------------------------------------------- //! Returns complex conjugate vector -template <> BasicVector3D<double> BasicVector3D<double>::conj() const -{ +template <> BasicVector3D<double> BasicVector3D<double>::conj() const { return *this; } -template <> BasicVector3D<complex_t> BasicVector3D<complex_t>::conj() const -{ +template <> BasicVector3D<complex_t> BasicVector3D<complex_t>::conj() const { return BasicVector3D<complex_t>(std::conj(v_[0]), std::conj(v_[1]), std::conj(v_[2])); } //! Returns azimuth angle. -template <> double BasicVector3D<double>::phi() const -{ +template <> double BasicVector3D<double>::phi() const { return x() == 0.0 && y() == 0.0 ? 0.0 : std::atan2(-y(), x()); } //! Returns polar angle. -template <> double BasicVector3D<double>::theta() const -{ +template <> double BasicVector3D<double>::theta() const { return x() == 0.0 && y() == 0.0 && z() == 0.0 ? 0.0 : std::atan2(magxy(), z()); } //! Returns cosine of polar angle. -template <> double BasicVector3D<double>::cosTheta() const -{ +template <> double BasicVector3D<double>::cosTheta() const { return mag() == 0 ? 1 : z() / mag(); } //! Returns squared sine of polar angle. -template <> double BasicVector3D<double>::sin2Theta() const -{ +template <> double BasicVector3D<double>::sin2Theta() const { return mag2() == 0 ? 0 : magxy2() / mag2(); } //! Returns this, trivially converted to complex type. -template <> BasicVector3D<complex_t> BasicVector3D<double>::complex() const -{ +template <> BasicVector3D<complex_t> BasicVector3D<double>::complex() const { return BasicVector3D<complex_t>(v_[0], v_[1], v_[2]); } //! Returns real parts. -template <> BasicVector3D<double> BasicVector3D<double>::real() const -{ +template <> BasicVector3D<double> BasicVector3D<double>::real() const { return *this; } -template <> BasicVector3D<double> BasicVector3D<complex_t>::real() const -{ +template <> BasicVector3D<double> BasicVector3D<complex_t>::real() const { return BasicVector3D<double>(v_[0].real(), v_[1].real(), v_[2].real()); } //! Returns unit vector in direction of this. Throws for null vector. -template <> BasicVector3D<double> BasicVector3D<double>::unit() const -{ +template <> BasicVector3D<double> BasicVector3D<double>::unit() const { double len = mag(); if (len == 0.0) throw std::runtime_error("Cannot normalize zero vector"); return BasicVector3D<double>(x() / len, y() / len, z() / len); } -template <> BasicVector3D<complex_t> BasicVector3D<complex_t>::unit() const -{ +template <> BasicVector3D<complex_t> BasicVector3D<complex_t>::unit() const { double len = mag(); if (len == 0.0) throw std::runtime_error("Cannot normalize zero vector"); @@ -107,8 +95,7 @@ template <> BasicVector3D<complex_t> BasicVector3D<complex_t>::unit() const // ----------------------------------------------------------------------------- //! Returns angle with respect to another vector. -template <> double BasicVector3D<double>::angle(const BasicVector3D<double>& v) const -{ +template <> double BasicVector3D<double>::angle(const BasicVector3D<double>& v) const { double cosa = 0; double ptot = mag() * v.mag(); if (ptot > 0) { diff --git a/Base/Vector/BasicVector3D.h b/Base/Vector/BasicVector3D.h index 7027700a0aa2805dbf873c169c6fceffe8bc24f1..8c32bfde7f187e491772b63123f19860eadac6e7 100644 --- a/Base/Vector/BasicVector3D.h +++ b/Base/Vector/BasicVector3D.h @@ -24,8 +24,7 @@ //! Three-dimensional vector template, for use with integer, double, or complex components. //! @ingroup tools_internal -template <class T> class BasicVector3D -{ +template <class T> class BasicVector3D { private: T v_[3]; @@ -35,16 +34,14 @@ public: // ------------------------------------------------------------------------- //! Default constructor. - BasicVector3D() - { + BasicVector3D() { v_[0] = 0.0; v_[1] = 0.0; v_[2] = 0.0; } //! Constructor from cartesian components. - BasicVector3D(const T x1, const T y1, const T z1) - { + BasicVector3D(const T x1, const T y1, const T z1) { v_[0] = x1; v_[1] = y1; v_[2] = z1; @@ -79,8 +76,7 @@ public: // ------------------------------------------------------------------------- //! Adds other vector to this, and returns result. - BasicVector3D<T>& operator+=(const BasicVector3D<T>& v) - { + BasicVector3D<T>& operator+=(const BasicVector3D<T>& v) { v_[0] += v.v_[0]; v_[1] += v.v_[1]; v_[2] += v.v_[2]; @@ -88,8 +84,7 @@ public: } //! Subtracts other vector from this, and returns result. - BasicVector3D<T>& operator-=(const BasicVector3D<T>& v) - { + BasicVector3D<T>& operator-=(const BasicVector3D<T>& v) { v_[0] -= v.v_[0]; v_[1] -= v.v_[1]; v_[2] -= v.v_[2]; @@ -98,8 +93,7 @@ public: //! Multiplies this with a scalar, and returns result. #ifndef SWIG - template <class U> auto operator*=(U a) - { + template <class U> auto operator*=(U a) { v_[0] *= a; v_[1] *= a; v_[2] *= a; @@ -109,8 +103,7 @@ public: //! Divides this by a scalar, and returns result. #ifndef SWIG - template <class U> auto operator/=(U a) - { + template <class U> auto operator/=(U a) { v_[0] /= a; v_[1] /= a; v_[2] /= a; @@ -176,8 +169,7 @@ public: double angle(const BasicVector3D<T>& v) const; //! Returns projection of this onto other vector: (this*v)*v/|v|^2. - inline BasicVector3D<T> project(const BasicVector3D<T>& v) const - { + inline BasicVector3D<T> project(const BasicVector3D<T>& v) const { return dot(v) * v / v.mag2(); } @@ -190,8 +182,7 @@ public: //! Returns result of rotation around y-axis. BasicVector3D<T> rotatedY(double a) const; //! Returns result of rotation around z-axis. - BasicVector3D<T> rotatedZ(double a) const - { + BasicVector3D<T> rotatedZ(double a) const { return BasicVector3D<T>(cos(a) * x() + sin(a) * y(), -sin(a) * x() + cos(a) * y(), z()); } //! Returns result of rotation around the axis specified by another vector. @@ -204,8 +195,7 @@ public: //! Output to stream. //! @relates BasicVector3D -template <class T> std::ostream& operator<<(std::ostream& os, const BasicVector3D<T>& a) -{ +template <class T> std::ostream& operator<<(std::ostream& os, const BasicVector3D<T>& a) { return os << "(" << a.x() << "," << a.y() << "," << a.z() << ")"; } @@ -215,15 +205,13 @@ template <class T> std::ostream& operator<<(std::ostream& os, const BasicVector3 //! Unary plus. //! @relates BasicVector3D -template <class T> inline BasicVector3D<T> operator+(const BasicVector3D<T>& v) -{ +template <class T> inline BasicVector3D<T> operator+(const BasicVector3D<T>& v) { return v; } //! Unary minus. //! @relates BasicVector3D -template <class T> inline BasicVector3D<T> operator-(const BasicVector3D<T>& v) -{ +template <class T> inline BasicVector3D<T> operator-(const BasicVector3D<T>& v) { return BasicVector3D<T>(-v.x(), -v.y(), -v.z()); } @@ -234,24 +222,21 @@ template <class T> inline BasicVector3D<T> operator-(const BasicVector3D<T>& v) //! Addition of two vectors. //! @relates BasicVector3D template <class T> -inline BasicVector3D<T> operator+(const BasicVector3D<T>& a, const BasicVector3D<T>& b) -{ +inline BasicVector3D<T> operator+(const BasicVector3D<T>& a, const BasicVector3D<T>& b) { return BasicVector3D<T>(a.x() + b.x(), a.y() + b.y(), a.z() + b.z()); } //! Subtraction of two vectors. //! @relates BasicVector3D template <class T> -inline BasicVector3D<T> operator-(const BasicVector3D<T>& a, const BasicVector3D<T>& b) -{ +inline BasicVector3D<T> operator-(const BasicVector3D<T>& a, const BasicVector3D<T>& b) { return BasicVector3D<T>(a.x() - b.x(), a.y() - b.y(), a.z() - b.z()); } //! Multiplication vector by scalar. //! @relates BasicVector3D #ifndef SWIG -template <class T, class U> inline auto operator*(const BasicVector3D<T>& v, const U a) -{ +template <class T, class U> inline auto operator*(const BasicVector3D<T>& v, const U a) { return BasicVector3D<decltype(v.x() * a)>(v.x() * a, v.y() * a, v.z() * a); } #endif // SWIG @@ -259,8 +244,7 @@ template <class T, class U> inline auto operator*(const BasicVector3D<T>& v, con //! Multiplication scalar by vector. //! @relates BasicVector3D #ifndef SWIG -template <class T, class U> inline auto operator*(const U a, const BasicVector3D<T>& v) -{ +template <class T, class U> inline auto operator*(const U a, const BasicVector3D<T>& v) { return BasicVector3D<decltype(a * v.x())>(a * v.x(), a * v.y(), a * v.z()); } #endif // SWIG @@ -272,22 +256,19 @@ template <class T, class U> inline auto operator*(const U a, const BasicVector3D //! Division vector by scalar. //! @relates BasicVector3D -template <class T, class U> inline BasicVector3D<T> operator/(const BasicVector3D<T>& v, U a) -{ +template <class T, class U> inline BasicVector3D<T> operator/(const BasicVector3D<T>& v, U a) { return BasicVector3D<T>(v.x() / a, v.y() / a, v.z() / a); } //! Comparison of two vectors for equality. //! @relates BasicVector3D -template <class T> inline bool operator==(const BasicVector3D<T>& a, const BasicVector3D<T>& b) -{ +template <class T> inline bool operator==(const BasicVector3D<T>& a, const BasicVector3D<T>& b) { return (a.x() == b.x() && a.y() == b.y() && a.z() == b.z()); } //! Comparison of two vectors for inequality. //! @relates BasicVector3D -template <class T> inline bool operator!=(const BasicVector3D<T>& a, const BasicVector3D<T>& b) -{ +template <class T> inline bool operator!=(const BasicVector3D<T>& a, const BasicVector3D<T>& b) { return (a.x() != b.x() || a.y() != b.y() || a.z() != b.z()); } @@ -307,8 +288,7 @@ BasicVector3D<double> vecOfLambdaAlphaPhi(double _lambda, double _alpha, double #ifndef SWIG template <class T> template <class U> -inline auto BasicVector3D<T>::dot(const BasicVector3D<U>& v) const -{ +inline auto BasicVector3D<T>::dot(const BasicVector3D<U>& v) const { BasicVector3D<T> left_star = this->conj(); return left_star.x() * v.x() + left_star.y() * v.y() + left_star.z() * v.z(); } @@ -318,8 +298,7 @@ inline auto BasicVector3D<T>::dot(const BasicVector3D<U>& v) const #ifndef SWIG template <class T> template <class U> -inline auto BasicVector3D<T>::cross(const BasicVector3D<U>& v) const -{ +inline auto BasicVector3D<T>::cross(const BasicVector3D<U>& v) const { return BasicVector3D<decltype(this->x() * v.x())>( y() * v.z() - v.y() * z(), z() * v.x() - v.z() * x(), x() * v.y() - v.x() * y()); } diff --git a/Base/Vector/Transform3D.cpp b/Base/Vector/Transform3D.cpp index 8f3140abfab6843aad2b6c5f16138294349589c4..1a2c304e2d9a792d05200cd4bbe2ca46427f36fa 100644 --- a/Base/Vector/Transform3D.cpp +++ b/Base/Vector/Transform3D.cpp @@ -15,19 +15,16 @@ #include "Base/Vector/Transform3D.h" #include <Eigen/LU> -Transform3D::Transform3D() -{ +Transform3D::Transform3D() { m_matrix.setIdentity(); m_inverse_matrix.setIdentity(); } -Transform3D::Transform3D(const Eigen::Matrix3d& matrix) : m_matrix(matrix) -{ +Transform3D::Transform3D(const Eigen::Matrix3d& matrix) : m_matrix(matrix) { m_inverse_matrix = m_matrix.inverse(); } -Transform3D Transform3D::createRotateX(double phi) -{ +Transform3D Transform3D::createRotateX(double phi) { double cosine = std::cos(phi); double sine = std::sin(phi); Eigen::Matrix3d matrix; @@ -39,8 +36,7 @@ Transform3D Transform3D::createRotateX(double phi) return Transform3D(matrix); } -Transform3D Transform3D::createRotateY(double phi) -{ +Transform3D Transform3D::createRotateY(double phi) { double cosine = std::cos(phi); double sine = std::sin(phi); Eigen::Matrix3d matrix; @@ -52,8 +48,7 @@ Transform3D Transform3D::createRotateY(double phi) return Transform3D(matrix); } -Transform3D Transform3D::createRotateZ(double phi) -{ +Transform3D Transform3D::createRotateZ(double phi) { double cosine = std::cos(phi); double sine = std::sin(phi); Eigen::Matrix3d matrix; @@ -65,16 +60,14 @@ Transform3D Transform3D::createRotateZ(double phi) return Transform3D(matrix); } -Transform3D Transform3D::createRotateEuler(double alpha, double beta, double gamma) -{ +Transform3D Transform3D::createRotateEuler(double alpha, double beta, double gamma) { Transform3D zrot = createRotateZ(alpha); Transform3D xrot = createRotateX(beta); Transform3D zrot2 = createRotateZ(gamma); return zrot * xrot * zrot2; } -void Transform3D::calculateEulerAngles(double* p_alpha, double* p_beta, double* p_gamma) const -{ +void Transform3D::calculateEulerAngles(double* p_alpha, double* p_beta, double* p_gamma) const { *p_beta = std::acos(m_matrix(2, 2)); // First check if second angle is zero or pi if (std::abs(m_matrix(2, 2)) == 1.0) { @@ -86,29 +79,24 @@ void Transform3D::calculateEulerAngles(double* p_alpha, double* p_beta, double* } } -double Transform3D::calculateRotateXAngle() const -{ +double Transform3D::calculateRotateXAngle() const { return std::atan2(m_matrix(2, 1), m_matrix(1, 1)); } -double Transform3D::calculateRotateYAngle() const -{ +double Transform3D::calculateRotateYAngle() const { return std::atan2(m_matrix(0, 2), m_matrix(2, 2)); } -double Transform3D::calculateRotateZAngle() const -{ +double Transform3D::calculateRotateZAngle() const { return std::atan2(m_matrix(1, 0), m_matrix(0, 0)); } -Transform3D Transform3D::getInverse() const -{ +Transform3D Transform3D::getInverse() const { Transform3D result(m_inverse_matrix); return result; } -template <class ivector_t> ivector_t Transform3D::transformed(const ivector_t& v) const -{ +template <class ivector_t> ivector_t Transform3D::transformed(const ivector_t& v) const { auto x = m_matrix(0, 0) * v.x() + m_matrix(0, 1) * v.y() + m_matrix(0, 2) * v.z(); auto y = m_matrix(1, 0) * v.x() + m_matrix(1, 1) * v.y() + m_matrix(1, 2) * v.z(); auto z = m_matrix(2, 0) * v.x() + m_matrix(2, 1) * v.y() + m_matrix(2, 2) * v.z(); @@ -118,8 +106,7 @@ template <class ivector_t> ivector_t Transform3D::transformed(const ivector_t& v template kvector_t Transform3D::transformed<kvector_t>(const kvector_t& v) const; template cvector_t Transform3D::transformed<cvector_t>(const cvector_t& v) const; -template <class ivector_t> ivector_t Transform3D::transformedInverse(const ivector_t& v) const -{ +template <class ivector_t> ivector_t Transform3D::transformedInverse(const ivector_t& v) const { auto x = m_inverse_matrix(0, 0) * v.x() + m_inverse_matrix(0, 1) * v.y() + m_inverse_matrix(0, 2) * v.z(); auto y = m_inverse_matrix(1, 0) * v.x() + m_inverse_matrix(1, 1) * v.y() @@ -132,24 +119,20 @@ template <class ivector_t> ivector_t Transform3D::transformedInverse(const ivect template kvector_t Transform3D::transformedInverse<kvector_t>(const kvector_t& v) const; template cvector_t Transform3D::transformedInverse<cvector_t>(const cvector_t& v) const; -Transform3D* Transform3D::clone() const -{ +Transform3D* Transform3D::clone() const { return new Transform3D(m_matrix); } -Transform3D Transform3D::operator*(const Transform3D& other) const -{ +Transform3D Transform3D::operator*(const Transform3D& other) const { Eigen::Matrix3d product_matrix = this->m_matrix * other.m_matrix; return Transform3D(product_matrix); } -bool Transform3D::operator==(const Transform3D& other) const -{ +bool Transform3D::operator==(const Transform3D& other) const { return this->m_matrix == other.m_matrix; } -Transform3D::ERotationType Transform3D::getRotationType() const -{ +Transform3D::ERotationType Transform3D::getRotationType() const { if (isXRotation()) return XAXIS; if (isYRotation()) @@ -159,20 +142,17 @@ Transform3D::ERotationType Transform3D::getRotationType() const return EULER; } -bool Transform3D::isIdentity() const -{ +bool Transform3D::isIdentity() const { double alpha, beta, gamma; calculateEulerAngles(&alpha, &beta, &gamma); return (alpha == 0.0 && beta == 0.0 && gamma == 0.0); } -void Transform3D::print(std::ostream& ostr) const -{ +void Transform3D::print(std::ostream& ostr) const { ostr << "Transform3D: " << m_matrix; } -bool Transform3D::isXRotation() const -{ +bool Transform3D::isXRotation() const { if (m_matrix(0, 0) != 1.0) return false; if (m_matrix(0, 1) != 0.0) @@ -186,8 +166,7 @@ bool Transform3D::isXRotation() const return true; } -bool Transform3D::isYRotation() const -{ +bool Transform3D::isYRotation() const { if (m_matrix(1, 1) != 1.0) return false; if (m_matrix(0, 1) != 0.0) @@ -201,8 +180,7 @@ bool Transform3D::isYRotation() const return true; } -bool Transform3D::isZRotation() const -{ +bool Transform3D::isZRotation() const { if (m_matrix(2, 2) != 1.0) return false; if (m_matrix(0, 2) != 0.0) diff --git a/Base/Vector/Transform3D.h b/Base/Vector/Transform3D.h index 32f47bf4d87ccd02e31ce97fc9461a7474089125..d10e9a7bb31397296a55684e9835ec3ce984abdc 100644 --- a/Base/Vector/Transform3D.h +++ b/Base/Vector/Transform3D.h @@ -24,8 +24,7 @@ //! Vector transformations in three dimensions. //! @ingroup tools_internal -class Transform3D -{ +class Transform3D { public: enum ERotationType { EULER, XAXIS, YAXIS, ZAXIS }; @@ -91,8 +90,7 @@ public: //! Determine if the transformation is trivial (identity) bool isIdentity() const; - friend std::ostream& operator<<(std::ostream& ostr, const Transform3D& m) - { + friend std::ostream& operator<<(std::ostream& ostr, const Transform3D& m) { m.print(ostr); return ostr; } diff --git a/Core/Computation/ComputationStatus.h b/Core/Computation/ComputationStatus.h index af6295b33c4fd10e69b965a106f4bf5248f0d768..33ad3c01c0dd93b542dea6ae962179f140d705d6 100644 --- a/Core/Computation/ComputationStatus.h +++ b/Core/Computation/ComputationStatus.h @@ -20,8 +20,7 @@ //! Completion status (flag and text) of a numeric computation. //! @ingroup algorithms_internal -class ComputationStatus -{ +class ComputationStatus { public: ComputationStatus() : m_status(IDLE) {} @@ -30,8 +29,7 @@ public: void setRunning() { m_status = RUNNING; } void setCompleted() { m_status = COMPLETED; } - void setFailed(const std::string& message) - { + void setFailed(const std::string& message) { m_error_message = message; m_status = FAILED; } diff --git a/Core/Computation/ConstantBackground.cpp b/Core/Computation/ConstantBackground.cpp index a06f6e5906792c1f121866dd09f8da08da0bf688..d4ee210a19447250eb183c08489146b97c130b9c 100644 --- a/Core/Computation/ConstantBackground.cpp +++ b/Core/Computation/ConstantBackground.cpp @@ -19,21 +19,15 @@ ConstantBackground::ConstantBackground(const std::vector<double> P) "class_tooltip", {{"BackgroundValue", "", "para_tooltip", 0, +INF, 0}}}, P) - , m_background_value(m_P[0]) -{ -} + , m_background_value(m_P[0]) {} ConstantBackground::ConstantBackground(double background_value) - : ConstantBackground(std::vector<double>{background_value}) -{ -} + : ConstantBackground(std::vector<double>{background_value}) {} -ConstantBackground* ConstantBackground::clone() const -{ +ConstantBackground* ConstantBackground::clone() const { return new ConstantBackground(m_background_value); } -double ConstantBackground::addBackground(double intensity) const -{ +double ConstantBackground::addBackground(double intensity) const { return intensity + m_background_value; } diff --git a/Core/Computation/ConstantBackground.h b/Core/Computation/ConstantBackground.h index 4bef013d94d11a68d5e40a159a579eb9cb65b3cf..ef5deb03a31da5812067caa136ec223757725b23 100644 --- a/Core/Computation/ConstantBackground.h +++ b/Core/Computation/ConstantBackground.h @@ -21,8 +21,7 @@ //! //! @ingroup simulation -class ConstantBackground : public IBackground -{ +class ConstantBackground : public IBackground { public: ConstantBackground(const std::vector<double> P); ConstantBackground(double background_value); diff --git a/Core/Computation/DWBAComputation.cpp b/Core/Computation/DWBAComputation.cpp index dfea2f66c1fb4a147ebbdb6b839a0200bebad734..c4923212d755e6195238af01e7d89f905d345c1a 100644 --- a/Core/Computation/DWBAComputation.cpp +++ b/Core/Computation/DWBAComputation.cpp @@ -32,8 +32,7 @@ DWBAComputation::DWBAComputation(const MultiLayer& multilayer, const SimulationO ProgressHandler& progress, std::vector<SimulationElement>::iterator begin_it, std::vector<SimulationElement>::iterator end_it) - : IComputation(multilayer, options, progress), m_begin_it(begin_it), m_end_it(end_it) -{ + : IComputation(multilayer, options, progress), m_begin_it(begin_it), m_end_it(end_it) { const IFresnelMap* p_fresnel_map = m_processed_sample->fresnelMap(); bool polarized = m_processed_sample->containsMagneticMaterial(); for (const ProcessedLayout& layout : m_processed_sample->layouts()) { @@ -55,8 +54,7 @@ DWBAComputation::~DWBAComputation() = default; // For roughness: (scattering cross-section of area S)/S // For specular peak: |R|^2 * sin(alpha_i) / solid_angle // This allows them to be added and normalized together to the beam afterwards -void DWBAComputation::runProtected() -{ +void DWBAComputation::runProtected() { if (!m_progress->alive()) return; m_single_computation.setProgressHandler(m_progress); diff --git a/Core/Computation/DWBAComputation.h b/Core/Computation/DWBAComputation.h index 1edfe833216b649a6066b52791dd4bf50a0bf5eb..cf375c40b77d19afde3e59faaefb0c88af0f9b4c 100644 --- a/Core/Computation/DWBAComputation.h +++ b/Core/Computation/DWBAComputation.h @@ -27,8 +27,7 @@ class SimulationElement; //! //! @ingroup algorithms_internal -class DWBAComputation : public IComputation -{ +class DWBAComputation : public IComputation { public: DWBAComputation(const MultiLayer& multilayer, const SimulationOptions& options, ProgressHandler& progress, std::vector<SimulationElement>::iterator begin_it, diff --git a/Core/Computation/DWBASingleComputation.cpp b/Core/Computation/DWBASingleComputation.cpp index 754f6efcee55744a0794ec856921a4d281ff3fb0..c5026b45d3c0a53dcd9283982e9f7dd1b629652c 100644 --- a/Core/Computation/DWBASingleComputation.cpp +++ b/Core/Computation/DWBASingleComputation.cpp @@ -22,29 +22,24 @@ DWBASingleComputation::DWBASingleComputation() = default; DWBASingleComputation::~DWBASingleComputation() = default; -void DWBASingleComputation::setProgressHandler(ProgressHandler* p_progress) -{ +void DWBASingleComputation::setProgressHandler(ProgressHandler* p_progress) { m_progress_counter = std::make_unique<DelayedProgressCounter>(p_progress, 100); } -void DWBASingleComputation::addLayoutComputation(ParticleLayoutComputation* p_layout_comp) -{ +void DWBASingleComputation::addLayoutComputation(ParticleLayoutComputation* p_layout_comp) { m_layout_comps.emplace_back(p_layout_comp); p_layout_comp->mergeRegionMap(m_region_map); } -void DWBASingleComputation::setRoughnessComputation(RoughMultiLayerComputation* p_roughness_comp) -{ +void DWBASingleComputation::setRoughnessComputation(RoughMultiLayerComputation* p_roughness_comp) { m_roughness_comp.reset(p_roughness_comp); } -void DWBASingleComputation::setSpecularBinComputation(GISASSpecularComputation* p_spec_comp) -{ +void DWBASingleComputation::setSpecularBinComputation(GISASSpecularComputation* p_spec_comp) { m_spec_comp.reset(p_spec_comp); } -void DWBASingleComputation::compute(SimulationElement& elem) const -{ +void DWBASingleComputation::compute(SimulationElement& elem) const { for (auto& layout_comp : m_layout_comps) layout_comp->compute(elem); diff --git a/Core/Computation/DWBASingleComputation.h b/Core/Computation/DWBASingleComputation.h index 354205ed097cd89425f8a10036442d4a8d3b621d..d04f6ce342258fa88594bad6f6bd30544765ad38 100644 --- a/Core/Computation/DWBASingleComputation.h +++ b/Core/Computation/DWBASingleComputation.h @@ -34,8 +34,7 @@ class SimulationElement; //! //! @ingroup algorithms_internal -class DWBASingleComputation -{ +class DWBASingleComputation { public: DWBASingleComputation(); ~DWBASingleComputation(); diff --git a/Core/Computation/DepthProbeComputation.cpp b/Core/Computation/DepthProbeComputation.cpp index 7de7f8c5df9361f9cd7cd053767aa21f1b6d8723..17846f24ab66cd81d089b3ee9954e4c5767580a8 100644 --- a/Core/Computation/DepthProbeComputation.cpp +++ b/Core/Computation/DepthProbeComputation.cpp @@ -30,14 +30,11 @@ DepthProbeComputation::DepthProbeComputation(const MultiLayer& multilayer, : IComputation(multilayer, options, progress) , m_begin_it(begin_it) , m_end_it(end_it) - , m_computation_term(m_processed_sample.get()) -{ -} + , m_computation_term(m_processed_sample.get()) {} DepthProbeComputation::~DepthProbeComputation() = default; -void DepthProbeComputation::runProtected() -{ +void DepthProbeComputation::runProtected() { if (!m_progress->alive()) return; m_computation_term.setProgressHandler(m_progress); diff --git a/Core/Computation/DepthProbeComputation.h b/Core/Computation/DepthProbeComputation.h index 615211334661ac45a870b9a70f339fbb33464ed2..b5c01a541358e4589e550282c5e1618ac86c6d9b 100644 --- a/Core/Computation/DepthProbeComputation.h +++ b/Core/Computation/DepthProbeComputation.h @@ -26,8 +26,7 @@ class MultiLayer; //! //! @ingroup algorithms_internal -class DepthProbeComputation : public IComputation -{ +class DepthProbeComputation : public IComputation { using DepthProbeElementIter = std::vector<DepthProbeElement>::iterator; public: diff --git a/Core/Computation/GISASSpecularComputation.cpp b/Core/Computation/GISASSpecularComputation.cpp index 5c2fb582ceb3c6eda4850f0115de89abcf220dcc..41db80e08f6a76358585372ed02b1d636db85ab1 100644 --- a/Core/Computation/GISASSpecularComputation.cpp +++ b/Core/Computation/GISASSpecularComputation.cpp @@ -18,12 +18,9 @@ #include "Sample/RT/ILayerRTCoefficients.h" GISASSpecularComputation::GISASSpecularComputation(const IFresnelMap* p_fresnel_map) - : m_fresnel_map{p_fresnel_map} -{ -} + : m_fresnel_map{p_fresnel_map} {} -void GISASSpecularComputation::compute(SimulationElement& elem) const -{ +void GISASSpecularComputation::compute(SimulationElement& elem) const { if (!elem.isSpecular()) return; complex_t R = m_fresnel_map->getInCoefficients(elem, 0)->getScalarR(); diff --git a/Core/Computation/GISASSpecularComputation.h b/Core/Computation/GISASSpecularComputation.h index 7f769f7f1f114666fca26a13f6934929ca73fd67..646d7273ce458fcc7eeed142d193da7162396a8e 100644 --- a/Core/Computation/GISASSpecularComputation.h +++ b/Core/Computation/GISASSpecularComputation.h @@ -21,8 +21,7 @@ class SimulationElement; //! Computes the specular signal in the bin where q_parallel = 0. Used by DWBAComputation. //! @ingroup algorithms_internal -class GISASSpecularComputation final -{ +class GISASSpecularComputation final { public: GISASSpecularComputation(const IFresnelMap* p_fresnel_map); diff --git a/Core/Computation/IBackground.cpp b/Core/Computation/IBackground.cpp index ec495328352d691329207e7ab79207d4479ec927..6b7cef8c7f7c79e472b2a23ef5e5591c3a9ce451 100644 --- a/Core/Computation/IBackground.cpp +++ b/Core/Computation/IBackground.cpp @@ -15,8 +15,6 @@ #include "Core/Computation/IBackground.h" IBackground::IBackground(const NodeMeta& meta, const std::vector<double>& PValues) - : INode(meta, PValues) -{ -} + : INode(meta, PValues) {} IBackground::~IBackground() = default; diff --git a/Core/Computation/IBackground.h b/Core/Computation/IBackground.h index a433b39476d7308c348bb970663cd7ce846b6dba..1a932bfd16dea9da6a328602e458399dfda8ba49 100644 --- a/Core/Computation/IBackground.h +++ b/Core/Computation/IBackground.h @@ -22,8 +22,7 @@ //! //! @ingroup algorithms_internal -class IBackground : public ICloneable, public INode -{ +class IBackground : public ICloneable, public INode { public: IBackground(const NodeMeta& meta, const std::vector<double>& PValues); virtual ~IBackground(); diff --git a/Core/Computation/IComputation.cpp b/Core/Computation/IComputation.cpp index 19c98155ee4e70e2e72c200212cb9bff8e9bf9af..dc9f4180462e03ecc377e88595da82356e001ce9 100644 --- a/Core/Computation/IComputation.cpp +++ b/Core/Computation/IComputation.cpp @@ -22,14 +22,11 @@ IComputation::IComputation(const MultiLayer& sample, const SimulationOptions& op ProgressHandler& progress) : m_sim_options(options) , m_progress(&progress) - , m_processed_sample(std::make_unique<ProcessedSample>(sample, options)) -{ -} + , m_processed_sample(std::make_unique<ProcessedSample>(sample, options)) {} IComputation::~IComputation() = default; -void IComputation::run() -{ +void IComputation::run() { m_status.setRunning(); try { runProtected(); diff --git a/Core/Computation/IComputation.h b/Core/Computation/IComputation.h index 6deb9a8e3f421009b25ea4af33cbfb2b2c97141a..61dd1bbb84e97982fc66ebca3f1e661a87ac9edf 100644 --- a/Core/Computation/IComputation.h +++ b/Core/Computation/IComputation.h @@ -31,8 +31,7 @@ class ProgressHandler; //! //! @ingroup algorithms_internal -class IComputation -{ +class IComputation { public: IComputation(const MultiLayer& sample, const SimulationOptions& options, ProgressHandler& progress); diff --git a/Core/Computation/ParticleLayoutComputation.cpp b/Core/Computation/ParticleLayoutComputation.cpp index 495c6077da84606cc80d02146bd7a31b9162f33e..16359a569a147996baaf212d937b40ee94e1558d 100644 --- a/Core/Computation/ParticleLayoutComputation.cpp +++ b/Core/Computation/ParticleLayoutComputation.cpp @@ -20,13 +20,11 @@ #include "Sample/Interference/SSCApproximationStrategy.h" #include "Sample/Processed/ProcessedLayout.h" -namespace -{ +namespace { std::unique_ptr<IInterferenceFunctionStrategy> processedInterferenceFunction(const ProcessedLayout& layout, const SimulationOptions& sim_params, - bool polarized) -{ + bool polarized) { const IInterferenceFunction* iff = layout.interferenceFunction(); if (iff && layout.numberOfSlices() > 1 && !iff->supportsMultilayer()) throw std::runtime_error("LayoutStrategyBuilder::checkInterferenceFunction: " @@ -52,14 +50,11 @@ ParticleLayoutComputation::ParticleLayoutComputation(const ProcessedLayout& layo bool polarized) : m_layout(layout) , m_region_map(layout.regionMap()) - , m_interference_function_strategy(processedInterferenceFunction(layout, options, polarized)) -{ -} + , m_interference_function_strategy(processedInterferenceFunction(layout, options, polarized)) {} ParticleLayoutComputation::~ParticleLayoutComputation() = default; -void ParticleLayoutComputation::compute(SimulationElement& elem) const -{ +void ParticleLayoutComputation::compute(SimulationElement& elem) const { const double alpha_f = elem.getAlphaMean(); const size_t n_layers = m_layout.numberOfSlices(); if (n_layers > 1 && alpha_f < 0) @@ -69,8 +64,7 @@ void ParticleLayoutComputation::compute(SimulationElement& elem) const } void ParticleLayoutComputation::mergeRegionMap( - std::map<size_t, std::vector<HomogeneousRegion>>& region_map) const -{ + std::map<size_t, std::vector<HomogeneousRegion>>& region_map) const { for (auto& entry : m_region_map) { size_t i = entry.first; auto& regions = entry.second; diff --git a/Core/Computation/ParticleLayoutComputation.h b/Core/Computation/ParticleLayoutComputation.h index 8ee888f002981559bd25df166910472a29ef71b2..ded7cb42e86910cffff89470d04683f4b847761f 100644 --- a/Core/Computation/ParticleLayoutComputation.h +++ b/Core/Computation/ParticleLayoutComputation.h @@ -29,8 +29,7 @@ class SimulationOptions; //! Used by DWBAComputation. //! @ingroup algorithms_internal -class ParticleLayoutComputation final -{ +class ParticleLayoutComputation final { public: ParticleLayoutComputation(const ProcessedLayout& layout, const SimulationOptions& options, bool polarized); diff --git a/Core/Computation/PoissonNoiseBackground.cpp b/Core/Computation/PoissonNoiseBackground.cpp index 51a0e632463221cf206e3aa8a87b8778a7b96756..76804f94004ff4a2f70ac12475927321e520952a 100644 --- a/Core/Computation/PoissonNoiseBackground.cpp +++ b/Core/Computation/PoissonNoiseBackground.cpp @@ -16,16 +16,12 @@ #include "Base/Math/Functions.h" PoissonNoiseBackground::PoissonNoiseBackground() - : IBackground({"PoissonNoiseBackground", "class_tooltip", {}}, {}) -{ -} + : IBackground({"PoissonNoiseBackground", "class_tooltip", {}}, {}) {} -PoissonNoiseBackground* PoissonNoiseBackground::clone() const -{ +PoissonNoiseBackground* PoissonNoiseBackground::clone() const { return new PoissonNoiseBackground; } -double PoissonNoiseBackground::addBackground(double intensity) const -{ +double PoissonNoiseBackground::addBackground(double intensity) const { return Math::GeneratePoissonRandom(intensity); } diff --git a/Core/Computation/PoissonNoiseBackground.h b/Core/Computation/PoissonNoiseBackground.h index 9b668b5a2736babe04c36cf2889cc5862e0e88bd..4fc830932c7b1a14629aa17fd616efa52b23c6de 100644 --- a/Core/Computation/PoissonNoiseBackground.h +++ b/Core/Computation/PoissonNoiseBackground.h @@ -21,8 +21,7 @@ //! //! @ingroup simulation -class PoissonNoiseBackground : public IBackground -{ +class PoissonNoiseBackground : public IBackground { public: PoissonNoiseBackground(); PoissonNoiseBackground* clone() const final; diff --git a/Core/Computation/RoughMultiLayerComputation.cpp b/Core/Computation/RoughMultiLayerComputation.cpp index 3bc911009874aadf776494759a022dde9fae8520..c37dc9c8491dc397d888c90deb3dea4d9ef2c478 100644 --- a/Core/Computation/RoughMultiLayerComputation.cpp +++ b/Core/Computation/RoughMultiLayerComputation.cpp @@ -28,25 +28,19 @@ // Diffuse scattering from rough interfaces is modelled after // Phys. Rev. B, vol. 51 (4), p. 2311 (1995) -namespace -{ -complex_t h_plus(complex_t z) -{ +namespace { +complex_t h_plus(complex_t z) { return 0.5 * cerfcx(-mul_I(z) / std::sqrt(2.0)); } -complex_t h_min(complex_t z) -{ +complex_t h_min(complex_t z) { return 0.5 * cerfcx(mul_I(z) / std::sqrt(2.0)); } } // namespace RoughMultiLayerComputation::RoughMultiLayerComputation(const ProcessedSample* p_sample) - : m_sample{p_sample} -{ -} + : m_sample{p_sample} {} -void RoughMultiLayerComputation::compute(SimulationElement& elem) const -{ +void RoughMultiLayerComputation::compute(SimulationElement& elem) const { if (elem.getAlphaMean() < 0.0) return; auto n_slices = m_sample->numberOfSlices(); @@ -82,16 +76,14 @@ void RoughMultiLayerComputation::compute(SimulationElement& elem) const elem.addIntensity((autocorr + crosscorr.real()) * M_PI / 4. / wavelength / wavelength); } -complex_t RoughMultiLayerComputation::get_refractive_term(size_t ilayer, double wavelength) const -{ +complex_t RoughMultiLayerComputation::get_refractive_term(size_t ilayer, double wavelength) const { auto& slices = m_sample->slices(); return slices[ilayer].material().refractiveIndex2(wavelength) - slices[ilayer + 1].material().refractiveIndex2(wavelength); } complex_t RoughMultiLayerComputation::get_sum8terms(size_t ilayer, - const SimulationElement& sim_element) const -{ + const SimulationElement& sim_element) const { auto& slices = m_sample->slices(); auto p_fresnel_map = m_sample->fresnelMap(); const auto P_in_plus = p_fresnel_map->getInCoefficients(sim_element, ilayer); diff --git a/Core/Computation/RoughMultiLayerComputation.h b/Core/Computation/RoughMultiLayerComputation.h index 0ed4fd53afe16812253b5d7912864a38aa8337f9..5d6b809696f5ad759bc1677acdcc325fe437313d 100644 --- a/Core/Computation/RoughMultiLayerComputation.h +++ b/Core/Computation/RoughMultiLayerComputation.h @@ -24,8 +24,7 @@ class SimulationElement; //! Used by DWBAComputation. //! @ingroup algorithms_internal -class RoughMultiLayerComputation final -{ +class RoughMultiLayerComputation final { public: RoughMultiLayerComputation(const ProcessedSample* p_sample); diff --git a/Core/Computation/SpecularComputation.cpp b/Core/Computation/SpecularComputation.cpp index 16c0a6ea1625346642fa03cef827b57dd6da5e3c..4f54e3783c27b3033bfc673616f42e317029141c 100644 --- a/Core/Computation/SpecularComputation.cpp +++ b/Core/Computation/SpecularComputation.cpp @@ -28,8 +28,7 @@ SpecularComputation::SpecularComputation(const MultiLayer& multilayer, const SimulationOptions& options, ProgressHandler& progress, SpecularElementIter begin_it, SpecularElementIter end_it) - : IComputation(multilayer, options, progress), m_begin_it(begin_it), m_end_it(end_it) -{ + : IComputation(multilayer, options, progress), m_begin_it(begin_it), m_end_it(end_it) { if (m_processed_sample->containsMagneticMaterial() || m_processed_sample->externalField() != kvector_t{}) m_computation_term.reset( @@ -41,8 +40,7 @@ SpecularComputation::SpecularComputation(const MultiLayer& multilayer, SpecularComputation::~SpecularComputation() = default; -void SpecularComputation::runProtected() -{ +void SpecularComputation::runProtected() { if (!m_progress->alive()) return; diff --git a/Core/Computation/SpecularComputation.h b/Core/Computation/SpecularComputation.h index 800ec8c461f7a67b8a2f5ace69e1fe6f52028fee..43a5c051d49ca349cbcf16c118c30c2d1bbe86b7 100644 --- a/Core/Computation/SpecularComputation.h +++ b/Core/Computation/SpecularComputation.h @@ -27,8 +27,7 @@ class SpecularSimulationElement; //! //! @ingroup algorithms_internal -class SpecularComputation : public IComputation -{ +class SpecularComputation : public IComputation { using SpecularElementIter = std::vector<SpecularSimulationElement>::iterator; public: diff --git a/Core/Element/DepthProbeElement.cpp b/Core/Element/DepthProbeElement.cpp index d312e02078e003ad21bb90ebf468b032c31ae1f5..96d7a4f2fcc7a37b640425d269702e2e0b79bafd 100644 --- a/Core/Element/DepthProbeElement.cpp +++ b/Core/Element/DepthProbeElement.cpp @@ -21,8 +21,7 @@ DepthProbeElement::DepthProbeElement(double wavelength, double alpha_i, const IA : m_wavelength(wavelength) , m_alpha_i(alpha_i) , m_z_positions(z_positions) - , m_calculation_flag(true) -{ + , m_calculation_flag(true) { if (!z_positions) throw std::runtime_error( "Error in DepthProbeElement::DepthProbeElement: z positions are not specified"); @@ -34,23 +33,18 @@ DepthProbeElement::DepthProbeElement(const DepthProbeElement& other) , m_alpha_i(other.m_alpha_i) , m_intensities(other.m_intensities) , m_z_positions(other.m_z_positions) - , m_calculation_flag(other.m_calculation_flag) -{ -} + , m_calculation_flag(other.m_calculation_flag) {} DepthProbeElement::DepthProbeElement(DepthProbeElement&& other) noexcept : m_wavelength(other.m_wavelength) , m_alpha_i(other.m_alpha_i) , m_intensities(std::move(other.m_intensities)) , m_z_positions(other.m_z_positions) - , m_calculation_flag(other.m_calculation_flag) -{ -} + , m_calculation_flag(other.m_calculation_flag) {} DepthProbeElement::~DepthProbeElement() = default; -DepthProbeElement& DepthProbeElement::operator=(const DepthProbeElement& other) -{ +DepthProbeElement& DepthProbeElement::operator=(const DepthProbeElement& other) { if (this != &other) { DepthProbeElement tmp(other); tmp.swapContent(*this); @@ -58,13 +52,11 @@ DepthProbeElement& DepthProbeElement::operator=(const DepthProbeElement& other) return *this; } -kvector_t DepthProbeElement::getKi() const -{ +kvector_t DepthProbeElement::getKi() const { return vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, phi_i_0); } -void DepthProbeElement::swapContent(DepthProbeElement& other) -{ +void DepthProbeElement::swapContent(DepthProbeElement& other) { std::swap(m_wavelength, other.m_wavelength); std::swap(m_alpha_i, other.m_alpha_i); m_intensities.swap(other.m_intensities); diff --git a/Core/Element/DepthProbeElement.h b/Core/Element/DepthProbeElement.h index ab41049b8db2d592af4d1bfc3d46446ae6369a44..d7062e911e917ccea7d64e7686ab7a818566d3ed 100644 --- a/Core/Element/DepthProbeElement.h +++ b/Core/Element/DepthProbeElement.h @@ -21,8 +21,7 @@ class IAxis; -class DepthProbeElement -{ +class DepthProbeElement { public: DepthProbeElement(double wavelength, double alpha_i, const IAxis* z_positions); DepthProbeElement(const DepthProbeElement& other); @@ -36,8 +35,7 @@ public: double getAlphaI() const { return m_alpha_i; } kvector_t getKi() const; - template <typename T> void setIntensities(T&& intensities) - { + template <typename T> void setIntensities(T&& intensities) { static_assert( std::is_assignable<std::valarray<double>, typename std::decay<T>::type>::value, "Error in DepthProbeElement::setIntensities: wrong type of input data."); diff --git a/Core/Element/SpecularSimulationElement.cpp b/Core/Element/SpecularSimulationElement.cpp index a489c63367c57e56c10242374d61ef12cda2ed26..d3030f5f07f3e190478b812847c7acb539647f1f 100644 --- a/Core/Element/SpecularSimulationElement.cpp +++ b/Core/Element/SpecularSimulationElement.cpp @@ -25,9 +25,7 @@ SpecularSimulationElement::SpecularSimulationElement(double kz, const Instrument , m_computable(computable) , m_kz_computation([kz](const std::vector<Slice>& slices) { return KzComputation::computeKzFromSLDs(slices, kz); - }) -{ -} + }) {} SpecularSimulationElement::SpecularSimulationElement(double wavelength, double alpha, const Instrument& instrument, bool computable) @@ -38,29 +36,22 @@ SpecularSimulationElement::SpecularSimulationElement(double wavelength, double a , m_kz_computation( [k = vecOfLambdaAlphaPhi(wavelength, alpha, 0.0)](const std::vector<Slice>& slices) { return KzComputation::computeKzFromRefIndices(slices, k); - }) -{ -} + }) {} SpecularSimulationElement::SpecularSimulationElement(const SpecularSimulationElement& other) : m_polarization(other.m_polarization) , m_intensity(other.m_intensity) , m_computable(other.m_computable) - , m_kz_computation(other.m_kz_computation) -{ -} + , m_kz_computation(other.m_kz_computation) {} SpecularSimulationElement::SpecularSimulationElement(SpecularSimulationElement&& other) noexcept : m_polarization(std::move(other.m_polarization)) , m_intensity(other.m_intensity) , m_computable(other.m_computable) - , m_kz_computation(std::move(other.m_kz_computation)) -{ -} + , m_kz_computation(std::move(other.m_kz_computation)) {} SpecularSimulationElement::~SpecularSimulationElement() = default; -std::vector<complex_t> SpecularSimulationElement::produceKz(const std::vector<Slice>& slices) -{ +std::vector<complex_t> SpecularSimulationElement::produceKz(const std::vector<Slice>& slices) { return m_kz_computation(slices); } diff --git a/Core/Element/SpecularSimulationElement.h b/Core/Element/SpecularSimulationElement.h index 413f2cef7c2ea739abddb331877fd015366d4701..46ee9c9c80429a256d162cceb98f149413c157be 100644 --- a/Core/Element/SpecularSimulationElement.h +++ b/Core/Element/SpecularSimulationElement.h @@ -27,8 +27,7 @@ class Slice; //! Data stucture containing both input and output of a single image pixel for specular simulation. //! @ingroup simulation -class SpecularSimulationElement -{ +class SpecularSimulationElement { public: SpecularSimulationElement(double kz, const Instrument& instrument, bool computable); SpecularSimulationElement(double wavelength, double alpha, const Instrument& instrument, diff --git a/Core/Export/ExportToPython.cpp b/Core/Export/ExportToPython.cpp index 91f76c7101b252bc0e1d2e93bb918e74f0adf795..10305e9d43cdaa26dfaa08eacef407a102bf4558 100644 --- a/Core/Export/ExportToPython.cpp +++ b/Core/Export/ExportToPython.cpp @@ -17,11 +17,9 @@ #include "Core/Export/SimulationToPython.h" #include "Core/Simulation/GISASSimulation.h" -namespace -{ +namespace { std::string simulationCode(const ISimulation& simulation, - SimulationToPython::EMainType mainFunctionType) -{ + SimulationToPython::EMainType mainFunctionType) { std::unique_ptr<ISimulation> sim(simulation.clone()); sim->prepareSimulation(); @@ -30,18 +28,15 @@ std::string simulationCode(const ISimulation& simulation, } } // namespace -std::string ExportToPython::generateSampleCode(const MultiLayer& multilayer) -{ +std::string ExportToPython::generateSampleCode(const MultiLayer& multilayer) { SampleToPython generator; return generator.generateSampleCode(multilayer); } -std::string ExportToPython::generateSimulationCode(const ISimulation& simulation) -{ +std::string ExportToPython::generateSimulationCode(const ISimulation& simulation) { return simulationCode(simulation, SimulationToPython::RUN_SIMULATION); } -std::string ExportToPython::generatePyExportTest(const ISimulation& simulation) -{ +std::string ExportToPython::generatePyExportTest(const ISimulation& simulation) { return simulationCode(simulation, SimulationToPython::SAVE_DATA); } diff --git a/Core/Export/ExportToPython.h b/Core/Export/ExportToPython.h index 766d5bd9579a2af74eefe137292d44c3c88a406d..d74a5a1d9cd82eaa5f1d91b91a64d29f57fb3ace 100644 --- a/Core/Export/ExportToPython.h +++ b/Core/Export/ExportToPython.h @@ -22,8 +22,7 @@ class ISimulation; //! Contains main methods to generate Python scripts from Core simulation objects. -namespace ExportToPython -{ +namespace ExportToPython { std::string generateSampleCode(const MultiLayer& multilayer); std::string generateSimulationCode(const ISimulation& simulation); diff --git a/Core/Export/INodeUtils.h b/Core/Export/INodeUtils.h index ca15c98c12688a51e0c878f9ae6529858f770dba..fb49a3a6704b63b27eafcac5cfe85f469e9dde13 100644 --- a/Core/Export/INodeUtils.h +++ b/Core/Export/INodeUtils.h @@ -17,10 +17,8 @@ #include "Param/Node/INode.h" -namespace INodeUtils -{ -template <typename T> std::vector<const T*> ChildNodesOfType(const INode& node) -{ +namespace INodeUtils { +template <typename T> std::vector<const T*> ChildNodesOfType(const INode& node) { std::vector<const T*> result; for (const auto& p_child : node.getChildren()) { if (const auto* t = dynamic_cast<const T*>(p_child)) @@ -29,16 +27,14 @@ template <typename T> std::vector<const T*> ChildNodesOfType(const INode& node) return result; } -template <typename T> const T* OnlyChildOfType(const INode& node) -{ +template <typename T> const T* OnlyChildOfType(const INode& node) { const auto list = ChildNodesOfType<T>(node); if (list.size() != 1) return nullptr; return list.front(); } -template <typename T> std::vector<const T*> AllDescendantsOfType(const INode& node) -{ +template <typename T> std::vector<const T*> AllDescendantsOfType(const INode& node) { std::vector<const T*> result; for (const auto* p_child : node.getChildren()) { if (const auto* t = dynamic_cast<const T*>(p_child)) diff --git a/Core/Export/OrderedMap.h b/Core/Export/OrderedMap.h index b515621cad14cf61b1abd7952ccd40a64f395016..fe5823099b5f7c824ade72329eef8fd070c8d76a 100644 --- a/Core/Export/OrderedMap.h +++ b/Core/Export/OrderedMap.h @@ -25,8 +25,7 @@ //! @ingroup tools_internal //! @brief Ordered map which saves the order of insertion -template <class Key, class Object> class OrderedMap -{ +template <class Key, class Object> class OrderedMap { public: typedef std::pair<Key, Object> entry_t; typedef std::list<entry_t> list_t; @@ -37,8 +36,7 @@ public: OrderedMap() {} virtual ~OrderedMap() {} - void clear() - { + void clear() { m_map.clear(); m_list.clear(); } @@ -48,37 +46,32 @@ public: iterator begin() { return m_list.begin(); } iterator end() { return m_list.end(); } - size_t size() const - { + size_t size() const { ASSERT(m_list.size() == m_map.size()); return m_list.size(); } bool empty() const { return size() == 0; } // if such key exists, pair will be deleted, and new pair appended to the end - void insert(const Key& key, const Object& object) - { + void insert(const Key& key, const Object& object) { erase(key); iterator it = m_list.insert(m_list.end(), std::make_pair(key, object)); m_map[key] = it; } - iterator find(const Key& key) - { + iterator find(const Key& key) { if (m_map.find(key) != m_map.end()) return m_map[key]; return m_list.end(); } - const_iterator find(const Key& key) const - { + const_iterator find(const Key& key) const { if (m_map.find(key) != m_map.end()) return m_map[key]; return m_list.end(); } - size_t erase(const Key& key) - { + size_t erase(const Key& key) { size_t result(0); if (m_map.find(key) == m_map.end()) return result; @@ -88,8 +81,7 @@ public: return 1; } - const Object& value(const Key& key) const - { + const Object& value(const Key& key) const { typename map_t::const_iterator mit = m_map.find(key); if (mit == m_map.end()) throw std::runtime_error("OrderedMap::value() -> No such key"); diff --git a/Core/Export/SampleLabelHandler.cpp b/Core/Export/SampleLabelHandler.cpp index b21a927b2fbf471e9157eeae30c1f4aa35a326f8..611990dcd9f1cec31b499be2f7171cc2cd35ad66 100644 --- a/Core/Export/SampleLabelHandler.cpp +++ b/Core/Export/SampleLabelHandler.cpp @@ -23,53 +23,43 @@ #include "Sample/Slice/LayerRoughness.h" #include <set> -std::string SampleLabelHandler::labelCrystal(const Crystal* cr) -{ +std::string SampleLabelHandler::labelCrystal(const Crystal* cr) { return m_CrystalLabel[cr]; } -std::string SampleLabelHandler::labelFormFactor(const IFormFactor* ff) -{ +std::string SampleLabelHandler::labelFormFactor(const IFormFactor* ff) { return m_FormFactorLabel[ff]; } -std::string SampleLabelHandler::labelInterferenceFunction(const IInterferenceFunction* iff) -{ +std::string SampleLabelHandler::labelInterferenceFunction(const IInterferenceFunction* iff) { return m_InterferenceFunctionLabel[iff]; } -std::string SampleLabelHandler::labelLayer(const Layer* layer) -{ +std::string SampleLabelHandler::labelLayer(const Layer* layer) { return m_LayerLabel[layer]; } -std::string SampleLabelHandler::labelLayout(const ParticleLayout* layout) -{ +std::string SampleLabelHandler::labelLayout(const ParticleLayout* layout) { return m_ParticleLayoutLabel[layout]; } -std::string SampleLabelHandler::labelMaterial(const Material* mat) -{ +std::string SampleLabelHandler::labelMaterial(const Material* mat) { return m_MaterialLabel[mat]; } -std::string SampleLabelHandler::labelLattice2D(const Lattice2D* lat) -{ +std::string SampleLabelHandler::labelLattice2D(const Lattice2D* lat) { return m_Lattice2DLabel[lat]; } -std::string SampleLabelHandler::labelLattice3D(const Lattice3D* lat) -{ +std::string SampleLabelHandler::labelLattice3D(const Lattice3D* lat) { return m_Lattice3DLabel[lat]; } -std::string SampleLabelHandler::labelMultiLayer(const MultiLayer* ml) -{ +std::string SampleLabelHandler::labelMultiLayer(const MultiLayer* ml) { return m_MultiLayerLabel[ml]; } -std::string SampleLabelHandler::labelParticle(const IAbstractParticle* absparticle) -{ +std::string SampleLabelHandler::labelParticle(const IAbstractParticle* absparticle) { if (const auto core_shell_particle = dynamic_cast<const ParticleCoreShell*>(absparticle)) return m_ParticleCoreShellLabel[core_shell_particle]; if (const auto particle = dynamic_cast<const Particle*>(absparticle)) @@ -84,60 +74,50 @@ std::string SampleLabelHandler::labelParticle(const IAbstractParticle* abspartic "SampleLabelHandler::getLabel: called for unknown IParticle type"); } -std::string SampleLabelHandler::labelRotation(const IRotation* rot) -{ +std::string SampleLabelHandler::labelRotation(const IRotation* rot) { return m_RotationsLabel[rot]; } -std::string SampleLabelHandler::labelRoughness(const LayerRoughness* roughness) -{ +std::string SampleLabelHandler::labelRoughness(const LayerRoughness* roughness) { return m_LayerRoughnessLabel[roughness]; } -void SampleLabelHandler::insertCrystal(const Crystal* sample) -{ +void SampleLabelHandler::insertCrystal(const Crystal* sample) { std::string label = "crystal_" + std::to_string(m_CrystalLabel.size() + 1); m_CrystalLabel.insert(sample, label); } -void SampleLabelHandler::insertFormFactor(const IFormFactor* sample) -{ +void SampleLabelHandler::insertFormFactor(const IFormFactor* sample) { std::string label = "formFactor_" + std::to_string(m_FormFactorLabel.size() + 1); m_FormFactorLabel.insert(sample, label); } -void SampleLabelHandler::insertInterferenceFunction(const IInterferenceFunction* sample) -{ +void SampleLabelHandler::insertInterferenceFunction(const IInterferenceFunction* sample) { std::string label = "interference_" + std::to_string(m_InterferenceFunctionLabel.size() + 1); m_InterferenceFunctionLabel.insert(sample, label); } -void SampleLabelHandler::insertLattice2D(const Lattice2D* sample) -{ +void SampleLabelHandler::insertLattice2D(const Lattice2D* sample) { std::string label = "lattice2D_" + std::to_string(m_Lattice2DLabel.size() + 1); m_Lattice2DLabel.insert(sample, label); } -void SampleLabelHandler::insertLattice3D(const Lattice3D* sample) -{ +void SampleLabelHandler::insertLattice3D(const Lattice3D* sample) { std::string label = "lattice3D_" + std::to_string(m_Lattice3DLabel.size() + 1); m_Lattice3DLabel.insert(sample, label); } -void SampleLabelHandler::insertLayer(const Layer* sample) -{ +void SampleLabelHandler::insertLayer(const Layer* sample) { std::string label = "layer_" + std::to_string(m_LayerLabel.size() + 1); m_LayerLabel.insert(sample, label); } -void SampleLabelHandler::insertLayout(const ParticleLayout* sample) -{ +void SampleLabelHandler::insertLayout(const ParticleLayout* sample) { std::string label = "layout_" + std::to_string(m_ParticleLayoutLabel.size() + 1); m_ParticleLayoutLabel.insert(sample, label); } -void SampleLabelHandler::insertMaterial(const Material* mat) -{ +void SampleLabelHandler::insertMaterial(const Material* mat) { for (auto it = m_MaterialLabel.begin(); it != m_MaterialLabel.end(); ++it) { if (*(it->first) == *mat) { m_MaterialLabel.insert(mat, it->second); @@ -153,52 +133,44 @@ void SampleLabelHandler::insertMaterial(const Material* mat) m_MaterialLabel.insert(mat, label); } -void SampleLabelHandler::insertMesoCrystal(const MesoCrystal* sample) -{ +void SampleLabelHandler::insertMesoCrystal(const MesoCrystal* sample) { std::string label = "mesocrystal_" + std::to_string(m_MesoCrystalLabel.size() + 1); m_MesoCrystalLabel.insert(sample, label); } -void SampleLabelHandler::insertMultiLayer(const MultiLayer* sample) -{ +void SampleLabelHandler::insertMultiLayer(const MultiLayer* sample) { std::string label = "multiLayer_" + std::to_string(m_MultiLayerLabel.size() + 1); m_MultiLayerLabel.insert(sample, label); } -void SampleLabelHandler::insertParticleComposition(const ParticleComposition* sample) -{ +void SampleLabelHandler::insertParticleComposition(const ParticleComposition* sample) { std::string label = "particleComposition_" + std::to_string(m_ParticleCompositionLabel.size() + 1); m_ParticleCompositionLabel.insert(sample, label); } -void SampleLabelHandler::insertParticleDistribution(const ParticleDistribution* sample) -{ +void SampleLabelHandler::insertParticleDistribution(const ParticleDistribution* sample) { std::string label = "particleDistribution_" + std::to_string(m_ParticleDistributionLabel.size() + 1); m_ParticleDistributionLabel.insert(sample, label); } -void SampleLabelHandler::insertParticle(const Particle* sample) -{ +void SampleLabelHandler::insertParticle(const Particle* sample) { std::string label = "particle_" + std::to_string(m_ParticleLabel.size() + 1); m_ParticleLabel.insert(sample, label); } -void SampleLabelHandler::insertParticleCoreShell(const ParticleCoreShell* sample) -{ +void SampleLabelHandler::insertParticleCoreShell(const ParticleCoreShell* sample) { std::string label = "particleCoreShell_" + std::to_string(m_ParticleCoreShellLabel.size() + 1); m_ParticleCoreShellLabel.insert(sample, label); } -void SampleLabelHandler::insertRotation(const IRotation* sample) -{ +void SampleLabelHandler::insertRotation(const IRotation* sample) { std::string label = "rotation_" + std::to_string(m_RotationsLabel.size() + 1); m_RotationsLabel.insert(sample, label); } -void SampleLabelHandler::insertRoughness(const LayerRoughness* sample) -{ +void SampleLabelHandler::insertRoughness(const LayerRoughness* sample) { if (sample->getSigma() != 0 && sample->getHurstParameter() != 0 && sample->getLatteralCorrLength() != 0) { std::string label = "layerRoughness_" + std::to_string(m_LayerRoughnessLabel.size() + 1); diff --git a/Core/Export/SampleLabelHandler.h b/Core/Export/SampleLabelHandler.h index 8785843b271223cc039bb233fe9604ea957ea269..10c136a3dd3d97cdd76aa2b01ea4940abd427205 100644 --- a/Core/Export/SampleLabelHandler.h +++ b/Core/Export/SampleLabelHandler.h @@ -36,15 +36,12 @@ class ParticleCoreShell; class ParticleDistribution; class MesoCrystal; -template <class Key> class LabelMap : public OrderedMap<Key, std::string> -{ -}; +template <class Key> class LabelMap : public OrderedMap<Key, std::string> {}; //! The handler which construct labels for sample variables during python script generation. //! @ingroup tools_internal -class SampleLabelHandler -{ +class SampleLabelHandler { public: typedef LabelMap<const Crystal*> crystals_t; typedef LabelMap<const IFormFactor*> formfactors_t; diff --git a/Core/Export/SampleToPython.cpp b/Core/Export/SampleToPython.cpp index b61483556e44239652ce78ba858d14a4b137f3b5..6391d69d3623497ab1b03a526776c53511ce1f1f 100644 --- a/Core/Export/SampleToPython.cpp +++ b/Core/Export/SampleToPython.cpp @@ -36,14 +36,12 @@ #include <map> #include <set> -std::string SampleToPython::generateSampleCode(const MultiLayer& multilayer) -{ +std::string SampleToPython::generateSampleCode(const MultiLayer& multilayer) { initLabels(multilayer); return defineGetSample(); } -void SampleToPython::initLabels(const MultiLayer& multilayer) -{ +void SampleToPython::initLabels(const MultiLayer& multilayer) { m_label.reset(new SampleLabelHandler()); m_label->insertMultiLayer(&multilayer); @@ -84,8 +82,7 @@ SampleToPython::SampleToPython() = default; SampleToPython::~SampleToPython() = default; -std::string SampleToPython::defineGetSample() const -{ +std::string SampleToPython::defineGetSample() const { return "def " + pyfmt::getSampleFunctionName() + "():\n" + defineMaterials() + defineLayers() + defineFormFactors() + defineParticles() + defineCoreShellParticles() + defineParticleCompositions() + defineLattices2D() + defineLattices3D() @@ -98,8 +95,7 @@ const std::map<MATERIAL_TYPES, std::string> factory_names{ {MATERIAL_TYPES::RefractiveMaterial, "HomogeneousMaterial"}, {MATERIAL_TYPES::MaterialBySLD, "MaterialBySLD"}}; -std::string SampleToPython::defineMaterials() const -{ +std::string SampleToPython::defineMaterials() const { const LabelMap<const Material*>* themap = m_label->materialMap(); if (themap->empty()) return "# No materials.\n\n"; @@ -136,8 +132,7 @@ std::string SampleToPython::defineMaterials() const return result.str(); } -std::string SampleToPython::defineLayers() const -{ +std::string SampleToPython::defineLayers() const { const auto* themap = m_label->layerMap(); if (themap->empty()) return "# No Layers.\n\n"; @@ -158,8 +153,7 @@ std::string SampleToPython::defineLayers() const return result.str(); } -std::string SampleToPython::defineFormFactors() const -{ +std::string SampleToPython::defineFormFactors() const { const auto* themap = m_label->formFactorMap(); if (themap->empty()) return ""; @@ -174,8 +168,7 @@ std::string SampleToPython::defineFormFactors() const return result.str(); } -std::string SampleToPython::defineParticles() const -{ +std::string SampleToPython::defineParticles() const { const auto* themap = m_label->particleMap(); if (themap->empty()) return ""; @@ -197,8 +190,7 @@ std::string SampleToPython::defineParticles() const return result.str(); } -std::string SampleToPython::defineCoreShellParticles() const -{ +std::string SampleToPython::defineCoreShellParticles() const { const auto* themap = m_label->particleCoreShellMap(); if (themap->empty()) return ""; @@ -218,8 +210,7 @@ std::string SampleToPython::defineCoreShellParticles() const return result.str(); } -std::string SampleToPython::defineParticleDistributions() const -{ +std::string SampleToPython::defineParticleDistributions() const { const auto* themap = m_label->particleDistributionsMap(); if (themap->empty()) return ""; @@ -266,8 +257,7 @@ std::string SampleToPython::defineParticleDistributions() const return result.str(); } -std::string SampleToPython::defineParticleCompositions() const -{ +std::string SampleToPython::defineParticleCompositions() const { const auto* themap = m_label->particleCompositionMap(); if (themap->empty()) return ""; @@ -289,8 +279,7 @@ std::string SampleToPython::defineParticleCompositions() const return result.str(); } -std::string SampleToPython::defineLattices2D() const -{ +std::string SampleToPython::defineLattices2D() const { const auto* themap = m_label->lattice2DMap(); if (themap->empty()) return ""; @@ -309,8 +298,7 @@ std::string SampleToPython::defineLattices2D() const return result.str(); } -std::string SampleToPython::defineLattices3D() const -{ +std::string SampleToPython::defineLattices3D() const { const auto* themap = m_label->lattice3DMap(); if (themap->empty()) return ""; @@ -334,8 +322,7 @@ std::string SampleToPython::defineLattices3D() const return result.str(); } -std::string SampleToPython::defineCrystals() const -{ +std::string SampleToPython::defineCrystals() const { const auto* themap = m_label->crystalMap(); if (themap->empty()) return ""; @@ -356,8 +343,7 @@ std::string SampleToPython::defineCrystals() const return result.str(); } -std::string SampleToPython::defineMesoCrystals() const -{ +std::string SampleToPython::defineMesoCrystals() const { const auto* themap = m_label->mesocrystalMap(); if (themap->empty()) return ""; @@ -380,8 +366,7 @@ std::string SampleToPython::defineMesoCrystals() const return result.str(); } -std::string SampleToPython::defineInterferenceFunctions() const -{ +std::string SampleToPython::defineInterferenceFunctions() const { const auto* themap = m_label->interferenceFunctionMap(); if (themap->empty()) return ""; @@ -504,8 +489,7 @@ std::string SampleToPython::defineInterferenceFunctions() const return result.str(); } -std::string SampleToPython::defineParticleLayouts() const -{ +std::string SampleToPython::defineParticleLayouts() const { const auto* themap = m_label->particleLayoutMap(); if (themap->empty()) return ""; @@ -536,8 +520,7 @@ std::string SampleToPython::defineParticleLayouts() const return result.str(); } -std::string SampleToPython::defineRoughnesses() const -{ +std::string SampleToPython::defineRoughnesses() const { const auto* themap = m_label->layerRoughnessMap(); if (themap->empty()) return ""; @@ -550,8 +533,7 @@ std::string SampleToPython::defineRoughnesses() const return result.str(); } -std::string SampleToPython::addLayoutsToLayers() const -{ +std::string SampleToPython::addLayoutsToLayers() const { if (m_label->particleLayoutMap()->empty()) return ""; std::ostringstream result; @@ -568,8 +550,7 @@ std::string SampleToPython::addLayoutsToLayers() const return result.str(); } -std::string SampleToPython::defineMultiLayers() const -{ +std::string SampleToPython::defineMultiLayers() const { const auto* themap = m_label->multiLayerMap(); if (themap->empty()) return "# No MultiLayers.\n\n"; @@ -614,14 +595,12 @@ std::string SampleToPython::defineMultiLayers() const return result.str(); } -std::string SampleToPython::indent() const -{ +std::string SampleToPython::indent() const { return " "; } void SampleToPython::setRotationInformation(const IParticle* particle, std::string name, - std::ostringstream& result) const -{ + std::ostringstream& result) const { if (particle->rotation()) { switch (particle->rotation()->getTransform3D().getRotationType()) { case Transform3D::EULER: { @@ -656,8 +635,7 @@ void SampleToPython::setRotationInformation(const IParticle* particle, std::stri } void SampleToPython::setPositionInformation(const IParticle* particle, std::string name, - std::ostringstream& result) const -{ + std::ostringstream& result) const { kvector_t pos = particle->position(); if (pos == kvector_t()) return; diff --git a/Core/Export/SampleToPython.h b/Core/Export/SampleToPython.h index c9ba6ba526ffbc1a37b1211dfb679c6619069e0f..bad1354fddaf173746bf2b18dc8543cf6ef5a160 100644 --- a/Core/Export/SampleToPython.h +++ b/Core/Export/SampleToPython.h @@ -24,8 +24,7 @@ class SampleLabelHandler; //! Generates Python code snippet from domain (C++) objects representing sample construction. -class SampleToPython -{ +class SampleToPython { public: SampleToPython(); ~SampleToPython(); diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp index f91189d67300d55b7e0c8742cdcf83076ad5c878..db09a2c0befa7b27eb39944b0c56c02c1912bb51 100644 --- a/Core/Export/SimulationToPython.cpp +++ b/Core/Export/SimulationToPython.cpp @@ -35,8 +35,7 @@ #include "Param/Varia/PyFmtLimits.h" #include <iomanip> -namespace -{ +namespace { const std::string defineSimulate = "def run_simulation():\n" " sample = " + pyfmt::getSampleFunctionName() @@ -48,8 +47,7 @@ const std::string defineSimulate = "def run_simulation():\n" "\n\n"; //! Returns a function that converts a coordinate to a Python code snippet with appropiate unit -std::function<std::string(double)> printFunc(const IDetector* detector) -{ +std::function<std::string(double)> printFunc(const IDetector* detector) { if (detector->defaultAxesUnits() == Axes::Units::MM) return pyfmt::printDouble; if (detector->defaultAxesUnits() == Axes::Units::RADIANS) @@ -59,8 +57,7 @@ std::function<std::string(double)> printFunc(const IDetector* detector) } //! returns true if it is (0, -1, 0) vector -bool isDefaultDirection(const kvector_t direction) -{ +bool isDefaultDirection(const kvector_t direction) { return algo::almostEqual(direction.x(), 0.0) && algo::almostEqual(direction.y(), -1.0) && algo::almostEqual(direction.z(), 0.0); } @@ -70,8 +67,7 @@ bool isDefaultDirection(const kvector_t direction) //! Returns a Python script that sets up a simulation and runs it if invoked as main program. std::string SimulationToPython::generateSimulationCode(const ISimulation& simulation, - EMainType mainType) -{ + EMainType mainType) { if (simulation.sample() == nullptr) throw std::runtime_error("SimulationToPython::generateSimulationCode() -> Error. " "ISimulation is not initialized."); @@ -82,8 +78,7 @@ std::string SimulationToPython::generateSimulationCode(const ISimulation& simula + defineGetSimulation(&simulation) + defineSimulate + defineMain(mainType); } -std::string SimulationToPython::defineGetSimulation(const ISimulation* simulation) const -{ +std::string SimulationToPython::defineGetSimulation(const ISimulation* simulation) const { std::ostringstream result; result << "def get_simulation():\n"; @@ -101,8 +96,7 @@ std::string SimulationToPython::defineGetSimulation(const ISimulation* simulatio return result.str(); } -std::string SimulationToPython::defineGISASSimulation(const GISASSimulation* simulation) const -{ +std::string SimulationToPython::defineGISASSimulation(const GISASSimulation* simulation) const { std::ostringstream result; result << pyfmt::indent() << "simulation = ba.GISASSimulation()\n"; result << defineDetector(simulation); @@ -116,8 +110,7 @@ std::string SimulationToPython::defineGISASSimulation(const GISASSimulation* sim return result.str(); } -std::string SimulationToPython::defineOffSpecSimulation(const OffSpecSimulation* simulation) const -{ +std::string SimulationToPython::defineOffSpecSimulation(const OffSpecSimulation* simulation) const { std::ostringstream result; result << pyfmt::indent() << "simulation = ba.OffSpecSimulation()\n"; result << defineDetector(simulation); @@ -131,8 +124,8 @@ std::string SimulationToPython::defineOffSpecSimulation(const OffSpecSimulation* return result.str(); } -std::string SimulationToPython::defineSpecularSimulation(const SpecularSimulation* simulation) const -{ +std::string +SimulationToPython::defineSpecularSimulation(const SpecularSimulation* simulation) const { std::ostringstream result; result << pyfmt::indent() << "simulation = ba.SpecularSimulation()\n"; result << defineDetectorPolarizationAnalysis(simulation); @@ -143,8 +136,7 @@ std::string SimulationToPython::defineSpecularSimulation(const SpecularSimulatio return result.str(); } -std::string SimulationToPython::defineDetector(const ISimulation* simulation) const -{ +std::string SimulationToPython::defineDetector(const ISimulation* simulation) const { const IDetector* const detector = simulation->instrument().getDetector(); if (detector->dimension() != 2) throw Exceptions::RuntimeErrorException("SimulationToPython::defineDetector: " @@ -218,8 +210,7 @@ std::string SimulationToPython::defineDetector(const ISimulation* simulation) co } std::string -SimulationToPython::defineDetectorResolutionFunction(const ISimulation* simulation) const -{ +SimulationToPython::defineDetectorResolutionFunction(const ISimulation* simulation) const { std::ostringstream result; const IDetector* detector = simulation->instrument().getDetector(); @@ -244,8 +235,7 @@ SimulationToPython::defineDetectorResolutionFunction(const ISimulation* simulati } std::string -SimulationToPython::defineDetectorPolarizationAnalysis(const ISimulation* simulation) const -{ +SimulationToPython::defineDetectorPolarizationAnalysis(const ISimulation* simulation) const { std::ostringstream result; const IDetector* detector = simulation->instrument().getDetector(); kvector_t analyzer_direction = detector->detectionProperties().analyzerDirection(); @@ -266,8 +256,7 @@ SimulationToPython::defineDetectorPolarizationAnalysis(const ISimulation* simula return result.str(); } -std::string SimulationToPython::defineGISASBeam(const GISASSimulation& simulation) const -{ +std::string SimulationToPython::defineGISASBeam(const GISASSimulation& simulation) const { std::ostringstream result; const Beam& beam = simulation.instrument().beam(); @@ -281,8 +270,7 @@ std::string SimulationToPython::defineGISASBeam(const GISASSimulation& simulatio return result.str(); } -std::string SimulationToPython::defineOffSpecBeam(const OffSpecSimulation& simulation) const -{ +std::string SimulationToPython::defineOffSpecBeam(const OffSpecSimulation& simulation) const { std::ostringstream result; const Beam& beam = simulation.instrument().beam(); @@ -298,8 +286,7 @@ std::string SimulationToPython::defineOffSpecBeam(const OffSpecSimulation& simul return result.str(); } -std::string SimulationToPython::defineSpecularScan(const SpecularSimulation& simulation) const -{ +std::string SimulationToPython::defineSpecularScan(const SpecularSimulation& simulation) const { std::ostringstream result; const ISpecularScan* scan = simulation.dataHandler(); if (!scan) @@ -313,8 +300,7 @@ std::string SimulationToPython::defineSpecularScan(const SpecularSimulation& sim return result.str(); } -std::string SimulationToPython::defineBeamPolarization(const Beam& beam) const -{ +std::string SimulationToPython::defineBeamPolarization(const Beam& beam) const { std::ostringstream result; auto bloch_vector = beam.getBlochVector(); if (bloch_vector.mag() > 0.0) { @@ -329,8 +315,7 @@ std::string SimulationToPython::defineBeamPolarization(const Beam& beam) const return result.str(); } -std::string SimulationToPython::defineBeamIntensity(const Beam& beam) const -{ +std::string SimulationToPython::defineBeamIntensity(const Beam& beam) const { std::ostringstream result; double beam_intensity = beam.getIntensity(); if (beam_intensity > 0.0) @@ -339,8 +324,7 @@ std::string SimulationToPython::defineBeamIntensity(const Beam& beam) const return result.str(); } -std::string SimulationToPython::defineParameterDistributions(const ISimulation* simulation) const -{ +std::string SimulationToPython::defineParameterDistributions(const ISimulation* simulation) const { std::ostringstream result; const std::vector<ParameterDistribution>& distributions = simulation->getDistributionHandler().getDistributions(); @@ -367,8 +351,7 @@ std::string SimulationToPython::defineParameterDistributions(const ISimulation* return result.str(); } -std::string SimulationToPython::defineMasks(const ISimulation* simulation) const -{ +std::string SimulationToPython::defineMasks(const ISimulation* simulation) const { std::ostringstream result; result << std::setprecision(12); @@ -387,8 +370,7 @@ std::string SimulationToPython::defineMasks(const ISimulation* simulation) const return result.str(); } -std::string SimulationToPython::defineSimulationOptions(const ISimulation* simulation) const -{ +std::string SimulationToPython::defineSimulationOptions(const ISimulation* simulation) const { std::ostringstream result; result << std::setprecision(12); @@ -406,8 +388,7 @@ std::string SimulationToPython::defineSimulationOptions(const ISimulation* simul return result.str(); } -std::string SimulationToPython::defineBackground(const ISimulation* simulation) const -{ +std::string SimulationToPython::defineBackground(const ISimulation* simulation) const { std::ostringstream result; auto p_bg = simulation->background(); @@ -424,8 +405,7 @@ std::string SimulationToPython::defineBackground(const ISimulation* simulation) return result.str(); } -std::string SimulationToPython::defineMain(SimulationToPython::EMainType mainType) -{ +std::string SimulationToPython::defineMain(SimulationToPython::EMainType mainType) { std::string result; if (mainType == RUN_SIMULATION) { result = "if __name__ == '__main__': \n" @@ -438,7 +418,7 @@ std::string SimulationToPython::defineMain(SimulationToPython::EMainType mainTyp " if len(sys.argv)>=2:\n" " ba.IntensityDataIOFactory.writeSimulationResult(result, sys.argv[1])\n" " else:\n" - " ba.plot_simulation_result(result, cmap='jet', aspect='auto')\n"; + " ba.plot_simulation_result(result, cmap='jet', aspect='auto')\n"; } else { throw std::runtime_error("SimulationToPython::defineMain() -> Error. Unknown main type."); } diff --git a/Core/Export/SimulationToPython.h b/Core/Export/SimulationToPython.h index 5c689f067db24d16eb506ccbe3af0b4670304523..afcdc9b0ef8083cd1ed8fec32861cce904445687 100644 --- a/Core/Export/SimulationToPython.h +++ b/Core/Export/SimulationToPython.h @@ -27,8 +27,7 @@ class SpecularSimulation; //! Write a Python script that allows to run the current simulation. -class SimulationToPython -{ +class SimulationToPython { public: enum EMainType { RUN_SIMULATION, //!< main function runs simulation diff --git a/Core/Fitting/FitObjective.cpp b/Core/Fitting/FitObjective.cpp index 5cf8afdeb91e99181a65c072e91d584fdda0053e..bbfe22194049751bd6793e6d3c5e08717955316a 100644 --- a/Core/Fitting/FitObjective.cpp +++ b/Core/Fitting/FitObjective.cpp @@ -21,16 +21,14 @@ #include "Device/Instrument/ChiSquaredModule.h" #include <stdexcept> -class IMetricWrapper -{ +class IMetricWrapper { public: virtual ~IMetricWrapper(); virtual double compute(const std::vector<SimDataPair>& fit_objects, size_t n_pars) const = 0; }; //! Metric wrapper for back-compaptibility with old scripts -class ChiModuleWrapper : public IMetricWrapper -{ +class ChiModuleWrapper : public IMetricWrapper { public: explicit ChiModuleWrapper(std::unique_ptr<IChiSquaredModule> module); double compute(const std::vector<SimDataPair>& fit_objects, size_t n_pars) const override; @@ -39,8 +37,7 @@ private: std::unique_ptr<IChiSquaredModule> m_module; }; -class ObjectiveMetricWrapper : public IMetricWrapper -{ +class ObjectiveMetricWrapper : public IMetricWrapper { public: explicit ObjectiveMetricWrapper(std::unique_ptr<ObjectiveMetric> module); double compute(const std::vector<SimDataPair>& fit_objects, size_t n_pars) const override; @@ -49,8 +46,7 @@ private: std::unique_ptr<ObjectiveMetric> m_module; }; -simulation_builder_t FitObjective::simulationBuilder(PyBuilderCallback& callback) -{ +simulation_builder_t FitObjective::simulationBuilder(PyBuilderCallback& callback) { return [&callback](const mumufit::Parameters& params) { auto simulation = callback.build_simulation(params); std::unique_ptr<ISimulation> clone(simulation->clone()); @@ -62,9 +58,7 @@ simulation_builder_t FitObjective::simulationBuilder(PyBuilderCallback& callback FitObjective::FitObjective() : m_metric_module( std::make_unique<ObjectiveMetricWrapper>(std::make_unique<PoissonLikeMetric>())) - , m_fit_status(std::make_unique<FitStatus>(this)) -{ -} + , m_fit_status(std::make_unique<FitStatus>(this)) {} FitObjective::~FitObjective() = default; @@ -76,21 +70,18 @@ FitObjective::~FitObjective() = default; void FitObjective::addSimulationAndData(simulation_builder_t builder, const OutputData<double>& data, std::unique_ptr<OutputData<double>> uncertainties, - double weight) -{ + double weight) { m_fit_objects.emplace_back(builder, data, std::move(uncertainties), weight); } -double FitObjective::evaluate(const mumufit::Parameters& params) -{ +double FitObjective::evaluate(const mumufit::Parameters& params) { run_simulations(params); const double metric_value = m_metric_module->compute(m_fit_objects, params.size()); m_fit_status->update(params, metric_value); return metric_value; } -std::vector<double> FitObjective::evaluate_residuals(const mumufit::Parameters& params) -{ +std::vector<double> FitObjective::evaluate_residuals(const mumufit::Parameters& params) { evaluate(params); std::vector<double> result = experimental_array(); // init result with experimental data values @@ -100,136 +91,113 @@ std::vector<double> FitObjective::evaluate_residuals(const mumufit::Parameters& return result; } -size_t FitObjective::numberOfFitElements() const -{ +size_t FitObjective::numberOfFitElements() const { return std::accumulate( m_fit_objects.begin(), m_fit_objects.end(), 0u, [](size_t acc, auto& obj) -> size_t { return acc + obj.numberOfFitElements(); }); } //! Returns simulation result in the form of SimulationResult. -SimulationResult FitObjective::simulationResult(size_t i_item) const -{ +SimulationResult FitObjective::simulationResult(size_t i_item) const { return dataPair(i_item).simulationResult(); } //! Returns experimental data in the form of SimulationResult. -SimulationResult FitObjective::experimentalData(size_t i_item) const -{ +SimulationResult FitObjective::experimentalData(size_t i_item) const { return dataPair(i_item).experimentalData(); } //! Returns experimental data uncertainties in the form of SimulationResult. -SimulationResult FitObjective::uncertaintyData(size_t i_item) const -{ +SimulationResult FitObjective::uncertaintyData(size_t i_item) const { return dataPair(i_item).uncertainties(); } //! Returns relative difference between simulation and experimental data //! in the form of SimulationResult. -SimulationResult FitObjective::relativeDifference(size_t i_item) const -{ +SimulationResult FitObjective::relativeDifference(size_t i_item) const { return dataPair(i_item).relativeDifference(); } //! Returns absolute value of difference between simulation and experimental data //! in the form of SimulationResult. -SimulationResult FitObjective::absoluteDifference(size_t i_item) const -{ +SimulationResult FitObjective::absoluteDifference(size_t i_item) const { return dataPair(i_item).absoluteDifference(); } //! Returns one dimensional array representing merged experimental data. //! The area outside of the region of interest is not included, masked data is nullified. -std::vector<double> FitObjective::experimental_array() const -{ +std::vector<double> FitObjective::experimental_array() const { return composeArray(&SimDataPair::experimental_array); } //! Returns one dimensional array representing merged simulated intensities data. //! The area outside of the region of interest is not included, masked data is nullified. -std::vector<double> FitObjective::simulation_array() const -{ +std::vector<double> FitObjective::simulation_array() const { return composeArray(&SimDataPair::simulation_array); } //! Returns one-dimensional array representing merged data uncertainties. //! The area outside of the region of interest is not included, masked data is nullified. -std::vector<double> FitObjective::uncertainties() const -{ +std::vector<double> FitObjective::uncertainties() const { return composeArray(&SimDataPair::uncertainties_array); } //! Returns one-dimensional array representing merged user weights. //! The area outside of the region of interest is not included, masked data is nullified. -std::vector<double> FitObjective::weights_array() const -{ +std::vector<double> FitObjective::weights_array() const { return composeArray(&SimDataPair::user_weights_array); } -const SimDataPair& FitObjective::dataPair(size_t i_item) const -{ +const SimDataPair& FitObjective::dataPair(size_t i_item) const { return m_fit_objects[check_index(i_item)]; } -void FitObjective::initPrint(int every_nth) -{ +void FitObjective::initPrint(int every_nth) { m_fit_status->initPrint(every_nth); } -void FitObjective::initPlot(int every_nth, fit_observer_t observer) -{ +void FitObjective::initPlot(int every_nth, fit_observer_t observer) { m_fit_status->addObserver(every_nth, observer); } -void FitObjective::initPlot(int every_nth, PyObserverCallback& callback) -{ +void FitObjective::initPlot(int every_nth, PyObserverCallback& callback) { fit_observer_t observer = [&](const FitObjective& objective) { callback.update(objective); }; m_fit_status->addObserver(every_nth, observer); } -bool FitObjective::isCompleted() const -{ +bool FitObjective::isCompleted() const { return m_fit_status->isCompleted(); } -IterationInfo FitObjective::iterationInfo() const -{ +IterationInfo FitObjective::iterationInfo() const { return m_fit_status->iterationInfo(); } -mumufit::MinimizerResult FitObjective::minimizerResult() const -{ +mumufit::MinimizerResult FitObjective::minimizerResult() const { return m_fit_status->minimizerResult(); } -void FitObjective::finalize(const mumufit::MinimizerResult& result) -{ +void FitObjective::finalize(const mumufit::MinimizerResult& result) { m_fit_status->finalize(result); } -unsigned FitObjective::fitObjectCount() const -{ +unsigned FitObjective::fitObjectCount() const { return static_cast<unsigned>(m_fit_objects.size()); } -void FitObjective::interruptFitting() -{ +void FitObjective::interruptFitting() { m_fit_status->setInterrupted(); } -bool FitObjective::isInterrupted() const -{ +bool FitObjective::isInterrupted() const { return m_fit_status->isInterrupted(); } -bool FitObjective::isFirstIteration() const -{ +bool FitObjective::isFirstIteration() const { return iterationInfo().iterationCount() == 1; } -void FitObjective::run_simulations(const mumufit::Parameters& params) -{ +void FitObjective::run_simulations(const mumufit::Parameters& params) { if (m_fit_status->isInterrupted()) throw std::runtime_error("Fitting was interrupted by the user."); @@ -241,8 +209,7 @@ void FitObjective::run_simulations(const mumufit::Parameters& params) obj.runSimulation(params); } -void FitObjective::setChiSquaredModule(const IChiSquaredModule& module) -{ +void FitObjective::setChiSquaredModule(const IChiSquaredModule& module) { std::cout << "Warning in FitObjective::setChiSquaredModule: setChiSquaredModule is deprecated " "and will be removed in future versions. Please use " "FitObjective::setObjectiveMetric instead." @@ -252,32 +219,27 @@ void FitObjective::setChiSquaredModule(const IChiSquaredModule& module) m_metric_module = std::make_unique<ChiModuleWrapper>(std::move(chi_module)); } -void FitObjective::setObjectiveMetric(std::unique_ptr<ObjectiveMetric> metric) -{ +void FitObjective::setObjectiveMetric(std::unique_ptr<ObjectiveMetric> metric) { m_metric_module = std::make_unique<ObjectiveMetricWrapper>(std::move(metric)); } -void FitObjective::setObjectiveMetric(const std::string& metric) -{ +void FitObjective::setObjectiveMetric(const std::string& metric) { m_metric_module = std::make_unique<ObjectiveMetricWrapper>( ObjectiveMetricUtils::createMetric(metric, ObjectiveMetricUtils::defaultNormName())); } -void FitObjective::setObjectiveMetric(const std::string& metric, const std::string& norm) -{ +void FitObjective::setObjectiveMetric(const std::string& metric, const std::string& norm) { m_metric_module = std::make_unique<ObjectiveMetricWrapper>(ObjectiveMetricUtils::createMetric(metric, norm)); } //! Returns true if the specified DataPair element contains uncertainties -bool FitObjective::containsUncertainties(size_t i_item) const -{ +bool FitObjective::containsUncertainties(size_t i_item) const { return dataPair(i_item).containsUncertainties(); } //! Returns true if all the data pairs in FitObjective instance contain uncertainties -bool FitObjective::allPairsHaveUncertainties() const -{ +bool FitObjective::allPairsHaveUncertainties() const { bool result = true; for (size_t i = 0, size = fitObjectCount(); i < size; ++i) result = result && dataPair(i).containsUncertainties(); @@ -285,13 +247,11 @@ bool FitObjective::allPairsHaveUncertainties() const } //! Returns available metrics and norms -std::string FitObjective::availableMetricOptions() -{ +std::string FitObjective::availableMetricOptions() { return ObjectiveMetricUtils::availableMetricOptions(); } -std::vector<double> FitObjective::composeArray(DataPairAccessor getter) const -{ +std::vector<double> FitObjective::composeArray(DataPairAccessor getter) const { const size_t n_objs = m_fit_objects.size(); if (n_objs == 0) return {}; @@ -307,8 +267,7 @@ std::vector<double> FitObjective::composeArray(DataPairAccessor getter) const return result; } -size_t FitObjective::check_index(size_t index) const -{ +size_t FitObjective::check_index(size_t index) const { if (index >= m_fit_objects.size()) throw std::runtime_error("FitObjective::check_index() -> Index outside of range"); return index; @@ -319,14 +278,12 @@ size_t FitObjective::check_index(size_t index) const IMetricWrapper::~IMetricWrapper() = default; ChiModuleWrapper::ChiModuleWrapper(std::unique_ptr<IChiSquaredModule> module) - : IMetricWrapper(), m_module(std::move(module)) -{ + : IMetricWrapper(), m_module(std::move(module)) { if (!m_module) throw std::runtime_error("Error in ChiModuleWrapper: empty chi square module passed"); } -double ChiModuleWrapper::compute(const std::vector<SimDataPair>& fit_objects, size_t n_pars) const -{ +double ChiModuleWrapper::compute(const std::vector<SimDataPair>& fit_objects, size_t n_pars) const { size_t n_points = 0; double result = 0.0; for (auto& obj : fit_objects) { @@ -349,14 +306,12 @@ double ChiModuleWrapper::compute(const std::vector<SimDataPair>& fit_objects, si } ObjectiveMetricWrapper::ObjectiveMetricWrapper(std::unique_ptr<ObjectiveMetric> module) - : IMetricWrapper(), m_module(std::move(module)) -{ + : IMetricWrapper(), m_module(std::move(module)) { if (!m_module) throw std::runtime_error("Error in ObjectiveMetricWrapper: empty objective metric passed"); } -double ObjectiveMetricWrapper::compute(const std::vector<SimDataPair>& fit_objects, size_t) const -{ +double ObjectiveMetricWrapper::compute(const std::vector<SimDataPair>& fit_objects, size_t) const { // deciding whether to use uncertainties in metrics computation. bool use_uncertainties = true; for (auto& obj : fit_objects) diff --git a/Core/Fitting/FitObjective.h b/Core/Fitting/FitObjective.h index 798e97e742aadf7dcf2df041887f9fe9f04d0c76..e3d1570096a439ab4689fb877b9f683b8649d49d 100644 --- a/Core/Fitting/FitObjective.h +++ b/Core/Fitting/FitObjective.h @@ -30,8 +30,7 @@ class PyObserverCallback; //! Holds vector of `SimDataPair`s (experimental data and simulation results) for use in fitting. //! @ingroup fitting_internal -class FitObjective -{ +class FitObjective { static simulation_builder_t simulationBuilder(PyBuilderCallback& callback); public: @@ -48,8 +47,7 @@ public: //! @param data: experimental data array //! @param weight: weight of dataset in metric calculations template <class T> - void addSimulationAndData(PyBuilderCallback& callback, const T& data, double weight = 1.0) - { + void addSimulationAndData(PyBuilderCallback& callback, const T& data, double weight = 1.0) { addSimulationAndData(simulationBuilder(callback), *ArrayUtils::createData(data), nullptr, weight); } @@ -61,8 +59,7 @@ public: //! @param weight: weight of dataset in metric calculations template <class T> void addSimulationAndData(PyBuilderCallback& callback, const T& data, const T& uncertainties, - double weight = 1.0) - { + double weight = 1.0) { addSimulationAndData(simulationBuilder(callback), *ArrayUtils::createData(data), ArrayUtils::createData(uncertainties), weight); } diff --git a/Core/Fitting/FitObserver.h b/Core/Fitting/FitObserver.h index 5881ffedd58e6caad76dc2d51e3e263b9b5d8791..6485796fd8f471557293360fced14269d08b8058 100644 --- a/Core/Fitting/FitObserver.h +++ b/Core/Fitting/FitObserver.h @@ -22,8 +22,7 @@ //! Contains collection of observers and call them at specified intervals. //! Each observer will be called at first iteration and every-nth iterations. -template <class T> class FitObserver -{ +template <class T> class FitObserver { public: using observer_t = std::function<void(const T&)>; FitObserver(); @@ -40,14 +39,11 @@ public: void notify_all(const T& data); private: - class ObserverData - { + class ObserverData { public: ObserverData() : m_every_nth(0) {} ObserverData(int every_nth, observer_t observer) - : m_every_nth(every_nth), m_observer(observer) - { - } + : m_every_nth(every_nth), m_observer(observer) {} int m_every_nth; observer_t m_observer; }; @@ -61,13 +57,11 @@ private: template <class T> FitObserver<T>::FitObserver() : m_notify_count(0) {} template <class T> -void FitObserver<T>::addObserver(int every_nth, typename FitObserver::observer_t observer) -{ +void FitObserver<T>::addObserver(int every_nth, typename FitObserver::observer_t observer) { m_observers.push_back(ObserverData(every_nth, observer)); } -template <class T> void FitObserver<T>::notify(const T& data) -{ +template <class T> void FitObserver<T>::notify(const T& data) { for (const auto& observer : m_observers) { if (need_notify(observer.m_every_nth)) observer.m_observer(data); @@ -76,16 +70,14 @@ template <class T> void FitObserver<T>::notify(const T& data) m_notify_count++; } -template <class T> void FitObserver<T>::notify_all(const T& data) -{ +template <class T> void FitObserver<T>::notify_all(const T& data) { for (const auto& observer : m_observers) observer.m_observer(data); m_notify_count++; } -template <class T> bool FitObserver<T>::need_notify(int every_nth) -{ +template <class T> bool FitObserver<T>::need_notify(int every_nth) { return m_notify_count == 0 || m_notify_count % every_nth == 0; } diff --git a/Core/Fitting/FitPrintService.cpp b/Core/Fitting/FitPrintService.cpp index 1cedd2398db89d50bfb941aea8eafa04eb7c84cf..8627fcbc298756b1b283a074aefb63cc92b0365b 100644 --- a/Core/Fitting/FitPrintService.cpp +++ b/Core/Fitting/FitPrintService.cpp @@ -19,11 +19,9 @@ #include <iostream> #include <sstream> -namespace -{ +namespace { -size_t length_of_longest_name(const mumufit::Parameters& params) -{ +size_t length_of_longest_name(const mumufit::Parameters& params) { size_t result(0); for (const auto& par : params) { if (par.name().size() > result) @@ -36,8 +34,7 @@ size_t length_of_longest_name(const mumufit::Parameters& params) FitPrintService::FitPrintService() = default; -void FitPrintService::print(const FitObjective& objective) -{ +void FitPrintService::print(const FitObjective& objective) { std::ostringstream ostr; if (objective.isFirstIteration()) { @@ -55,8 +52,7 @@ void FitPrintService::print(const FitObjective& objective) std::cout << ostr.str() << "\n"; } -std::string FitPrintService::iterationHeaderString(const FitObjective& objective) -{ +std::string FitPrintService::iterationHeaderString(const FitObjective& objective) { std::ostringstream result; result << "FitPrintService::update() -> Info." @@ -66,8 +62,7 @@ std::string FitPrintService::iterationHeaderString(const FitObjective& objective return result.str(); } -std::string FitPrintService::wallTimeString() -{ +std::string FitPrintService::wallTimeString() { std::ostringstream result; m_last_call_time.stop(); @@ -78,8 +73,7 @@ std::string FitPrintService::wallTimeString() return result.str(); } -std::string FitPrintService::parameterString(const FitObjective& objective) -{ +std::string FitPrintService::parameterString(const FitObjective& objective) { std::ostringstream result; const auto params = objective.iterationInfo().parameters(); @@ -94,8 +88,7 @@ std::string FitPrintService::parameterString(const FitObjective& objective) return result.str(); } -std::string FitPrintService::fitResultString(const FitObjective& objective) -{ +std::string FitPrintService::fitResultString(const FitObjective& objective) { std::ostringstream result; m_run_time.stop(); diff --git a/Core/Fitting/FitPrintService.h b/Core/Fitting/FitPrintService.h index acb44756b4372ce449e6c036a654f06dcae3bc2e..4e8bde5f2dfef7a738fdd2f59979dd31a72374fa 100644 --- a/Core/Fitting/FitPrintService.h +++ b/Core/Fitting/FitPrintService.h @@ -22,8 +22,7 @@ class FitObjective; //! Prints fit statistics to standard output during minimizer iterations. -class FitPrintService -{ +class FitPrintService { public: FitPrintService(); diff --git a/Core/Fitting/FitStatus.cpp b/Core/Fitting/FitStatus.cpp index c968949989b0f327e742ad12c87a7113980981f5..4c29d6685c301421bef5705096bbf8e49d0a019b 100644 --- a/Core/Fitting/FitStatus.cpp +++ b/Core/Fitting/FitStatus.cpp @@ -18,29 +18,23 @@ #include <stdexcept> FitStatus::FitStatus(const FitObjective* fit_objective) - : m_fit_status(IDLE), m_fit_objective(fit_objective) -{ -} + : m_fit_status(IDLE), m_fit_objective(fit_objective) {} FitStatus::~FitStatus() = default; -void FitStatus::setInterrupted() -{ +void FitStatus::setInterrupted() { m_fit_status = INTERRUPTED; } -bool FitStatus::isInterrupted() const -{ +bool FitStatus::isInterrupted() const { return m_fit_status == INTERRUPTED; } -bool FitStatus::isCompleted() const -{ +bool FitStatus::isCompleted() const { return m_fit_status == COMPLETED; } -void FitStatus::update(const mumufit::Parameters& params, double chi2) -{ +void FitStatus::update(const mumufit::Parameters& params, double chi2) { if (!isInterrupted()) m_fit_status = RUNNING; @@ -49,8 +43,7 @@ void FitStatus::update(const mumufit::Parameters& params, double chi2) m_observers.notify(*m_fit_objective); } -void FitStatus::initPrint(int every_nth) -{ +void FitStatus::initPrint(int every_nth) { m_print_service.reset(new FitPrintService); FitObserver<FitObjective>::observer_t callback = [&](const FitObjective& objective) { @@ -60,18 +53,15 @@ void FitStatus::initPrint(int every_nth) addObserver(every_nth, callback); } -void FitStatus::addObserver(int every_nth, fit_observer_t observer) -{ +void FitStatus::addObserver(int every_nth, fit_observer_t observer) { m_observers.addObserver(every_nth, observer); } -IterationInfo FitStatus::iterationInfo() const -{ +IterationInfo FitStatus::iterationInfo() const { return m_iterationInfo; } -mumufit::MinimizerResult FitStatus::minimizerResult() const -{ +mumufit::MinimizerResult FitStatus::minimizerResult() const { if (!m_minimizer_result) throw std::runtime_error("FitStatus::minimizerResult() -> Minimizer result wasn't set. " "Make sure that FitObjective::finalize() was called."); @@ -79,8 +69,7 @@ mumufit::MinimizerResult FitStatus::minimizerResult() const return mumufit::MinimizerResult(*m_minimizer_result); } -void FitStatus::finalize(const mumufit::MinimizerResult& result) -{ +void FitStatus::finalize(const mumufit::MinimizerResult& result) { m_minimizer_result.reset(new mumufit::MinimizerResult(result)); m_fit_status = COMPLETED; m_observers.notify_all(*m_fit_objective); diff --git a/Core/Fitting/FitStatus.h b/Core/Fitting/FitStatus.h index a4541f418d4557cce85d724782eb91904b0cd701..3d72fdb2fd78ce6fdf50d7083f474dfb108ac84e 100644 --- a/Core/Fitting/FitStatus.h +++ b/Core/Fitting/FitStatus.h @@ -20,8 +20,7 @@ #include <functional> #include <vector> -namespace mumufit -{ +namespace mumufit { class MinimizerResult; } class FitObjective; @@ -31,8 +30,7 @@ class FitPrintService; //! information which has to be collected during the fit. //! Owned by FitObjective. -class FitStatus -{ +class FitStatus { public: FitStatus(const FitObjective* fit_objective); ~FitStatus(); diff --git a/Core/Fitting/FitTypes.h b/Core/Fitting/FitTypes.h index 606ef36709d69172c9ed8a128f5179975c8c610d..f9cdab0806d79dd0f00f14114463d43bc1007364 100644 --- a/Core/Fitting/FitTypes.h +++ b/Core/Fitting/FitTypes.h @@ -19,8 +19,7 @@ #include <memory> class ISimulation; -namespace mumufit -{ +namespace mumufit { class Parameters; } class FitObjective; diff --git a/Core/Fitting/IObserver.cpp b/Core/Fitting/IObserver.cpp index b7c42040b00ede4cf455dc3ba8718c35736e8de3..3758b81cf5db58fa50f1575cbc089348024bc7fa 100644 --- a/Core/Fitting/IObserver.cpp +++ b/Core/Fitting/IObserver.cpp @@ -14,13 +14,11 @@ #include "Core/Fitting/IObserver.h" -void IObservable::attachObserver(observer_t obj) -{ +void IObservable::attachObserver(observer_t obj) { m_observers.push_back(obj); } -void IObservable::notifyObservers() -{ +void IObservable::notifyObservers() { for (auto it : m_observers) it->notify(this); } diff --git a/Core/Fitting/IObserver.h b/Core/Fitting/IObserver.h index 9cd75428eeaf4ed9053893c59b59cbac610c7d94..caecd709cb88ddb9c2bd6400dfb81815ccd41e24 100644 --- a/Core/Fitting/IObserver.h +++ b/Core/Fitting/IObserver.h @@ -23,8 +23,7 @@ class IObservable; //! Observer interface from %Observer pattern. //! @ingroup tools_internal -class IObserver -{ +class IObserver { public: virtual ~IObserver(); @@ -35,8 +34,7 @@ public: //! Observable interface from %Observer pattern //! @ingroup tools_internal -class IObservable -{ +class IObservable { public: //! Shared pointer is used when passing these objects from Python to C++ typedef std::shared_ptr<IObserver> observer_t; diff --git a/Core/Fitting/IterationInfo.cpp b/Core/Fitting/IterationInfo.cpp index 4cc50a18725fe500a13465cc9c0eec6fd50728ed..7db580ec40f3d9a15a6f8cb65c49fde7c67255ae 100644 --- a/Core/Fitting/IterationInfo.cpp +++ b/Core/Fitting/IterationInfo.cpp @@ -16,30 +16,25 @@ IterationInfo::IterationInfo() : m_chi2(0.0), m_iteration_count(0) {} -void IterationInfo::update(const mumufit::Parameters& params, double chi2) -{ +void IterationInfo::update(const mumufit::Parameters& params, double chi2) { m_current_parameters = params; m_chi2 = chi2; m_iteration_count++; } -unsigned IterationInfo::iterationCount() const -{ +unsigned IterationInfo::iterationCount() const { return m_iteration_count; } -double IterationInfo::chi2() const -{ +double IterationInfo::chi2() const { return m_chi2; } -mumufit::Parameters IterationInfo::parameters() const -{ +mumufit::Parameters IterationInfo::parameters() const { return m_current_parameters; } -std::map<std::string, double> IterationInfo::parameterMap() const -{ +std::map<std::string, double> IterationInfo::parameterMap() const { std::map<std::string, double> result; for (const auto& par : m_current_parameters) diff --git a/Core/Fitting/IterationInfo.h b/Core/Fitting/IterationInfo.h index 45e32d9c92daae80f3cf6b031eea117092157814..5f818bf5b7e054cb0052eb1b182081348ee25c5c 100644 --- a/Core/Fitting/IterationInfo.h +++ b/Core/Fitting/IterationInfo.h @@ -22,8 +22,7 @@ //! Stores fit iteration info to track fit flow from various observers. //! Used in context of FitObjective. -class IterationInfo -{ +class IterationInfo { public: IterationInfo(); diff --git a/Core/Fitting/ObjectiveMetric.cpp b/Core/Fitting/ObjectiveMetric.cpp index e2fbd82260dcf82317cad5fde1998b01f952add9..a84555a7e536ed642d50cc322b0635afe1184cbf 100644 --- a/Core/Fitting/ObjectiveMetric.cpp +++ b/Core/Fitting/ObjectiveMetric.cpp @@ -19,22 +19,19 @@ #include <cmath> #include <limits> -namespace -{ +namespace { const double double_max = std::numeric_limits<double>::max(); const double double_min = std::numeric_limits<double>::min(); const double ln10 = std::log(10.0); -template <class T> T* copyMetric(const T& metric) -{ +template <class T> T* copyMetric(const T& metric) { auto* result = new T; result->setNorm(metric.norm()); return result; } void checkIntegrity(const std::vector<double>& sim_data, const std::vector<double>& exp_data, - const std::vector<double>& weight_factors) -{ + const std::vector<double>& weight_factors) { const size_t sim_size = sim_data.size(); if (sim_size != exp_data.size() || sim_size != weight_factors.size()) throw std::runtime_error("Error in ObjectiveMetric: input arrays have different sizes"); @@ -47,8 +44,7 @@ void checkIntegrity(const std::vector<double>& sim_data, const std::vector<doubl void checkIntegrity(const std::vector<double>& sim_data, const std::vector<double>& exp_data, const std::vector<double>& uncertainties, - const std::vector<double>& weight_factors) -{ + const std::vector<double>& weight_factors) { if (sim_data.size() != uncertainties.size()) throw std::runtime_error("Error in ObjectiveMetric: input arrays have different sizes"); @@ -58,8 +54,7 @@ void checkIntegrity(const std::vector<double>& sim_data, const std::vector<doubl ObjectiveMetric::ObjectiveMetric(std::function<double(double)> norm) : m_norm(std::move(norm)) {} -double ObjectiveMetric::compute(const SimDataPair& data_pair, bool use_weights) const -{ +double ObjectiveMetric::compute(const SimDataPair& data_pair, bool use_weights) const { if (use_weights && !data_pair.containsUncertainties()) throw std::runtime_error("Error in ObjectiveMetric::compute: the metric is weighted, but " "the simulation-data pair does not contain uncertainties"); @@ -72,8 +67,7 @@ double ObjectiveMetric::compute(const SimDataPair& data_pair, bool use_weights) data_pair.user_weights_array()); } -void ObjectiveMetric::setNorm(std::function<double(double)> norm) -{ +void ObjectiveMetric::setNorm(std::function<double(double)> norm) { m_norm = std::move(norm); } @@ -81,15 +75,13 @@ void ObjectiveMetric::setNorm(std::function<double(double)> norm) Chi2Metric::Chi2Metric() : ObjectiveMetric(ObjectiveMetricUtils::l2Norm()) {} -Chi2Metric* Chi2Metric::clone() const -{ +Chi2Metric* Chi2Metric::clone() const { return copyMetric(*this); } double Chi2Metric::computeFromArrays(std::vector<double> sim_data, std::vector<double> exp_data, std::vector<double> uncertainties, - std::vector<double> weight_factors) const -{ + std::vector<double> weight_factors) const { checkIntegrity(sim_data, exp_data, uncertainties, weight_factors); double result = 0.0; @@ -102,8 +94,7 @@ double Chi2Metric::computeFromArrays(std::vector<double> sim_data, std::vector<d } double Chi2Metric::computeFromArrays(std::vector<double> sim_data, std::vector<double> exp_data, - std::vector<double> weight_factors) const -{ + std::vector<double> weight_factors) const { checkIntegrity(sim_data, exp_data, weight_factors); auto norm_fun = norm(); @@ -119,15 +110,13 @@ double Chi2Metric::computeFromArrays(std::vector<double> sim_data, std::vector<d PoissonLikeMetric::PoissonLikeMetric() : Chi2Metric() {} -PoissonLikeMetric* PoissonLikeMetric::clone() const -{ +PoissonLikeMetric* PoissonLikeMetric::clone() const { return copyMetric(*this); } double PoissonLikeMetric::computeFromArrays(std::vector<double> sim_data, std::vector<double> exp_data, - std::vector<double> weight_factors) const -{ + std::vector<double> weight_factors) const { checkIntegrity(sim_data, exp_data, weight_factors); double result = 0.0; @@ -147,15 +136,13 @@ double PoissonLikeMetric::computeFromArrays(std::vector<double> sim_data, LogMetric::LogMetric() : ObjectiveMetric(ObjectiveMetricUtils::l2Norm()) {} -LogMetric* LogMetric::clone() const -{ +LogMetric* LogMetric::clone() const { return copyMetric(*this); } double LogMetric::computeFromArrays(std::vector<double> sim_data, std::vector<double> exp_data, std::vector<double> uncertainties, - std::vector<double> weight_factors) const -{ + std::vector<double> weight_factors) const { checkIntegrity(sim_data, exp_data, uncertainties, weight_factors); double result = 0.0; @@ -174,8 +161,7 @@ double LogMetric::computeFromArrays(std::vector<double> sim_data, std::vector<do } double LogMetric::computeFromArrays(std::vector<double> sim_data, std::vector<double> exp_data, - std::vector<double> weight_factors) const -{ + std::vector<double> weight_factors) const { checkIntegrity(sim_data, exp_data, weight_factors); double result = 0.0; @@ -195,15 +181,13 @@ double LogMetric::computeFromArrays(std::vector<double> sim_data, std::vector<do RelativeDifferenceMetric::RelativeDifferenceMetric() : Chi2Metric() {} -RelativeDifferenceMetric* RelativeDifferenceMetric::clone() const -{ +RelativeDifferenceMetric* RelativeDifferenceMetric::clone() const { return copyMetric(*this); } double RelativeDifferenceMetric::computeFromArrays(std::vector<double> sim_data, std::vector<double> exp_data, - std::vector<double> weight_factors) const -{ + std::vector<double> weight_factors) const { checkIntegrity(sim_data, exp_data, weight_factors); double result = 0.0; @@ -223,13 +207,11 @@ double RelativeDifferenceMetric::computeFromArrays(std::vector<double> sim_data, RQ4Metric::RQ4Metric() : Chi2Metric() {} -RQ4Metric* RQ4Metric::clone() const -{ +RQ4Metric* RQ4Metric::clone() const { return copyMetric(*this); } -double RQ4Metric::compute(const SimDataPair& data_pair, bool use_weights) const -{ +double RQ4Metric::compute(const SimDataPair& data_pair, bool use_weights) const { if (use_weights) return Chi2Metric::compute(data_pair, use_weights); diff --git a/Core/Fitting/ObjectiveMetric.h b/Core/Fitting/ObjectiveMetric.h index 95afa4100a07420ca4b68365da5b942a7d7b6f5f..8990aafa4008cb2be5ffcdf8f8d1283256bc3c05 100644 --- a/Core/Fitting/ObjectiveMetric.h +++ b/Core/Fitting/ObjectiveMetric.h @@ -23,8 +23,7 @@ class SimDataPair; //! Base class for metric implementations -class ObjectiveMetric : public ICloneable -{ +class ObjectiveMetric : public ICloneable { public: ObjectiveMetric(std::function<double(double)> norm); @@ -70,8 +69,7 @@ private: //! derived from maximum likelihood with Gaussian uncertainties. //! With default L2 norm corresponds to the formula //! \f[\chi^2 = \sum \frac{(I - D)^2}{\delta_D^2}\f] -class Chi2Metric : public ObjectiveMetric -{ +class Chi2Metric : public ObjectiveMetric { public: Chi2Metric(); Chi2Metric* clone() const override; @@ -106,8 +104,7 @@ public: //! \f[\chi^2 = \sum \frac{(I - D)^2}{max(I, 1)}\f] //! for unweighted experimental data. Falls to standard //! Chi2Metric when data uncertainties are taken into account. -class PoissonLikeMetric : public Chi2Metric -{ +class PoissonLikeMetric : public Chi2Metric { public: PoissonLikeMetric(); PoissonLikeMetric* clone() const override; @@ -130,8 +127,7 @@ public: //! being replaced by \f$ \log_{10} I \f$ and \f$\log_{10} D\f$ accordingly. //! With default L2 norm corresponds to the formula //! \f[\chi^2 = \sum \frac{(\log_{10} I - log_{10} D)^2 D^2 \ln^2{10}}{\delta_D^2}\f] -class LogMetric : public ObjectiveMetric -{ +class LogMetric : public ObjectiveMetric { public: LogMetric(); LogMetric* clone() const override; @@ -164,8 +160,7 @@ public: //! \f[Result = \sum \frac{(I - D)^2}{(I + D)^2}\f] //! where \f$I\f$ is the simulated intensity, \f$D\f$ - experimental data. //! If weighting is on, falls back to the standard \f$\chi^2\f$ metric. -class RelativeDifferenceMetric : public Chi2Metric -{ +class RelativeDifferenceMetric : public Chi2Metric { public: RelativeDifferenceMetric(); RelativeDifferenceMetric* clone() const override; @@ -188,8 +183,7 @@ public: //! \f[Result = \sum (I \cdot Q^4 - D \cdot Q^4)^2\f] //! where \f$Q\f$ is the scattering vector magnitude. If weighting is on, //! coincides with the metric provided by Chi2Metric class. -class RQ4Metric : public Chi2Metric -{ +class RQ4Metric : public Chi2Metric { public: RQ4Metric(); RQ4Metric* clone() const override; diff --git a/Core/Fitting/ObjectiveMetricUtils.cpp b/Core/Fitting/ObjectiveMetricUtils.cpp index 8d497b8e06b4116f4b15cca03fc15f16a388791d..77fc48b901f4e5bb216f693c3975bd9a249a62d1 100644 --- a/Core/Fitting/ObjectiveMetricUtils.cpp +++ b/Core/Fitting/ObjectiveMetricUtils.cpp @@ -19,8 +19,7 @@ #include <map> #include <sstream> -namespace -{ +namespace { const std::function<double(double)> l1_norm = [](double term) { return std::abs(term); }; const std::function<double(double)> l2_norm = [](double term) { return term * term; }; @@ -36,8 +35,7 @@ const std::map<std::string, std::function<double(double)>> norm_factory = {{"l1" {"l2", l2_norm}}; const std::string default_norm_name = "l2"; -template <class U> std::vector<std::string> keys(const std::map<std::string, U>& map) -{ +template <class U> std::vector<std::string> keys(const std::map<std::string, U>& map) { std::vector<std::string> result; result.reserve(map.size()); for (auto& item : map) @@ -46,24 +44,20 @@ template <class U> std::vector<std::string> keys(const std::map<std::string, U>& } } // namespace -const std::function<double(double)> ObjectiveMetricUtils::l1Norm() -{ +const std::function<double(double)> ObjectiveMetricUtils::l1Norm() { return l1_norm; } -const std::function<double(double)> ObjectiveMetricUtils::l2Norm() -{ +const std::function<double(double)> ObjectiveMetricUtils::l2Norm() { return l2_norm; } -std::unique_ptr<ObjectiveMetric> ObjectiveMetricUtils::createMetric(const std::string& metric) -{ +std::unique_ptr<ObjectiveMetric> ObjectiveMetricUtils::createMetric(const std::string& metric) { return createMetric(metric, defaultNormName()); } std::unique_ptr<ObjectiveMetric> ObjectiveMetricUtils::createMetric(std::string metric, - std::string norm) -{ + std::string norm) { std::transform(metric.begin(), metric.end(), metric.begin(), ::tolower); std::transform(norm.begin(), norm.end(), norm.begin(), ::tolower); const auto metric_iter = metric_factory.find(metric); @@ -81,8 +75,7 @@ std::unique_ptr<ObjectiveMetric> ObjectiveMetricUtils::createMetric(std::string return result; } -std::string ObjectiveMetricUtils::availableMetricOptions() -{ +std::string ObjectiveMetricUtils::availableMetricOptions() { std::stringstream ss; ss << "Available metrics:\n"; for (auto& item : metricNames()) @@ -95,22 +88,18 @@ std::string ObjectiveMetricUtils::availableMetricOptions() return ss.str(); } -std::vector<std::string> ObjectiveMetricUtils::normNames() -{ +std::vector<std::string> ObjectiveMetricUtils::normNames() { return keys(norm_factory); } -std::vector<std::string> ObjectiveMetricUtils::metricNames() -{ +std::vector<std::string> ObjectiveMetricUtils::metricNames() { return keys(metric_factory); } -std::string ObjectiveMetricUtils::defaultNormName() -{ +std::string ObjectiveMetricUtils::defaultNormName() { return default_norm_name; } -std::string ObjectiveMetricUtils::defaultMetricName() -{ +std::string ObjectiveMetricUtils::defaultMetricName() { return default_metric_name; } diff --git a/Core/Fitting/ObjectiveMetricUtils.h b/Core/Fitting/ObjectiveMetricUtils.h index 2c281a4f9d1660a67c2394590fa45975bc8df140..22f3bb6434aade8a00d2c8329213094d7e4b9e4b 100644 --- a/Core/Fitting/ObjectiveMetricUtils.h +++ b/Core/Fitting/ObjectiveMetricUtils.h @@ -24,8 +24,7 @@ class ObjectiveMetric; //! Utility functions related to class ObjectiveMetric. -namespace ObjectiveMetricUtils -{ +namespace ObjectiveMetricUtils { //! Returns L1 normalization function. const std::function<double(double)> l1Norm(); diff --git a/Core/Fitting/PyFittingCallbacks.cpp b/Core/Fitting/PyFittingCallbacks.cpp index 6493ed95d4ac662532c127d65953eb3f99cd1933..0be3fd4578ec510405eba8cfc1e20357d9f8f564 100644 --- a/Core/Fitting/PyFittingCallbacks.cpp +++ b/Core/Fitting/PyFittingCallbacks.cpp @@ -20,8 +20,7 @@ PyBuilderCallback::PyBuilderCallback() = default; PyBuilderCallback::~PyBuilderCallback() = default; -ISimulation* PyBuilderCallback::build_simulation(mumufit::Parameters) -{ +ISimulation* PyBuilderCallback::build_simulation(mumufit::Parameters) { throw std::runtime_error("PyBuilderCallback::build_simulation() -> Error. Not implemented"); } @@ -31,7 +30,6 @@ PyObserverCallback::PyObserverCallback() = default; PyObserverCallback::~PyObserverCallback() = default; -void PyObserverCallback::update(const FitObjective&) -{ +void PyObserverCallback::update(const FitObjective&) { throw std::runtime_error("PyObserverCallback::update() -> Error. Not implemented"); } diff --git a/Core/Fitting/PyFittingCallbacks.h b/Core/Fitting/PyFittingCallbacks.h index afca9017ab84ab096d390ae598dcb9b74e4f2239..5759435c7aac4422b380abc62502c164b0f1ae38 100644 --- a/Core/Fitting/PyFittingCallbacks.h +++ b/Core/Fitting/PyFittingCallbacks.h @@ -25,8 +25,7 @@ class ISimulation; //! Base class to wrap Python callable and pass it to C++. Used in swig interface file, //! intended to be overloaded from Python. -class PyBuilderCallback -{ +class PyBuilderCallback { public: PyBuilderCallback(); virtual ~PyBuilderCallback(); @@ -40,8 +39,7 @@ class FitObjective; //! Base class to wrap Python callable and pass it to C++. Used in swig interface file, //! intended to be overloaded from Python. -class PyObserverCallback -{ +class PyObserverCallback { public: PyObserverCallback(); virtual ~PyObserverCallback(); diff --git a/Core/Fitting/SimDataPair.cpp b/Core/Fitting/SimDataPair.cpp index 62e6eb125b7e407c22a0d4225bc8316e475a1379..96340ff15711e04bcae87c552b8aeb1d5664140d 100644 --- a/Core/Fitting/SimDataPair.cpp +++ b/Core/Fitting/SimDataPair.cpp @@ -18,17 +18,14 @@ #include "Core/Simulation/UnitConverterUtils.h" #include "Device/Instrument/IntensityDataFunctions.h" -namespace -{ -[[noreturn]] void throwInitializationException(std::string method) -{ +namespace { +[[noreturn]] void throwInitializationException(std::string method) { std::stringstream ss; ss << "Error in SimDataPair::" << method << ": Trying access non-initialized data\n"; throw std::runtime_error(ss.str()); } -std::unique_ptr<OutputData<double>> initUserWeights(const OutputData<double>& shape, double value) -{ +std::unique_ptr<OutputData<double>> initUserWeights(const OutputData<double>& shape, double value) { auto result = std::make_unique<OutputData<double>>(); result->copyShapeFrom(shape); result->setAllTo(value); @@ -40,8 +37,7 @@ SimDataPair::SimDataPair(simulation_builder_t builder, const OutputData<double>& std::unique_ptr<OutputData<double>> uncertainties, double user_weight) : m_simulation_builder(builder) , m_raw_data(data.clone()) - , m_raw_uncertainties(std::move(uncertainties)) -{ + , m_raw_uncertainties(std::move(uncertainties)) { m_raw_user_weights = initUserWeights(*m_raw_data, user_weight); validate(); } @@ -52,8 +48,7 @@ SimDataPair::SimDataPair(simulation_builder_t builder, const OutputData<double>& : m_simulation_builder(builder) , m_raw_data(data.clone()) , m_raw_uncertainties(std::move(uncertainties)) - , m_raw_user_weights(std::move(user_weights)) -{ + , m_raw_user_weights(std::move(user_weights)) { if (!m_raw_user_weights) m_raw_user_weights = initUserWeights(*m_raw_data, 1.0); validate(); @@ -68,15 +63,13 @@ SimDataPair::SimDataPair(SimDataPair&& other) , m_user_weights(std::move(other.m_user_weights)) , m_raw_data(std::move(other.m_raw_data)) , m_raw_uncertainties(std::move(other.m_raw_uncertainties)) - , m_raw_user_weights(std::move(other.m_raw_user_weights)) -{ + , m_raw_user_weights(std::move(other.m_raw_user_weights)) { validate(); } SimDataPair::~SimDataPair() = default; -void SimDataPair::runSimulation(const mumufit::Parameters& params) -{ +void SimDataPair::runSimulation(const mumufit::Parameters& params) { m_simulation = m_simulation_builder(params); m_simulation->runSimulation(); m_sim_data = m_simulation->result(); @@ -84,40 +77,34 @@ void SimDataPair::runSimulation(const mumufit::Parameters& params) initResultArrays(); } -bool SimDataPair::containsUncertainties() const -{ +bool SimDataPair::containsUncertainties() const { return static_cast<bool>(m_raw_uncertainties); } -size_t SimDataPair::numberOfFitElements() const -{ +size_t SimDataPair::numberOfFitElements() const { return m_simulation ? m_simulation->intensityMapSize() : 0; } -SimulationResult SimDataPair::simulationResult() const -{ +SimulationResult SimDataPair::simulationResult() const { if (m_sim_data.empty()) throwInitializationException("simulationResult"); return m_sim_data; } -SimulationResult SimDataPair::experimentalData() const -{ +SimulationResult SimDataPair::experimentalData() const { if (m_exp_data.empty()) throwInitializationException("experimentalData"); return m_exp_data; } -SimulationResult SimDataPair::uncertainties() const -{ +SimulationResult SimDataPair::uncertainties() const { if (m_uncertainties.empty()) throwInitializationException("uncertainties"); return m_uncertainties; } //! Returns the user uncertainties cut to the ROI area. -SimulationResult SimDataPair::userWeights() const -{ +SimulationResult SimDataPair::userWeights() const { if (m_user_weights.empty()) throwInitializationException("userWeights"); return m_user_weights; @@ -125,8 +112,7 @@ SimulationResult SimDataPair::userWeights() const //! Returns relative difference between simulation and experimental data. -SimulationResult SimDataPair::relativeDifference() const -{ +SimulationResult SimDataPair::relativeDifference() const { if (m_sim_data.size() == 0 || m_exp_data.size() == 0) throwInitializationException("relativeDifference"); @@ -137,8 +123,7 @@ SimulationResult SimDataPair::relativeDifference() const return result; } -SimulationResult SimDataPair::absoluteDifference() const -{ +SimulationResult SimDataPair::absoluteDifference() const { if (m_sim_data.size() == 0 || m_exp_data.size() == 0) throwInitializationException("absoluteDifference"); @@ -149,36 +134,31 @@ SimulationResult SimDataPair::absoluteDifference() const return result; } -std::vector<double> SimDataPair::experimental_array() const -{ +std::vector<double> SimDataPair::experimental_array() const { if (m_exp_data.empty()) throwInitializationException("experimental_array"); return m_exp_data.data()->getRawDataVector(); } -std::vector<double> SimDataPair::simulation_array() const -{ +std::vector<double> SimDataPair::simulation_array() const { if (m_sim_data.empty()) throwInitializationException("simulation_array"); return m_sim_data.data()->getRawDataVector(); } -std::vector<double> SimDataPair::uncertainties_array() const -{ +std::vector<double> SimDataPair::uncertainties_array() const { if (m_uncertainties.empty()) throwInitializationException("uncertainties_array"); return m_uncertainties.data()->getRawDataVector(); } -std::vector<double> SimDataPair::user_weights_array() const -{ +std::vector<double> SimDataPair::user_weights_array() const { if (m_user_weights.empty()) throwInitializationException("user_weights_array"); return m_user_weights.data()->getRawDataVector(); } -void SimDataPair::initResultArrays() -{ +void SimDataPair::initResultArrays() { if (m_exp_data.size() != 0 && m_uncertainties.size() != 0 && m_user_weights.size() != 0) return; @@ -199,8 +179,7 @@ void SimDataPair::initResultArrays() m_user_weights = m_simulation->convertData(*m_raw_user_weights, true); } -void SimDataPair::validate() const -{ +void SimDataPair::validate() const { if (!m_simulation_builder) throw std::runtime_error("Error in SimDataPair: simulation builder is empty"); diff --git a/Core/Fitting/SimDataPair.h b/Core/Fitting/SimDataPair.h index e0f6ccff2f91a5fdabe524709183ff530f77847d..e40a7f1f88509b8bb7b88464359f975d4309f1a0 100644 --- a/Core/Fitting/SimDataPair.h +++ b/Core/Fitting/SimDataPair.h @@ -22,8 +22,7 @@ template <class T> class OutputData; //! Holds pair of simulation/experimental data to fit. -class SimDataPair -{ +class SimDataPair { public: SimDataPair(simulation_builder_t builder, const OutputData<double>& data, std::unique_ptr<OutputData<double>> uncertainties, double user_weight = 1.0); diff --git a/Core/Scan/AngularSpecScan.cpp b/Core/Scan/AngularSpecScan.cpp index 6b487cccc99c949e798b93e547c77960fdb22194..ffec862f5ccf88680cf418dd74b4c1a6529425af 100644 --- a/Core/Scan/AngularSpecScan.cpp +++ b/Core/Scan/AngularSpecScan.cpp @@ -21,12 +21,10 @@ #include "Device/Resolution/ScanResolution.h" #include "Param/Distrib/RangedDistributions.h" -namespace -{ +namespace { std::vector<std::vector<double>> extractValues(std::vector<std::vector<ParameterSample>> samples, - const std::function<double(const ParameterSample&)> extractor) -{ + const std::function<double(const ParameterSample&)> extractor) { std::vector<std::vector<double>> result; result.resize(samples.size()); for (size_t i = 0, size = result.size(); i < size; ++i) { @@ -47,8 +45,7 @@ AngularSpecScan::AngularSpecScan(double wl, std::vector<double> inc_angle) : m_wl(wl) , m_inc_angle(std::make_unique<PointwiseAxis>("inc_angles", std::move(inc_angle))) , m_wl_resolution(ScanResolution::scanEmptyResolution()) - , m_inc_resolution(ScanResolution::scanEmptyResolution()) -{ + , m_inc_resolution(ScanResolution::scanEmptyResolution()) { checkInitialization(); } @@ -56,8 +53,7 @@ AngularSpecScan::AngularSpecScan(double wl, const IAxis& inc_angle) : m_wl(wl) , m_inc_angle(inc_angle.clone()) , m_wl_resolution(ScanResolution::scanEmptyResolution()) - , m_inc_resolution(ScanResolution::scanEmptyResolution()) -{ + , m_inc_resolution(ScanResolution::scanEmptyResolution()) { checkInitialization(); } @@ -65,13 +61,11 @@ AngularSpecScan::AngularSpecScan(double wl, int nbins, double alpha_i_min, doubl : m_wl(wl) , m_inc_angle(std::make_unique<FixedBinAxis>("inc_angles", nbins, alpha_i_min, alpha_i_max)) , m_wl_resolution(ScanResolution::scanEmptyResolution()) - , m_inc_resolution(ScanResolution::scanEmptyResolution()) -{ + , m_inc_resolution(ScanResolution::scanEmptyResolution()) { checkInitialization(); } -AngularSpecScan* AngularSpecScan::clone() const -{ +AngularSpecScan* AngularSpecScan::clone() const { auto* result = new AngularSpecScan(m_wl, *m_inc_angle); result->setFootprintFactor(m_footprint.get()); result->setWavelengthResolution(*m_wl_resolution); @@ -82,8 +76,7 @@ AngularSpecScan* AngularSpecScan::clone() const AngularSpecScan::~AngularSpecScan() = default; std::vector<SpecularSimulationElement> -AngularSpecScan::generateSimulationElements(const Instrument& instrument) const -{ +AngularSpecScan::generateSimulationElements(const Instrument& instrument) const { const auto wls = extractValues(applyWlResolution(), [](const ParameterSample& sample) { return sample.value; }); const auto incs = extractValues(applyIncResolution(), @@ -104,89 +97,79 @@ AngularSpecScan::generateSimulationElements(const Instrument& instrument) const return result; } -void AngularSpecScan::setFootprintFactor(const IFootprintFactor* f_factor) -{ +void AngularSpecScan::setFootprintFactor(const IFootprintFactor* f_factor) { m_footprint.reset(f_factor ? f_factor->clone() : nullptr); } -void AngularSpecScan::setWavelengthResolution(const ScanResolution& resolution) -{ +void AngularSpecScan::setWavelengthResolution(const ScanResolution& resolution) { m_wl_resolution.reset(resolution.clone()); m_wl_res_cache.clear(); m_wl_res_cache.shrink_to_fit(); } void AngularSpecScan::setRelativeWavelengthResolution(const RangedDistribution& distr, - double rel_dev) -{ + double rel_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanRelativeResolution(distr, rel_dev)); setWavelengthResolution(*resolution); } void AngularSpecScan::setRelativeWavelengthResolution(const RangedDistribution& distr, - const std::vector<double>& rel_dev) -{ + const std::vector<double>& rel_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanRelativeResolution(distr, rel_dev)); setWavelengthResolution(*resolution); } void AngularSpecScan::setAbsoluteWavelengthResolution(const RangedDistribution& distr, - double std_dev) -{ + double std_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanAbsoluteResolution(distr, std_dev)); setWavelengthResolution(*resolution); } void AngularSpecScan::setAbsoluteWavelengthResolution(const RangedDistribution& distr, - const std::vector<double>& std_dev) -{ + const std::vector<double>& std_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanAbsoluteResolution(distr, std_dev)); setWavelengthResolution(*resolution); } -void AngularSpecScan::setAngleResolution(const ScanResolution& resolution) -{ +void AngularSpecScan::setAngleResolution(const ScanResolution& resolution) { m_inc_resolution.reset(resolution.clone()); m_inc_res_cache.clear(); m_inc_res_cache.shrink_to_fit(); } -void AngularSpecScan::setRelativeAngularResolution(const RangedDistribution& distr, double rel_dev) -{ +void AngularSpecScan::setRelativeAngularResolution(const RangedDistribution& distr, + double rel_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanRelativeResolution(distr, rel_dev)); setAngleResolution(*resolution); } void AngularSpecScan::setRelativeAngularResolution(const RangedDistribution& distr, - const std::vector<double>& rel_dev) -{ + const std::vector<double>& rel_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanRelativeResolution(distr, rel_dev)); setAngleResolution(*resolution); } -void AngularSpecScan::setAbsoluteAngularResolution(const RangedDistribution& distr, double std_dev) -{ +void AngularSpecScan::setAbsoluteAngularResolution(const RangedDistribution& distr, + double std_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanAbsoluteResolution(distr, std_dev)); setAngleResolution(*resolution); } void AngularSpecScan::setAbsoluteAngularResolution(const RangedDistribution& distr, - const std::vector<double>& std_dev) -{ + const std::vector<double>& std_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanAbsoluteResolution(distr, std_dev)); setAngleResolution(*resolution); } -std::vector<double> AngularSpecScan::footprint(size_t start, size_t n_elements) const -{ +std::vector<double> AngularSpecScan::footprint(size_t start, size_t n_elements) const { if (start + n_elements > numberOfSimulationElements()) throw std::runtime_error("Error in AngularSpecScan::footprint: given index exceeds the " "number of simulation elements"); @@ -222,14 +205,12 @@ std::vector<double> AngularSpecScan::footprint(size_t start, size_t n_elements) return result; } -size_t AngularSpecScan::numberOfSimulationElements() const -{ +size_t AngularSpecScan::numberOfSimulationElements() const { return m_inc_angle->size() * m_wl_resolution->nSamples() * m_inc_resolution->nSamples(); } -std::vector<double> -AngularSpecScan::createIntensities(const std::vector<SpecularSimulationElement>& sim_elements) const -{ +std::vector<double> AngularSpecScan::createIntensities( + const std::vector<SpecularSimulationElement>& sim_elements) const { const size_t axis_size = m_inc_angle->size(); std::vector<double> result(axis_size, 0.0); @@ -252,8 +233,7 @@ AngularSpecScan::createIntensities(const std::vector<SpecularSimulationElement>& return result; } -std::string AngularSpecScan::print() const -{ +std::string AngularSpecScan::print() const { std::stringstream result; result << "\n" << pyfmt::indent() << "# Defining specular scan:\n"; const std::string axis_def = pyfmt::indent() + "axis = "; @@ -279,8 +259,7 @@ std::string AngularSpecScan::print() const return result.str(); } -void AngularSpecScan::checkInitialization() -{ +void AngularSpecScan::checkInitialization() { if (m_wl <= 0.0) throw std::runtime_error( "Error in AngularSpecScan::checkInitialization: wavelength shell be positive"); @@ -293,15 +272,13 @@ void AngularSpecScan::checkInitialization() // TODO: check for inclination angle limits after switching to pointwise resolution. } -AngularSpecScan::DistrOutput AngularSpecScan::applyWlResolution() const -{ +AngularSpecScan::DistrOutput AngularSpecScan::applyWlResolution() const { if (m_wl_res_cache.empty()) m_wl_res_cache = m_wl_resolution->generateSamples(m_wl, m_inc_angle->size()); return m_wl_res_cache; } -AngularSpecScan::DistrOutput AngularSpecScan::applyIncResolution() const -{ +AngularSpecScan::DistrOutput AngularSpecScan::applyIncResolution() const { if (m_inc_res_cache.empty()) m_inc_res_cache = m_inc_resolution->generateSamples(m_inc_angle->binCenters()); return m_inc_res_cache; diff --git a/Core/Scan/AngularSpecScan.h b/Core/Scan/AngularSpecScan.h index 9f7b89deaba14ecad0c83b4246d8d36d2b64be19..ca0027b6fd64f66e81a53988f6654b371edfb11a 100644 --- a/Core/Scan/AngularSpecScan.h +++ b/Core/Scan/AngularSpecScan.h @@ -24,8 +24,7 @@ class ScanResolution; //! Scan type with inclination angles as coordinate values and a unique wavelength. //! Features footprint correction. -class AngularSpecScan : public ISpecularScan -{ +class AngularSpecScan : public ISpecularScan { public: AngularSpecScan(double wl, std::vector<double> inc_angle); AngularSpecScan(double wl, const IAxis& inc_angle); diff --git a/Core/Scan/ISpecularScan.h b/Core/Scan/ISpecularScan.h index 29c4c9beb17be76bd92597f90f9134c919644d12..cd2214fcd97f8bf5920e42f580d237fa3dc9fe75 100644 --- a/Core/Scan/ISpecularScan.h +++ b/Core/Scan/ISpecularScan.h @@ -28,8 +28,7 @@ class SpecularSimulationElement; //! Abstract base class for all types of specular scans. -class ISpecularScan : public ICloneable -{ +class ISpecularScan : public ICloneable { public: ISpecularScan* clone() const override = 0; @@ -60,8 +59,7 @@ public: #endif // SWIG }; -inline std::ostream& operator<<(std::ostream& os, const ISpecularScan& scan) -{ +inline std::ostream& operator<<(std::ostream& os, const ISpecularScan& scan) { return os << scan.print(); } #endif // BORNAGAIN_CORE_SCAN_ISPECULARSCAN_H diff --git a/Core/Scan/QSpecScan.cpp b/Core/Scan/QSpecScan.cpp index 7a3ab98b9e1a16ff40ab1eef677c62cb52323277..17de3c898415919b2d65876663f543620f71d78a 100644 --- a/Core/Scan/QSpecScan.cpp +++ b/Core/Scan/QSpecScan.cpp @@ -22,28 +22,24 @@ QSpecScan::QSpecScan(std::vector<double> qs_nm) : m_qs(std::make_unique<PointwiseAxis>("qs", std::move(qs_nm))) - , m_resolution(ScanResolution::scanEmptyResolution()) -{ + , m_resolution(ScanResolution::scanEmptyResolution()) { checkInitialization(); } QSpecScan::QSpecScan(const IAxis& qs_nm) - : m_qs(qs_nm.clone()), m_resolution(ScanResolution::scanEmptyResolution()) -{ + : m_qs(qs_nm.clone()), m_resolution(ScanResolution::scanEmptyResolution()) { checkInitialization(); } QSpecScan::QSpecScan(int nbins, double qz_min, double qz_max) : m_qs(std::make_unique<FixedBinAxis>("qs", nbins, qz_min, qz_max)) - , m_resolution(ScanResolution::scanEmptyResolution()) -{ + , m_resolution(ScanResolution::scanEmptyResolution()) { checkInitialization(); } QSpecScan::~QSpecScan() = default; -QSpecScan* QSpecScan::clone() const -{ +QSpecScan* QSpecScan::clone() const { auto* result = new QSpecScan(*m_qs); result->setQResolution(*m_resolution); return result; @@ -51,8 +47,7 @@ QSpecScan* QSpecScan::clone() const //! Generates simulation elements for specular simulations std::vector<SpecularSimulationElement> -QSpecScan::generateSimulationElements(const Instrument& instrument) const -{ +QSpecScan::generateSimulationElements(const Instrument& instrument) const { const std::vector<double> qz = generateQzVector(); std::vector<SpecularSimulationElement> result; @@ -62,8 +57,7 @@ QSpecScan::generateSimulationElements(const Instrument& instrument) const return result; } -std::vector<double> QSpecScan::footprint(size_t i, size_t n_elements) const -{ +std::vector<double> QSpecScan::footprint(size_t i, size_t n_elements) const { if (i + n_elements > numberOfSimulationElements()) throw std::runtime_error("Error in QSpecScan::footprint: given index exceeds the " "number of simulation elements"); @@ -71,14 +65,12 @@ std::vector<double> QSpecScan::footprint(size_t i, size_t n_elements) const } //! Returns the number of simulation elements -size_t QSpecScan::numberOfSimulationElements() const -{ +size_t QSpecScan::numberOfSimulationElements() const { return m_qs->size() * m_resolution->nSamples(); } std::vector<double> -QSpecScan::createIntensities(const std::vector<SpecularSimulationElement>& sim_elements) const -{ +QSpecScan::createIntensities(const std::vector<SpecularSimulationElement>& sim_elements) const { const size_t axis_size = m_qs->size(); std::vector<double> result(axis_size, 0.0); @@ -95,8 +87,7 @@ QSpecScan::createIntensities(const std::vector<SpecularSimulationElement>& sim_e return result; } -std::string QSpecScan::print() const -{ +std::string QSpecScan::print() const { std::stringstream result; const std::string axis_def = pyfmt::indent() + "axis = "; result << axis_def << coordinateAxis()->pyString("", axis_def.size()) << "\n"; @@ -110,45 +101,39 @@ std::string QSpecScan::print() const return result.str(); } -void QSpecScan::setQResolution(const ScanResolution& resolution) -{ +void QSpecScan::setQResolution(const ScanResolution& resolution) { m_resolution.reset(resolution.clone()); m_q_res_cache.clear(); m_q_res_cache.shrink_to_fit(); } -void QSpecScan::setRelativeQResolution(const RangedDistribution& distr, double rel_dev) -{ +void QSpecScan::setRelativeQResolution(const RangedDistribution& distr, double rel_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanRelativeResolution(distr, rel_dev)); setQResolution(*resolution); } void QSpecScan::setRelativeQResolution(const RangedDistribution& distr, - const std::vector<double>& rel_dev) -{ + const std::vector<double>& rel_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanRelativeResolution(distr, rel_dev)); setQResolution(*resolution); } -void QSpecScan::setAbsoluteQResolution(const RangedDistribution& distr, double std_dev) -{ +void QSpecScan::setAbsoluteQResolution(const RangedDistribution& distr, double std_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanAbsoluteResolution(distr, std_dev)); setQResolution(*resolution); } void QSpecScan::setAbsoluteQResolution(const RangedDistribution& distr, - const std::vector<double>& std_dev) -{ + const std::vector<double>& std_dev) { std::unique_ptr<ScanResolution> resolution( ScanResolution::scanAbsoluteResolution(distr, std_dev)); setQResolution(*resolution); } -void QSpecScan::checkInitialization() -{ +void QSpecScan::checkInitialization() { std::vector<double> axis_values = m_qs->binCenters(); if (!std::is_sorted(axis_values.begin(), axis_values.end())) throw std::runtime_error("Error in QSpecScan::checkInitialization: q-vector values shall " @@ -159,8 +144,7 @@ void QSpecScan::checkInitialization() "of acceptable range."); } -std::vector<double> QSpecScan::generateQzVector() const -{ +std::vector<double> QSpecScan::generateQzVector() const { const auto samples = applyQResolution(); std::vector<double> result; @@ -171,8 +155,7 @@ std::vector<double> QSpecScan::generateQzVector() const return result; } -std::vector<std::vector<ParameterSample>> QSpecScan::applyQResolution() const -{ +std::vector<std::vector<ParameterSample>> QSpecScan::applyQResolution() const { if (m_q_res_cache.empty()) m_q_res_cache = m_resolution->generateSamples(m_qs->binCenters()); return m_q_res_cache; diff --git a/Core/Scan/QSpecScan.h b/Core/Scan/QSpecScan.h index 07883efd32b0f90c54a5d25cbf6cb976bec5e42f..7ecfb4147ebc069c455f77e0bdc46db6fdd35917 100644 --- a/Core/Scan/QSpecScan.h +++ b/Core/Scan/QSpecScan.h @@ -25,8 +25,7 @@ class ScanResolution; //! Scan type with z-components of scattering vector as coordinate values. //! Wavelength and incident angles are not accessible separately. -class QSpecScan : public ISpecularScan -{ +class QSpecScan : public ISpecularScan { public: //! Accepts qz-value vector (in inverse nm) QSpecScan(std::vector<double> qs_nm); diff --git a/Core/Scan/UnitConverter1D.cpp b/Core/Scan/UnitConverter1D.cpp index 334cf60bc6fd90a291a32b8e800d1424b8f76dbf..0e78b827dfc19eed0e25cb65cc006df3310938f3 100644 --- a/Core/Scan/UnitConverter1D.cpp +++ b/Core/Scan/UnitConverter1D.cpp @@ -22,8 +22,7 @@ #include "Device/Data/OutputData.h" #include "Device/Unit/AxisNames.h" -namespace -{ +namespace { double getQ(double wavelength, double angle); double getInvQ(double wavelength, double q); @@ -32,8 +31,7 @@ std::unique_ptr<PointwiseAxis> createTranslatedAxis(const IAxis& axis, std::function<double(double)> translator, std::string name); } // namespace -std::unique_ptr<UnitConverter1D> UnitConverter1D::createUnitConverter(const ISpecularScan& scan) -{ +std::unique_ptr<UnitConverter1D> UnitConverter1D::createUnitConverter(const ISpecularScan& scan) { if (const auto* aScan = dynamic_cast<const AngularSpecScan*>(&scan)) return std::make_unique<UnitConverterConvSpec>(*aScan); @@ -43,13 +41,11 @@ std::unique_ptr<UnitConverter1D> UnitConverter1D::createUnitConverter(const ISpe throw std::runtime_error("Bug in UnitConverter1D::createUnitConverter: invalid case"); } -size_t UnitConverter1D::dimension() const -{ +size_t UnitConverter1D::dimension() const { return 1u; } -double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units_type) const -{ +double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units_type) const { checkIndex(i_axis); units_type = substituteDefaultUnits(units_type); if (units_type == Axes::Units::NBINS) @@ -58,8 +54,7 @@ double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units_type) cons return translator(coordinateAxis()->binCenter(0)); } -double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units_type) const -{ +double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units_type) const { checkIndex(i_axis); units_type = substituteDefaultUnits(units_type); auto coordinate_axis = coordinateAxis(); @@ -69,8 +64,8 @@ double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units_type) cons return translator(coordinate_axis->binCenter(coordinate_axis->size() - 1)); } -std::unique_ptr<IAxis> UnitConverter1D::createConvertedAxis(size_t i_axis, Axes::Units units) const -{ +std::unique_ptr<IAxis> UnitConverter1D::createConvertedAxis(size_t i_axis, + Axes::Units units) const { checkIndex(i_axis); units = substituteDefaultUnits(units); if (units == Axes::Units::NBINS) @@ -80,8 +75,7 @@ std::unique_ptr<IAxis> UnitConverter1D::createConvertedAxis(size_t i_axis, Axes: } std::unique_ptr<OutputData<double>> -UnitConverter1D::createConvertedData(const OutputData<double>& data, Axes::Units units) const -{ +UnitConverter1D::createConvertedData(const OutputData<double>& data, Axes::Units units) const { if (data.rank() != 1) throw std::runtime_error("Error in UnitConverter1D::createConvertedData: unexpected " "dimensions of the input data"); @@ -102,56 +96,46 @@ UnitConverter1D::createConvertedData(const OutputData<double>& data, Axes::Units UnitConverterConvSpec::UnitConverterConvSpec(const Beam& beam, const IAxis& axis, Axes::Units axis_units) - : m_wavelength(beam.getWavelength()) -{ + : m_wavelength(beam.getWavelength()) { m_axis = createTranslatedAxis(axis, getTraslatorFrom(axis_units), axisName(0, axis_units)); if (m_axis->lowerBound() < 0 || m_axis->upperBound() > M_PI_2) throw std::runtime_error("Error in UnitConverter1D: input axis range is out of bounds"); } UnitConverterConvSpec::UnitConverterConvSpec(const AngularSpecScan& handler) - : m_wavelength(handler.wavelength()), m_axis(handler.coordinateAxis()->clone()) -{ -} + : m_wavelength(handler.wavelength()), m_axis(handler.coordinateAxis()->clone()) {} UnitConverterConvSpec::~UnitConverterConvSpec() = default; -UnitConverterConvSpec* UnitConverterConvSpec::clone() const -{ +UnitConverterConvSpec* UnitConverterConvSpec::clone() const { return new UnitConverterConvSpec(*this); } -size_t UnitConverterConvSpec::axisSize(size_t i_axis) const -{ +size_t UnitConverterConvSpec::axisSize(size_t i_axis) const { checkIndex(i_axis); return m_axis->size(); } -std::vector<Axes::Units> UnitConverterConvSpec::availableUnits() const -{ +std::vector<Axes::Units> UnitConverterConvSpec::availableUnits() const { return {Axes::Units::NBINS, Axes::Units::RADIANS, Axes::Units::DEGREES, Axes::Units::QSPACE, Axes::Units::RQ4}; } -Axes::Units UnitConverterConvSpec::defaultUnits() const -{ +Axes::Units UnitConverterConvSpec::defaultUnits() const { return Axes::Units::DEGREES; } UnitConverterConvSpec::UnitConverterConvSpec(const UnitConverterConvSpec& other) - : m_wavelength(other.m_wavelength), m_axis(other.m_axis->clone()) -{ -} + : m_wavelength(other.m_wavelength), m_axis(other.m_axis->clone()) {} -std::vector<std::map<Axes::Units, std::string>> UnitConverterConvSpec::createNameMaps() const -{ +std::vector<std::map<Axes::Units, std::string>> UnitConverterConvSpec::createNameMaps() const { std::vector<std::map<Axes::Units, std::string>> result; result.push_back(AxisNames::InitSpecAxis()); return result; } -std::function<double(double)> UnitConverterConvSpec::getTraslatorFrom(Axes::Units units_type) const -{ +std::function<double(double)> +UnitConverterConvSpec::getTraslatorFrom(Axes::Units units_type) const { switch (units_type) { case Axes::Units::RADIANS: return [](double value) { return value; }; @@ -165,8 +149,7 @@ std::function<double(double)> UnitConverterConvSpec::getTraslatorFrom(Axes::Unit } } -std::function<double(double)> UnitConverterConvSpec::getTraslatorTo(Axes::Units units_type) const -{ +std::function<double(double)> UnitConverterConvSpec::getTraslatorTo(Axes::Units units_type) const { switch (units_type) { case Axes::Units::RADIANS: return [](double value) { return value; }; @@ -182,52 +165,42 @@ std::function<double(double)> UnitConverterConvSpec::getTraslatorTo(Axes::Units } UnitConverterQSpec::UnitConverterQSpec(const QSpecScan& handler) - : m_axis(handler.coordinateAxis()->clone()) -{ -} + : m_axis(handler.coordinateAxis()->clone()) {} UnitConverterQSpec::~UnitConverterQSpec() = default; -UnitConverterQSpec* UnitConverterQSpec::clone() const -{ +UnitConverterQSpec* UnitConverterQSpec::clone() const { return new UnitConverterQSpec(*this); } //! Returns the size of underlying axis. -size_t UnitConverterQSpec::axisSize(size_t i_axis) const -{ +size_t UnitConverterQSpec::axisSize(size_t i_axis) const { checkIndex(i_axis); return m_axis->size(); } //! Returns the list of all available units -std::vector<Axes::Units> UnitConverterQSpec::availableUnits() const -{ +std::vector<Axes::Units> UnitConverterQSpec::availableUnits() const { return {Axes::Units::NBINS, Axes::Units::QSPACE, Axes::Units::RQ4}; } //! Returns default units to convert to. -Axes::Units UnitConverterQSpec::defaultUnits() const -{ +Axes::Units UnitConverterQSpec::defaultUnits() const { return Axes::Units::QSPACE; } UnitConverterQSpec::UnitConverterQSpec(const UnitConverterQSpec& other) - : m_axis(std::unique_ptr<IAxis>(other.coordinateAxis()->clone())) -{ -} + : m_axis(std::unique_ptr<IAxis>(other.coordinateAxis()->clone())) {} //! Creates name map for axis in various units -std::vector<std::map<Axes::Units, std::string>> UnitConverterQSpec::createNameMaps() const -{ +std::vector<std::map<Axes::Units, std::string>> UnitConverterQSpec::createNameMaps() const { std::vector<std::map<Axes::Units, std::string>> result; result.push_back(AxisNames::InitSpecAxisQ()); return result; } //! Returns translating functional (inv. nm --> desired units) -std::function<double(double)> UnitConverterQSpec::getTraslatorTo(Axes::Units units_type) const -{ +std::function<double(double)> UnitConverterQSpec::getTraslatorTo(Axes::Units units_type) const { switch (units_type) { case Axes::Units::QSPACE: return [](double value) { return value; }; @@ -238,22 +211,19 @@ std::function<double(double)> UnitConverterQSpec::getTraslatorTo(Axes::Units uni } } -namespace -{ -double getQ(double wavelength, double angle) -{ +namespace { +double getQ(double wavelength, double angle) { return 4.0 * M_PI * std::sin(angle) / wavelength; } -double getInvQ(double wavelength, double q) -{ +double getInvQ(double wavelength, double q) { double sin_angle = q * wavelength / (4.0 * M_PI); return std::asin(sin_angle); } -std::unique_ptr<PointwiseAxis> -createTranslatedAxis(const IAxis& axis, std::function<double(double)> translator, std::string name) -{ +std::unique_ptr<PointwiseAxis> createTranslatedAxis(const IAxis& axis, + std::function<double(double)> translator, + std::string name) { auto coordinates = axis.binCenters(); for (size_t i = 0, size = coordinates.size(); i < size; ++i) coordinates[i] = translator(coordinates[i]); diff --git a/Core/Scan/UnitConverter1D.h b/Core/Scan/UnitConverter1D.h index 63542810b28be9ffbbc15f11a8398333bd8424a4..710c0f713536e24f0ca3c9c0efca8d29dae97003 100644 --- a/Core/Scan/UnitConverter1D.h +++ b/Core/Scan/UnitConverter1D.h @@ -26,8 +26,7 @@ class QSpecScan; //! Conversion of axis units for the case of 1D simulation result. -class UnitConverter1D : public IUnitConverter -{ +class UnitConverter1D : public IUnitConverter { public: //! Factory function to create unit converter for particular type of specular data static std::unique_ptr<UnitConverter1D> createUnitConverter(const ISpecularScan& handler); @@ -60,8 +59,7 @@ protected: }; //! Conversion of axis units for the case of conventional (angle-based) reflectometry. -class UnitConverterConvSpec : public UnitConverter1D -{ +class UnitConverterConvSpec : public UnitConverter1D { public: //! Constructs the object for unit conversion. UnitConverterConvSpec(const Beam& beam, const IAxis& axis, @@ -99,8 +97,7 @@ protected: }; //! Conversion of axis units for the case of q-defined reflectometry. -class UnitConverterQSpec : public UnitConverter1D -{ +class UnitConverterQSpec : public UnitConverter1D { public: UnitConverterQSpec(const QSpecScan& handler); ~UnitConverterQSpec() override; diff --git a/Core/Simulation/DepthProbeSimulation.cpp b/Core/Simulation/DepthProbeSimulation.cpp index 11d86cf482ef3291fd64b37c8cc97d9054d567be..dd87ac5cbf0239cb1cc1307d4b748988004e417d 100644 --- a/Core/Simulation/DepthProbeSimulation.cpp +++ b/Core/Simulation/DepthProbeSimulation.cpp @@ -27,84 +27,73 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/SampleBuilderEngine/ISampleBuilder.h" -namespace -{ +namespace { const RealLimits alpha_limits = RealLimits::limited(0.0, M_PI_2); const double zero_phi_i = 0.0; const double zero_alpha_i = 0.0; } // namespace -DepthProbeSimulation::DepthProbeSimulation() : ISimulation() -{ +DepthProbeSimulation::DepthProbeSimulation() : ISimulation() { initialize(); } DepthProbeSimulation::~DepthProbeSimulation() = default; -DepthProbeSimulation* DepthProbeSimulation::clone() const -{ +DepthProbeSimulation* DepthProbeSimulation::clone() const { return new DepthProbeSimulation(*this); } -size_t DepthProbeSimulation::numberOfSimulationElements() const -{ +size_t DepthProbeSimulation::numberOfSimulationElements() const { return getAlphaAxis()->size(); } -SimulationResult DepthProbeSimulation::result() const -{ +SimulationResult DepthProbeSimulation::result() const { validityCheck(); auto data = createIntensityData(); return SimulationResult(*data, *createUnitConverter()); } void DepthProbeSimulation::setBeamParameters(double lambda, int nbins, double alpha_i_min, - double alpha_i_max, const IFootprintFactor* beam_shape) -{ + double alpha_i_max, + const IFootprintFactor* beam_shape) { FixedBinAxis axis("alpha_i", static_cast<size_t>(nbins), alpha_i_min, alpha_i_max); setBeamParameters(lambda, axis, beam_shape); } -void DepthProbeSimulation::setZSpan(size_t n_bins, double z_min, double z_max) -{ +void DepthProbeSimulation::setZSpan(size_t n_bins, double z_min, double z_max) { if (z_max <= z_min) throw std::runtime_error("Error in DepthProbeSimulation::setZSpan: maximum on-axis value " "is less or equal to the minimum one"); m_z_axis = std::make_unique<FixedBinAxis>("z", n_bins, z_min, z_max); } -const IAxis* DepthProbeSimulation::getAlphaAxis() const -{ +const IAxis* DepthProbeSimulation::getAlphaAxis() const { if (!m_alpha_axis) throw std::runtime_error("Error in DepthProbeSimulation::getAlphaAxis: incident angle axis " "was not initialized."); return m_alpha_axis.get(); } -const IAxis* DepthProbeSimulation::getZAxis() const -{ +const IAxis* DepthProbeSimulation::getZAxis() const { if (!m_z_axis) throw std::runtime_error("Error in DepthProbeSimulation::getZAxis: position axis " "was not initialized."); return m_z_axis.get(); } -size_t DepthProbeSimulation::intensityMapSize() const -{ +size_t DepthProbeSimulation::intensityMapSize() const { if (!m_z_axis || !m_alpha_axis) throw std::runtime_error("Error in DepthProbeSimulation::intensityMapSize: attempt to " "access non-initialized data."); return m_z_axis->size() * m_alpha_axis->size(); } -std::unique_ptr<IUnitConverter> DepthProbeSimulation::createUnitConverter() const -{ +std::unique_ptr<IUnitConverter> DepthProbeSimulation::createUnitConverter() const { return std::make_unique<DepthProbeConverter>(instrument().beam(), *m_alpha_axis, *m_z_axis); } DepthProbeSimulation::DepthProbeSimulation(const DepthProbeSimulation& other) - : ISimulation(other), m_sim_elements(other.m_sim_elements), m_cache(other.m_cache) -{ + : ISimulation(other), m_sim_elements(other.m_sim_elements), m_cache(other.m_cache) { if (other.m_alpha_axis) m_alpha_axis.reset(other.m_alpha_axis->clone()); if (other.m_z_axis) @@ -115,8 +104,7 @@ DepthProbeSimulation::DepthProbeSimulation(const DepthProbeSimulation& other) } void DepthProbeSimulation::setBeamParameters(double lambda, const IAxis& alpha_axis, - const IFootprintFactor* beam_shape) -{ + const IFootprintFactor* beam_shape) { if (lambda <= 0.0) throw std::runtime_error( "Error in DepthProbeSimulation::setBeamParameters: wavelength must be positive."); @@ -145,8 +133,7 @@ void DepthProbeSimulation::setBeamParameters(double lambda, const IAxis& alpha_a instrument().beam().setFootprintFactor(*beam_shape); } -void DepthProbeSimulation::initSimulationElementVector() -{ +void DepthProbeSimulation::initSimulationElementVector() { m_sim_elements = generateSimulationElements(instrument().beam()); if (!m_cache.empty()) @@ -154,8 +141,7 @@ void DepthProbeSimulation::initSimulationElementVector() m_cache.resize(m_sim_elements.size(), std::valarray<double>(0.0, getZAxis()->size())); } -std::vector<DepthProbeElement> DepthProbeSimulation::generateSimulationElements(const Beam& beam) -{ +std::vector<DepthProbeElement> DepthProbeSimulation::generateSimulationElements(const Beam& beam) { std::vector<DepthProbeElement> result; const double wavelength = beam.getWavelength(); @@ -173,16 +159,14 @@ std::vector<DepthProbeElement> DepthProbeSimulation::generateSimulationElements( } std::unique_ptr<IComputation> -DepthProbeSimulation::generateSingleThreadedComputation(size_t start, size_t n_elements) -{ +DepthProbeSimulation::generateSingleThreadedComputation(size_t start, size_t n_elements) { ASSERT(start < m_sim_elements.size() && start + n_elements <= m_sim_elements.size()); const auto& begin = m_sim_elements.begin() + static_cast<long>(start); return std::make_unique<DepthProbeComputation>(*sample(), options(), progress(), begin, begin + static_cast<long>(n_elements)); } -void DepthProbeSimulation::validityCheck() const -{ +void DepthProbeSimulation::validityCheck() const { const MultiLayer* current_sample = sample(); if (!current_sample) throw std::runtime_error( @@ -195,15 +179,13 @@ void DepthProbeSimulation::validityCheck() const "element vector is not equal to the number of inclination angles"); } -void DepthProbeSimulation::checkCache() const -{ +void DepthProbeSimulation::checkCache() const { if (m_sim_elements.size() != m_cache.size()) throw std::runtime_error("Error in DepthProbeSimulation: the sizes of simulation element " "vector and of its cache are different"); } -void DepthProbeSimulation::validateParametrization(const ParameterDistribution& par_distr) const -{ +void DepthProbeSimulation::validateParametrization(const ParameterDistribution& par_distr) const { const bool zero_mean = par_distr.getDistribution()->getMean() == 0.0; if (zero_mean) return; @@ -217,8 +199,7 @@ void DepthProbeSimulation::validateParametrization(const ParameterDistribution& "beam inclination angle should have zero mean."); } -void DepthProbeSimulation::initialize() -{ +void DepthProbeSimulation::initialize() { setName("DepthProbeSimulation"); // allow for negative inclinations in the beam of specular simulation @@ -227,8 +208,7 @@ void DepthProbeSimulation::initialize() inclination->setLimits(RealLimits::limited(-M_PI_2, M_PI_2)); } -void DepthProbeSimulation::normalize(size_t start_ind, size_t n_elements) -{ +void DepthProbeSimulation::normalize(size_t start_ind, size_t n_elements) { const double beam_intensity = getBeamIntensity(); for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) { auto& element = m_sim_elements[i]; @@ -241,22 +221,19 @@ void DepthProbeSimulation::normalize(size_t start_ind, size_t n_elements) } } -void DepthProbeSimulation::addBackgroundIntensity(size_t, size_t) -{ +void DepthProbeSimulation::addBackgroundIntensity(size_t, size_t) { if (background()) throw std::runtime_error( "Error: nonzero background is not supported by DepthProbeSimulation"); } -void DepthProbeSimulation::addDataToCache(double weight) -{ +void DepthProbeSimulation::addDataToCache(double weight) { checkCache(); for (size_t i = 0, size = m_sim_elements.size(); i < size; ++i) m_cache[i] += m_sim_elements[i].getIntensities() * weight; } -void DepthProbeSimulation::moveDataFromCache() -{ +void DepthProbeSimulation::moveDataFromCache() { checkCache(); for (size_t i = 0, size = m_sim_elements.size(); i < size; ++i) m_sim_elements[i].setIntensities(std::move(m_cache[i])); @@ -264,13 +241,11 @@ void DepthProbeSimulation::moveDataFromCache() m_cache.shrink_to_fit(); } -double DepthProbeSimulation::incidentAngle(size_t index) const -{ +double DepthProbeSimulation::incidentAngle(size_t index) const { return m_alpha_axis->bin(index).center(); } -std::unique_ptr<OutputData<double>> DepthProbeSimulation::createIntensityData() const -{ +std::unique_ptr<OutputData<double>> DepthProbeSimulation::createIntensityData() const { std::unique_ptr<OutputData<double>> result = std::make_unique<OutputData<double>>(); result->addAxis(*getAlphaAxis()); result->addAxis(*getZAxis()); @@ -286,8 +261,7 @@ std::unique_ptr<OutputData<double>> DepthProbeSimulation::createIntensityData() return result; } -std::vector<double> DepthProbeSimulation::rawResults() const -{ +std::vector<double> DepthProbeSimulation::rawResults() const { validityCheck(); const size_t z_size = getZAxis()->size(); const size_t alpha_size = getAlphaAxis()->size(); @@ -305,8 +279,7 @@ std::vector<double> DepthProbeSimulation::rawResults() const return result; } -void DepthProbeSimulation::setRawResults(const std::vector<double>& raw_results) -{ +void DepthProbeSimulation::setRawResults(const std::vector<double>& raw_results) { validityCheck(); const size_t z_size = getZAxis()->size(); const size_t alpha_size = getAlphaAxis()->size(); diff --git a/Core/Simulation/DepthProbeSimulation.h b/Core/Simulation/DepthProbeSimulation.h index bd5b9527752a562eae25bffbfa6a3dcd98627689..52ed5beaa948cb1f87d0357801f8a32d6aaab1ba 100644 --- a/Core/Simulation/DepthProbeSimulation.h +++ b/Core/Simulation/DepthProbeSimulation.h @@ -30,8 +30,7 @@ class MultiLayer; class Histogram1D; class IUnitConverter; -class DepthProbeSimulation : public ISimulation -{ +class DepthProbeSimulation : public ISimulation { public: DepthProbeSimulation(); ~DepthProbeSimulation() override; diff --git a/Core/Simulation/GISASSimulation.cpp b/Core/Simulation/GISASSimulation.cpp index ad2265118ef27cc3aca7a91335f770931178bc7e..f15db695882362e6eb8698b585f629b43dd6d852 100644 --- a/Core/Simulation/GISASSimulation.cpp +++ b/Core/Simulation/GISASSimulation.cpp @@ -20,13 +20,11 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/SampleBuilderEngine/ISampleBuilder.h" -GISASSimulation::GISASSimulation() -{ +GISASSimulation::GISASSimulation() { initialize(); } -void GISASSimulation::prepareSimulation() -{ +void GISASSimulation::prepareSimulation() { if (instrument().getDetectorDimension() != 2) throw Exceptions::LogicErrorException( "GISASSimulation::prepareSimulation() " @@ -35,42 +33,36 @@ void GISASSimulation::prepareSimulation() ISimulation2D::prepareSimulation(); } -SimulationResult GISASSimulation::result() const -{ +SimulationResult GISASSimulation::result() const { const auto converter = UnitConverterUtils::createConverterForGISAS(instrument()); const std::unique_ptr<OutputData<double>> data( instrument().detector().createDetectorIntensity(m_sim_elements)); return SimulationResult(*data, *converter); } -void GISASSimulation::setBeamParameters(double wavelength, double alpha_i, double phi_i) -{ +void GISASSimulation::setBeamParameters(double wavelength, double alpha_i, double phi_i) { if (wavelength <= 0.0) throw Exceptions::ClassInitializationException( "ISimulation::setBeamParameters() -> Error. Incoming wavelength <= 0."); instrument().setBeamParameters(wavelength, alpha_i, phi_i); } -size_t GISASSimulation::intensityMapSize() const -{ +size_t GISASSimulation::intensityMapSize() const { size_t result = 0; instrument().detector().iterate([&result](IDetector::const_iterator) { ++result; }, true); return result; } -GISASSimulation::GISASSimulation(const GISASSimulation& other) : ISimulation2D(other) -{ +GISASSimulation::GISASSimulation(const GISASSimulation& other) : ISimulation2D(other) { initialize(); } -void GISASSimulation::initSimulationElementVector() -{ +void GISASSimulation::initSimulationElementVector() { m_sim_elements = generateSimulationElements(instrument().beam()); if (m_cache.empty()) m_cache.resize(m_sim_elements.size(), 0.0); } -void GISASSimulation::initialize() -{ +void GISASSimulation::initialize() { setName("GISASSimulation"); } diff --git a/Core/Simulation/GISASSimulation.h b/Core/Simulation/GISASSimulation.h index e0bf58f9cbc44fa32d6000fe5b738e294c6ba54c..84a667bf327e04461e62e22dcd03dc289ab1b529 100644 --- a/Core/Simulation/GISASSimulation.h +++ b/Core/Simulation/GISASSimulation.h @@ -24,8 +24,7 @@ class ISampleBuilder; //! Main class to run a Grazing-Incidence Small-Angle Scattering simulation. //! @ingroup simulation -class GISASSimulation : public ISimulation2D -{ +class GISASSimulation : public ISimulation2D { public: GISASSimulation(); ~GISASSimulation() {} diff --git a/Core/Simulation/ISimulation.cpp b/Core/Simulation/ISimulation.cpp index c7aa303f26f6b0cc490c0ff7f07e4900fc0e8147..0e39995d59bbc3071497393702246f2d6d573bae 100644 --- a/Core/Simulation/ISimulation.cpp +++ b/Core/Simulation/ISimulation.cpp @@ -27,11 +27,9 @@ #include <iostream> #include <thread> -namespace -{ +namespace { -bool detHasSameDimensions(const IDetector& detector, const OutputData<double>& data) -{ +bool detHasSameDimensions(const IDetector& detector, const OutputData<double>& data) { if (data.rank() != detector.dimension()) return false; @@ -42,16 +40,14 @@ bool detHasSameDimensions(const IDetector& detector, const OutputData<double>& d return true; } -size_t getIndexStep(size_t total_size, size_t n_handlers) -{ +size_t getIndexStep(size_t total_size, size_t n_handlers) { ASSERT(total_size > 0); ASSERT(n_handlers > 0); size_t result = total_size / n_handlers; return total_size % n_handlers ? ++result : result; } -size_t getStartIndex(size_t n_handlers, size_t current_handler, size_t n_elements) -{ +size_t getStartIndex(size_t n_handlers, size_t current_handler, size_t n_elements) { const size_t handler_size = getIndexStep(n_elements, static_cast<size_t>(n_handlers)); const size_t start_index = current_handler * handler_size; if (start_index >= n_elements) @@ -59,8 +55,7 @@ size_t getStartIndex(size_t n_handlers, size_t current_handler, size_t n_element return start_index; } -size_t getNumberOfElements(size_t n_handlers, size_t current_handler, size_t n_elements) -{ +size_t getNumberOfElements(size_t n_handlers, size_t current_handler, size_t n_elements) { const size_t handler_size = getIndexStep(n_elements, static_cast<size_t>(n_handlers)); const size_t start_index = current_handler * handler_size; if (start_index >= n_elements) @@ -68,8 +63,7 @@ size_t getNumberOfElements(size_t n_handlers, size_t current_handler, size_t n_e return std::min(handler_size, n_elements - start_index); } -void runComputations(std::vector<std::unique_ptr<IComputation>>& computations) -{ +void runComputations(std::vector<std::unique_ptr<IComputation>>& computations) { ASSERT(!computations.empty()); if (computations.size() == 1) { // Running computation in current thread @@ -118,8 +112,7 @@ void runComputations(std::vector<std::unique_ptr<IComputation>>& computations) // class ISimulation // ************************************************************************************************ -ISimulation::ISimulation() -{ +ISimulation::ISimulation() { initialize(); } @@ -130,8 +123,7 @@ ISimulation::ISimulation(const ISimulation& other) , m_progress(other.m_progress) , m_sample_provider(other.m_sample_provider) , m_distribution_handler(other.m_distribution_handler) - , m_instrument(other.instrument()) -{ + , m_instrument(other.instrument()) { if (other.m_background) setBackground(*other.m_background); initialize(); @@ -139,15 +131,13 @@ ISimulation::ISimulation(const ISimulation& other) ISimulation::~ISimulation() = default; -void ISimulation::initialize() -{ +void ISimulation::initialize() { registerChild(&m_instrument); registerChild(&m_sample_provider); } //! Initializes a progress monitor that prints to stdout. -void ISimulation::setTerminalProgressMonitor() -{ +void ISimulation::setTerminalProgressMonitor() { m_progress.subscribe([](size_t percentage_done) -> bool { if (percentage_done < 100) std::cout << std::setprecision(2) << "\r... " << percentage_done << "%" << std::flush; @@ -157,36 +147,30 @@ void ISimulation::setTerminalProgressMonitor() }); } -void ISimulation::setDetectorResolutionFunction(const IResolutionFunction2D& resolution_function) -{ +void ISimulation::setDetectorResolutionFunction(const IResolutionFunction2D& resolution_function) { instrument().setDetectorResolutionFunction(resolution_function); } //! Sets the polarization analyzer characteristics of the detector void ISimulation::setAnalyzerProperties(const kvector_t direction, double efficiency, - double total_transmission) -{ + double total_transmission) { instrument().setAnalyzerProperties(direction, efficiency, total_transmission); } -void ISimulation::setBeamIntensity(double intensity) -{ +void ISimulation::setBeamIntensity(double intensity) { instrument().setBeamIntensity(intensity); } -double ISimulation::getBeamIntensity() const -{ +double ISimulation::getBeamIntensity() const { return instrument().getBeamIntensity(); } //! Sets the beam polarization according to the given Bloch vector -void ISimulation::setBeamPolarization(const kvector_t bloch_vector) -{ +void ISimulation::setBeamPolarization(const kvector_t bloch_vector) { instrument().setBeamPolarization(bloch_vector); } -void ISimulation::prepareSimulation() -{ +void ISimulation::prepareSimulation() { m_sample_provider.updateSample(); if (!MultiLayerUtils::ContainsCompatibleMaterials(*m_sample_provider.sample())) throw std::runtime_error( @@ -196,8 +180,7 @@ void ISimulation::prepareSimulation() } //! Run simulation with possible averaging over parameter distributions -void ISimulation::runSimulation() -{ +void ISimulation::runSimulation() { prepareSimulation(); const size_t total_size = numberOfSimulationElements(); @@ -225,42 +208,35 @@ void ISimulation::runSimulation() transferResultsToIntensityMap(); } -void ISimulation::runMPISimulation() -{ +void ISimulation::runMPISimulation() { MPISimulation ompi; ompi.runSimulation(this); } -void ISimulation::setInstrument(const Instrument& instrument_) -{ +void ISimulation::setInstrument(const Instrument& instrument_) { m_instrument = instrument_; updateIntensityMap(); } //! The MultiLayer object will not be owned by the ISimulation object -void ISimulation::setSample(const MultiLayer& sample) -{ +void ISimulation::setSample(const MultiLayer& sample) { m_sample_provider.setSample(sample); } -const MultiLayer* ISimulation::sample() const -{ +const MultiLayer* ISimulation::sample() const { return m_sample_provider.sample(); } -void ISimulation::setSampleBuilder(const std::shared_ptr<class ISampleBuilder>& sample_builder) -{ +void ISimulation::setSampleBuilder(const std::shared_ptr<class ISampleBuilder>& sample_builder) { m_sample_provider.setBuilder(sample_builder); } -void ISimulation::setBackground(const IBackground& bg) -{ +void ISimulation::setBackground(const IBackground& bg) { m_background.reset(bg.clone()); registerChild(m_background.get()); } -std::vector<const INode*> ISimulation::getChildren() const -{ +std::vector<const INode*> ISimulation::getChildren() const { std::vector<const INode*> result; result.push_back(&instrument()); result << m_sample_provider.getChildren(); @@ -271,22 +247,19 @@ std::vector<const INode*> ISimulation::getChildren() const void ISimulation::addParameterDistribution(const std::string& param_name, const IDistribution1D& distribution, size_t nbr_samples, - double sigma_factor, const RealLimits& limits) -{ + double sigma_factor, const RealLimits& limits) { ParameterDistribution par_distr(param_name, distribution, nbr_samples, sigma_factor, limits); addParameterDistribution(par_distr); } -void ISimulation::addParameterDistribution(const ParameterDistribution& par_distr) -{ +void ISimulation::addParameterDistribution(const ParameterDistribution& par_distr) { validateParametrization(par_distr); m_distribution_handler.addParameterDistribution(par_distr); } //! Runs a single simulation with fixed parameter values. //! If desired, the simulation is run in several threads. -void ISimulation::runSingleSimulation(size_t batch_start, size_t batch_size, double weight) -{ +void ISimulation::runSingleSimulation(size_t batch_start, size_t batch_size, double weight) { initSimulationElementVector(); const size_t n_threads = m_options.getNumberOfThreads(); @@ -314,8 +287,7 @@ void ISimulation::runSingleSimulation(size_t batch_start, size_t batch_size, dou //! corresponding to the masked areas of the detector will be set to zero. SimulationResult ISimulation::convertData(const OutputData<double>& data, - bool put_masked_areas_to_zero) -{ + bool put_masked_areas_to_zero) { auto converter = UnitConverterUtils::createConverter(*this); auto roi_data = UnitConverterUtils::createOutputData(*converter, converter->defaultUnits()); diff --git a/Core/Simulation/ISimulation.h b/Core/Simulation/ISimulation.h index de07e6615bf82bc70085943f05097561317c0f44..cbda0e5beaf5e81f51920d37f1425b1e566d8d5c 100644 --- a/Core/Simulation/ISimulation.h +++ b/Core/Simulation/ISimulation.h @@ -34,8 +34,7 @@ class MultiLayer; //! weighting over parameter distributions, ... //! @ingroup simulation -class ISimulation : public ICloneable, public INode -{ +class ISimulation : public ICloneable, public INode { public: ISimulation(); virtual ~ISimulation(); diff --git a/Core/Simulation/ISimulation2D.cpp b/Core/Simulation/ISimulation2D.cpp index 510da0f3d0af59ea078023835de2e6f4d201ef60..13d1cb0d8788ac9fdb1a835f23dd165e500d7f9d 100644 --- a/Core/Simulation/ISimulation2D.cpp +++ b/Core/Simulation/ISimulation2D.cpp @@ -23,68 +23,56 @@ ISimulation2D::ISimulation2D() = default; ISimulation2D::~ISimulation2D() = default; -void ISimulation2D::prepareSimulation() -{ +void ISimulation2D::prepareSimulation() { ISimulation::prepareSimulation(); m_detector_context = instrument().detector2D().createContext(); } -void ISimulation2D::removeMasks() -{ +void ISimulation2D::removeMasks() { instrument().detector2D().removeMasks(); } -void ISimulation2D::addMask(const IShape2D& shape, bool mask_value) -{ +void ISimulation2D::addMask(const IShape2D& shape, bool mask_value) { instrument().detector2D().addMask(shape, mask_value); } -void ISimulation2D::maskAll() -{ +void ISimulation2D::maskAll() { instrument().detector2D().maskAll(); } -void ISimulation2D::setRegionOfInterest(double xlow, double ylow, double xup, double yup) -{ +void ISimulation2D::setRegionOfInterest(double xlow, double ylow, double xup, double yup) { instrument().detector2D().setRegionOfInterest(xlow, ylow, xup, yup); } ISimulation2D::ISimulation2D(const ISimulation2D& other) - : ISimulation(other), m_sim_elements(other.m_sim_elements), m_cache(other.m_cache) -{ -} + : ISimulation(other), m_sim_elements(other.m_sim_elements), m_cache(other.m_cache) {} -size_t ISimulation2D::numberOfSimulationElements() const -{ +size_t ISimulation2D::numberOfSimulationElements() const { if (!m_detector_context) throw std::runtime_error("Error in numberOfSimulationElements(): no detector context"); return m_detector_context->numberOfSimulationElements(); } void ISimulation2D::setDetectorParameters(size_t n_x, double x_min, double x_max, size_t n_y, - double y_min, double y_max) -{ + double y_min, double y_max) { instrument().detector2D().setDetectorParameters(n_x, x_min, x_max, n_y, y_min, y_max); updateIntensityMap(); } -void ISimulation2D::setDetector(const IDetector2D& detector) -{ +void ISimulation2D::setDetector(const IDetector2D& detector) { instrument().setDetector(detector); initUnitConverter(); } std::unique_ptr<IComputation> ISimulation2D::generateSingleThreadedComputation(size_t start, - size_t n_elements) -{ + size_t n_elements) { ASSERT(start < m_sim_elements.size() && start + n_elements <= m_sim_elements.size()); const auto& begin = m_sim_elements.begin() + static_cast<long>(start); return std::make_unique<DWBAComputation>(*sample(), options(), progress(), begin, begin + static_cast<long>(n_elements)); } -std::vector<SimulationElement> ISimulation2D::generateSimulationElements(const Beam& beam) -{ +std::vector<SimulationElement> ISimulation2D::generateSimulationElements(const Beam& beam) { const double wavelength = beam.getWavelength(); const double alpha_i = -beam.getAlpha(); // Defined to be always positive in Beam const double phi_i = beam.getPhi(); @@ -108,8 +96,7 @@ std::vector<SimulationElement> ISimulation2D::generateSimulationElements(const B return result; } -void ISimulation2D::normalize(size_t start_ind, size_t n_elements) -{ +void ISimulation2D::normalize(size_t start_ind, size_t n_elements) { const double beam_intensity = getBeamIntensity(); for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) { SimulationElement& element = m_sim_elements[i]; @@ -123,8 +110,7 @@ void ISimulation2D::normalize(size_t start_ind, size_t n_elements) } } -void ISimulation2D::addBackgroundIntensity(size_t start_ind, size_t n_elements) -{ +void ISimulation2D::addBackgroundIntensity(size_t start_ind, size_t n_elements) { if (!background()) return; for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) { @@ -133,8 +119,7 @@ void ISimulation2D::addBackgroundIntensity(size_t start_ind, size_t n_elements) } } -void ISimulation2D::addDataToCache(double weight) -{ +void ISimulation2D::addDataToCache(double weight) { if (m_sim_elements.size() != m_cache.size()) throw std::runtime_error("Error in ISimulation2D::addDataToCache(double): cache size" " not the same as element size"); @@ -142,8 +127,7 @@ void ISimulation2D::addDataToCache(double weight) m_cache[i] += m_sim_elements[i].getIntensity() * weight; } -void ISimulation2D::moveDataFromCache() -{ +void ISimulation2D::moveDataFromCache() { ASSERT(!m_cache.empty()); if (!m_cache.empty()) { for (unsigned i = 0; i < m_sim_elements.size(); i++) @@ -152,8 +136,7 @@ void ISimulation2D::moveDataFromCache() } } -std::vector<double> ISimulation2D::rawResults() const -{ +std::vector<double> ISimulation2D::rawResults() const { std::vector<double> result; result.resize(m_sim_elements.size()); for (unsigned i = 0; i < m_sim_elements.size(); ++i) @@ -161,8 +144,7 @@ std::vector<double> ISimulation2D::rawResults() const return result; } -void ISimulation2D::setRawResults(const std::vector<double>& raw_data) -{ +void ISimulation2D::setRawResults(const std::vector<double>& raw_data) { initSimulationElementVector(); if (raw_data.size() != m_sim_elements.size()) throw std::runtime_error("ISimulation2D::setRawResults: size of vector passed as " diff --git a/Core/Simulation/ISimulation2D.h b/Core/Simulation/ISimulation2D.h index 0e07928a2f87656388f20647d40f83bf1b8e407c..a410a786f6c35856d4a66610a00d6b7f6def487d 100644 --- a/Core/Simulation/ISimulation2D.h +++ b/Core/Simulation/ISimulation2D.h @@ -23,8 +23,7 @@ class DetectorContext; //! Holds the common implementations for simulations with a 2D detector //! @ingroup simulation -class ISimulation2D : public ISimulation -{ +class ISimulation2D : public ISimulation { public: ISimulation2D(); ~ISimulation2D() override; diff --git a/Core/Simulation/MPISimulation.cpp b/Core/Simulation/MPISimulation.cpp index a289e9b97d1a5e1155db0a9c37a230fa0e934c99..b6f2c04e275fcfefc45126feaa1a078c7bc6a720 100644 --- a/Core/Simulation/MPISimulation.cpp +++ b/Core/Simulation/MPISimulation.cpp @@ -24,8 +24,7 @@ // MPI support // ----------------------------------------------------------------------------- -void MPISimulation::runSimulation(ISimulation* simulation) -{ +void MPISimulation::runSimulation(ISimulation* simulation) { MPI_Status st; int world_size(0), world_rank(0); @@ -72,8 +71,7 @@ void MPISimulation::runSimulation(ISimulation* simulation) // No MPI support // ----------------------------------------------------------------------------- -void MPISimulation::runSimulation(ISimulation* /* simulation */) -{ +void MPISimulation::runSimulation(ISimulation* /* simulation */) { throw std::runtime_error( "MPISimulation::runSimulation() -> Error! Can't run MPI simulation. " "The package was compiled without MPI support (compile with -DBORNAGAIN_MPI=ON)"); diff --git a/Core/Simulation/MPISimulation.h b/Core/Simulation/MPISimulation.h index f455d586fe0c6087b44a658c326d117ab9683950..7beb7fd189d0a92445ff4291ec351b280d0ca8d4 100644 --- a/Core/Simulation/MPISimulation.h +++ b/Core/Simulation/MPISimulation.h @@ -18,8 +18,7 @@ class ISimulation; -class MPISimulation -{ +class MPISimulation { public: void runSimulation(ISimulation* simulation); }; diff --git a/Core/Simulation/OffSpecSimulation.cpp b/Core/Simulation/OffSpecSimulation.cpp index 446d5b4c20eda6829b389c97058d1f27b1436054..5b33ab01b5cebce8bffd712debe323e3a4381b8a 100644 --- a/Core/Simulation/OffSpecSimulation.cpp +++ b/Core/Simulation/OffSpecSimulation.cpp @@ -22,32 +22,28 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/SampleBuilderEngine/ISampleBuilder.h" -OffSpecSimulation::OffSpecSimulation() -{ +OffSpecSimulation::OffSpecSimulation() { initialize(); } -void OffSpecSimulation::prepareSimulation() -{ +void OffSpecSimulation::prepareSimulation() { checkInitialization(); ISimulation2D::prepareSimulation(); } -size_t OffSpecSimulation::numberOfSimulationElements() const -{ +size_t OffSpecSimulation::numberOfSimulationElements() const { checkInitialization(); return ISimulation2D::numberOfSimulationElements() * m_alpha_i_axis->size(); } -SimulationResult OffSpecSimulation::result() const -{ +SimulationResult OffSpecSimulation::result() const { auto data = std::unique_ptr<OutputData<double>>(m_intensity_map.clone()); OffSpecularConverter converter(instrument().detector2D(), instrument().beam(), *m_alpha_i_axis); return SimulationResult(*data, converter); } -void OffSpecSimulation::setBeamParameters(double wavelength, const IAxis& alpha_axis, double phi_i) -{ +void OffSpecSimulation::setBeamParameters(double wavelength, const IAxis& alpha_axis, + double phi_i) { m_alpha_i_axis.reset(alpha_axis.clone()); if (alpha_axis.size() < 1) throw Exceptions::ClassInitializationException("OffSpecSimulation::prepareSimulation() " @@ -57,13 +53,11 @@ void OffSpecSimulation::setBeamParameters(double wavelength, const IAxis& alpha_ updateIntensityMap(); } -const IAxis* OffSpecSimulation::beamAxis() const -{ +const IAxis* OffSpecSimulation::beamAxis() const { return m_alpha_i_axis.get(); } -std::unique_ptr<IUnitConverter> OffSpecSimulation::createUnitConverter() const -{ +std::unique_ptr<IUnitConverter> OffSpecSimulation::createUnitConverter() const { const IAxis* axis = beamAxis(); if (!axis) throw std::runtime_error("Error in OffSpecSimulation::createUnitConverter:" @@ -72,22 +66,19 @@ std::unique_ptr<IUnitConverter> OffSpecSimulation::createUnitConverter() const *axis); } -size_t OffSpecSimulation::intensityMapSize() const -{ +size_t OffSpecSimulation::intensityMapSize() const { checkInitialization(); return m_alpha_i_axis->size() * instrument().getDetectorAxis(1).size(); } -OffSpecSimulation::OffSpecSimulation(const OffSpecSimulation& other) : ISimulation2D(other) -{ +OffSpecSimulation::OffSpecSimulation(const OffSpecSimulation& other) : ISimulation2D(other) { if (other.m_alpha_i_axis) m_alpha_i_axis.reset(other.m_alpha_i_axis->clone()); m_intensity_map.copyFrom(other.m_intensity_map); initialize(); } -void OffSpecSimulation::initSimulationElementVector() -{ +void OffSpecSimulation::initSimulationElementVector() { m_sim_elements.clear(); Beam beam = instrument().beam(); const double wavelength = beam.getWavelength(); @@ -106,8 +97,7 @@ void OffSpecSimulation::initSimulationElementVector() m_cache.resize(m_sim_elements.size(), 0.0); } -void OffSpecSimulation::validateParametrization(const ParameterDistribution& par_distr) const -{ +void OffSpecSimulation::validateParametrization(const ParameterDistribution& par_distr) const { const bool zero_mean = par_distr.getDistribution()->getMean() == 0.0; if (zero_mean) return; @@ -121,8 +111,7 @@ void OffSpecSimulation::validateParametrization(const ParameterDistribution& par "beam inclination angle should have zero mean."); } -void OffSpecSimulation::transferResultsToIntensityMap() -{ +void OffSpecSimulation::transferResultsToIntensityMap() { checkInitialization(); const IAxis& phi_axis = instrument().getDetectorAxis(0); size_t phi_f_size = phi_axis.size(); @@ -134,8 +123,7 @@ void OffSpecSimulation::transferResultsToIntensityMap() transferDetectorImage(i); } -void OffSpecSimulation::updateIntensityMap() -{ +void OffSpecSimulation::updateIntensityMap() { m_intensity_map.clear(); if (m_alpha_i_axis) m_intensity_map.addAxis(*m_alpha_i_axis); @@ -145,8 +133,7 @@ void OffSpecSimulation::updateIntensityMap() m_intensity_map.setAllTo(0.); } -void OffSpecSimulation::transferDetectorImage(size_t index) -{ +void OffSpecSimulation::transferDetectorImage(size_t index) { OutputData<double> detector_image; size_t detector_dimension = instrument().getDetectorDimension(); for (size_t dim = 0; dim < detector_dimension; ++dim) @@ -160,8 +147,7 @@ void OffSpecSimulation::transferDetectorImage(size_t index) m_intensity_map[index * y_axis_size + i % y_axis_size] += detector_image[i]; } -void OffSpecSimulation::checkInitialization() const -{ +void OffSpecSimulation::checkInitialization() const { if (!m_alpha_i_axis || m_alpha_i_axis->size() < 1) throw Exceptions::ClassInitializationException("OffSpecSimulation::checkInitialization() " "Incoming alpha range not configured."); @@ -170,7 +156,6 @@ void OffSpecSimulation::checkInitialization() const "OffSpecSimulation::checkInitialization: detector is not two-dimensional"); } -void OffSpecSimulation::initialize() -{ +void OffSpecSimulation::initialize() { setName("OffSpecSimulation"); } diff --git a/Core/Simulation/OffSpecSimulation.h b/Core/Simulation/OffSpecSimulation.h index b44e25b532fbb28ea1476ac6db86026ff9469570..4916d2a3c4fa5dbf0131bf0695ea8d83b04c5f46 100644 --- a/Core/Simulation/OffSpecSimulation.h +++ b/Core/Simulation/OffSpecSimulation.h @@ -23,8 +23,7 @@ class Histogram2D; //! Main class to run an off-specular simulation. //! @ingroup simulation -class OffSpecSimulation : public ISimulation2D -{ +class OffSpecSimulation : public ISimulation2D { public: OffSpecSimulation(); ~OffSpecSimulation() override {} diff --git a/Core/Simulation/SimulationFactory.cpp b/Core/Simulation/SimulationFactory.cpp index 8069e3c44fc734b2bb834c7f61586e40f5d81550..f85e1d56f357b824b075cd0e5c41226ca506096d 100644 --- a/Core/Simulation/SimulationFactory.cpp +++ b/Core/Simulation/SimulationFactory.cpp @@ -19,8 +19,7 @@ #include "Core/Simulation/StandardSimulations.h" #include "Param/Base/RealParameter.h" -SimulationFactory::SimulationFactory() -{ +SimulationFactory::SimulationFactory() { registerItem("BasicGISAS", StandardSimulations::BasicGISAS); registerItem("BasicGISAS00", StandardSimulations::BasicGISAS00); diff --git a/Core/Simulation/SimulationFactory.h b/Core/Simulation/SimulationFactory.h index 9b49288b0933609372611e3e3fdce3d27b32764c..a8da0f9e651c12efee2ea66f93da7f5c4f4e7b05 100644 --- a/Core/Simulation/SimulationFactory.h +++ b/Core/Simulation/SimulationFactory.h @@ -23,8 +23,7 @@ //! Used in functional tests, performance measurements, etc. //! @ingroup standard_samples -class SimulationFactory : public IFactory<std::string, ISimulation> -{ +class SimulationFactory : public IFactory<std::string, ISimulation> { public: SimulationFactory(); }; diff --git a/Core/Simulation/SpecularSimulation.cpp b/Core/Simulation/SpecularSimulation.cpp index b18d99eb8c173fafd5370aa2d6fa9fdadd329361..bd600e194c56aa30aa6cf9503590668d6706ff85 100644 --- a/Core/Simulation/SpecularSimulation.cpp +++ b/Core/Simulation/SpecularSimulation.cpp @@ -26,12 +26,10 @@ #include "Param/Base/RealParameter.h" #include "Param/Distrib/Distributions.h" -namespace -{ +namespace { // TODO: remove when pointwise resolution is implemented -std::unique_ptr<AngularSpecScan> mangledScan(const AngularSpecScan& scan, const Beam& beam) -{ +std::unique_ptr<AngularSpecScan> mangledScan(const AngularSpecScan& scan, const Beam& beam) { const double wl = beam.getWavelength(); const double angle_shift = beam.getAlpha(); std::vector<double> angles = scan.coordinateAxis()->binCenters(); @@ -45,8 +43,7 @@ std::unique_ptr<AngularSpecScan> mangledScan(const AngularSpecScan& scan, const } std::vector<SpecularSimulationElement> generateSimulationElements(const Instrument& instrument, - const ISpecularScan& scan) -{ + const ISpecularScan& scan) { // TODO: remove if statement when pointwise resolution is implemented if (const auto* aScan = dynamic_cast<const AngularSpecScan*>(&scan)) return mangledScan(*aScan, instrument.beam())->generateSimulationElements(instrument); @@ -60,8 +57,7 @@ std::vector<SpecularSimulationElement> generateSimulationElements(const Instrume // class SpecularSimulation // ************************************************************************************************ -SpecularSimulation::SpecularSimulation() : ISimulation() -{ +SpecularSimulation::SpecularSimulation() : ISimulation() { initialize(); } @@ -69,20 +65,17 @@ SpecularSimulation::SpecularSimulation(const SpecularSimulation& other) : ISimulation(other) , m_scan(other.m_scan ? other.m_scan->clone() : nullptr) , m_sim_elements(other.m_sim_elements) - , m_cache(other.m_cache) -{ + , m_cache(other.m_cache) { initialize(); } SpecularSimulation::~SpecularSimulation() = default; -SpecularSimulation* SpecularSimulation::clone() const -{ +SpecularSimulation* SpecularSimulation::clone() const { return new SpecularSimulation(*this); } -void SpecularSimulation::prepareSimulation() -{ +void SpecularSimulation::prepareSimulation() { if (instrument().getDetectorDimension() != 1) // detector must have only one axis throw std::runtime_error("Error in SpecularSimulation::prepareSimulation: the detector was " "not properly configured."); @@ -90,13 +83,11 @@ void SpecularSimulation::prepareSimulation() ISimulation::prepareSimulation(); } -size_t SpecularSimulation::numberOfSimulationElements() const -{ +size_t SpecularSimulation::numberOfSimulationElements() const { return m_scan->numberOfSimulationElements(); } -SimulationResult SpecularSimulation::result() const -{ +SimulationResult SpecularSimulation::result() const { OutputData<double> data; data.addAxis(*coordinateAxis()); @@ -109,8 +100,7 @@ SimulationResult SpecularSimulation::result() const return SimulationResult(data, *converter); } -void SpecularSimulation::setScan(const ISpecularScan& scan) -{ +void SpecularSimulation::setScan(const ISpecularScan& scan) { // TODO: move inside AngularSpecScan when pointwise resolution is implemented if (scan.coordinateAxis()->lowerBound() < 0.0) throw std::runtime_error( @@ -126,26 +116,22 @@ void SpecularSimulation::setScan(const ISpecularScan& scan) instrument().setBeamParameters(aScan->wavelength(), 0.0, 0.0); } -const IAxis* SpecularSimulation::coordinateAxis() const -{ +const IAxis* SpecularSimulation::coordinateAxis() const { if (!m_scan || !m_scan->coordinateAxis()) throw std::runtime_error( "Error in SpecularSimulation::getAlphaAxis: coordinate axis was not initialized."); return m_scan->coordinateAxis(); } -const IFootprintFactor* SpecularSimulation::footprintFactor() const -{ +const IFootprintFactor* SpecularSimulation::footprintFactor() const { return m_scan->footprintFactor(); } -size_t SpecularSimulation::intensityMapSize() const -{ +size_t SpecularSimulation::intensityMapSize() const { return m_scan->coordinateAxis()->size(); } -void SpecularSimulation::initSimulationElementVector() -{ +void SpecularSimulation::initSimulationElementVector() { if (!m_scan) throw std::runtime_error("Error in SpecularSimulation: beam parameters were not set."); m_sim_elements = generateSimulationElements(instrument(), *m_scan); @@ -156,23 +142,20 @@ void SpecularSimulation::initSimulationElementVector() } std::unique_ptr<IComputation> -SpecularSimulation::generateSingleThreadedComputation(size_t start, size_t n_elements) -{ +SpecularSimulation::generateSingleThreadedComputation(size_t start, size_t n_elements) { ASSERT(start < m_sim_elements.size() && start + n_elements <= m_sim_elements.size()); const auto& begin = m_sim_elements.begin() + static_cast<long>(start); return std::make_unique<SpecularComputation>(*sample(), options(), progress(), begin, begin + static_cast<long>(n_elements)); } -void SpecularSimulation::checkCache() const -{ +void SpecularSimulation::checkCache() const { if (m_sim_elements.size() != m_cache.size()) throw std::runtime_error("Error in SpecularSimulation: the sizes of simulation element " "vector and of its cache are different"); } -void SpecularSimulation::validateParametrization(const ParameterDistribution& par_distr) const -{ +void SpecularSimulation::validateParametrization(const ParameterDistribution& par_distr) const { const bool zero_mean = par_distr.getDistribution()->getMean() == 0.0; if (zero_mean) return; @@ -186,8 +169,7 @@ void SpecularSimulation::validateParametrization(const ParameterDistribution& pa "beam inclination angle should have zero mean."); } -void SpecularSimulation::initialize() -{ +void SpecularSimulation::initialize() { setName("SpecularSimulation"); // allow for negative inclinations in the beam of specular simulation @@ -198,8 +180,7 @@ void SpecularSimulation::initialize() ->setLimits(RealLimits::limited(-M_PI_2, M_PI_2)); } -void SpecularSimulation::normalize(size_t start_ind, size_t n_elements) -{ +void SpecularSimulation::normalize(size_t start_ind, size_t n_elements) { const double beam_intensity = getBeamIntensity(); std::vector<double> footprints; @@ -215,8 +196,7 @@ void SpecularSimulation::normalize(size_t start_ind, size_t n_elements) } } -void SpecularSimulation::addBackgroundIntensity(size_t start_ind, size_t n_elements) -{ +void SpecularSimulation::addBackgroundIntensity(size_t start_ind, size_t n_elements) { if (!background()) return; for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) { @@ -225,15 +205,13 @@ void SpecularSimulation::addBackgroundIntensity(size_t start_ind, size_t n_eleme } } -void SpecularSimulation::addDataToCache(double weight) -{ +void SpecularSimulation::addDataToCache(double weight) { checkCache(); for (size_t i = 0, size = m_sim_elements.size(); i < size; ++i) m_cache[i] += m_sim_elements[i].getIntensity() * weight; } -void SpecularSimulation::moveDataFromCache() -{ +void SpecularSimulation::moveDataFromCache() { checkCache(); for (size_t i = 0, size = m_sim_elements.size(); i < size; ++i) m_sim_elements[i].setIntensity(m_cache[i]); @@ -241,8 +219,7 @@ void SpecularSimulation::moveDataFromCache() m_cache.shrink_to_fit(); } -std::vector<double> SpecularSimulation::rawResults() const -{ +std::vector<double> SpecularSimulation::rawResults() const { std::vector<double> result; result.resize(m_sim_elements.size()); for (unsigned i = 0; i < m_sim_elements.size(); ++i) @@ -250,8 +227,7 @@ std::vector<double> SpecularSimulation::rawResults() const return result; } -void SpecularSimulation::setRawResults(const std::vector<double>& raw_data) -{ +void SpecularSimulation::setRawResults(const std::vector<double>& raw_data) { initSimulationElementVector(); if (raw_data.size() != m_sim_elements.size()) throw std::runtime_error("SpecularSimulation::setRawResults: size of vector passed as " diff --git a/Core/Simulation/SpecularSimulation.h b/Core/Simulation/SpecularSimulation.h index 48663862dfeb1d8483e21b72d9b4abd31f49948c..a708deedcdcc187c14b934f6db451cbb4112e3e6 100644 --- a/Core/Simulation/SpecularSimulation.h +++ b/Core/Simulation/SpecularSimulation.h @@ -29,8 +29,7 @@ class SpecularSimulationElement; //! Main class to run a specular simulation. //! @ingroup simulation -class SpecularSimulation : public ISimulation -{ +class SpecularSimulation : public ISimulation { public: SpecularSimulation(); ~SpecularSimulation() override; diff --git a/Core/Simulation/StandardSimulations.cpp b/Core/Simulation/StandardSimulations.cpp index 03c91556f0392b868e537a2fb6f6576f48fe558e..649dc1301bc3b01f47d77d7dd06cc1dc031dc1ce 100644 --- a/Core/Simulation/StandardSimulations.cpp +++ b/Core/Simulation/StandardSimulations.cpp @@ -38,16 +38,14 @@ #include "Sample/StandardSamples/SampleBuilderFactory.h" #include <memory> -namespace -{ +namespace { const size_t rdet_nbinsx(40), rdet_nbinsy(30); const double rdet_width(20.0), rdet_height(18.0), rdet_distance(1000.0); } // namespace //! Basic GISAS simulation with the detector phi[0,2], theta[0,2]. -GISASSimulation* StandardSimulations::BasicGISAS() -{ +GISASSimulation* StandardSimulations::BasicGISAS() { GISASSimulation* result = new GISASSimulation(); result->setDetectorParameters(100, 0.0 * Units::deg, 2.0 * Units::deg, 100, 0.0 * Units::deg, 2.0 * Units::deg); @@ -57,8 +55,7 @@ GISASSimulation* StandardSimulations::BasicGISAS() //! Basic GISAS for polarization studies. -GISASSimulation* StandardSimulations::BasicGISAS00() -{ +GISASSimulation* StandardSimulations::BasicGISAS00() { GISASSimulation* result = BasicGISAS(); kvector_t zplus(0.0, 0.0, 1.0); result->setBeamPolarization(zplus); @@ -68,8 +65,7 @@ GISASSimulation* StandardSimulations::BasicGISAS00() //! Basic GISAS simulation for spin flip channel. -GISASSimulation* StandardSimulations::BasicPolarizedGISAS() -{ +GISASSimulation* StandardSimulations::BasicPolarizedGISAS() { GISASSimulation* result = BasicGISAS(); kvector_t zplus(0.0, 0.0, 1.0); result->setBeamPolarization(zplus); @@ -79,8 +75,7 @@ GISASSimulation* StandardSimulations::BasicPolarizedGISAS() //! GISAS simulation with small detector and phi[-2,2], theta[0,2]. -GISASSimulation* StandardSimulations::MiniGISAS() -{ +GISASSimulation* StandardSimulations::MiniGISAS() { GISASSimulation* result = new GISASSimulation(); result->setDetectorParameters(25, -2.0 * Units::deg, 2.0 * Units::deg, 25, 0.0 * Units::deg, 2.0 * Units::deg); @@ -90,8 +85,7 @@ GISASSimulation* StandardSimulations::MiniGISAS() //! GISAS simulation with small detector and phi[-1,1], theta[0,1]. -GISASSimulation* StandardSimulations::MiniGISAS_v2() -{ +GISASSimulation* StandardSimulations::MiniGISAS_v2() { GISASSimulation* result = new GISASSimulation(); result->setDetectorParameters(25, -1.0 * Units::deg, 1.0 * Units::deg, 25, 0.0 * Units::deg, 1.0 * Units::deg); @@ -101,8 +95,7 @@ GISASSimulation* StandardSimulations::MiniGISAS_v2() //! GISAS simulation with beam divergence applied. -GISASSimulation* StandardSimulations::MiniGISASBeamDivergence() -{ +GISASSimulation* StandardSimulations::MiniGISASBeamDivergence() { GISASSimulation* result = MiniGISAS(); DistributionLogNormal wavelength_distr(1.0 * Units::angstrom, 0.1); @@ -124,8 +117,7 @@ GISASSimulation* StandardSimulations::MiniGISASBeamDivergence() //! GISAS simulation with multiple masks on the detector plane. -GISASSimulation* StandardSimulations::GISASWithMasks() -{ +GISASSimulation* StandardSimulations::GISASWithMasks() { GISASSimulation* result = new GISASSimulation(); result->setDetectorParameters(50, -1.0 * Units::deg, 1.0 * Units::deg, 50, 0.0 * Units::deg, 2.0 * Units::deg); @@ -158,16 +150,14 @@ GISASSimulation* StandardSimulations::GISASWithMasks() //! GISAS simulation with detector resolution. -GISASSimulation* StandardSimulations::MiniGISASDetectorResolution() -{ +GISASSimulation* StandardSimulations::MiniGISASDetectorResolution() { GISASSimulation* result = MiniGISAS(); ResolutionFunction2DGaussian resfunc(0.0025, 0.0025); result->setDetectorResolutionFunction(resfunc); return result; } -GISASSimulation* StandardSimulations::MiniGISASPolarizationPP() -{ +GISASSimulation* StandardSimulations::MiniGISASPolarizationPP() { GISASSimulation* result = MiniGISAS(); kvector_t analyzer_dir(0.0, 0.0, 1.0); @@ -178,8 +168,7 @@ GISASSimulation* StandardSimulations::MiniGISASPolarizationPP() return result; } -GISASSimulation* StandardSimulations::MiniGISASPolarizationPM() -{ +GISASSimulation* StandardSimulations::MiniGISASPolarizationPM() { GISASSimulation* result = MiniGISAS(); kvector_t analyzer_dir(0.0, 0.0, -1.0); @@ -190,8 +179,7 @@ GISASSimulation* StandardSimulations::MiniGISASPolarizationPM() return result; } -GISASSimulation* StandardSimulations::MiniGISASPolarizationMP() -{ +GISASSimulation* StandardSimulations::MiniGISASPolarizationMP() { GISASSimulation* result = MiniGISAS(); kvector_t analyzer_dir(0.0, 0.0, 1.0); @@ -202,8 +190,7 @@ GISASSimulation* StandardSimulations::MiniGISASPolarizationMP() return result; } -GISASSimulation* StandardSimulations::MiniGISASPolarizationMM() -{ +GISASSimulation* StandardSimulations::MiniGISASPolarizationMM() { GISASSimulation* result = MiniGISAS(); kvector_t analyzer_dir(0.0, 0.0, -1.0); @@ -216,8 +203,7 @@ GISASSimulation* StandardSimulations::MiniGISASPolarizationMM() //! GISAS simulation with small detector and including specular peak. -GISASSimulation* StandardSimulations::MiniGISASSpecularPeak() -{ +GISASSimulation* StandardSimulations::MiniGISASSpecularPeak() { GISASSimulation* result = new GISASSimulation(); result->setDetectorParameters(25, -2.0 * Units::deg, 2.0 * Units::deg, 25, 0.0 * Units::deg, 2.0 * Units::deg); @@ -228,8 +214,7 @@ GISASSimulation* StandardSimulations::MiniGISASSpecularPeak() //! GISAS simulation with large detector to test performance. -GISASSimulation* StandardSimulations::MaxiGISAS() -{ +GISASSimulation* StandardSimulations::MaxiGISAS() { GISASSimulation* result = new GISASSimulation(); result->setDetectorParameters(256, -2.0 * Units::deg, 2.0 * Units::deg, 256, 0.0 * Units::deg, 2.0 * Units::deg); @@ -239,8 +224,7 @@ GISASSimulation* StandardSimulations::MaxiGISAS() //! Basic GISAS for polarization studies. -GISASSimulation* StandardSimulations::MaxiGISAS00() -{ +GISASSimulation* StandardSimulations::MaxiGISAS00() { GISASSimulation* result = MaxiGISAS(); kvector_t zplus(0.0, 0.0, 1.0); result->setBeamPolarization(zplus); @@ -250,8 +234,7 @@ GISASSimulation* StandardSimulations::MaxiGISAS00() //! Typical IsGISAXS simulation with the detector phi[-1,1], theta[0,2]. -GISASSimulation* StandardSimulations::IsGISAXSSimulation1() -{ +GISASSimulation* StandardSimulations::IsGISAXSSimulation1() { GISASSimulation* result = new GISASSimulation(); IsGISAXSDetector detector; detector.setDetectorParameters(100, -1.0 * Units::deg, 1.0 * Units::deg, 100, 0.0 * Units::deg, @@ -263,8 +246,7 @@ GISASSimulation* StandardSimulations::IsGISAXSSimulation1() //! Typical IsGISAXS simulation with the detector phi[0,2], theta[0,2]. -GISASSimulation* StandardSimulations::IsGISAXSSimulation2() -{ +GISASSimulation* StandardSimulations::IsGISAXSSimulation2() { GISASSimulation* result = new GISASSimulation(); IsGISAXSDetector detector; detector.setDetectorParameters(100, 0.0 * Units::deg, 2.0 * Units::deg, 100, 0.0 * Units::deg, @@ -276,8 +258,7 @@ GISASSimulation* StandardSimulations::IsGISAXSSimulation2() //! GISAS simulation with generic rectangular detector. -GISASSimulation* StandardSimulations::RectDetectorGeneric() -{ +GISASSimulation* StandardSimulations::RectDetectorGeneric() { GISASSimulation* result = new GISASSimulation(); result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::deg, 0.0 * Units::deg); @@ -291,8 +272,7 @@ GISASSimulation* StandardSimulations::RectDetectorGeneric() //! GISAS simulation with the rectangular detector perpendicular to the sample. -GISASSimulation* StandardSimulations::RectDetectorPerpToSample() -{ +GISASSimulation* StandardSimulations::RectDetectorPerpToSample() { GISASSimulation* result = new GISASSimulation(); result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::deg, 0.0 * Units::deg); @@ -305,8 +285,7 @@ GISASSimulation* StandardSimulations::RectDetectorPerpToSample() //! GISAS simulation with the rectangular detector perpendicular to the direct beam. -GISASSimulation* StandardSimulations::RectDetectorPerpToDirectBeam() -{ +GISASSimulation* StandardSimulations::RectDetectorPerpToDirectBeam() { GISASSimulation* result = new GISASSimulation(); result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::deg, 0.0 * Units::deg); @@ -319,8 +298,7 @@ GISASSimulation* StandardSimulations::RectDetectorPerpToDirectBeam() //! GISAS simulation with the rectangular detector perpendicular to the reflected beam. -GISASSimulation* StandardSimulations::RectDetectorPerpToReflectedBeam() -{ +GISASSimulation* StandardSimulations::RectDetectorPerpToReflectedBeam() { GISASSimulation* result = new GISASSimulation(); result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::deg, 0.0 * Units::deg); @@ -334,8 +312,7 @@ GISASSimulation* StandardSimulations::RectDetectorPerpToReflectedBeam() //! GISAS simulation with the rectangular detector perpendicular to the reflected beam when //! the coordinates of direct beam are known. -GISASSimulation* StandardSimulations::RectDetectorPerpToReflectedBeamDpos() -{ +GISASSimulation* StandardSimulations::RectDetectorPerpToReflectedBeamDpos() { GISASSimulation* result = new GISASSimulation(); result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::deg, 0.0 * Units::deg); @@ -349,8 +326,7 @@ GISASSimulation* StandardSimulations::RectDetectorPerpToReflectedBeamDpos() //! GISAS simulation with Monte-Carlo integration switched ON. -GISASSimulation* StandardSimulations::MiniGISASMonteCarlo() -{ +GISASSimulation* StandardSimulations::MiniGISASMonteCarlo() { GISASSimulation* result = MiniGISAS(); result->getOptions().setMonteCarloIntegration(true, 100); return result; @@ -358,8 +334,7 @@ GISASSimulation* StandardSimulations::MiniGISASMonteCarlo() //! GISAS simulation with spherical detector, region of interest and mask. -GISASSimulation* StandardSimulations::SphericalDetWithRoi() -{ +GISASSimulation* StandardSimulations::SphericalDetWithRoi() { GISASSimulation* result = new GISASSimulation(); result->setDetectorParameters(40, -2.0 * Units::deg, 2.0 * Units::deg, 30, 0.0 * Units::deg, 3.0 * Units::deg); @@ -373,16 +348,14 @@ GISASSimulation* StandardSimulations::SphericalDetWithRoi() //! GISAS simulation with rectangular detector, region of interest and mask. -GISASSimulation* StandardSimulations::RectDetWithRoi() -{ +GISASSimulation* StandardSimulations::RectDetWithRoi() { GISASSimulation* result = RectDetectorPerpToDirectBeam(); result->addMask(Rectangle(3.0, 4.0, 5.0, 7.0)); result->setRegionOfInterest(2.0, 3.0, 18.0, 15.0); return result; } -GISASSimulation* StandardSimulations::ConstantBackgroundGISAS() -{ +GISASSimulation* StandardSimulations::ConstantBackgroundGISAS() { GISASSimulation* result = MiniGISAS(); ConstantBackground bg(1e3); result->setBackground(bg); @@ -391,8 +364,7 @@ GISASSimulation* StandardSimulations::ConstantBackgroundGISAS() //! GISAS simulation with an extra long wavelength -GISASSimulation* StandardSimulations::ExtraLongWavelengthGISAS() -{ +GISASSimulation* StandardSimulations::ExtraLongWavelengthGISAS() { auto* simulation = new GISASSimulation; simulation->setDetectorParameters(100, -1.0 * Units::deg, 1.0 * Units::deg, 100, 0.0, 2.0 * Units::deg); @@ -403,8 +375,7 @@ GISASSimulation* StandardSimulations::ExtraLongWavelengthGISAS() return simulation; } -SpecularSimulation* StandardSimulations::BasicSpecular() -{ +SpecularSimulation* StandardSimulations::BasicSpecular() { const double wavelength = 1.54 * Units::angstrom; const int number_of_bins = 2000; const double min_angle = 0 * Units::deg; @@ -417,8 +388,7 @@ SpecularSimulation* StandardSimulations::BasicSpecular() return result; } -SpecularSimulation* StandardSimulations::BasicSpecularQ() -{ +SpecularSimulation* StandardSimulations::BasicSpecularQ() { std::vector<double> qs; { const double wavelength_0 = 1.54 * Units::angstrom; @@ -440,8 +410,7 @@ SpecularSimulation* StandardSimulations::BasicSpecularQ() return result; } -SpecularSimulation* StandardSimulations::SpecularWithGaussianBeam() -{ +SpecularSimulation* StandardSimulations::SpecularWithGaussianBeam() { const double wavelength = 1.54 * Units::angstrom; const int number_of_bins = 2000; const double min_angle = 0 * Units::deg; @@ -455,8 +424,7 @@ SpecularSimulation* StandardSimulations::SpecularWithGaussianBeam() return result; } -SpecularSimulation* StandardSimulations::SpecularWithSquareBeam() -{ +SpecularSimulation* StandardSimulations::SpecularWithSquareBeam() { const double wavelength = 1.54 * Units::angstrom; const int number_of_bins = 2000; const double min_angle = 0 * Units::deg; @@ -470,8 +438,7 @@ SpecularSimulation* StandardSimulations::SpecularWithSquareBeam() return result; } -SpecularSimulation* StandardSimulations::SpecularDivergentBeam() -{ +SpecularSimulation* StandardSimulations::SpecularDivergentBeam() { const double wavelength = 1.54 * Units::angstrom; const int number_of_bins = 20; const size_t n_integration_points = 10; @@ -497,8 +464,7 @@ SpecularSimulation* StandardSimulations::SpecularDivergentBeam() return result; } -SpecularSimulation* StandardSimulations::TOFRWithRelativeResolution() -{ +SpecularSimulation* StandardSimulations::TOFRWithRelativeResolution() { FixedBinAxis qs("axis", 500, 0.0, 1.0); QSpecScan q_scan(qs); q_scan.setRelativeQResolution(RangedDistributionGaussian(20, 2.0), 0.03); @@ -509,8 +475,7 @@ SpecularSimulation* StandardSimulations::TOFRWithRelativeResolution() return result; } -SpecularSimulation* StandardSimulations::TOFRWithPointwiseResolution() -{ +SpecularSimulation* StandardSimulations::TOFRWithPointwiseResolution() { FixedBinAxis qs("axis", 500, 0.0, 1.0); QSpecScan q_scan(qs); @@ -528,64 +493,56 @@ SpecularSimulation* StandardSimulations::TOFRWithPointwiseResolution() } // ------------ polarized specular ---------------- -SpecularSimulation* StandardSimulations::BasicSpecularPP() -{ +SpecularSimulation* StandardSimulations::BasicSpecularPP() { auto* simulation = BasicSpecular(); simulation->setBeamPolarization({0.0, 1.0, 0.0}); simulation->setAnalyzerProperties({0.0, 1.0, 0.0}, 1.0, 0.5); return simulation; } -SpecularSimulation* StandardSimulations::BasicSpecularPM() -{ +SpecularSimulation* StandardSimulations::BasicSpecularPM() { auto* simulation = BasicSpecular(); simulation->setBeamPolarization({0.0, 1.0, 0.0}); simulation->setAnalyzerProperties({0.0, -1.0, 0.0}, 1.0, 0.5); return simulation; } -SpecularSimulation* StandardSimulations::BasicSpecularMP() -{ +SpecularSimulation* StandardSimulations::BasicSpecularMP() { auto* simulation = BasicSpecular(); simulation->setBeamPolarization({0.0, -1.0, 0.0}); simulation->setAnalyzerProperties({0.0, 1.0, 0.0}, 1.0, 0.5); return simulation; } -SpecularSimulation* StandardSimulations::BasicSpecularMM() -{ +SpecularSimulation* StandardSimulations::BasicSpecularMM() { auto* simulation = BasicSpecular(); simulation->setBeamPolarization({0.0, -1.0, 0.0}); simulation->setAnalyzerProperties({0.0, -1.0, 0.0}, 1.0, 0.5); return simulation; } -SpecularSimulation* StandardSimulations::BasicSpecularQPP() -{ +SpecularSimulation* StandardSimulations::BasicSpecularQPP() { auto* simulation = BasicSpecularQ(); simulation->setBeamPolarization({0.0, 1.0, 0.0}); simulation->setAnalyzerProperties({0.0, 1.0, 0.0}, 1.0, 0.5); return simulation; } -SpecularSimulation* StandardSimulations::BasicSpecularQMM() -{ +SpecularSimulation* StandardSimulations::BasicSpecularQMM() { auto* simulation = BasicSpecularQ(); simulation->setBeamPolarization({0.0, -1.0, 0.0}); simulation->setAnalyzerProperties({0.0, -1.0, 0.0}, 1.0, 0.5); return simulation; } -SpecularSimulation* StandardSimulations::BasicSpecularQPM() -{ +SpecularSimulation* StandardSimulations::BasicSpecularQPM() { auto* simulation = BasicSpecularQ(); simulation->setBeamPolarization({0.0, 1.0, 0.0}); simulation->setAnalyzerProperties({0.0, -1.0, 0.0}, 1.0, 0.5); return simulation; } -SpecularSimulation* StandardSimulations::BasicSpecularQMP() -{ +SpecularSimulation* StandardSimulations::BasicSpecularQMP() { auto* simulation = BasicSpecularQ(); simulation->setBeamPolarization({0.0, -1.0, 0.0}); simulation->setAnalyzerProperties({0.0, 1.0, 0.0}, 1.0, 0.5); @@ -595,8 +552,7 @@ SpecularSimulation* StandardSimulations::BasicSpecularQMP() // ----------------------- off-spec simulations ------------------ // OffSpec simulation used in ResonatorOffSpecSetup.py -OffSpecSimulation* StandardSimulations::MiniOffSpec() -{ +OffSpecSimulation* StandardSimulations::MiniOffSpec() { auto* result = new OffSpecSimulation; const int n_alpha(19); @@ -621,8 +577,7 @@ OffSpecSimulation* StandardSimulations::MiniOffSpec() return result; } -DepthProbeSimulation* StandardSimulations::BasicDepthProbe() -{ +DepthProbeSimulation* StandardSimulations::BasicDepthProbe() { auto* result = new DepthProbeSimulation; const double wavelength = 10.0 * Units::angstrom; @@ -641,8 +596,7 @@ DepthProbeSimulation* StandardSimulations::BasicDepthProbe() //! ISimulation with fitting. //! Beam intensity set to provide reasonably large values in detector channels. -GISASSimulation* StandardSimulations::MiniGISASFit() -{ +GISASSimulation* StandardSimulations::MiniGISASFit() { auto* result = new GISASSimulation; result->setDetectorParameters(25, -2.0 * Units::deg, 2.0 * Units::deg, 25, 0.0 * Units::deg, 2.0 * Units::deg); diff --git a/Core/Simulation/StandardSimulations.h b/Core/Simulation/StandardSimulations.h index fa277bedb55ae0245d814497eaf72c9dac36acb2..3b753909a284a484badfab48071d9f65a1d82f5a 100644 --- a/Core/Simulation/StandardSimulations.h +++ b/Core/Simulation/StandardSimulations.h @@ -22,8 +22,7 @@ class OffSpecSimulation; //! Standard pre-defined simulations. -namespace StandardSimulations -{ +namespace StandardSimulations { // CoreSuite tests: GISASSimulation* BasicGISAS(); diff --git a/Core/Simulation/UnitConverterUtils.cpp b/Core/Simulation/UnitConverterUtils.cpp index dd9c63bbc736aec5958a052f7509f91dc7f5af27..21439b45ea1844d72679ac38832cafd11be8e7a9 100644 --- a/Core/Simulation/UnitConverterUtils.cpp +++ b/Core/Simulation/UnitConverterUtils.cpp @@ -23,8 +23,7 @@ #include "Device/Detector/SphericalDetector.h" std::unique_ptr<OutputData<double>> -UnitConverterUtils::createOutputData(const IUnitConverter& converter, Axes::Units units) -{ +UnitConverterUtils::createOutputData(const IUnitConverter& converter, Axes::Units units) { std::unique_ptr<OutputData<double>> result = std::make_unique<OutputData<double>>(); for (size_t i = 0; i < converter.dimension(); ++i) result->addAxis(*converter.createConvertedAxis(i, units)); @@ -33,8 +32,7 @@ UnitConverterUtils::createOutputData(const IUnitConverter& converter, Axes::Unit } std::unique_ptr<IUnitConverter> -UnitConverterUtils::createConverterForGISAS(const Instrument& instrument) -{ +UnitConverterUtils::createConverterForGISAS(const Instrument& instrument) { const IDetector* const detector = instrument.getDetector(); if (const auto* const det = dynamic_cast<const SphericalDetector*>(detector)) @@ -45,8 +43,7 @@ UnitConverterUtils::createConverterForGISAS(const Instrument& instrument) throw std::runtime_error("Error in createConverterForGISAS: wrong or absent detector type"); } -std::unique_ptr<IUnitConverter> UnitConverterUtils::createConverter(const ISimulation& simulation) -{ +std::unique_ptr<IUnitConverter> UnitConverterUtils::createConverter(const ISimulation& simulation) { if (auto gisas = dynamic_cast<const GISASSimulation*>(&simulation)) { return createConverterForGISAS(gisas->instrument()); diff --git a/Core/Simulation/UnitConverterUtils.h b/Core/Simulation/UnitConverterUtils.h index db69a907f4e8653ecae7a7a829ed95362a2761a3..c781aa0102fbd35fd0af0f6ecb852f34a5c1fe39 100644 --- a/Core/Simulation/UnitConverterUtils.h +++ b/Core/Simulation/UnitConverterUtils.h @@ -23,8 +23,7 @@ template <class T> class OutputData; //! Namespace enclosing a number of utilities/helpers for unit converters -namespace UnitConverterUtils -{ +namespace UnitConverterUtils { //! Returns zero-valued output data array in specified units std::unique_ptr<OutputData<double>> createOutputData(const IUnitConverter& converter, diff --git a/Core/Term/DepthProbeComputationTerm.cpp b/Core/Term/DepthProbeComputationTerm.cpp index a865b76722318a0617d287d2ebcb0875564eaefe..d3fb30a10bf6f0ee62ff8693f59a22390dde7eb5 100644 --- a/Core/Term/DepthProbeComputationTerm.cpp +++ b/Core/Term/DepthProbeComputationTerm.cpp @@ -21,19 +21,15 @@ #include "Sample/RT/ILayerRTCoefficients.h" DepthProbeComputationTerm::DepthProbeComputationTerm(const ProcessedSample* p_sample) - : m_sample{p_sample} -{ -} + : m_sample{p_sample} {} DepthProbeComputationTerm::~DepthProbeComputationTerm() = default; -void DepthProbeComputationTerm::setProgressHandler(ProgressHandler* p_progress) -{ +void DepthProbeComputationTerm::setProgressHandler(ProgressHandler* p_progress) { m_progress_counter = std::make_unique<DelayedProgressCounter>(p_progress, 100); } -void DepthProbeComputationTerm::compute(DepthProbeElement& elem) const -{ +void DepthProbeComputationTerm::compute(DepthProbeElement& elem) const { if (elem.isCalculated()) { const IAxis& z_positions = *elem.getZPositions(); const size_t n_z = z_positions.size(); diff --git a/Core/Term/DepthProbeComputationTerm.h b/Core/Term/DepthProbeComputationTerm.h index 105f17b56a43d683656428e5174135754066104b..dc4c2d14660e314589c858ee84d4e7af2caef5a7 100644 --- a/Core/Term/DepthProbeComputationTerm.h +++ b/Core/Term/DepthProbeComputationTerm.h @@ -22,8 +22,7 @@ class ProcessedSample; class ProgressHandler; class DepthProbeElement; -class DepthProbeComputationTerm -{ +class DepthProbeComputationTerm { public: DepthProbeComputationTerm(const ProcessedSample* p_sample); ~DepthProbeComputationTerm(); diff --git a/Core/Term/SpecularComputationTerm.cpp b/Core/Term/SpecularComputationTerm.cpp index 3f6ef32ff5709ee5473e8a1e2d610961bdeec45d..02db5199fe89c67baf7c91bfa54d993177a4238d 100644 --- a/Core/Term/SpecularComputationTerm.cpp +++ b/Core/Term/SpecularComputationTerm.cpp @@ -25,20 +25,16 @@ SpecularComputationTerm::SpecularComputationTerm(std::unique_ptr<ISpecularStrate : m_Strategy(std::move(strategy)){}; SpecularScalarTerm::SpecularScalarTerm(std::unique_ptr<ISpecularStrategy> strategy) - : SpecularComputationTerm(std::move(strategy)) -{ -} + : SpecularComputationTerm(std::move(strategy)) {} SpecularComputationTerm::~SpecularComputationTerm() = default; -void SpecularComputationTerm::setProgressHandler(ProgressHandler* p_progress) -{ +void SpecularComputationTerm::setProgressHandler(ProgressHandler* p_progress) { m_progress_counter = std::make_unique<DelayedProgressCounter>(p_progress, 100); } void SpecularComputationTerm::computeIntensity(SpecularSimulationElement& elem, - const std::vector<Slice>& slices) const -{ + const std::vector<Slice>& slices) const { if (!elem.isCalculated()) return; @@ -55,8 +51,7 @@ void SpecularComputationTerm::computeIntensity(SpecularSimulationElement& elem, SpecularScalarTerm::~SpecularScalarTerm() = default; void SpecularScalarTerm::eval(SpecularSimulationElement& elem, - const std::vector<Slice>& slices) const -{ + const std::vector<Slice>& slices) const { const auto coeff = m_Strategy->Execute(slices, elem.produceKz(slices)); elem.setIntensity(std::norm(coeff.front()->getScalarR())); } @@ -65,12 +60,10 @@ void SpecularScalarTerm::eval(SpecularSimulationElement& elem, // class SpecularMatrixTerm // ************************************************************************************************ -namespace -{ +namespace { double matrix_intensity(const SpecularSimulationElement& elem, - const std::unique_ptr<const ILayerRTCoefficients>& coeff) -{ + const std::unique_ptr<const ILayerRTCoefficients>& coeff) { const auto& polarization = elem.polarizationHandler().getPolarization(); const auto& analyzer = elem.polarizationHandler().getAnalyzerOperator(); @@ -84,15 +77,12 @@ double matrix_intensity(const SpecularSimulationElement& elem, } // namespace SpecularMatrixTerm::SpecularMatrixTerm(std::unique_ptr<ISpecularStrategy> strategy) - : SpecularComputationTerm(std::move(strategy)) -{ -} + : SpecularComputationTerm(std::move(strategy)) {} SpecularMatrixTerm::~SpecularMatrixTerm() = default; void SpecularMatrixTerm::eval(SpecularSimulationElement& elem, - const std::vector<Slice>& slices) const -{ + const std::vector<Slice>& slices) const { const auto coeff = m_Strategy->Execute(slices, elem.produceKz(slices)); elem.setIntensity(matrix_intensity(elem, coeff.front())); } diff --git a/Core/Term/SpecularComputationTerm.h b/Core/Term/SpecularComputationTerm.h index b6127aa7adccfc14eaf53130af815d541e1989fd..e835a040946881f570fcb6c0f67a2e2798f61bb6 100644 --- a/Core/Term/SpecularComputationTerm.h +++ b/Core/Term/SpecularComputationTerm.h @@ -32,8 +32,7 @@ class Slice; //! //! @ingroup algorithms_internal -class SpecularComputationTerm -{ +class SpecularComputationTerm { public: SpecularComputationTerm(std::unique_ptr<ISpecularStrategy> strategy); virtual ~SpecularComputationTerm(); @@ -57,8 +56,7 @@ private: //! Used by SpecularComputation. //! @ingroup algorithms_internal -class SpecularScalarTerm : public SpecularComputationTerm -{ +class SpecularScalarTerm : public SpecularComputationTerm { public: SpecularScalarTerm(std::unique_ptr<ISpecularStrategy> strategy); @@ -72,8 +70,7 @@ private: //! Used by SpecularComputation. //! @ingroup algorithms_internal -class SpecularMatrixTerm : public SpecularComputationTerm -{ +class SpecularMatrixTerm : public SpecularComputationTerm { public: SpecularMatrixTerm(std::unique_ptr<ISpecularStrategy> strategy); diff --git a/Device/Beam/Beam.cpp b/Device/Beam/Beam.cpp index 04aa1d5fc95ad8c09caa35da494af3e4ff5d614f..958c5260fcafe5e46bd7b1d6bb6a14f2e51ec252 100644 --- a/Device/Beam/Beam.cpp +++ b/Device/Beam/Beam.cpp @@ -24,8 +24,7 @@ static constexpr double INCLINATION_LIMIT = M_PI_2 + 1e-10; Beam::Beam(double wavelength, double alpha, double phi, double intensity) - : m_wavelength(wavelength), m_alpha(alpha), m_phi(phi), m_intensity(intensity) -{ + : m_wavelength(wavelength), m_alpha(alpha), m_phi(phi), m_intensity(intensity) { setName("Beam"); registerParameter("Wavelength", &m_wavelength).setUnit("nm").setNonnegative(); registerParameter("InclinationAngle", &m_alpha).setUnit("rad").setLimited(0, INCLINATION_LIMIT); @@ -34,14 +33,12 @@ Beam::Beam(double wavelength, double alpha, double phi, double intensity) registerVector("BlochVector", &m_bloch_vector, ""); } -Beam Beam::horizontalBeam() -{ +Beam Beam::horizontalBeam() { return Beam(1.0, 0.0, 0.0, 1.0); } Beam::Beam(const Beam& other) - : Beam(other.m_wavelength, other.m_alpha, other.m_phi, other.m_intensity) -{ + : Beam(other.m_wavelength, other.m_alpha, other.m_phi, other.m_intensity) { m_bloch_vector = other.m_bloch_vector; setName(other.getName()); if (other.m_shape_factor) { @@ -50,8 +47,7 @@ Beam::Beam(const Beam& other) } } -Beam& Beam::operator=(const Beam& other) -{ +Beam& Beam::operator=(const Beam& other) { m_wavelength = other.m_wavelength; m_alpha = other.m_alpha; m_phi = other.m_phi; @@ -68,13 +64,11 @@ Beam& Beam::operator=(const Beam& other) Beam::~Beam() = default; -kvector_t Beam::getCentralK() const -{ +kvector_t Beam::getCentralK() const { return vecOfLambdaAlphaPhi(m_wavelength, -m_alpha, m_phi); } -void Beam::setCentralK(double wavelength, double alpha_i, double phi_i) -{ +void Beam::setCentralK(double wavelength, double alpha_i, double phi_i) { if (wavelength <= 0.0) throw Exceptions::ClassInitializationException( "Beam::setCentralK() -> Error. Wavelength can't be negative or zero."); @@ -86,27 +80,23 @@ void Beam::setCentralK(double wavelength, double alpha_i, double phi_i) m_phi = phi_i; } -const IFootprintFactor* Beam::footprintFactor() const -{ +const IFootprintFactor* Beam::footprintFactor() const { return m_shape_factor.get(); } -void Beam::setFootprintFactor(const IFootprintFactor& shape_factor) -{ +void Beam::setFootprintFactor(const IFootprintFactor& shape_factor) { m_shape_factor.reset(shape_factor.clone()); registerChild(m_shape_factor.get()); } -void Beam::setWidthRatio(double width_ratio) -{ +void Beam::setWidthRatio(double width_ratio) { if (!m_shape_factor) throw std::runtime_error("Error in Beam::setWidthRatio: footprint factor is nullptr. " "Probably, you have forgotten to initialize it."); m_shape_factor->setWidthRatio(width_ratio); } -void Beam::setPolarization(const kvector_t bloch_vector) -{ +void Beam::setPolarization(const kvector_t bloch_vector) { if (bloch_vector.mag() > 1.0) { throw Exceptions::ClassInitializationException( "Beam::setPolarization: " @@ -115,13 +105,11 @@ void Beam::setPolarization(const kvector_t bloch_vector) m_bloch_vector = bloch_vector; } -kvector_t Beam::getBlochVector() const -{ +kvector_t Beam::getBlochVector() const { return m_bloch_vector; } -Eigen::Matrix2cd Beam::getPolarization() const -{ +Eigen::Matrix2cd Beam::getPolarization() const { Eigen::Matrix2cd result; double x = m_bloch_vector.x(); double y = m_bloch_vector.y(); @@ -133,8 +121,7 @@ Eigen::Matrix2cd Beam::getPolarization() const return result; } -std::vector<const INode*> Beam::getChildren() const -{ +std::vector<const INode*> Beam::getChildren() const { if (m_shape_factor) return {m_shape_factor.get()}; return {}; diff --git a/Device/Beam/Beam.h b/Device/Beam/Beam.h index 65957cba13e0d2fbc7f2901445670efff759d7dc..bf1dbd2d311a19d854ff297583bf14408d6e8d67 100644 --- a/Device/Beam/Beam.h +++ b/Device/Beam/Beam.h @@ -23,8 +23,7 @@ class IFootprintFactor; //! Beam defined by wavelength, direction and intensity. //! @ingroup beam -class Beam : public INode -{ +class Beam : public INode { public: Beam(double wavelength, double alpha, double phi, double intensity); diff --git a/Device/Beam/FootprintGauss.cpp b/Device/Beam/FootprintGauss.cpp index 5b517679628062ddf71d70a447cf5b193d98ce7c..aed8c01ebbf707c40c5431c4a9cc6217c1cd7e27 100644 --- a/Device/Beam/FootprintGauss.cpp +++ b/Device/Beam/FootprintGauss.cpp @@ -18,22 +18,16 @@ #include "Base/Utils/PyFmt.h" FootprintGauss::FootprintGauss(const std::vector<double> P) - : IFootprintFactor({"FootprintGauss", "class_tooltip", {}}, P) -{ -} + : IFootprintFactor({"FootprintGauss", "class_tooltip", {}}, P) {} FootprintGauss::FootprintGauss(double width_ratio) - : FootprintGauss(std::vector<double>{width_ratio}) -{ -} + : FootprintGauss(std::vector<double>{width_ratio}) {} -FootprintGauss* FootprintGauss::clone() const -{ +FootprintGauss* FootprintGauss::clone() const { return new FootprintGauss(m_width_ratio); } -double FootprintGauss::calculate(double alpha) const -{ +double FootprintGauss::calculate(double alpha) const { if (alpha < 0.0 || alpha > M_PI_2) return 0.0; if (widthRatio() == 0.0) @@ -42,8 +36,7 @@ double FootprintGauss::calculate(double alpha) const return Math::erf(arg); } -std::string FootprintGauss::print() const -{ +std::string FootprintGauss::print() const { std::stringstream result; result << "\n" << pyfmt::indent() << "# Defining footprint:\n"; result << pyfmt::indent() << "footprint = "; diff --git a/Device/Beam/FootprintGauss.h b/Device/Beam/FootprintGauss.h index 3e51b70658f316670f1dd3f4411804bab6e6c056..cf3a15b6aac49fd33c60c7881f72ef025e12785c 100644 --- a/Device/Beam/FootprintGauss.h +++ b/Device/Beam/FootprintGauss.h @@ -22,8 +22,7 @@ //! of \f[ \exp{-1/2} \f] from the peak intensity. //! @ingroup beam -class FootprintGauss : public IFootprintFactor -{ +class FootprintGauss : public IFootprintFactor { public: FootprintGauss(const std::vector<double> P); FootprintGauss(double width_ratio); diff --git a/Device/Beam/FootprintSquare.cpp b/Device/Beam/FootprintSquare.cpp index e12379d5b89f531ff83943f947ebd1fbbdef481d..7b336d32d4479ed3cf26503f7b2120a85d0fac73 100644 --- a/Device/Beam/FootprintSquare.cpp +++ b/Device/Beam/FootprintSquare.cpp @@ -19,22 +19,16 @@ #include <stdexcept> FootprintSquare::FootprintSquare(const std::vector<double> P) - : IFootprintFactor({"FootprintSquare", "class_tooltip", {}}, P) -{ -} + : IFootprintFactor({"FootprintSquare", "class_tooltip", {}}, P) {} FootprintSquare::FootprintSquare(double width_ratio) - : FootprintSquare(std::vector<double>{width_ratio}) -{ -} + : FootprintSquare(std::vector<double>{width_ratio}) {} -FootprintSquare* FootprintSquare::clone() const -{ +FootprintSquare* FootprintSquare::clone() const { return new FootprintSquare(m_width_ratio); } -double FootprintSquare::calculate(double alpha) const -{ +double FootprintSquare::calculate(double alpha) const { if (alpha < 0.0 || alpha > M_PI_2) return 0.0; if (widthRatio() == 0.0) @@ -43,8 +37,7 @@ double FootprintSquare::calculate(double alpha) const return std::min(arg, 1.0); } -std::string FootprintSquare::print() const -{ +std::string FootprintSquare::print() const { std::stringstream result; result << "\n" << pyfmt::indent() << "# Defining footprint:\n"; result << pyfmt::indent() << "footprint = "; diff --git a/Device/Beam/FootprintSquare.h b/Device/Beam/FootprintSquare.h index da3161bd6cf920b27f53c1dde20b3fed761a1847..e97a337badc54dd3f53b65df455d2775f014731b 100644 --- a/Device/Beam/FootprintSquare.h +++ b/Device/Beam/FootprintSquare.h @@ -20,8 +20,7 @@ //! Calculates footprint coefficient for a square beam //! @ingroup beam -class FootprintSquare : public IFootprintFactor -{ +class FootprintSquare : public IFootprintFactor { public: FootprintSquare(const std::vector<double> P); FootprintSquare(double width_ratio); diff --git a/Device/Beam/IFootprintFactor.cpp b/Device/Beam/IFootprintFactor.cpp index 7d6c55779727e15cc5671b2dd75aa57163c946d1..fff226085f78d9aba0ffdd1eddf27a8130bda0c1 100644 --- a/Device/Beam/IFootprintFactor.cpp +++ b/Device/Beam/IFootprintFactor.cpp @@ -20,8 +20,7 @@ IFootprintFactor::IFootprintFactor(const NodeMeta& meta, const std::vector<doubl {{"BeamToSampleWidthRatio", "", "ratio of beam width to sample width", 0, INF, 1.}}, meta), PValues) - , m_width_ratio(m_P[0]) -{ + , m_width_ratio(m_P[0]) { if (m_P[0] < 0.0) throw std::runtime_error( "Error in IFootprintFactor::setWidthRatio: width ratio is negative"); @@ -29,8 +28,7 @@ IFootprintFactor::IFootprintFactor(const NodeMeta& meta, const std::vector<doubl IFootprintFactor::~IFootprintFactor() = default; -void IFootprintFactor::setWidthRatio(double width_ratio) -{ +void IFootprintFactor::setWidthRatio(double width_ratio) { if (width_ratio < 0.0) throw std::runtime_error( "Error in IFootprintFactor::setWidthRatio: width ratio is negative"); diff --git a/Device/Beam/IFootprintFactor.h b/Device/Beam/IFootprintFactor.h index a34e5e9719342c53e210815af36a7ec81e6440a7..6a52dc52f99555181013ae8ace5cbda13f9be710 100644 --- a/Device/Beam/IFootprintFactor.h +++ b/Device/Beam/IFootprintFactor.h @@ -24,8 +24,7 @@ class Beam; //! Abstract base for classes that calculate the beam footprint factor //! @ingroup beam -class IFootprintFactor : public ICloneable, public INode -{ +class IFootprintFactor : public ICloneable, public INode { public: IFootprintFactor(const NodeMeta& meta, const std::vector<double>& PValues); IFootprintFactor() = delete; @@ -49,8 +48,7 @@ private: void initialize(); }; -inline std::ostream& operator<<(std::ostream& os, const IFootprintFactor& f_factor) -{ +inline std::ostream& operator<<(std::ostream& os, const IFootprintFactor& f_factor) { return os << f_factor.print(); } diff --git a/Device/Data/CumulativeValue.cpp b/Device/Data/CumulativeValue.cpp index c397ebf461e7fca12d8f6ea59e82e2ea86715f64..64bfc743108bb1f48ccc996cb3bd1d67c07d8e84 100644 --- a/Device/Data/CumulativeValue.cpp +++ b/Device/Data/CumulativeValue.cpp @@ -15,13 +15,11 @@ #include "Device/Data/CumulativeValue.h" #include <cmath> -double CumulativeValue::getRMS() const -{ +double CumulativeValue::getRMS() const { return std::sqrt(m_rms2); } -void CumulativeValue::add(double value, double weight) -{ +void CumulativeValue::add(double value, double weight) { m_n_entries++; m_sum += value; m_rms2 = @@ -32,8 +30,7 @@ void CumulativeValue::add(double value, double weight) m_sum_of_weights += weight; } -void CumulativeValue::clear() -{ +void CumulativeValue::clear() { m_n_entries = 0; m_sum = 0.0; m_average = 0.0; @@ -41,12 +38,10 @@ void CumulativeValue::clear() m_sum_of_weights = 0.0; } -bool operator<(const CumulativeValue& lhs, const CumulativeValue& rhs) -{ +bool operator<(const CumulativeValue& lhs, const CumulativeValue& rhs) { return lhs.getContent() < rhs.getContent(); } -bool operator>(const CumulativeValue& lhs, const CumulativeValue& rhs) -{ +bool operator>(const CumulativeValue& lhs, const CumulativeValue& rhs) { return rhs < lhs; } diff --git a/Device/Data/CumulativeValue.h b/Device/Data/CumulativeValue.h index 6ce3d8ab7a73030d3d060383450d089b0502fc32..a000a77db23a285698053db9a0a24693e44fe41b 100644 --- a/Device/Data/CumulativeValue.h +++ b/Device/Data/CumulativeValue.h @@ -18,8 +18,7 @@ //! The cumulative value with average and rms on-the-flight calculations. //! @ingroup tools -class CumulativeValue -{ +class CumulativeValue { public: CumulativeValue() { clear(); } diff --git a/Device/Data/LLData.cpp b/Device/Data/LLData.cpp index 99cd47e5c7255d41fe9a7add252390e9f4944a7a..f79a28ed11692bd98bd05fffb553df2dd5ddc743 100644 --- a/Device/Data/LLData.cpp +++ b/Device/Data/LLData.cpp @@ -14,8 +14,7 @@ #include "Device/Data/LLData.h" -template <> Eigen::Matrix2d LLData<Eigen::Matrix2d>::getZeroElement() const -{ +template <> Eigen::Matrix2d LLData<Eigen::Matrix2d>::getZeroElement() const { Eigen::Matrix2d result = Eigen::Matrix2d::Zero(); return result; } diff --git a/Device/Data/LLData.h b/Device/Data/LLData.h index 8b1f1d70c7cd1de88b8b30485df5b80b8097c2a9..fb76c6a0c6d2d5766281798aafbd679cdb3d2cd2 100644 --- a/Device/Data/LLData.h +++ b/Device/Data/LLData.h @@ -24,8 +24,7 @@ //! Template class to store data of any type in multi-dimensional space (low-level). //! @ingroup tools_internal -template <class T> class LLData -{ +template <class T> class LLData { public: // construction, destruction and assignment LLData(size_t rank, const int* dimensions); @@ -84,26 +83,24 @@ template <class T> LLData<T> operator/(const LLData<T>& left, const LLData<T>& r template <class T> bool HaveSameDimensions(const LLData<T>& left, const LLData<T>& right); template <class T> -inline LLData<T>::LLData(size_t rank, const int* dimensions) : m_rank(0), m_dims(0), m_data_array(0) -{ +inline LLData<T>::LLData(size_t rank, const int* dimensions) + : m_rank(0), m_dims(0), m_data_array(0) { allocate(rank, dimensions); } -template <class T> LLData<T>::LLData(const LLData<T>& right) : m_rank(0), m_dims(0), m_data_array(0) -{ +template <class T> +LLData<T>::LLData(const LLData<T>& right) : m_rank(0), m_dims(0), m_data_array(0) { allocate(right.rank(), right.dimensions()); for (size_t i = 0; i < getTotalSize(); ++i) { m_data_array[i] = right[i]; } } -template <class T> LLData<T>::~LLData() -{ +template <class T> LLData<T>::~LLData() { clear(); } -template <class T> LLData<T>& LLData<T>::operator=(const LLData<T>& right) -{ +template <class T> LLData<T>& LLData<T>::operator=(const LLData<T>& right) { if (this != &right) { LLData<T> copy(right); swapContents(copy); @@ -111,28 +108,23 @@ template <class T> LLData<T>& LLData<T>::operator=(const LLData<T>& right) return *this; } -template <class T> inline T& LLData<T>::operator[](size_t i) -{ +template <class T> inline T& LLData<T>::operator[](size_t i) { return m_data_array[i]; } -template <class T> inline const T& LLData<T>::operator[](size_t i) const -{ +template <class T> inline const T& LLData<T>::operator[](size_t i) const { return m_data_array[i]; } -template <class T> inline T& LLData<T>::atCoordinate(int* coordinate) -{ +template <class T> inline T& LLData<T>::atCoordinate(int* coordinate) { return m_data_array[convertCoordinate(coordinate)]; } -template <class T> inline const T& LLData<T>::atCoordinate(int* coordinate) const -{ +template <class T> inline const T& LLData<T>::atCoordinate(int* coordinate) const { return m_data_array[convertCoordinate(coordinate)]; } -template <class T> LLData<T>& LLData<T>::operator+=(const LLData<T>& right) -{ +template <class T> LLData<T>& LLData<T>::operator+=(const LLData<T>& right) { if (!HaveSameDimensions(*this, right)) throw Exceptions::RuntimeErrorException( "Operation += on LLData requires both operands to have the same dimensions"); @@ -142,8 +134,7 @@ template <class T> LLData<T>& LLData<T>::operator+=(const LLData<T>& right) return *this; } -template <class T> LLData<T>& LLData<T>::operator-=(const LLData& right) -{ +template <class T> LLData<T>& LLData<T>::operator-=(const LLData& right) { if (!HaveSameDimensions(*this, right)) throw Exceptions::RuntimeErrorException( "Operation -= on LLData requires both operands to have the same dimensions"); @@ -153,8 +144,7 @@ template <class T> LLData<T>& LLData<T>::operator-=(const LLData& right) return *this; } -template <class T> LLData<T>& LLData<T>::operator*=(const LLData& right) -{ +template <class T> LLData<T>& LLData<T>::operator*=(const LLData& right) { if (!HaveSameDimensions(*this, right)) throw Exceptions::RuntimeErrorException( "Operation *= on LLData requires both operands to have the same dimensions"); @@ -164,8 +154,7 @@ template <class T> LLData<T>& LLData<T>::operator*=(const LLData& right) return *this; } -template <class T> LLData<T>& LLData<T>::operator/=(const LLData& right) -{ +template <class T> LLData<T>& LLData<T>::operator/=(const LLData& right) { if (!HaveSameDimensions(*this, right)) throw Exceptions::RuntimeErrorException( "Operation /= on LLData requires both operands to have the same dimensions"); @@ -184,30 +173,25 @@ template <class T> LLData<T>& LLData<T>::operator/=(const LLData& right) return *this; } -template <class T> void LLData<T>::setAll(const T& value) -{ +template <class T> void LLData<T>::setAll(const T& value) { std::fill(m_data_array, m_data_array + getTotalSize(), value); } -template <class T> void LLData<T>::scaleAll(const T& factor) -{ +template <class T> void LLData<T>::scaleAll(const T& factor) { std::transform(m_data_array, m_data_array + getTotalSize(), m_data_array, [&factor](const T& value) -> T { return value * factor; }); } -template <class T> inline size_t LLData<T>::getTotalSize() const -{ +template <class T> inline size_t LLData<T>::getTotalSize() const { int result = std::accumulate(m_dims, m_dims + m_rank, 1, std::multiplies<int>{}); return static_cast<size_t>(result); } -template <class T> T LLData<T>::getTotalSum() const -{ +template <class T> T LLData<T>::getTotalSum() const { return std::accumulate(m_data_array, m_data_array + getTotalSize(), getZeroElement()); } -template <class T> void LLData<T>::allocate(size_t rank, const int* dimensions) -{ +template <class T> void LLData<T>::allocate(size_t rank, const int* dimensions) { clear(); if (!checkDimensions(rank, dimensions)) { throw std::runtime_error("LLData<T>::allocate error: dimensions must be > 0"); @@ -222,8 +206,7 @@ template <class T> void LLData<T>::allocate(size_t rank, const int* dimensions) } } -template <class T> void LLData<T>::clear() -{ +template <class T> void LLData<T>::clear() { if (m_rank > 0) { m_rank = 0; delete[] m_data_array; @@ -235,14 +218,13 @@ template <class T> void LLData<T>::clear() } } -template <class T> inline bool LLData<T>::checkDimensions(size_t rank, const int* dimensions) const -{ +template <class T> +inline bool LLData<T>::checkDimensions(size_t rank, const int* dimensions) const { return std::all_of(dimensions, dimensions + rank, [](const int& dim) -> bool { return dim > 0; }); } -template <class T> inline size_t LLData<T>::convertCoordinate(int* coordinate) const -{ +template <class T> inline size_t LLData<T>::convertCoordinate(int* coordinate) const { size_t offset = 1; size_t result = 0; for (size_t i = m_rank; i > 0; --i) { @@ -252,49 +234,42 @@ template <class T> inline size_t LLData<T>::convertCoordinate(int* coordinate) c return result; } -template <class T> void LLData<T>::swapContents(LLData<T>& other) -{ +template <class T> void LLData<T>::swapContents(LLData<T>& other) { std::swap(this->m_rank, other.m_rank); std::swap(this->m_dims, other.m_dims); std::swap(this->m_data_array, other.m_data_array); } -template <class T> T LLData<T>::getZeroElement() const -{ +template <class T> T LLData<T>::getZeroElement() const { T result = 0; return result; } -template <class T> LLData<T> operator+(const LLData<T>& left, const LLData<T>& right) -{ +template <class T> LLData<T> operator+(const LLData<T>& left, const LLData<T>& right) { LLData<T>* p_result = new LLData<T>(left); (*p_result) += right; return *p_result; } -template <class T> LLData<T> operator-(const LLData<T>& left, const LLData<T>& right) -{ +template <class T> LLData<T> operator-(const LLData<T>& left, const LLData<T>& right) { LLData<T>* p_result = new LLData<T>(left); (*p_result) -= right; return *p_result; } -template <class T> LLData<T> operator*(const LLData<T>& left, const LLData<T>& right) -{ +template <class T> LLData<T> operator*(const LLData<T>& left, const LLData<T>& right) { LLData<T>* p_result = new LLData<T>(left); (*p_result) *= right; return *p_result; } -template <class T> LLData<T> operator/(const LLData<T>& left, const LLData<T>& right) -{ +template <class T> LLData<T> operator/(const LLData<T>& left, const LLData<T>& right) { LLData<T>* p_result = new LLData<T>(left); *p_result /= right; return *p_result; } -template <class T> bool HaveSameDimensions(const LLData<T>& left, const LLData<T>& right) -{ +template <class T> bool HaveSameDimensions(const LLData<T>& left, const LLData<T>& right) { if (left.rank() != right.rank()) return false; const int* ldims = left.dimensions(); diff --git a/Device/Data/OutputData.cpp b/Device/Data/OutputData.cpp index a42012178afdf4362d3bd59262fa6aae4fed03f4..0a14b1aba67656598977be7537e89d0cb7d1be5c 100644 --- a/Device/Data/OutputData.cpp +++ b/Device/Data/OutputData.cpp @@ -19,8 +19,7 @@ #include "Base/Utils/PythonCore.h" -template <> PyObject* OutputData<double>::getArray() const -{ +template <> PyObject* OutputData<double>::getArray() const { std::vector<size_t> dimensions; for (size_t i = 0; i < rank(); i++) dimensions.push_back(axis(i).size()); @@ -64,12 +63,10 @@ template <> PyObject* OutputData<double>::getArray() const #endif // BORNAGAIN_PYTHON -template <> double OutputData<double>::getValue(size_t index) const -{ +template <> double OutputData<double>::getValue(size_t index) const { return (*this)[index]; } -template <> double OutputData<CumulativeValue>::getValue(size_t index) const -{ +template <> double OutputData<CumulativeValue>::getValue(size_t index) const { return (*this)[index].getContent(); } diff --git a/Device/Data/OutputData.h b/Device/Data/OutputData.h index eb53cdf333490e697536adc76b2b764af50bfac1..41dc79b31c2d97123ecd6dc8aa8d5ffb6420cb88 100644 --- a/Device/Data/OutputData.h +++ b/Device/Data/OutputData.h @@ -29,8 +29,7 @@ using std::size_t; //! Template class to store data of any type in multi-dimensional space. //! @ingroup tools -template <class T> class OutputData -{ +template <class T> class OutputData { public: using value_type = T; @@ -59,8 +58,7 @@ public: size_t rank() const { return m_value_axes.size(); } //! Returns total size of data buffer (product of bin number in every dimension). - size_t getAllocatedSize() const - { + size_t getAllocatedSize() const { if (m_ll_data) return m_ll_data->getTotalSize(); return 0; @@ -192,15 +190,13 @@ public: double getValue(size_t index) const; //! indexed accessor - T& operator[](size_t index) - { + T& operator[](size_t index) { ASSERT(m_ll_data); return (*m_ll_data)[index]; } //! indexed accessor (const) - const T& operator[](size_t index) const - { + const T& operator[](size_t index) const { ASSERT(m_ll_data); return (*m_ll_data)[index]; } @@ -239,27 +235,23 @@ private: // Implementation // --------------------------------------------------------------------- // -template <class T> OutputData<T>::OutputData() : m_value_axes(), m_ll_data(nullptr) -{ +template <class T> OutputData<T>::OutputData() : m_value_axes(), m_ll_data(nullptr) { allocate(); } -template <class T> OutputData<T>::~OutputData() -{ +template <class T> OutputData<T>::~OutputData() { clear(); delete m_ll_data; } -template <class T> OutputData<T>* OutputData<T>::clone() const -{ +template <class T> OutputData<T>* OutputData<T>::clone() const { OutputData<T>* ret = new OutputData<T>(); ret->m_value_axes = m_value_axes; (*ret->m_ll_data) = *m_ll_data; return ret; } -template <class T> void OutputData<T>::copyFrom(const OutputData<T>& other) -{ +template <class T> void OutputData<T>::copyFrom(const OutputData<T>& other) { clear(); m_value_axes = other.m_value_axes; delete m_ll_data; @@ -268,16 +260,16 @@ template <class T> void OutputData<T>::copyFrom(const OutputData<T>& other) m_ll_data = new LLData<T>(*other.m_ll_data); } -template <class T> template <class U> void OutputData<T>::copyShapeFrom(const OutputData<U>& other) -{ +template <class T> +template <class U> +void OutputData<T>::copyShapeFrom(const OutputData<U>& other) { clear(); size_t rank = other.rank(); for (size_t i = 0; i < rank; ++i) addAxis(other.axis(i)); } -template <class T> OutputData<double>* OutputData<T>::meanValues() const -{ +template <class T> OutputData<double>* OutputData<T>::meanValues() const { auto* ret = new OutputData<double>(); ret->copyShapeFrom(*this); ret->allocate(); @@ -286,8 +278,7 @@ template <class T> OutputData<double>* OutputData<T>::meanValues() const return ret; } -template <class T> void OutputData<T>::addAxis(const IAxis& new_axis) -{ +template <class T> void OutputData<T>::addAxis(const IAxis& new_axis) { if (axisNameExists(new_axis.getName())) throw Exceptions::LogicErrorException( "OutputData<T>::addAxis(const IAxis& new_axis) -> " @@ -300,8 +291,7 @@ template <class T> void OutputData<T>::addAxis(const IAxis& new_axis) } template <class T> -void OutputData<T>::addAxis(const std::string& name, size_t size, double start, double end) -{ +void OutputData<T>::addAxis(const std::string& name, size_t size, double start, double end) { if (axisNameExists(name)) throw Exceptions::LogicErrorException( "OutputData<T>::addAxis(std::string name) -> " @@ -311,18 +301,15 @@ void OutputData<T>::addAxis(const std::string& name, size_t size, double start, addAxis(new_axis); } -template <class T> const IAxis& OutputData<T>::axis(size_t serial_number) const -{ +template <class T> const IAxis& OutputData<T>::axis(size_t serial_number) const { return *m_value_axes[serial_number]; } -template <class T> const IAxis& OutputData<T>::axis(const std::string& axis_name) const -{ +template <class T> const IAxis& OutputData<T>::axis(const std::string& axis_name) const { return axis(getAxisIndex(axis_name)); } -template <class T> inline std::vector<size_t> OutputData<T>::getAllSizes() const -{ +template <class T> inline std::vector<size_t> OutputData<T>::getAllSizes() const { ASSERT(m_ll_data); std::vector<size_t> result; for (size_t i = 0; i < rank(); ++i) { @@ -332,8 +319,7 @@ template <class T> inline std::vector<size_t> OutputData<T>::getAllSizes() const return result; } -template <class T> inline std::vector<T> OutputData<T>::getRawDataVector() const -{ +template <class T> inline std::vector<T> OutputData<T>::getRawDataVector() const { ASSERT(m_ll_data); std::vector<T> result; for (size_t i = 0; i < getAllocatedSize(); ++i) @@ -341,20 +327,17 @@ template <class T> inline std::vector<T> OutputData<T>::getRawDataVector() const return result; } -template <class T> typename OutputData<T>::iterator OutputData<T>::begin() -{ +template <class T> typename OutputData<T>::iterator OutputData<T>::begin() { typename OutputData<T>::iterator result(this); return result; } -template <class T> typename OutputData<T>::const_iterator OutputData<T>::begin() const -{ +template <class T> typename OutputData<T>::const_iterator OutputData<T>::begin() const { typename OutputData<T>::const_iterator result(this); return result; } -template <class T> std::vector<int> OutputData<T>::getAxesBinIndices(size_t global_index) const -{ +template <class T> std::vector<int> OutputData<T>::getAxesBinIndices(size_t global_index) const { ASSERT(m_ll_data); size_t remainder = global_index; std::vector<int> result; @@ -368,8 +351,7 @@ template <class T> std::vector<int> OutputData<T>::getAxesBinIndices(size_t glob } template <class T> -size_t OutputData<T>::getAxisBinIndex(size_t global_index, size_t i_selected_axis) const -{ +size_t OutputData<T>::getAxisBinIndex(size_t global_index, size_t i_selected_axis) const { ASSERT(m_ll_data); size_t remainder(global_index); for (size_t i = 0; i < m_ll_data->rank(); ++i) { @@ -384,14 +366,12 @@ size_t OutputData<T>::getAxisBinIndex(size_t global_index, size_t i_selected_axi } template <class T> -size_t OutputData<T>::getAxisBinIndex(size_t global_index, const std::string& axis_name) const -{ +size_t OutputData<T>::getAxisBinIndex(size_t global_index, const std::string& axis_name) const { return getAxisBinIndex(global_index, getAxisIndex(axis_name)); } template <class T> -size_t OutputData<T>::toGlobalIndex(const std::vector<unsigned>& axes_indices) const -{ +size_t OutputData<T>::toGlobalIndex(const std::vector<unsigned>& axes_indices) const { ASSERT(m_ll_data); if (axes_indices.size() != m_ll_data->rank()) throw Exceptions::LogicErrorException( @@ -415,8 +395,7 @@ size_t OutputData<T>::toGlobalIndex(const std::vector<unsigned>& axes_indices) c } template <class T> -size_t OutputData<T>::findGlobalIndex(const std::vector<double>& coordinates) const -{ +size_t OutputData<T>::findGlobalIndex(const std::vector<double>& coordinates) const { ASSERT(m_ll_data); if (coordinates.size() != m_ll_data->rank()) throw Exceptions::LogicErrorException( @@ -430,20 +409,17 @@ size_t OutputData<T>::findGlobalIndex(const std::vector<double>& coordinates) co } template <class T> -double OutputData<T>::getAxisValue(size_t global_index, size_t i_selected_axis) const -{ +double OutputData<T>::getAxisValue(size_t global_index, size_t i_selected_axis) const { auto axis_index = getAxisBinIndex(global_index, i_selected_axis); return (*m_value_axes[i_selected_axis])[axis_index]; } template <class T> -double OutputData<T>::getAxisValue(size_t global_index, const std::string& axis_name) const -{ +double OutputData<T>::getAxisValue(size_t global_index, const std::string& axis_name) const { return getAxisValue(global_index, getAxisIndex(axis_name)); } -template <class T> std::vector<double> OutputData<T>::getAxesValues(size_t global_index) const -{ +template <class T> std::vector<double> OutputData<T>::getAxesValues(size_t global_index) const { std::vector<int> indices = getAxesBinIndices(global_index); std::vector<double> result; for (size_t i_axis = 0; i_axis < indices.size(); ++i_axis) @@ -452,48 +428,41 @@ template <class T> std::vector<double> OutputData<T>::getAxesValues(size_t globa } template <class T> -Bin1D OutputData<T>::getAxisBin(size_t global_index, size_t i_selected_axis) const -{ +Bin1D OutputData<T>::getAxisBin(size_t global_index, size_t i_selected_axis) const { auto axis_index = getAxisBinIndex(global_index, i_selected_axis); return m_value_axes[i_selected_axis]->bin(axis_index); } template <class T> -Bin1D OutputData<T>::getAxisBin(size_t global_index, const std::string& axis_name) const -{ +Bin1D OutputData<T>::getAxisBin(size_t global_index, const std::string& axis_name) const { return getAxisBin(global_index, getAxisIndex(axis_name)); } -template <class T> inline T OutputData<T>::totalSum() const -{ +template <class T> inline T OutputData<T>::totalSum() const { ASSERT(m_ll_data); return m_ll_data->getTotalSum(); } -template <class T> void OutputData<T>::clear() -{ +template <class T> void OutputData<T>::clear() { m_value_axes.clear(); allocate(); } -template <class T> void OutputData<T>::setAllTo(const T& value) -{ +template <class T> void OutputData<T>::setAllTo(const T& value) { if (!m_ll_data) throw Exceptions::ClassInitializationException( "OutputData::setAllTo() -> Error! Low-level data object was not yet initialized."); m_ll_data->setAll(value); } -template <class T> void OutputData<T>::scaleAll(const T& factor) -{ +template <class T> void OutputData<T>::scaleAll(const T& factor) { if (!m_ll_data) throw Exceptions::ClassInitializationException( "OutputData::scaleAll() -> Error! Low-level data object was not yet initialized."); m_ll_data->scaleAll(factor); } -template <class T> void OutputData<T>::setAxisSizes(size_t rank, int* n_dims) -{ +template <class T> void OutputData<T>::setAxisSizes(size_t rank, int* n_dims) { clear(); std::string basename("axis"); for (size_t i = 0; i < rank; ++i) { @@ -503,29 +472,25 @@ template <class T> void OutputData<T>::setAxisSizes(size_t rank, int* n_dims) } } -template <class T> const OutputData<T>& OutputData<T>::operator+=(const OutputData<T>& right) -{ +template <class T> const OutputData<T>& OutputData<T>::operator+=(const OutputData<T>& right) { ASSERT(m_ll_data); *this->m_ll_data += *right.m_ll_data; return *this; } -template <class T> const OutputData<T>& OutputData<T>::operator-=(const OutputData<T>& right) -{ +template <class T> const OutputData<T>& OutputData<T>::operator-=(const OutputData<T>& right) { ASSERT(m_ll_data); *this->m_ll_data -= *right.m_ll_data; return *this; } -template <class T> const OutputData<T>& OutputData<T>::operator*=(const OutputData<T>& right) -{ +template <class T> const OutputData<T>& OutputData<T>::operator*=(const OutputData<T>& right) { ASSERT(m_ll_data); *this->m_ll_data *= *right.m_ll_data; return *this; } -template <class T> bool OutputData<T>::isInitialized() const -{ +template <class T> bool OutputData<T>::isInitialized() const { if (!m_ll_data) return false; if (rank() != m_ll_data->rank()) @@ -535,15 +500,13 @@ template <class T> bool OutputData<T>::isInitialized() const return true; } -template <class T> const OutputData<T>& OutputData<T>::operator/=(const OutputData<T>& right) -{ +template <class T> const OutputData<T>& OutputData<T>::operator/=(const OutputData<T>& right) { ASSERT(m_ll_data); *this->m_ll_data /= *right.m_ll_data; return *this; } -template <class T> void OutputData<T>::allocate() -{ +template <class T> void OutputData<T>::allocate() { delete m_ll_data; size_t rank = m_value_axes.size(); int* dims = new int[rank]; @@ -556,8 +519,7 @@ template <class T> void OutputData<T>::allocate() delete[] dims; } -template <class T> inline void OutputData<T>::setRawDataVector(const std::vector<T>& data_vector) -{ +template <class T> inline void OutputData<T>::setRawDataVector(const std::vector<T>& data_vector) { if (data_vector.size() != getAllocatedSize()) throw Exceptions::RuntimeErrorException( "OutputData<T>::setRawDataVector() -> Error! " @@ -566,8 +528,7 @@ template <class T> inline void OutputData<T>::setRawDataVector(const std::vector (*m_ll_data)[i] = data_vector[i]; } -template <class T> inline void OutputData<T>::setRawDataArray(const T* source) -{ +template <class T> inline void OutputData<T>::setRawDataArray(const T* source) { for (size_t i = 0; i < getAllocatedSize(); ++i) (*m_ll_data)[i] = source[i]; } @@ -575,8 +536,7 @@ template <class T> inline void OutputData<T>::setRawDataArray(const T* source) //! Returns true if object have same dimensions template <class T> template <class U> -inline bool OutputData<T>::hasSameDimensions(const OutputData<U>& right) const -{ +inline bool OutputData<T>::hasSameDimensions(const OutputData<U>& right) const { if (!isInitialized()) return false; if (!right.isInitialized()) @@ -592,8 +552,7 @@ inline bool OutputData<T>::hasSameDimensions(const OutputData<U>& right) const //! Returns true if object have same dimensions and shape of axis template <class T> template <class U> -bool OutputData<T>::hasSameShape(const OutputData<U>& right) const -{ +bool OutputData<T>::hasSameShape(const OutputData<U>& right) const { if (!hasSameDimensions(right)) return false; @@ -609,8 +568,7 @@ template <> PyObject* OutputData<double>::getArray() const; #endif // return index of axis -template <class T> size_t OutputData<T>::getAxisIndex(const std::string& axis_name) const -{ +template <class T> size_t OutputData<T>::getAxisIndex(const std::string& axis_name) const { for (size_t i = 0; i < m_value_axes.size(); ++i) if (m_value_axes[i]->getName() == axis_name) return i; @@ -619,8 +577,7 @@ template <class T> size_t OutputData<T>::getAxisIndex(const std::string& axis_na + axis_name + "'"); } -template <class T> bool OutputData<T>::axisNameExists(const std::string& axis_name) const -{ +template <class T> bool OutputData<T>::axisNameExists(const std::string& axis_name) const { for (size_t i = 0; i < m_value_axes.size(); ++i) if (m_value_axes[i]->getName() == axis_name) return true; diff --git a/Device/Data/OutputDataIterator.h b/Device/Data/OutputDataIterator.h index 4bcaa28aaab9f0e5286f3beeee233c087097f973..0ff84b877a5eac4ace6c0906c3270b2068cca4a5 100644 --- a/Device/Data/OutputDataIterator.h +++ b/Device/Data/OutputDataIterator.h @@ -22,8 +22,7 @@ //! Iterator for underlying OutputData container. //! @ingroup tools_internal -template <class TValue, class TContainer> class OutputDataIterator -{ +template <class TValue, class TContainer> class OutputDataIterator { public: //! Empty constructor to comply with stl forward iterators OutputDataIterator(); @@ -89,8 +88,7 @@ private: //! make Swappable template <class TValue, class TContainer> void swap(OutputDataIterator<TValue, TContainer>& left, - OutputDataIterator<TValue, TContainer>& right) -{ + OutputDataIterator<TValue, TContainer>& right) { left.swap(right); } @@ -105,23 +103,19 @@ bool operator!=(const OutputDataIterator<TValue1, TContainer1>& left, const OutputDataIterator<TValue2, TContainer2>& right); template <class TValue, class TContainer> -OutputDataIterator<TValue, TContainer>::OutputDataIterator() : m_current_index(0), m_output_data(0) -{ -} +OutputDataIterator<TValue, TContainer>::OutputDataIterator() + : m_current_index(0), m_output_data(0) {} template <class TValue, class TContainer> OutputDataIterator<TValue, TContainer>::OutputDataIterator(TContainer* p_output_data, size_t start_at_index) - : m_current_index(start_at_index), m_output_data(p_output_data) -{ -} + : m_current_index(start_at_index), m_output_data(p_output_data) {} template <class TValue, class TContainer> template <class TValue2, class TContainer2> OutputDataIterator<TValue, TContainer>::OutputDataIterator( const OutputDataIterator<TValue2, TContainer2>& other) - : m_current_index(0), m_output_data(0) -{ + : m_current_index(0), m_output_data(0) { m_output_data = static_cast<TContainer*>(other.getContainer()); m_current_index = other.getIndex(); } @@ -129,8 +123,7 @@ OutputDataIterator<TValue, TContainer>::OutputDataIterator( template <class TValue, class TContainer> OutputDataIterator<TValue, TContainer>::OutputDataIterator( const OutputDataIterator<TValue, TContainer>& other) - : m_current_index(0), m_output_data(0) -{ + : m_current_index(0), m_output_data(0) { m_output_data = other.getContainer(); m_current_index = other.getIndex(); } @@ -138,8 +131,7 @@ OutputDataIterator<TValue, TContainer>::OutputDataIterator( template <class TValue, class TContainer> template <class TValue2, class TContainer2> OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>::operator=( - const OutputDataIterator<TValue2, TContainer2>& right) -{ + const OutputDataIterator<TValue2, TContainer2>& right) { OutputDataIterator<TValue, TContainer> copy(right); swap(copy); return *this; @@ -147,21 +139,17 @@ OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>:: template <class TValue, class TContainer> OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>::operator=( - const OutputDataIterator<TValue, TContainer>& right) -{ + const OutputDataIterator<TValue, TContainer>& right) { OutputDataIterator<TValue, TContainer> copy(right); swap(copy); return *this; } template <class TValue, class TContainer> -OutputDataIterator<TValue, TContainer>::~OutputDataIterator() -{ -} +OutputDataIterator<TValue, TContainer>::~OutputDataIterator() {} template <class TValue, class TContainer> -OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>::operator++() -{ +OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>::operator++() { if (m_current_index < m_output_data->getAllocatedSize()) { ++m_current_index; } @@ -169,28 +157,25 @@ OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>:: } template <class TValue, class TContainer> -OutputDataIterator<TValue, TContainer> OutputDataIterator<TValue, TContainer>::operator++(int /**/) -{ +OutputDataIterator<TValue, TContainer> +OutputDataIterator<TValue, TContainer>::operator++(int /**/) { OutputDataIterator<TValue, TContainer> result(*this); this->operator++(); return result; } template <class TValue, class TContainer> -TValue& OutputDataIterator<TValue, TContainer>::operator*() const -{ +TValue& OutputDataIterator<TValue, TContainer>::operator*() const { return (*m_output_data)[m_current_index]; } template <class TValue, class TContainer> -TValue* OutputDataIterator<TValue, TContainer>::operator->() const -{ +TValue* OutputDataIterator<TValue, TContainer>::operator->() const { return &((*m_output_data)[m_current_index]); } template <class TValue, class TContainer> -void OutputDataIterator<TValue, TContainer>::swap(OutputDataIterator<TValue, TContainer>& other) -{ +void OutputDataIterator<TValue, TContainer>::swap(OutputDataIterator<TValue, TContainer>& other) { std::swap(this->m_current_index, other.m_current_index); std::swap(this->m_output_data, other.m_output_data); } @@ -198,16 +183,14 @@ void OutputDataIterator<TValue, TContainer>::swap(OutputDataIterator<TValue, TCo //! test for equality template <class TValue1, class TContainer1, class TValue2, class TContainer2> bool operator==(const OutputDataIterator<TValue1, TContainer1>& left, - const OutputDataIterator<TValue2, TContainer2>& right) -{ + const OutputDataIterator<TValue2, TContainer2>& right) { return left.getContainer() == right.getContainer() && left.getIndex() == right.getIndex(); } //! test for inequality template <class TValue1, class TContainer1, class TValue2, class TContainer2> bool operator!=(const OutputDataIterator<TValue1, TContainer1>& left, - const OutputDataIterator<TValue2, TContainer2>& right) -{ + const OutputDataIterator<TValue2, TContainer2>& right) { return !(left == right); } diff --git a/Device/Detector/DetectionProperties.cpp b/Device/Detector/DetectionProperties.cpp index 05fccc5dfbf1a8b3ec8766c5c59e665b4579d4eb..7d828ceb3a1951b13e1ab84c65b45081963dcfe3 100644 --- a/Device/Detector/DetectionProperties.cpp +++ b/Device/Detector/DetectionProperties.cpp @@ -19,8 +19,7 @@ DetectionProperties::DetectionProperties(kvector_t direction, double efficiency, double total_transmission) - : m_direction(direction), m_efficiency(efficiency), m_total_transmission(total_transmission) -{ + : m_direction(direction), m_efficiency(efficiency), m_total_transmission(total_transmission) { setName("Analyzer"); registerVector("Direction", &m_direction, ""); registerParameter("Efficiency", &m_efficiency); @@ -30,13 +29,10 @@ DetectionProperties::DetectionProperties(kvector_t direction, double efficiency, DetectionProperties::DetectionProperties() : DetectionProperties({}, {}, 1.0) {} DetectionProperties::DetectionProperties(const DetectionProperties& other) - : DetectionProperties(other.m_direction, other.m_efficiency, other.m_total_transmission) -{ -} + : DetectionProperties(other.m_direction, other.m_efficiency, other.m_total_transmission) {} void DetectionProperties::setAnalyzerProperties(const kvector_t direction, double efficiency, - double total_transmission) -{ + double total_transmission) { if (!checkAnalyzerProperties(direction, efficiency, total_transmission)) throw Exceptions::ClassInitializationException("IDetector2D::setAnalyzerProperties: the " "given properties are not physical"); @@ -50,8 +46,7 @@ void DetectionProperties::setAnalyzerProperties(const kvector_t direction, doubl m_total_transmission = total_transmission; } -Eigen::Matrix2cd DetectionProperties::analyzerOperator() const -{ +Eigen::Matrix2cd DetectionProperties::analyzerOperator() const { if (m_direction.mag() == 0.0 || m_efficiency == 0.0) return m_total_transmission * Eigen::Matrix2cd::Identity(); Eigen::Matrix2cd result; @@ -68,24 +63,20 @@ Eigen::Matrix2cd DetectionProperties::analyzerOperator() const return result; } -kvector_t DetectionProperties::analyzerDirection() const -{ +kvector_t DetectionProperties::analyzerDirection() const { return m_direction; } -double DetectionProperties::analyzerEfficiency() const -{ +double DetectionProperties::analyzerEfficiency() const { return m_efficiency; } -double DetectionProperties::analyzerTotalTransmission() const -{ +double DetectionProperties::analyzerTotalTransmission() const { return m_total_transmission; } bool DetectionProperties::checkAnalyzerProperties(const kvector_t direction, double efficiency, - double total_transmission) const -{ + double total_transmission) const { if (direction.mag() == 0.0) return false; double aplus = total_transmission * (1.0 + efficiency); diff --git a/Device/Detector/DetectionProperties.h b/Device/Detector/DetectionProperties.h index 246a52757fb7c9e0f56b5658a324b20523c3e70d..9b0a1729958ce356282004e2ebe1dcadb47218a2 100644 --- a/Device/Detector/DetectionProperties.h +++ b/Device/Detector/DetectionProperties.h @@ -21,8 +21,7 @@ //! Detector properties (efficiency, transmission). //! @ingroup detector -class DetectionProperties : public INode -{ +class DetectionProperties : public INode { public: DetectionProperties(kvector_t direction, double efficiency, double total_transmission); DetectionProperties(); diff --git a/Device/Detector/DetectorContext.cpp b/Device/Detector/DetectorContext.cpp index 2133b19cd570f5090a93568c93959fa63d979a11..b307210ce4b976b011d0debc47e9e28f3d5204bf 100644 --- a/Device/Detector/DetectorContext.cpp +++ b/Device/Detector/DetectorContext.cpp @@ -15,13 +15,11 @@ #include "Device/Detector/DetectorContext.h" #include "Device/Detector/IDetector2D.h" -DetectorContext::DetectorContext(const IDetector2D* detector) -{ +DetectorContext::DetectorContext(const IDetector2D* detector) { setup_context(detector); } -size_t DetectorContext::numberOfSimulationElements() const -{ +size_t DetectorContext::numberOfSimulationElements() const { return active_indices.size(); } @@ -29,18 +27,15 @@ size_t DetectorContext::numberOfSimulationElements() const //! of SimulationElements. Corresponds to sequence of detector bins inside ROI and outside //! of masked areas. -std::unique_ptr<IPixel> DetectorContext::createPixel(size_t element_index) const -{ +std::unique_ptr<IPixel> DetectorContext::createPixel(size_t element_index) const { return std::unique_ptr<IPixel>(pixels[element_index]->clone()); } -size_t DetectorContext::detectorIndex(size_t element_index) const -{ +size_t DetectorContext::detectorIndex(size_t element_index) const { return active_indices[element_index]; } -void DetectorContext::setup_context(const IDetector2D* detector) -{ +void DetectorContext::setup_context(const IDetector2D* detector) { active_indices = detector->active_indices(); analyzer_operator = detector->detectionProperties().analyzerOperator(); pixels.reserve(active_indices.size()); diff --git a/Device/Detector/DetectorContext.h b/Device/Detector/DetectorContext.h index dd90e2b74bdb4b385c225ebcda4420183de288d0..d4129120baa356852ff73be6b6f13c82bfd13238 100644 --- a/Device/Detector/DetectorContext.h +++ b/Device/Detector/DetectorContext.h @@ -25,8 +25,7 @@ class IDetector2D; //! Holds precalculated information for faster SimulationElement generation. //! @ingroup detector -class DetectorContext -{ +class DetectorContext { public: DetectorContext(const IDetector2D* detector); diff --git a/Device/Detector/DetectorMask.cpp b/Device/Detector/DetectorMask.cpp index 64b961d94bb8ce934ef88f01a0aa60eb08b93240..36ad3eb2592711b9f28e7333e37fc7c21612878f 100644 --- a/Device/Detector/DetectorMask.cpp +++ b/Device/Detector/DetectorMask.cpp @@ -21,13 +21,11 @@ DetectorMask::DetectorMask() : m_number_of_masked_channels(0) {} DetectorMask::DetectorMask(const DetectorMask& other) : m_shapes(other.m_shapes) , m_mask_of_shape(other.m_mask_of_shape) - , m_number_of_masked_channels(other.m_number_of_masked_channels) -{ + , m_number_of_masked_channels(other.m_number_of_masked_channels) { m_mask_data.copyFrom(other.m_mask_data); } -DetectorMask& DetectorMask::operator=(const DetectorMask& other) -{ +DetectorMask& DetectorMask::operator=(const DetectorMask& other) { if (this != &other) { m_shapes = other.m_shapes; m_mask_of_shape = other.m_mask_of_shape; @@ -39,16 +37,14 @@ DetectorMask& DetectorMask::operator=(const DetectorMask& other) return *this; } -void DetectorMask::addMask(const IShape2D& shape, bool mask_value) -{ +void DetectorMask::addMask(const IShape2D& shape, bool mask_value) { m_shapes.push_back(shape.clone()); m_mask_of_shape.push_back(mask_value); m_mask_data.clear(); m_number_of_masked_channels = 0; } -void DetectorMask::initMaskData(const IDetector2D& detector) -{ +void DetectorMask::initMaskData(const IDetector2D& detector) { if (detector.dimension() != 2) throw Exceptions::RuntimeErrorException("DetectorMask::initMaskData() -> Error. Attempt " "to add masks to uninitialized detector."); @@ -64,8 +60,7 @@ void DetectorMask::initMaskData(const IDetector2D& detector) process_masks(); } -void DetectorMask::initMaskData(const OutputData<double>& data) -{ +void DetectorMask::initMaskData(const OutputData<double>& data) { ASSERT(m_shapes.size() == m_mask_of_shape.size()); m_mask_data.clear(); @@ -75,13 +70,11 @@ void DetectorMask::initMaskData(const OutputData<double>& data) process_masks(); } -bool DetectorMask::isMasked(size_t index) const -{ +bool DetectorMask::isMasked(size_t index) const { return m_number_of_masked_channels == 0 ? false : m_mask_data[index]; } -Histogram2D* DetectorMask::createHistogram() const -{ +Histogram2D* DetectorMask::createHistogram() const { OutputData<double> data; data.copyShapeFrom(m_mask_data); for (size_t i = 0; i < m_mask_data.getAllocatedSize(); ++i) @@ -89,28 +82,24 @@ Histogram2D* DetectorMask::createHistogram() const return dynamic_cast<Histogram2D*>(IHistogram::createHistogram(data)); } -void DetectorMask::removeMasks() -{ +void DetectorMask::removeMasks() { m_shapes.clear(); m_mask_of_shape.clear(); m_mask_data.clear(); } -size_t DetectorMask::numberOfMasks() const -{ +size_t DetectorMask::numberOfMasks() const { return m_shapes.size(); } -const IShape2D* DetectorMask::getMaskShape(size_t mask_index, bool& mask_value) const -{ +const IShape2D* DetectorMask::getMaskShape(size_t mask_index, bool& mask_value) const { if (mask_index >= numberOfMasks()) return nullptr; mask_value = m_mask_of_shape[mask_index]; return m_shapes[mask_index]; } -void DetectorMask::process_masks() -{ +void DetectorMask::process_masks() { m_mask_data.setAllTo(false); if (!!m_shapes.empty()) return; diff --git a/Device/Detector/DetectorMask.h b/Device/Detector/DetectorMask.h index d9b8f4bc0e8e1098cdf2665f43968759657acf54..58743f70213792964f8c8289bd6338ed3f99e406 100644 --- a/Device/Detector/DetectorMask.h +++ b/Device/Detector/DetectorMask.h @@ -25,8 +25,7 @@ class Histogram2D; //! Collection of detector masks. //! @ingroup detector -class DetectorMask -{ +class DetectorMask { public: DetectorMask(); DetectorMask(const DetectorMask& other); diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp index 610a7d6f0ad4abd357f2c33f5115f7845a0e9868..93937f9513830621f743c15eab7e6bb926738269 100644 --- a/Device/Detector/IDetector.cpp +++ b/Device/Detector/IDetector.cpp @@ -19,8 +19,7 @@ #include "Device/Detector/SimulationArea.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" -IDetector::IDetector() -{ +IDetector::IDetector() { registerChild(&m_detection_properties); } @@ -28,8 +27,7 @@ IDetector::IDetector(const IDetector& other) : ICloneable() , INode() , m_axes(other.m_axes) - , m_detection_properties(other.m_detection_properties) -{ + , m_detection_properties(other.m_detection_properties) { if (other.m_detector_resolution) setDetectorResolution(*other.m_detector_resolution); setName(other.getName()); @@ -38,30 +36,25 @@ IDetector::IDetector(const IDetector& other) IDetector::~IDetector() = default; -void IDetector::addAxis(const IAxis& axis) -{ +void IDetector::addAxis(const IAxis& axis) { m_axes.push_back(axis.clone()); } -size_t IDetector::dimension() const -{ +size_t IDetector::dimension() const { return m_axes.size(); } -void IDetector::clear() -{ +void IDetector::clear() { m_axes.clear(); } -const IAxis& IDetector::axis(size_t index) const -{ +const IAxis& IDetector::axis(size_t index) const { if (index < dimension()) return *m_axes[index]; throw std::runtime_error("Error in IDetector::getAxis: not so many axes in this detector."); } -size_t IDetector::axisBinIndex(size_t index, size_t selected_axis) const -{ +size_t IDetector::axisBinIndex(size_t index, size_t selected_axis) const { const size_t dim = dimension(); size_t remainder(index); size_t i_axis = dim; @@ -76,8 +69,7 @@ size_t IDetector::axisBinIndex(size_t index, size_t selected_axis) const } std::unique_ptr<IAxis> IDetector::createAxis(size_t index, size_t n_bins, double min, - double max) const -{ + double max) const { if (max <= min) throw Exceptions::LogicErrorException("IDetector::createAxis() -> Error! max <= min"); if (n_bins == 0) @@ -86,8 +78,7 @@ std::unique_ptr<IAxis> IDetector::createAxis(size_t index, size_t n_bins, double return std::make_unique<FixedBinAxis>(axisName(index), n_bins, min, max); } -size_t IDetector::totalSize() const -{ +size_t IDetector::totalSize() const { const size_t dim = dimension(); if (dim == 0) return 0; @@ -98,26 +89,22 @@ size_t IDetector::totalSize() const } void IDetector::setAnalyzerProperties(const kvector_t direction, double efficiency, - double total_transmission) -{ + double total_transmission) { m_detection_properties.setAnalyzerProperties(direction, efficiency, total_transmission); } -void IDetector::setDetectorResolution(const IDetectorResolution& p_detector_resolution) -{ +void IDetector::setDetectorResolution(const IDetectorResolution& p_detector_resolution) { m_detector_resolution.reset(p_detector_resolution.clone()); registerChild(m_detector_resolution.get()); } // TODO: pass dimension-independent argument to this function -void IDetector::setResolutionFunction(const IResolutionFunction2D& resFunc) -{ +void IDetector::setResolutionFunction(const IResolutionFunction2D& resFunc) { ConvolutionDetectorResolution convFunc(resFunc); setDetectorResolution(convFunc); } -void IDetector::applyDetectorResolution(OutputData<double>* p_intensity_map) const -{ +void IDetector::applyDetectorResolution(OutputData<double>* p_intensity_map) const { if (!p_intensity_map) throw std::runtime_error("IDetector::applyDetectorResolution() -> " "Error! Null pointer to intensity map"); @@ -136,19 +123,16 @@ void IDetector::applyDetectorResolution(OutputData<double>* p_intensity_map) con } } -void IDetector::removeDetectorResolution() -{ +void IDetector::removeDetectorResolution() { m_detector_resolution.reset(); } -const IDetectorResolution* IDetector::detectorResolution() const -{ +const IDetectorResolution* IDetector::detectorResolution() const { return m_detector_resolution.get(); } OutputData<double>* -IDetector::createDetectorIntensity(const std::vector<SimulationElement>& elements) const -{ +IDetector::createDetectorIntensity(const std::vector<SimulationElement>& elements) const { std::unique_ptr<OutputData<double>> detectorMap(createDetectorMap()); if (!detectorMap) throw Exceptions::RuntimeErrorException("Instrument::createDetectorIntensity:" @@ -161,8 +145,7 @@ IDetector::createDetectorIntensity(const std::vector<SimulationElement>& element return detectorMap.release(); } -std::unique_ptr<OutputData<double>> IDetector::createDetectorMap() const -{ +std::unique_ptr<OutputData<double>> IDetector::createDetectorMap() const { const size_t dim = dimension(); if (dim == 0) throw std::runtime_error( @@ -179,8 +162,7 @@ std::unique_ptr<OutputData<double>> IDetector::createDetectorMap() const } void IDetector::setDataToDetectorMap(OutputData<double>& detectorMap, - const std::vector<SimulationElement>& elements) const -{ + const std::vector<SimulationElement>& elements) const { if (elements.empty()) return; iterate([&](const_iterator it) { @@ -188,20 +170,18 @@ void IDetector::setDataToDetectorMap(OutputData<double>& detectorMap, }); } -size_t IDetector::numberOfSimulationElements() const -{ +size_t IDetector::numberOfSimulationElements() const { size_t result(0); iterate([&result](const_iterator) { ++result; }); return result; } -std::vector<const INode*> IDetector::getChildren() const -{ +std::vector<const INode*> IDetector::getChildren() const { return std::vector<const INode*>() << &m_detection_properties << m_detector_resolution; } -void IDetector::iterate(std::function<void(IDetector::const_iterator)> func, bool visit_masks) const -{ +void IDetector::iterate(std::function<void(IDetector::const_iterator)> func, + bool visit_masks) const { if (this->dimension() == 0) return; diff --git a/Device/Detector/IDetector.h b/Device/Detector/IDetector.h index fb2df6cd6a24c1dfcf58ca8d38785a51c6613e64..3a103fa995e2b03da6c89af59e744d9e5fcad531 100644 --- a/Device/Detector/IDetector.h +++ b/Device/Detector/IDetector.h @@ -32,8 +32,7 @@ class RegionOfInterest; //! Abstract detector interface. //! @ingroup detector -class IDetector : public ICloneable, public INode -{ +class IDetector : public ICloneable, public INode { public: using const_iterator = const SimulationAreaIterator&; IDetector(); diff --git a/Device/Detector/IDetector2D.cpp b/Device/Detector/IDetector2D.cpp index abcdac2a0e7a8d6b74c30935ad90f02093d86dcc..d56939358b591bb483d0a4d15db68da997405455 100644 --- a/Device/Detector/IDetector2D.cpp +++ b/Device/Detector/IDetector2D.cpp @@ -24,8 +24,7 @@ IDetector2D::IDetector2D() = default; IDetector2D::IDetector2D(const IDetector2D& other) - : IDetector(other), m_detector_mask(other.m_detector_mask) -{ + : IDetector(other), m_detector_mask(other.m_detector_mask) { if (other.regionOfInterest()) m_region_of_interest.reset(other.regionOfInterest()->clone()); } @@ -33,32 +32,27 @@ IDetector2D::IDetector2D(const IDetector2D& other) IDetector2D::~IDetector2D() = default; void IDetector2D::setDetectorParameters(size_t n_x, double x_min, double x_max, size_t n_y, - double y_min, double y_max) -{ + double y_min, double y_max) { clear(); addAxis(*createAxis(0, n_x, x_min, x_max)); addAxis(*createAxis(1, n_y, y_min, y_max)); } -const RegionOfInterest* IDetector2D::regionOfInterest() const -{ +const RegionOfInterest* IDetector2D::regionOfInterest() const { return m_region_of_interest.get(); } -void IDetector2D::setRegionOfInterest(double xlow, double ylow, double xup, double yup) -{ +void IDetector2D::setRegionOfInterest(double xlow, double ylow, double xup, double yup) { m_region_of_interest = std::make_unique<RegionOfInterest>(*this, xlow, ylow, xup, yup); m_detector_mask.initMaskData(*this); } -void IDetector2D::resetRegionOfInterest() -{ +void IDetector2D::resetRegionOfInterest() { m_region_of_interest.reset(); m_detector_mask.initMaskData(*this); } -std::vector<size_t> IDetector2D::active_indices() const -{ +std::vector<size_t> IDetector2D::active_indices() const { std::vector<size_t> result; SimulationArea area(this); for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it) @@ -66,37 +60,31 @@ std::vector<size_t> IDetector2D::active_indices() const return result; } -std::unique_ptr<DetectorContext> IDetector2D::createContext() const -{ +std::unique_ptr<DetectorContext> IDetector2D::createContext() const { return std::make_unique<DetectorContext>(this); } -void IDetector2D::removeMasks() -{ +void IDetector2D::removeMasks() { m_detector_mask.removeMasks(); } -void IDetector2D::addMask(const IShape2D& shape, bool mask_value) -{ +void IDetector2D::addMask(const IShape2D& shape, bool mask_value) { m_detector_mask.addMask(shape, mask_value); m_detector_mask.initMaskData(*this); } -void IDetector2D::maskAll() -{ +void IDetector2D::maskAll() { if (dimension() != 2) return; m_detector_mask.removeMasks(); addMask(InfinitePlane(), true); } -const DetectorMask* IDetector2D::detectorMask() const -{ +const DetectorMask* IDetector2D::detectorMask() const { return &m_detector_mask; } -size_t IDetector2D::getGlobalIndex(size_t x, size_t y) const -{ +size_t IDetector2D::getGlobalIndex(size_t x, size_t y) const { if (dimension() != 2) return totalSize(); return x * axis(1).size() + y; diff --git a/Device/Detector/IDetector2D.h b/Device/Detector/IDetector2D.h index 0a8abe5b6716d695e12d8f040cd5bee69f904ad9..8bdfc087c625f5a9a02ffea6eada5324597a2e6f 100644 --- a/Device/Detector/IDetector2D.h +++ b/Device/Detector/IDetector2D.h @@ -27,8 +27,7 @@ class DetectorContext; //! Abstract 2D detector interface. //! @ingroup detector -class IDetector2D : public IDetector -{ +class IDetector2D : public IDetector { public: IDetector2D(); diff --git a/Device/Detector/IsGISAXSDetector.cpp b/Device/Detector/IsGISAXSDetector.cpp index 302917761a7115476373a6b3d981925a1eee531c..7d8c0545185b3218213bce1baedf08c26d913311 100644 --- a/Device/Detector/IsGISAXSDetector.cpp +++ b/Device/Detector/IsGISAXSDetector.cpp @@ -15,31 +15,26 @@ #include "Device/Detector/IsGISAXSDetector.h" #include "Base/Axis/CustomBinAxis.h" -IsGISAXSDetector::IsGISAXSDetector() -{ +IsGISAXSDetector::IsGISAXSDetector() { setName("IsGISAXSDetector"); } IsGISAXSDetector::IsGISAXSDetector(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, - double alpha_min, double alpha_max) -{ + double alpha_min, double alpha_max) { setName("IsGISAXSDetector"); setDetectorParameters(n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max); } -IsGISAXSDetector::IsGISAXSDetector(const IsGISAXSDetector& other) : SphericalDetector(other) -{ +IsGISAXSDetector::IsGISAXSDetector(const IsGISAXSDetector& other) : SphericalDetector(other) { setName("IsGISAXSDetector"); } -IsGISAXSDetector* IsGISAXSDetector::clone() const -{ +IsGISAXSDetector* IsGISAXSDetector::clone() const { return new IsGISAXSDetector(*this); } std::unique_ptr<IAxis> IsGISAXSDetector::createAxis(size_t index, size_t n_bins, double min, - double max) const -{ + double max) const { if (max <= min) { throw Exceptions::LogicErrorException( "IsGISAXSDetector::createAxis() -> Error! max <= min"); @@ -51,7 +46,6 @@ std::unique_ptr<IAxis> IsGISAXSDetector::createAxis(size_t index, size_t n_bins, return std::make_unique<CustomBinAxis>(axisName(index), n_bins, min, max); } -size_t IsGISAXSDetector::indexOfSpecular(const Beam& /*beam*/) const -{ +size_t IsGISAXSDetector::indexOfSpecular(const Beam& /*beam*/) const { return totalSize(); } diff --git a/Device/Detector/IsGISAXSDetector.h b/Device/Detector/IsGISAXSDetector.h index 406434feed9ae1af527e6f314fa3308461fe7161..90625de09b8ac40b429134b52718c1439fa8ce84 100644 --- a/Device/Detector/IsGISAXSDetector.h +++ b/Device/Detector/IsGISAXSDetector.h @@ -20,8 +20,7 @@ //! A spherical detector used for validation with IsGISAXS results. //! @ingroup detector -class IsGISAXSDetector : public SphericalDetector -{ +class IsGISAXSDetector : public SphericalDetector { public: IsGISAXSDetector(); IsGISAXSDetector(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, diff --git a/Device/Detector/RectangularDetector.cpp b/Device/Detector/RectangularDetector.cpp index 31f058f6f142d4fb9f172bd002e84f4f6543df19..919d19d86aaa4108cda4d748e0df971e696cd8b7 100644 --- a/Device/Detector/RectangularDetector.cpp +++ b/Device/Detector/RectangularDetector.cpp @@ -28,8 +28,7 @@ RectangularDetector::RectangularDetector(size_t nxbins, double width, size_t nyb , m_distance(0.0) , m_dbeam_u0(0.0) , m_dbeam_v0(0.0) - , m_detector_arrangement(GENERIC) -{ + , m_detector_arrangement(GENERIC) { setDetectorParameters(nxbins, 0.0, width, nybins, 0.0, height); setName("RectangularDetector"); } @@ -45,20 +44,17 @@ RectangularDetector::RectangularDetector(const RectangularDetector& other) , m_dbeam_v0(other.m_dbeam_v0) , m_detector_arrangement(other.m_detector_arrangement) , m_u_unit(other.m_u_unit) - , m_v_unit(other.m_v_unit) -{ + , m_v_unit(other.m_v_unit) { setName("RectangularDetector"); } RectangularDetector::~RectangularDetector() = default; -RectangularDetector* RectangularDetector::clone() const -{ +RectangularDetector* RectangularDetector::clone() const { return new RectangularDetector(*this); } -void RectangularDetector::init(const Beam& beam) -{ +void RectangularDetector::init(const Beam& beam) { double alpha_i = beam.getAlpha(); kvector_t central_k = beam.getCentralK(); initNormalVector(central_k); @@ -66,8 +62,7 @@ void RectangularDetector::init(const Beam& beam) } void RectangularDetector::setPosition(const kvector_t normal_to_detector, double u0, double v0, - const kvector_t direction) -{ + const kvector_t direction) { m_detector_arrangement = GENERIC; m_normal_to_detector = normal_to_detector; m_distance = m_normal_to_detector.mag(); @@ -76,98 +71,80 @@ void RectangularDetector::setPosition(const kvector_t normal_to_detector, double m_direction = direction; } -void RectangularDetector::setPerpendicularToSampleX(double distance, double u0, double v0) -{ +void RectangularDetector::setPerpendicularToSampleX(double distance, double u0, double v0) { m_detector_arrangement = PERPENDICULAR_TO_SAMPLE; setDistanceAndOffset(distance, u0, v0); } -void RectangularDetector::setPerpendicularToDirectBeam(double distance, double u0, double v0) -{ +void RectangularDetector::setPerpendicularToDirectBeam(double distance, double u0, double v0) { m_detector_arrangement = PERPENDICULAR_TO_DIRECT_BEAM; setDistanceAndOffset(distance, u0, v0); } -void RectangularDetector::setPerpendicularToReflectedBeam(double distance, double u0, double v0) -{ +void RectangularDetector::setPerpendicularToReflectedBeam(double distance, double u0, double v0) { m_detector_arrangement = PERPENDICULAR_TO_REFLECTED_BEAM; setDistanceAndOffset(distance, u0, v0); } -void RectangularDetector::setDirectBeamPosition(double u0, double v0) -{ +void RectangularDetector::setDirectBeamPosition(double u0, double v0) { m_detector_arrangement = PERPENDICULAR_TO_REFLECTED_BEAM_DPOS; m_dbeam_u0 = u0; m_dbeam_v0 = v0; } -double RectangularDetector::getWidth() const -{ +double RectangularDetector::getWidth() const { return axis(0).span(); } -double RectangularDetector::getHeight() const -{ +double RectangularDetector::getHeight() const { return axis(1).span(); } -size_t RectangularDetector::getNbinsX() const -{ +size_t RectangularDetector::getNbinsX() const { return axis(0).size(); } -size_t RectangularDetector::getNbinsY() const -{ +size_t RectangularDetector::getNbinsY() const { return axis(1).size(); } -kvector_t RectangularDetector::getNormalVector() const -{ +kvector_t RectangularDetector::getNormalVector() const { return m_normal_to_detector; } -double RectangularDetector::getU0() const -{ +double RectangularDetector::getU0() const { return m_u0; } -double RectangularDetector::getV0() const -{ +double RectangularDetector::getV0() const { return m_v0; } -kvector_t RectangularDetector::getDirectionVector() const -{ +kvector_t RectangularDetector::getDirectionVector() const { return m_direction; } -double RectangularDetector::getDistance() const -{ +double RectangularDetector::getDistance() const { return m_distance; } -double RectangularDetector::getDirectBeamU0() const -{ +double RectangularDetector::getDirectBeamU0() const { return m_dbeam_u0; } -double RectangularDetector::getDirectBeamV0() const -{ +double RectangularDetector::getDirectBeamV0() const { return m_dbeam_v0; } -RectangularDetector::EDetectorArrangement RectangularDetector::getDetectorArrangment() const -{ +RectangularDetector::EDetectorArrangement RectangularDetector::getDetectorArrangment() const { return m_detector_arrangement; } -Axes::Units RectangularDetector::defaultAxesUnits() const -{ +Axes::Units RectangularDetector::defaultAxesUnits() const { return Axes::Units::MM; } -RectangularPixel* RectangularDetector::regionOfInterestPixel() const -{ +RectangularPixel* RectangularDetector::regionOfInterestPixel() const { const IAxis& u_axis = axis(0); const IAxis& v_axis = axis(1); double u_min, v_min, width, height; @@ -190,8 +167,7 @@ RectangularPixel* RectangularDetector::regionOfInterestPixel() const return new RectangularPixel(corner_position, uaxis_vector, vaxis_vector); } -IPixel* RectangularDetector::createPixel(size_t index) const -{ +IPixel* RectangularDetector::createPixel(size_t index) const { const IAxis& u_axis = axis(0); const IAxis& v_axis = axis(1); const size_t u_index = axisBinIndex(index, 0); @@ -206,8 +182,7 @@ IPixel* RectangularDetector::createPixel(size_t index) const return new RectangularPixel(corner_position, width, height); } -std::string RectangularDetector::axisName(size_t index) const -{ +std::string RectangularDetector::axisName(size_t index) const { switch (index) { case 0: return "u"; @@ -219,8 +194,7 @@ std::string RectangularDetector::axisName(size_t index) const } } -size_t RectangularDetector::indexOfSpecular(const Beam& beam) const -{ +size_t RectangularDetector::indexOfSpecular(const Beam& beam) const { if (dimension() != 2) return totalSize(); const double alpha = beam.getAlpha(); @@ -241,8 +215,7 @@ size_t RectangularDetector::indexOfSpecular(const Beam& beam) const return getGlobalIndex(u_axis.findClosestIndex(u), v_axis.findClosestIndex(v)); } -void RectangularDetector::setDistanceAndOffset(double distance, double u0, double v0) -{ +void RectangularDetector::setDistanceAndOffset(double distance, double u0, double v0) { if (distance <= 0.0) { std::ostringstream message; message << "RectangularDetector::setPerpendicularToSample() -> Error. " @@ -254,8 +227,7 @@ void RectangularDetector::setDistanceAndOffset(double distance, double u0, doubl m_v0 = v0; } -void RectangularDetector::initNormalVector(const kvector_t central_k) -{ +void RectangularDetector::initNormalVector(const kvector_t central_k) { kvector_t central_k_unit = central_k.unit(); if (m_detector_arrangement == GENERIC) { @@ -282,8 +254,7 @@ void RectangularDetector::initNormalVector(const kvector_t central_k) } } -void RectangularDetector::initUandV(double alpha_i) -{ +void RectangularDetector::initUandV(double alpha_i) { double d2 = m_normal_to_detector.dot(m_normal_to_detector); kvector_t u_direction = d2 * m_direction - m_direction.dot(m_normal_to_detector) * m_normal_to_detector; diff --git a/Device/Detector/RectangularDetector.h b/Device/Detector/RectangularDetector.h index 0b76af44ab66409629aa80128c9d96c155548c28..cb66caae9a9a1f617a41b6b6e137078d32162200 100644 --- a/Device/Detector/RectangularDetector.h +++ b/Device/Detector/RectangularDetector.h @@ -23,8 +23,7 @@ class RectangularPixel; //! A flat rectangular detector with axes and resolution function. //! @ingroup detector -class RectangularDetector : public IDetector2D -{ +class RectangularDetector : public IDetector2D { public: enum EDetectorArrangement { GENERIC, diff --git a/Device/Detector/RectangularPixel.cpp b/Device/Detector/RectangularPixel.cpp index 09838042f578b73ea2aa5245097e78f6b30a6644..6af9140f02010a323cfcae1f9f1c86b1afa0c5cc 100644 --- a/Device/Detector/RectangularPixel.cpp +++ b/Device/Detector/RectangularPixel.cpp @@ -20,37 +20,31 @@ RectangularPixel::RectangularPixel(const kvector_t& corner_pos, const kvector_t& : m_corner_pos(std::move(corner_pos)) , m_width(std::move(width)) , m_height(std::move(height)) - , m_normal(width.cross(height)) -{ + , m_normal(width.cross(height)) { // TODO URGENT: why allow solid angle <=0 ?? auto solid_angle_value = calculateSolidAngle(); m_solid_angle = solid_angle_value <= 0.0 ? 1.0 : solid_angle_value; } -RectangularPixel* RectangularPixel::clone() const -{ +RectangularPixel* RectangularPixel::clone() const { return new RectangularPixel(m_corner_pos, m_width, m_height); } -RectangularPixel* RectangularPixel::createZeroSizePixel(double x, double y) const -{ +RectangularPixel* RectangularPixel::createZeroSizePixel(double x, double y) const { return new RectangularPixel(getPosition(x, y), kvector_t(), kvector_t()); } -kvector_t RectangularPixel::getK(double x, double y, double wavelength) const -{ +kvector_t RectangularPixel::getK(double x, double y, double wavelength) const { kvector_t direction = getPosition(x, y); double length = M_TWOPI / wavelength; return normalizeLength(direction, length); } -kvector_t RectangularPixel::getPosition(double x, double y) const -{ +kvector_t RectangularPixel::getPosition(double x, double y) const { return m_corner_pos + x * m_width + y * m_height; } -double RectangularPixel::integrationFactor(double x, double y) const -{ +double RectangularPixel::integrationFactor(double x, double y) const { if (m_solid_angle == 0.0) return 1.0; kvector_t position = getPosition(x, y); @@ -58,18 +52,15 @@ double RectangularPixel::integrationFactor(double x, double y) const return std::abs(position.dot(m_normal)) / std::pow(length, 3) / m_solid_angle; } -double RectangularPixel::solidAngle() const -{ +double RectangularPixel::solidAngle() const { return m_solid_angle; } -kvector_t RectangularPixel::normalizeLength(const kvector_t direction, double length) const -{ +kvector_t RectangularPixel::normalizeLength(const kvector_t direction, double length) const { return direction.unit() * length; } -double RectangularPixel::calculateSolidAngle() const -{ +double RectangularPixel::calculateSolidAngle() const { kvector_t position = getPosition(0.5, 0.5); double length = position.mag(); return std::abs(position.dot(m_normal)) / std::pow(length, 3); diff --git a/Device/Detector/RectangularPixel.h b/Device/Detector/RectangularPixel.h index 759d74893d1aeb28248a64e4ada2c7dfeb1bce3f..7b87cb051aee0fb7c4905081508d122cbc103a03 100644 --- a/Device/Detector/RectangularPixel.h +++ b/Device/Detector/RectangularPixel.h @@ -19,8 +19,7 @@ //! A pixel in a RectangularDetector. -class RectangularPixel : public IPixel -{ +class RectangularPixel : public IPixel { public: RectangularPixel(const kvector_t& corner_pos, const kvector_t& width, const kvector_t& height); diff --git a/Device/Detector/RegionOfInterest.cpp b/Device/Detector/RegionOfInterest.cpp index 47ae5e46915a26ce5f51c7a4451caac503b50c27..3929ad4e9177d24de5a980a803ae1cb7fb10be2f 100644 --- a/Device/Detector/RegionOfInterest.cpp +++ b/Device/Detector/RegionOfInterest.cpp @@ -18,15 +18,13 @@ RegionOfInterest::RegionOfInterest(const IDetector2D& detector, double xlow, double ylow, double xup, double yup) - : RegionOfInterest(xlow, ylow, xup, yup) -{ + : RegionOfInterest(xlow, ylow, xup, yup) { initFrom(detector.axis(0), detector.axis(1)); } RegionOfInterest::RegionOfInterest(const OutputData<double>& data, double xlow, double ylow, double xup, double yup) - : RegionOfInterest(xlow, ylow, xup, yup) -{ + : RegionOfInterest(xlow, ylow, xup, yup) { if (data.rank() != 2) throw Exceptions::RuntimeErrorException("RegionOfInterest::RegionOfInterest() -> Error. " "Data is not two-dimensional."); @@ -40,12 +38,9 @@ RegionOfInterest::RegionOfInterest(double xlow, double ylow, double xup, double , m_ay1(0) , m_ax2(0) , m_ay2(0) - , m_glob_index0(0) -{ -} + , m_glob_index0(0) {} -RegionOfInterest* RegionOfInterest::clone() const -{ +RegionOfInterest* RegionOfInterest::clone() const { return new RegionOfInterest(*this); } @@ -60,38 +55,30 @@ RegionOfInterest::RegionOfInterest(const RegionOfInterest& other) , m_ay2(other.m_ay2) , m_glob_index0(other.m_glob_index0) , m_detector_dims(other.m_detector_dims) - , m_roi_dims(other.m_roi_dims) -{ -} + , m_roi_dims(other.m_roi_dims) {} -double RegionOfInterest::getXlow() const -{ +double RegionOfInterest::getXlow() const { return m_rectangle->getXlow(); } -double RegionOfInterest::getYlow() const -{ +double RegionOfInterest::getYlow() const { return m_rectangle->getYlow(); } -double RegionOfInterest::getXup() const -{ +double RegionOfInterest::getXup() const { return m_rectangle->getXup(); } -double RegionOfInterest::getYup() const -{ +double RegionOfInterest::getYup() const { return m_rectangle->getYup(); } -size_t RegionOfInterest::detectorIndex(size_t roiIndex) const -{ +size_t RegionOfInterest::detectorIndex(size_t roiIndex) const { return m_glob_index0 + ycoord(roiIndex, m_roi_dims) + xcoord(roiIndex, m_roi_dims) * m_detector_dims[1]; } -size_t RegionOfInterest::roiIndex(size_t globalIndex) const -{ +size_t RegionOfInterest::roiIndex(size_t globalIndex) const { size_t ny = ycoord(globalIndex, m_detector_dims); if (ny < m_ay1 || ny > m_ay2) throw Exceptions::RuntimeErrorException("RegionOfInterest::roiIndex() -> Error."); @@ -103,18 +90,15 @@ size_t RegionOfInterest::roiIndex(size_t globalIndex) const return ny - m_ay1 + (nx - m_ax1) * m_roi_dims[1]; } -size_t RegionOfInterest::roiSize() const -{ +size_t RegionOfInterest::roiSize() const { return m_roi_dims[0] * m_roi_dims[1]; } -size_t RegionOfInterest::detectorSize() const -{ +size_t RegionOfInterest::detectorSize() const { return m_detector_dims[0] * m_detector_dims[1]; } -bool RegionOfInterest::isInROI(size_t detectorIndex) const -{ +bool RegionOfInterest::isInROI(size_t detectorIndex) const { size_t ny = ycoord(detectorIndex, m_detector_dims); if (ny < m_ay1 || ny > m_ay2) return false; @@ -124,16 +108,14 @@ bool RegionOfInterest::isInROI(size_t detectorIndex) const return true; } -std::unique_ptr<IAxis> RegionOfInterest::clipAxisToRoi(size_t axis_index, const IAxis& axis) const -{ +std::unique_ptr<IAxis> RegionOfInterest::clipAxisToRoi(size_t axis_index, const IAxis& axis) const { size_t nbin1 = (axis_index == 0 ? m_ax1 : m_ay1); size_t nbin2 = (axis_index == 0 ? m_ax2 : m_ay2); return std::unique_ptr<IAxis>(new FixedBinAxis( axis.getName(), nbin2 - nbin1 + 1, axis.bin(nbin1).m_lower, axis.bin(nbin2).m_upper)); } -void RegionOfInterest::initFrom(const IAxis& x_axis, const IAxis& y_axis) -{ +void RegionOfInterest::initFrom(const IAxis& x_axis, const IAxis& y_axis) { m_detector_dims.push_back(x_axis.size()); m_detector_dims.push_back(y_axis.size()); diff --git a/Device/Detector/RegionOfInterest.h b/Device/Detector/RegionOfInterest.h index b5ed09d9079f02ec494f03ccf4ab089ed2fd3e44..f5e00d9932bdf84db5a2b3362d29d1f7da417ed9 100644 --- a/Device/Detector/RegionOfInterest.h +++ b/Device/Detector/RegionOfInterest.h @@ -27,8 +27,7 @@ template <class T> class OutputData; //! Defines rectangular area for the detector which will be simulated/fitted. //! @ingroup detector -class RegionOfInterest : public ICloneable -{ +class RegionOfInterest : public ICloneable { public: RegionOfInterest(const IDetector2D& detector, double xlow, double ylow, double xup, double yup); RegionOfInterest(const OutputData<double>& data, double xlow, double ylow, double xup, @@ -77,13 +76,11 @@ private: std::vector<size_t> m_roi_dims; }; -inline size_t RegionOfInterest::xcoord(size_t index, const std::vector<size_t>& dims) const -{ +inline size_t RegionOfInterest::xcoord(size_t index, const std::vector<size_t>& dims) const { return index / dims[1] % dims[0]; } -inline size_t RegionOfInterest::ycoord(size_t index, const std::vector<size_t>& dims) const -{ +inline size_t RegionOfInterest::ycoord(size_t index, const std::vector<size_t>& dims) const { return index % dims[1]; } diff --git a/Device/Detector/SimpleUnitConverters.cpp b/Device/Detector/SimpleUnitConverters.cpp index 64a119897e63fe56baac50fe17d935d93dc15a67..5b4b480d5f9cacc05b2fcd1c33e9d6327d1de616 100644 --- a/Device/Detector/SimpleUnitConverters.cpp +++ b/Device/Detector/SimpleUnitConverters.cpp @@ -25,10 +25,8 @@ #include <cmath> #include <stdexcept> -namespace -{ -double getQ(double wavelength, double angle) -{ +namespace { +double getQ(double wavelength, double angle) { return 4.0 * M_PI * std::sin(angle) / wavelength; } } // namespace @@ -38,24 +36,19 @@ double getQ(double wavelength, double angle) // ************************************************************************************************ UnitConverterSimple::UnitConverterSimple(const Beam& beam) - : m_wavelength(beam.getWavelength()), m_alpha_i(-beam.getAlpha()), m_phi_i(beam.getPhi()) -{ -} + : m_wavelength(beam.getWavelength()), m_alpha_i(-beam.getAlpha()), m_phi_i(beam.getPhi()) {} -size_t UnitConverterSimple::dimension() const -{ +size_t UnitConverterSimple::dimension() const { return m_axis_data_table.size(); } void UnitConverterSimple::addAxisData(std::string name, double min, double max, - Axes::Units default_units, size_t nbins) -{ + Axes::Units default_units, size_t nbins) { AxisData axis_data{name, min, max, default_units, nbins}; m_axis_data_table.push_back(axis_data); } -double UnitConverterSimple::calculateMin(size_t i_axis, Axes::Units units_type) const -{ +double UnitConverterSimple::calculateMin(size_t i_axis, Axes::Units units_type) const { checkIndex(i_axis); units_type = substituteDefaultUnits(units_type); const auto& axis_data = m_axis_data_table[i_axis]; @@ -64,8 +57,7 @@ double UnitConverterSimple::calculateMin(size_t i_axis, Axes::Units units_type) return calculateValue(i_axis, units_type, axis_data.min); } -double UnitConverterSimple::calculateMax(size_t i_axis, Axes::Units units_type) const -{ +double UnitConverterSimple::calculateMax(size_t i_axis, Axes::Units units_type) const { checkIndex(i_axis); units_type = substituteDefaultUnits(units_type); const auto& axis_data = m_axis_data_table[i_axis]; @@ -74,20 +66,17 @@ double UnitConverterSimple::calculateMax(size_t i_axis, Axes::Units units_type) return calculateValue(i_axis, units_type, axis_data.max); } -size_t UnitConverterSimple::axisSize(size_t i_axis) const -{ +size_t UnitConverterSimple::axisSize(size_t i_axis) const { checkIndex(i_axis); return m_axis_data_table[i_axis].nbins; } -std::vector<Axes::Units> UnitConverterSimple::availableUnits() const -{ +std::vector<Axes::Units> UnitConverterSimple::availableUnits() const { return {Axes::Units::NBINS, Axes::Units::RADIANS, Axes::Units::DEGREES}; } std::unique_ptr<IAxis> UnitConverterSimple::createConvertedAxis(size_t i_axis, - Axes::Units units) const -{ + Axes::Units units) const { const double min = calculateMin(i_axis, units); const double max = calculateMax(i_axis, units); const auto& axis_name = axisName(i_axis, units); @@ -99,12 +88,9 @@ UnitConverterSimple::UnitConverterSimple(const UnitConverterSimple& other) : m_axis_data_table(other.m_axis_data_table) , m_wavelength(other.m_wavelength) , m_alpha_i(other.m_alpha_i) - , m_phi_i(other.m_phi_i) -{ -} + , m_phi_i(other.m_phi_i) {} -void UnitConverterSimple::addDetectorAxis(const IDetector& detector, size_t i_axis) -{ +void UnitConverterSimple::addDetectorAxis(const IDetector& detector, size_t i_axis) { const auto& axis = detector.axis(i_axis); const auto* p_roi = detector.regionOfInterest(); const auto& axis_name = axisName(i_axis); @@ -122,8 +108,7 @@ void UnitConverterSimple::addDetectorAxis(const IDetector& detector, size_t i_ax // ************************************************************************************************ SphericalConverter::SphericalConverter(const SphericalDetector& detector, const Beam& beam) - : UnitConverterSimple(beam) -{ + : UnitConverterSimple(beam) { if (detector.dimension() != 2) throw std::runtime_error("Error in SphericalConverter constructor: " "detector has wrong dimension: " @@ -134,29 +119,25 @@ SphericalConverter::SphericalConverter(const SphericalDetector& detector, const SphericalConverter::~SphericalConverter() = default; -SphericalConverter* SphericalConverter::clone() const -{ +SphericalConverter* SphericalConverter::clone() const { return new SphericalConverter(*this); } -std::vector<Axes::Units> SphericalConverter::availableUnits() const -{ +std::vector<Axes::Units> SphericalConverter::availableUnits() const { auto result = UnitConverterSimple::availableUnits(); result.push_back(Axes::Units::QSPACE); return result; } -Axes::Units SphericalConverter::defaultUnits() const -{ +Axes::Units SphericalConverter::defaultUnits() const { return Axes::Units::DEGREES; } -SphericalConverter::SphericalConverter(const SphericalConverter& other) : UnitConverterSimple(other) -{ -} +SphericalConverter::SphericalConverter(const SphericalConverter& other) + : UnitConverterSimple(other) {} -double SphericalConverter::calculateValue(size_t i_axis, Axes::Units units_type, double value) const -{ +double SphericalConverter::calculateValue(size_t i_axis, Axes::Units units_type, + double value) const { switch (units_type) { case Axes::Units::RADIANS: return value; @@ -193,8 +174,7 @@ double SphericalConverter::calculateValue(size_t i_axis, Axes::Units units_type, } } -std::vector<std::map<Axes::Units, std::string>> SphericalConverter::createNameMaps() const -{ +std::vector<std::map<Axes::Units, std::string>> SphericalConverter::createNameMaps() const { std::vector<std::map<Axes::Units, std::string>> result; result.push_back(AxisNames::InitSphericalAxis0()); result.push_back(AxisNames::InitSphericalAxis1()); @@ -206,8 +186,7 @@ std::vector<std::map<Axes::Units, std::string>> SphericalConverter::createNameMa // ************************************************************************************************ RectangularConverter::RectangularConverter(const RectangularDetector& detector, const Beam& beam) - : UnitConverterSimple(beam) -{ + : UnitConverterSimple(beam) { if (detector.dimension() != 2) throw std::runtime_error("Error in RectangularConverter constructor: " "detector has wrong dimension: " @@ -219,32 +198,26 @@ RectangularConverter::RectangularConverter(const RectangularDetector& detector, RectangularConverter::~RectangularConverter() = default; -RectangularConverter* RectangularConverter::clone() const -{ +RectangularConverter* RectangularConverter::clone() const { return new RectangularConverter(*this); } -std::vector<Axes::Units> RectangularConverter::availableUnits() const -{ +std::vector<Axes::Units> RectangularConverter::availableUnits() const { auto result = UnitConverterSimple::availableUnits(); result.push_back(Axes::Units::QSPACE); result.push_back(Axes::Units::MM); return result; } -Axes::Units RectangularConverter::defaultUnits() const -{ +Axes::Units RectangularConverter::defaultUnits() const { return Axes::Units::MM; } RectangularConverter::RectangularConverter(const RectangularConverter& other) - : UnitConverterSimple(other), m_detector_pixel(other.m_detector_pixel->clone()) -{ -} + : UnitConverterSimple(other), m_detector_pixel(other.m_detector_pixel->clone()) {} double RectangularConverter::calculateValue(size_t i_axis, Axes::Units units_type, - double value) const -{ + double value) const { if (units_type == Axes::Units::MM) return value; const auto k00 = m_detector_pixel->getPosition(0.0, 0.0); @@ -283,16 +256,14 @@ double RectangularConverter::calculateValue(size_t i_axis, Axes::Units units_typ } } -std::vector<std::map<Axes::Units, std::string>> RectangularConverter::createNameMaps() const -{ +std::vector<std::map<Axes::Units, std::string>> RectangularConverter::createNameMaps() const { std::vector<std::map<Axes::Units, std::string>> result; result.push_back(AxisNames::InitRectangularAxis0()); result.push_back(AxisNames::InitRectangularAxis1()); return result; } -kvector_t RectangularConverter::normalizeToWavelength(kvector_t vector) const -{ +kvector_t RectangularConverter::normalizeToWavelength(kvector_t vector) const { if (m_wavelength <= 0.0) throw std::runtime_error("Error in RectangularConverter::normalizeToWavelength: " "wavelength <= 0"); @@ -300,8 +271,7 @@ kvector_t RectangularConverter::normalizeToWavelength(kvector_t vector) const return vector.unit() * K; } -double RectangularConverter::axisAngle(size_t i_axis, kvector_t k_f) const -{ +double RectangularConverter::axisAngle(size_t i_axis, kvector_t k_f) const { if (i_axis == 0) return k_f.phi(); if (i_axis == 1) @@ -317,8 +287,7 @@ double RectangularConverter::axisAngle(size_t i_axis, kvector_t k_f) const OffSpecularConverter::OffSpecularConverter(const IDetector2D& detector, const Beam& beam, const IAxis& alpha_axis) - : UnitConverterSimple(beam) -{ + : UnitConverterSimple(beam) { if (detector.dimension() != 2) throw std::runtime_error("Error in OffSpecularConverter constructor: " "detector has wrong dimension: " @@ -330,23 +299,18 @@ OffSpecularConverter::OffSpecularConverter(const IDetector2D& detector, const Be OffSpecularConverter::~OffSpecularConverter() = default; -OffSpecularConverter* OffSpecularConverter::clone() const -{ +OffSpecularConverter* OffSpecularConverter::clone() const { return new OffSpecularConverter(*this); } -Axes::Units OffSpecularConverter::defaultUnits() const -{ +Axes::Units OffSpecularConverter::defaultUnits() const { return Axes::Units::DEGREES; } OffSpecularConverter::OffSpecularConverter(const OffSpecularConverter& other) - : UnitConverterSimple(other) -{ -} + : UnitConverterSimple(other) {} -double OffSpecularConverter::calculateValue(size_t, Axes::Units units_type, double value) const -{ +double OffSpecularConverter::calculateValue(size_t, Axes::Units units_type, double value) const { switch (units_type) { case Axes::Units::RADIANS: return value; @@ -357,16 +321,14 @@ double OffSpecularConverter::calculateValue(size_t, Axes::Units units_type, doub } } -std::vector<std::map<Axes::Units, std::string>> OffSpecularConverter::createNameMaps() const -{ +std::vector<std::map<Axes::Units, std::string>> OffSpecularConverter::createNameMaps() const { std::vector<std::map<Axes::Units, std::string>> result; result.push_back(AxisNames::InitOffSpecAxis0()); result.push_back(AxisNames::InitOffSpecAxis1()); return result; } -void OffSpecularConverter::addDetectorYAxis(const IDetector2D& detector) -{ +void OffSpecularConverter::addDetectorYAxis(const IDetector2D& detector) { const auto& axis = detector.axis(1); const auto* p_roi = detector.regionOfInterest(); const auto& axis_name = axisName(1); @@ -404,8 +366,7 @@ const std::string z_axis_name = "Position [nm]"; DepthProbeConverter::DepthProbeConverter(const Beam& beam, const IAxis& alpha_axis, const IAxis& z_axis) - : UnitConverterSimple(beam) -{ + : UnitConverterSimple(beam) { const auto& alpha_axis_name = axisName(0); const auto& z_axis_name = axisName(1); addAxisData(alpha_axis_name, alpha_axis.lowerBound(), alpha_axis.upperBound(), defaultUnits(), @@ -416,26 +377,21 @@ DepthProbeConverter::DepthProbeConverter(const Beam& beam, const IAxis& alpha_ax DepthProbeConverter::~DepthProbeConverter() = default; -DepthProbeConverter* DepthProbeConverter::clone() const -{ +DepthProbeConverter* DepthProbeConverter::clone() const { return new DepthProbeConverter(*this); } -std::vector<Axes::Units> DepthProbeConverter::availableUnits() const -{ +std::vector<Axes::Units> DepthProbeConverter::availableUnits() const { auto result = UnitConverterSimple::availableUnits(); result.push_back(Axes::Units::QSPACE); return result; } DepthProbeConverter::DepthProbeConverter(const DepthProbeConverter& other) - : UnitConverterSimple(other) -{ -} + : UnitConverterSimple(other) {} double DepthProbeConverter::calculateValue(size_t i_axis, Axes::Units units_type, - double value) const -{ + double value) const { checkUnits(units_type); if (i_axis == 1) return value; // unit conversions are not applied to sample position axis @@ -449,16 +405,14 @@ double DepthProbeConverter::calculateValue(size_t i_axis, Axes::Units units_type } } -std::vector<std::map<Axes::Units, std::string>> DepthProbeConverter::createNameMaps() const -{ +std::vector<std::map<Axes::Units, std::string>> DepthProbeConverter::createNameMaps() const { std::vector<std::map<Axes::Units, std::string>> result; result.push_back(AxisNames::InitSpecAxis()); result.push_back(AxisNames::InitSampleDepthAxis()); return result; } -void DepthProbeConverter::checkUnits(Axes::Units units_type) const -{ +void DepthProbeConverter::checkUnits(Axes::Units units_type) const { const auto& available_units = availableUnits(); if (std::find(available_units.begin(), available_units.end(), units_type) == available_units.cend()) diff --git a/Device/Detector/SimpleUnitConverters.h b/Device/Detector/SimpleUnitConverters.h index c345f7d23c24d00ebcaa383ad4dfb2cfd6347a9b..491db8a1f166b4d9a0098ffab572be81ff14efff 100644 --- a/Device/Detector/SimpleUnitConverters.h +++ b/Device/Detector/SimpleUnitConverters.h @@ -28,8 +28,7 @@ class SphericalDetector; //! Interface for objects that provide axis translations to different units for IDetector objects //! @ingroup simulation_internal -class UnitConverterSimple : public IUnitConverter -{ +class UnitConverterSimple : public IUnitConverter { public: UnitConverterSimple(const Beam& beam); ~UnitConverterSimple() override = default; @@ -73,8 +72,7 @@ private: //! Its default units are radians for both axes //! @ingroup simulation_internal -class SphericalConverter : public UnitConverterSimple -{ +class SphericalConverter : public UnitConverterSimple { public: SphericalConverter(const SphericalDetector& detector, const Beam& beam); @@ -97,8 +95,7 @@ private: //! Its default units are mm for both axes //! @ingroup simulation_internal -class RectangularConverter : public UnitConverterSimple -{ +class RectangularConverter : public UnitConverterSimple { public: RectangularConverter(const RectangularDetector& detector, const Beam& beam); ~RectangularConverter() override; @@ -124,8 +121,7 @@ private: //! Its default units are radians for both axes //! @ingroup simulation_internal -class OffSpecularConverter : public UnitConverterSimple -{ +class OffSpecularConverter : public UnitConverterSimple { public: OffSpecularConverter(const IDetector2D& detector, const Beam& beam, const IAxis& alpha_axis); ~OffSpecularConverter() override; @@ -145,8 +141,7 @@ private: //! Its default units are radians for x-axis and nm for y-axis //! @ingroup simulation_internal -class DepthProbeConverter : public UnitConverterSimple -{ +class DepthProbeConverter : public UnitConverterSimple { public: DepthProbeConverter(const Beam& beam, const IAxis& alpha_axis, const IAxis& z_axis); ~DepthProbeConverter() override; diff --git a/Device/Detector/SimulationArea.cpp b/Device/Detector/SimulationArea.cpp index 5b0e09115790f5c8881aae4242ce12396e3e2567..80769155880390eb172a62ae50b08d84ed688c7e 100644 --- a/Device/Detector/SimulationArea.cpp +++ b/Device/Detector/SimulationArea.cpp @@ -19,8 +19,7 @@ #include "Device/Mask/Rectangle.h" #include <sstream> -SimulationArea::SimulationArea(const IDetector* detector) : m_detector(detector), m_max_index(0) -{ +SimulationArea::SimulationArea(const IDetector* detector) : m_detector(detector), m_max_index(0) { if (m_detector == nullptr) throw std::runtime_error("SimulationArea::SimulationArea: null pointer passed" " as detector"); @@ -35,29 +34,24 @@ SimulationArea::SimulationArea(const IDetector* detector) : m_detector(detector) m_max_index = m_detector->totalSize(); } -SimulationAreaIterator SimulationArea::begin() -{ +SimulationAreaIterator SimulationArea::begin() { return SimulationAreaIterator(this, 0); } -SimulationAreaIterator SimulationArea::end() -{ +SimulationAreaIterator SimulationArea::end() { return SimulationAreaIterator(this, totalSize()); } -bool SimulationArea::isMasked(size_t index) const -{ +bool SimulationArea::isMasked(size_t index) const { auto masks = m_detector->detectorMask(); return (masks && masks->hasMasks() && masks->isMasked(detectorIndex(index))); } -size_t SimulationArea::roiIndex(size_t index) const -{ +size_t SimulationArea::roiIndex(size_t index) const { return index; } -size_t SimulationArea::detectorIndex(size_t index) const -{ +size_t SimulationArea::detectorIndex(size_t index) const { if (!m_detector->regionOfInterest()) return index; @@ -68,7 +62,6 @@ size_t SimulationArea::detectorIndex(size_t index) const SimulationRoiArea::SimulationRoiArea(const IDetector* detector) : SimulationArea(detector) {} -bool SimulationRoiArea::isMasked(size_t) const -{ +bool SimulationRoiArea::isMasked(size_t) const { return false; } diff --git a/Device/Detector/SimulationArea.h b/Device/Detector/SimulationArea.h index 06e223ce6dcc9c0b79ed7058349cdfb0e412d1b6..bf79efa44159484064b394b963874d2c0c066a85 100644 --- a/Device/Detector/SimulationArea.h +++ b/Device/Detector/SimulationArea.h @@ -23,8 +23,7 @@ class IDetector; //! and RegionOfInterest defined. //! @ingroup detector -class SimulationArea -{ +class SimulationArea { public: using iterator = SimulationAreaIterator; explicit SimulationArea(const IDetector* detector); @@ -49,8 +48,7 @@ protected: size_t m_max_index; }; -inline size_t SimulationArea::totalSize() const -{ +inline size_t SimulationArea::totalSize() const { return m_max_index; } @@ -58,8 +56,7 @@ inline size_t SimulationArea::totalSize() const //! to SimulationArea class, iterates also over masked areas. //! @ingroup detector -class SimulationRoiArea : public SimulationArea -{ +class SimulationRoiArea : public SimulationArea { public: explicit SimulationRoiArea(const IDetector* detector); diff --git a/Device/Detector/SimulationAreaIterator.cpp b/Device/Detector/SimulationAreaIterator.cpp index 52f27a009c64d019f5cb34b0e8dc6923dc7d2935..24f6f818291c0e45271b19981fc0779745a6f032 100644 --- a/Device/Detector/SimulationAreaIterator.cpp +++ b/Device/Detector/SimulationAreaIterator.cpp @@ -16,8 +16,7 @@ #include "Device/Detector/SimulationArea.h" SimulationAreaIterator::SimulationAreaIterator(const SimulationArea* area, size_t start_at_index) - : m_area(area), m_index(start_at_index), m_element_index(0) -{ + : m_area(area), m_index(start_at_index), m_element_index(0) { if (m_index > m_area->totalSize()) throw Exceptions::RuntimeErrorException("SimulationAreaIterator::SimulationAreaIterator() " "-> Error. Invalid initial index"); @@ -26,18 +25,15 @@ SimulationAreaIterator::SimulationAreaIterator(const SimulationArea* area, size_ m_index = nextIndex(m_index); } -size_t SimulationAreaIterator::roiIndex() const -{ +size_t SimulationAreaIterator::roiIndex() const { return m_area->roiIndex(m_index); } -size_t SimulationAreaIterator::detectorIndex() const -{ +size_t SimulationAreaIterator::detectorIndex() const { return m_area->detectorIndex(m_index); } -SimulationAreaIterator& SimulationAreaIterator::operator++() -{ +SimulationAreaIterator& SimulationAreaIterator::operator++() { size_t index = nextIndex(m_index); if (index != m_index) { ++m_element_index; @@ -46,15 +42,13 @@ SimulationAreaIterator& SimulationAreaIterator::operator++() return *this; } -SimulationAreaIterator SimulationAreaIterator::operator++(int) -{ +SimulationAreaIterator SimulationAreaIterator::operator++(int) { SimulationAreaIterator result(*this); this->operator++(); return result; } -size_t SimulationAreaIterator::nextIndex(size_t currentIndex) -{ +size_t SimulationAreaIterator::nextIndex(size_t currentIndex) { size_t result = ++currentIndex; if (result < m_area->totalSize()) { while (m_area->isMasked(result)) { diff --git a/Device/Detector/SimulationAreaIterator.h b/Device/Detector/SimulationAreaIterator.h index 6d8877fe2ae79a2cc5e0aa947620f97154059a0f..2bfbb0c75f5fb6eff55147b81c98db651f769114 100644 --- a/Device/Detector/SimulationAreaIterator.h +++ b/Device/Detector/SimulationAreaIterator.h @@ -21,8 +21,7 @@ class SimulationArea; //! An iterator for SimulationArea. //! @ingroup detector -class SimulationAreaIterator -{ +class SimulationAreaIterator { public: explicit SimulationAreaIterator(const SimulationArea* area, size_t start_at_index); @@ -47,13 +46,11 @@ private: size_t m_element_index; //!< sequential number for SimulationElementVector }; -inline bool SimulationAreaIterator::operator==(const SimulationAreaIterator& other) const -{ +inline bool SimulationAreaIterator::operator==(const SimulationAreaIterator& other) const { return m_area == other.m_area && m_index == other.m_index; } -inline bool SimulationAreaIterator::operator!=(const SimulationAreaIterator& right) const -{ +inline bool SimulationAreaIterator::operator!=(const SimulationAreaIterator& right) const { return !(*this == right); } diff --git a/Device/Detector/SpecularDetector1D.cpp b/Device/Detector/SpecularDetector1D.cpp index f51582b86653e5b64f475ba2965379e8646208c5..47b1fa37bdaa8c21dca2e2a47f4185c3d2e6eec5 100644 --- a/Device/Detector/SpecularDetector1D.cpp +++ b/Device/Detector/SpecularDetector1D.cpp @@ -14,31 +14,26 @@ #include "Device/Detector/SpecularDetector1D.h" -SpecularDetector1D::SpecularDetector1D(const IAxis& axis) -{ +SpecularDetector1D::SpecularDetector1D(const IAxis& axis) { initialize(); addAxis(axis); } -SpecularDetector1D::SpecularDetector1D(const SpecularDetector1D& detector) : IDetector(detector) -{ +SpecularDetector1D::SpecularDetector1D(const SpecularDetector1D& detector) : IDetector(detector) { initialize(); } SpecularDetector1D::~SpecularDetector1D() = default; -SpecularDetector1D* SpecularDetector1D::clone() const -{ +SpecularDetector1D* SpecularDetector1D::clone() const { return new SpecularDetector1D(*this); } -Axes::Units SpecularDetector1D::defaultAxesUnits() const -{ +Axes::Units SpecularDetector1D::defaultAxesUnits() const { return Axes::Units::RADIANS; } -std::string SpecularDetector1D::axisName(size_t index) const -{ +std::string SpecularDetector1D::axisName(size_t index) const { if (index == 0) { return "u"; } else @@ -46,7 +41,6 @@ std::string SpecularDetector1D::axisName(size_t index) const "SpecularDetector1D::getAxisName(size_t index) -> Error! index > 0"); } -void SpecularDetector1D::initialize() -{ +void SpecularDetector1D::initialize() { setName("SpecularDetector1D"); } diff --git a/Device/Detector/SpecularDetector1D.h b/Device/Detector/SpecularDetector1D.h index ba42dd125dc487afb78c5ea6aabd9d0b294e09f7..49d21651cf550147e513f84b0f4602bef64d48e2 100644 --- a/Device/Detector/SpecularDetector1D.h +++ b/Device/Detector/SpecularDetector1D.h @@ -22,8 +22,7 @@ class SpecularSimulationElement; //! 1D detector for specular simulations. Use of this detector is deprecated. //! @ingroup detector -class SpecularDetector1D : public IDetector -{ +class SpecularDetector1D : public IDetector { public: SpecularDetector1D(const IAxis& axis); virtual ~SpecularDetector1D(); diff --git a/Device/Detector/SphericalDetector.cpp b/Device/Detector/SphericalDetector.cpp index 6e595ee06c650cd7ae66a6469eb860ee4b3b45c1..eab85862c54afb03e386703e076877fffe933bb2 100644 --- a/Device/Detector/SphericalDetector.cpp +++ b/Device/Detector/SphericalDetector.cpp @@ -20,35 +20,29 @@ #include "Device/Detector/SphericalPixel.h" #include "Device/Resolution/IDetectorResolution.h" -SphericalDetector::SphericalDetector() -{ +SphericalDetector::SphericalDetector() { setName("SphericalDetector"); } SphericalDetector::SphericalDetector(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, - double alpha_min, double alpha_max) -{ + double alpha_min, double alpha_max) { setName("SphericalDetector"); setDetectorParameters(n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max); } -SphericalDetector::SphericalDetector(const SphericalDetector& other) : IDetector2D(other) -{ +SphericalDetector::SphericalDetector(const SphericalDetector& other) : IDetector2D(other) { setName("SphericalDetector"); } -SphericalDetector* SphericalDetector::clone() const -{ +SphericalDetector* SphericalDetector::clone() const { return new SphericalDetector(*this); } -Axes::Units SphericalDetector::defaultAxesUnits() const -{ +Axes::Units SphericalDetector::defaultAxesUnits() const { return Axes::Units::RADIANS; } -IPixel* SphericalDetector::createPixel(size_t index) const -{ +IPixel* SphericalDetector::createPixel(size_t index) const { const IAxis& phi_axis = axis(0); const IAxis& alpha_axis = axis(1); const size_t phi_index = axisBinIndex(index, 0); @@ -59,8 +53,7 @@ IPixel* SphericalDetector::createPixel(size_t index) const return new SphericalPixel(alpha_bin, phi_bin); } -std::string SphericalDetector::axisName(size_t index) const -{ +std::string SphericalDetector::axisName(size_t index) const { switch (index) { case 0: return "phi_f"; @@ -72,8 +65,7 @@ std::string SphericalDetector::axisName(size_t index) const } } -size_t SphericalDetector::indexOfSpecular(const Beam& beam) const -{ +size_t SphericalDetector::indexOfSpecular(const Beam& beam) const { if (dimension() != 2) return totalSize(); double alpha = beam.getAlpha(); diff --git a/Device/Detector/SphericalDetector.h b/Device/Detector/SphericalDetector.h index 35827ca50bd54a3be4115c167ad84b4dd880625e..256034574065c3d87fd621092b07975731e226e8 100644 --- a/Device/Detector/SphericalDetector.h +++ b/Device/Detector/SphericalDetector.h @@ -23,8 +23,7 @@ class SphericalPixel; //! A spherical detector with axes and resolution function. //! @ingroup detector -class SphericalDetector : public IDetector2D -{ +class SphericalDetector : public IDetector2D { public: SphericalDetector(); diff --git a/Device/Detector/SphericalPixel.cpp b/Device/Detector/SphericalPixel.cpp index ca85aff2b5fc5a36c71d9f2d60ded3b8e3b99adb..8768aad62646ae654f476b811822e5f98bf2b9fb 100644 --- a/Device/Detector/SphericalPixel.cpp +++ b/Device/Detector/SphericalPixel.cpp @@ -19,19 +19,16 @@ SphericalPixel::SphericalPixel(const Bin1D& alpha_bin, const Bin1D& phi_bin) : m_alpha(alpha_bin.m_lower) , m_phi(phi_bin.m_lower) , m_dalpha(alpha_bin.binSize()) - , m_dphi(phi_bin.binSize()) -{ + , m_dphi(phi_bin.binSize()) { auto solid_angle_value = std::abs(m_dphi * (std::sin(m_alpha + m_dalpha) - std::sin(m_alpha))); m_solid_angle = solid_angle_value <= 0.0 ? 1.0 : solid_angle_value; } -SphericalPixel* SphericalPixel::clone() const -{ +SphericalPixel* SphericalPixel::clone() const { return new SphericalPixel(*this); } -SphericalPixel* SphericalPixel::createZeroSizePixel(double x, double y) const -{ +SphericalPixel* SphericalPixel::createZeroSizePixel(double x, double y) const { double phi = m_phi + x * m_dphi; double alpha = m_alpha + y * m_dalpha; Bin1D alpha_bin(alpha, alpha); @@ -39,22 +36,19 @@ SphericalPixel* SphericalPixel::createZeroSizePixel(double x, double y) const return new SphericalPixel(alpha_bin, phi_bin); } -kvector_t SphericalPixel::getK(double x, double y, double wavelength) const -{ +kvector_t SphericalPixel::getK(double x, double y, double wavelength) const { double phi = m_phi + x * m_dphi; double alpha = m_alpha + y * m_dalpha; return vecOfLambdaAlphaPhi(wavelength, alpha, phi); } -double SphericalPixel::integrationFactor(double /* x */, double y) const -{ +double SphericalPixel::integrationFactor(double /* x */, double y) const { if (m_dalpha == 0.0) return 1.0; double alpha = m_alpha + y * m_dalpha; return std::cos(alpha) * m_dalpha / (std::sin(m_alpha + m_dalpha) - std::sin(m_alpha)); } -double SphericalPixel::solidAngle() const -{ +double SphericalPixel::solidAngle() const { return m_solid_angle; } diff --git a/Device/Detector/SphericalPixel.h b/Device/Detector/SphericalPixel.h index a4d124f7967ddc3b34bff9f7361b0f98f1e3c820..f21306f0dd91bcf9898fddfec0cdcfa8717f9e21 100644 --- a/Device/Detector/SphericalPixel.h +++ b/Device/Detector/SphericalPixel.h @@ -21,8 +21,7 @@ struct Bin1D; //! A pixel in a SphericalDetector -class SphericalPixel : public IPixel -{ +class SphericalPixel : public IPixel { public: SphericalPixel(const Bin1D& alpha_bin, const Bin1D& phi_bin); diff --git a/Device/Histo/Histogram1D.cpp b/Device/Histo/Histogram1D.cpp index 89cd9a7ed96375c08029755d16302c6ad3a6cb7b..38f4612a08d56bf0d3f904f748c46c755fe632fb 100644 --- a/Device/Histo/Histogram1D.cpp +++ b/Device/Histo/Histogram1D.cpp @@ -17,30 +17,25 @@ #include "Device/Intensity/ArrayUtils.h" #include <memory> -Histogram1D::Histogram1D(int nbinsx, double xlow, double xup) -{ +Histogram1D::Histogram1D(int nbinsx, double xlow, double xup) { m_data.addAxis(FixedBinAxis("x-axis", nbinsx, xlow, xup)); } -Histogram1D::Histogram1D(int nbinsx, const std::vector<double>& xbins) -{ +Histogram1D::Histogram1D(int nbinsx, const std::vector<double>& xbins) { m_data.addAxis(VariableBinAxis("x-axis", nbinsx, xbins)); } Histogram1D::Histogram1D(const IAxis& axis) : IHistogram(axis) {} -Histogram1D::Histogram1D(const OutputData<double>& data) -{ +Histogram1D::Histogram1D(const OutputData<double>& data) { init_from_data(data); } -Histogram1D* Histogram1D::clone() const -{ +Histogram1D* Histogram1D::clone() const { return new Histogram1D(*this); } -int Histogram1D::fill(double x, double weight) -{ +int Histogram1D::fill(double x, double weight) { const IAxis& axis = xAxis(); if (!axis.contains(x)) return -1; @@ -49,42 +44,35 @@ int Histogram1D::fill(double x, double weight) return (int)index; } -std::vector<double> Histogram1D::binCenters() const -{ +std::vector<double> Histogram1D::binCenters() const { return xAxis().binCenters(); } -std::vector<double> Histogram1D::binValues() const -{ +std::vector<double> Histogram1D::binValues() const { return IHistogram::getDataVector(IHistogram::DataType::INTEGRAL); } -std::vector<double> Histogram1D::binErrors() const -{ +std::vector<double> Histogram1D::binErrors() const { return IHistogram::getDataVector(IHistogram::DataType::STANDARD_ERROR); } #ifdef BORNAGAIN_PYTHON -PyObject* Histogram1D::binCentersNumpy() const -{ +PyObject* Histogram1D::binCentersNumpy() const { return ArrayUtils::createNumpyArray(binCenters()); } -PyObject* Histogram1D::binValuesNumpy() const -{ +PyObject* Histogram1D::binValuesNumpy() const { return ArrayUtils::createNumpyArray(binValues()); } -PyObject* Histogram1D::binErrorsNumpy() const -{ +PyObject* Histogram1D::binErrorsNumpy() const { return ArrayUtils::createNumpyArray(binErrors()); } #endif // BORNAGAIN_PYTHON -Histogram1D* Histogram1D::crop(double xmin, double xmax) -{ +Histogram1D* Histogram1D::crop(double xmin, double xmax) { const std::unique_ptr<IAxis> xaxis(xAxis().createClippedAxis(xmin, xmax)); Histogram1D* result = new Histogram1D(*xaxis); OutputData<CumulativeValue>::const_iterator it_origin = m_data.begin(); diff --git a/Device/Histo/Histogram1D.h b/Device/Histo/Histogram1D.h index 8fdef4996fa00f08d10550cc4a31012b556be0c7..0cfd5e28b42bdf67d0ee8da604fdb7858b0e9235 100644 --- a/Device/Histo/Histogram1D.h +++ b/Device/Histo/Histogram1D.h @@ -20,8 +20,7 @@ //! One dimensional histogram. //! @ingroup tools -class Histogram1D : public IHistogram -{ +class Histogram1D : public IHistogram { public: //! Constructor for fix bin size histograms. //! @param nbinsx number of bins diff --git a/Device/Histo/Histogram2D.cpp b/Device/Histo/Histogram2D.cpp index 8e6ba303a474726ce91023687a8387408e37c5f9..34ef6e4ccc09b00880a7f2b9d9d33ff0080c7f46 100644 --- a/Device/Histo/Histogram2D.cpp +++ b/Device/Histo/Histogram2D.cpp @@ -17,40 +17,34 @@ #include "Device/Histo/Histogram1D.h" #include <memory> -Histogram2D::Histogram2D(int nbinsx, double xlow, double xup, int nbinsy, double ylow, double yup) -{ +Histogram2D::Histogram2D(int nbinsx, double xlow, double xup, int nbinsy, double ylow, double yup) { m_data.addAxis(FixedBinAxis("x-axis", nbinsx, xlow, xup)); m_data.addAxis(FixedBinAxis("y-axis", nbinsy, ylow, yup)); } Histogram2D::Histogram2D(int nbinsx, const std::vector<double>& xbins, int nbinsy, - const std::vector<double>& ybins) -{ + const std::vector<double>& ybins) { m_data.addAxis(VariableBinAxis("x-axis", nbinsx, xbins)); m_data.addAxis(VariableBinAxis("y-axis", nbinsy, ybins)); } Histogram2D::Histogram2D(const IAxis& axis_x, const IAxis& axis_y) : IHistogram(axis_x, axis_y) {} -Histogram2D::Histogram2D(const OutputData<double>& data) -{ +Histogram2D::Histogram2D(const OutputData<double>& data) { init_from_data(data); } // IMPORTANT intentionally passed by copy to avoid problems on Python side -Histogram2D::Histogram2D(std::vector<std::vector<double>> data) -{ +Histogram2D::Histogram2D(std::vector<std::vector<double>> data) { initFromShape(data); this->setContent(data); } -Histogram2D* Histogram2D::clone() const -{ +Histogram2D* Histogram2D::clone() const { return new Histogram2D(*this); } -int Histogram2D::fill(double x, double y, double weight) -{ +int Histogram2D::fill(double x, double y, double weight) { if (!xAxis().contains(x)) return -1; if (!yAxis().contains(y)) @@ -60,44 +54,37 @@ int Histogram2D::fill(double x, double y, double weight) return (int)index; } -Histogram1D* Histogram2D::projectionX() -{ +Histogram1D* Histogram2D::projectionX() { return create_projectionX(0, static_cast<int>(xAxis().size()) - 1); } -Histogram1D* Histogram2D::projectionX(double yvalue) -{ +Histogram1D* Histogram2D::projectionX(double yvalue) { int ybin_selected = static_cast<int>(yAxis().findClosestIndex(yvalue)); return create_projectionX(ybin_selected, ybin_selected); } -Histogram1D* Histogram2D::projectionX(double ylow, double yup) -{ +Histogram1D* Histogram2D::projectionX(double ylow, double yup) { int ybinlow = static_cast<int>(yAxis().findClosestIndex(ylow)); int ybinup = static_cast<int>(yAxis().findClosestIndex(yup)); return create_projectionX(ybinlow, ybinup); } -Histogram1D* Histogram2D::projectionY() -{ +Histogram1D* Histogram2D::projectionY() { return create_projectionY(0, static_cast<int>(xAxis().size()) - 1); } -Histogram1D* Histogram2D::projectionY(double xvalue) -{ +Histogram1D* Histogram2D::projectionY(double xvalue) { int xbin_selected = static_cast<int>(xAxis().findClosestIndex(xvalue)); return create_projectionY(xbin_selected, xbin_selected); } -Histogram1D* Histogram2D::projectionY(double xlow, double xup) -{ +Histogram1D* Histogram2D::projectionY(double xlow, double xup) { int xbinlow = static_cast<int>(xAxis().findClosestIndex(xlow)); int xbinup = static_cast<int>(xAxis().findClosestIndex(xup)); return create_projectionY(xbinlow, xbinup); } -Histogram2D* Histogram2D::crop(double xmin, double ymin, double xmax, double ymax) -{ +Histogram2D* Histogram2D::crop(double xmin, double ymin, double xmax, double ymax) { const std::unique_ptr<IAxis> xaxis(xAxis().createClippedAxis(xmin, xmax)); const std::unique_ptr<IAxis> yaxis(yAxis().createClippedAxis(ymin, ymax)); @@ -116,14 +103,12 @@ Histogram2D* Histogram2D::crop(double xmin, double ymin, double xmax, double yma return result; } -void Histogram2D::setContent(const std::vector<std::vector<double>>& data) -{ +void Histogram2D::setContent(const std::vector<std::vector<double>>& data) { reset(); addContent(data); } -void Histogram2D::addContent(const std::vector<std::vector<double>>& data) -{ +void Histogram2D::addContent(const std::vector<std::vector<double>>& data) { auto shape = ArrayUtils::getShape(data); const size_t nrows = shape.first; const size_t ncols = shape.second; @@ -145,8 +130,7 @@ void Histogram2D::addContent(const std::vector<std::vector<double>>& data) } } -Histogram1D* Histogram2D::create_projectionX(int ybinlow, int ybinup) -{ +Histogram1D* Histogram2D::create_projectionX(int ybinlow, int ybinup) { Histogram1D* result = new Histogram1D(this->xAxis()); for (size_t index = 0; index < getTotalNumberOfBins(); ++index) { @@ -160,8 +144,7 @@ Histogram1D* Histogram2D::create_projectionX(int ybinlow, int ybinup) return result; } -Histogram1D* Histogram2D::create_projectionY(int xbinlow, int xbinup) -{ +Histogram1D* Histogram2D::create_projectionY(int xbinlow, int xbinup) { Histogram1D* result = new Histogram1D(this->yAxis()); for (size_t index = 0; index < getTotalNumberOfBins(); ++index) { diff --git a/Device/Histo/Histogram2D.h b/Device/Histo/Histogram2D.h index 021b14ca28a9939b39afb1cd4931500f0c3a63a3..0647ce939d3ae65fe489e56d2fd363723d0ec9e5 100644 --- a/Device/Histo/Histogram2D.h +++ b/Device/Histo/Histogram2D.h @@ -21,8 +21,7 @@ //! Two dimensional histogram. //! @ingroup tools -class Histogram2D : public IHistogram -{ +class Histogram2D : public IHistogram { public: //! @brief Constructor for fix bin size histograms. //! @param nbinsx number of bins on X-axis @@ -112,8 +111,7 @@ protected: Histogram1D* create_projectionY(int xbinlow, int xbinup); }; -template <typename T> void Histogram2D::initFromShape(const T& data) -{ +template <typename T> void Histogram2D::initFromShape(const T& data) { auto shape = ArrayUtils::getShape(data); const size_t nrows = shape.first; const size_t ncols = shape.second; diff --git a/Device/Histo/IHistogram.cpp b/Device/Histo/IHistogram.cpp index 9d6807cfa46626b5b8a4a5de0d6dcc6133a2747e..d80dc02c7f3ebae3d20d380e6e3ea07bb171834b 100644 --- a/Device/Histo/IHistogram.cpp +++ b/Device/Histo/IHistogram.cpp @@ -20,71 +20,58 @@ IHistogram::IHistogram() = default; -IHistogram::IHistogram(const IHistogram& other) -{ +IHistogram::IHistogram(const IHistogram& other) { m_data.copyFrom(other.m_data); } -IHistogram::IHistogram(const IAxis& axis_x) -{ +IHistogram::IHistogram(const IAxis& axis_x) { m_data.addAxis(axis_x); } -IHistogram::IHistogram(const IAxis& axis_x, const IAxis& axis_y) -{ +IHistogram::IHistogram(const IAxis& axis_x, const IAxis& axis_y) { m_data.addAxis(axis_x); m_data.addAxis(axis_y); } -size_t IHistogram::getTotalNumberOfBins() const -{ +size_t IHistogram::getTotalNumberOfBins() const { return m_data.getAllocatedSize(); } -const IAxis& IHistogram::xAxis() const -{ +const IAxis& IHistogram::xAxis() const { check_x_axis(); return m_data.axis(0); } -const IAxis& IHistogram::yAxis() const -{ +const IAxis& IHistogram::yAxis() const { check_y_axis(); return m_data.axis(1); } -double IHistogram::getXmin() const -{ +double IHistogram::getXmin() const { return xAxis().lowerBound(); } -double IHistogram::getXmax() const -{ +double IHistogram::getXmax() const { return xAxis().upperBound(); } -size_t IHistogram::getNbinsX() const -{ +size_t IHistogram::getNbinsX() const { return xAxis().size(); } -double IHistogram::getYmin() const -{ +double IHistogram::getYmin() const { return yAxis().lowerBound(); } -double IHistogram::getYmax() const -{ +double IHistogram::getYmax() const { return yAxis().upperBound(); } -size_t IHistogram::getNbinsY() const -{ +size_t IHistogram::getNbinsY() const { return yAxis().size(); } -size_t IHistogram::getGlobalBin(size_t binx, size_t biny) const -{ +size_t IHistogram::getGlobalBin(size_t binx, size_t biny) const { std::vector<unsigned> axes_indices; axes_indices.push_back(static_cast<unsigned>(binx)); if (rank() == 2) @@ -92,8 +79,7 @@ size_t IHistogram::getGlobalBin(size_t binx, size_t biny) const return m_data.toGlobalIndex(axes_indices); } -size_t IHistogram::findGlobalBin(double x, double y) const -{ +size_t IHistogram::findGlobalBin(double x, double y) const { std::vector<double> coordinates; coordinates.push_back(x); if (rank() == 2) @@ -101,120 +87,98 @@ size_t IHistogram::findGlobalBin(double x, double y) const return m_data.findGlobalIndex(coordinates); } -size_t IHistogram::xAxisIndex(size_t i) const -{ +size_t IHistogram::xAxisIndex(size_t i) const { return m_data.getAxisBinIndex(i, 0); } -size_t IHistogram::yAxisIndex(size_t i) const -{ +size_t IHistogram::yAxisIndex(size_t i) const { return m_data.getAxisBinIndex(i, 1); } -double IHistogram::xAxisValue(size_t i) -{ +double IHistogram::xAxisValue(size_t i) { check_x_axis(); return m_data.getAxisValue(i, 0); } -double IHistogram::yAxisValue(size_t i) -{ +double IHistogram::yAxisValue(size_t i) { check_y_axis(); return m_data.getAxisValue(i, 1); } -const OutputData<CumulativeValue>& IHistogram::getData() const -{ +const OutputData<CumulativeValue>& IHistogram::getData() const { return m_data; } -OutputData<CumulativeValue>& IHistogram::getData() -{ +OutputData<CumulativeValue>& IHistogram::getData() { return m_data; } -double IHistogram::binContent(size_t i) const -{ +double IHistogram::binContent(size_t i) const { return m_data[i].getContent(); } -double IHistogram::binContent(size_t binx, size_t biny) const -{ +double IHistogram::binContent(size_t binx, size_t biny) const { return binContent(getGlobalBin(binx, biny)); } -void IHistogram::setBinContent(size_t i, double value) -{ +void IHistogram::setBinContent(size_t i, double value) { m_data[i].setContent(value); } -void IHistogram::addBinContent(size_t i, double value) -{ +void IHistogram::addBinContent(size_t i, double value) { m_data[i].add(value); } -double IHistogram::binError(size_t i) const -{ +double IHistogram::binError(size_t i) const { return m_data[i].getRMS(); } -double IHistogram::binError(size_t binx, size_t biny) const -{ +double IHistogram::binError(size_t binx, size_t biny) const { return binError(getGlobalBin(binx, biny)); } -double IHistogram::binAverage(size_t i) const -{ +double IHistogram::binAverage(size_t i) const { return m_data[i].getAverage(); } -double IHistogram::binAverage(size_t binx, size_t biny) const -{ +double IHistogram::binAverage(size_t binx, size_t biny) const { return binAverage(getGlobalBin(binx, biny)); } -int IHistogram::binNumberOfEntries(size_t i) const -{ +int IHistogram::binNumberOfEntries(size_t i) const { return m_data[i].getNumberOfEntries(); } -int IHistogram::binNumberOfEntries(size_t binx, size_t biny) const -{ +int IHistogram::binNumberOfEntries(size_t binx, size_t biny) const { return binNumberOfEntries(getGlobalBin(binx, biny)); } -double IHistogram::getMaximum() const -{ +double IHistogram::getMaximum() const { OutputData<CumulativeValue>::const_iterator it = std::max_element(m_data.begin(), m_data.end()); return it->getContent(); } -size_t IHistogram::getMaximumBinIndex() const -{ +size_t IHistogram::getMaximumBinIndex() const { OutputData<CumulativeValue>::const_iterator it = std::max_element(m_data.begin(), m_data.end()); return std::distance(m_data.begin(), it); } -double IHistogram::getMinimum() const -{ +double IHistogram::getMinimum() const { OutputData<CumulativeValue>::const_iterator it = std::min_element(m_data.begin(), m_data.end()); return it->getContent(); } -size_t IHistogram::getMinimumBinIndex() const -{ +size_t IHistogram::getMinimumBinIndex() const { return std::distance(m_data.begin(), std::min_element(m_data.begin(), m_data.end())); } -void IHistogram::scale(double value) -{ +void IHistogram::scale(double value) { for (size_t index = 0; index < getTotalNumberOfBins(); ++index) { m_data[index].setContent(value * m_data[index].getContent()); } } -double IHistogram::integral() const -{ +double IHistogram::integral() const { double result(0.0); for (size_t index = 0; index < getTotalNumberOfBins(); ++index) { result += m_data[index].getContent(); @@ -223,25 +187,21 @@ double IHistogram::integral() const } #ifdef BORNAGAIN_PYTHON -PyObject* IHistogram::array(DataType dataType) const -{ +PyObject* IHistogram::array(DataType dataType) const { const std::unique_ptr<OutputData<double>> data(createOutputData(dataType)); return data->getArray(); } -PyObject* IHistogram::getArray(DataType dataType) const -{ +PyObject* IHistogram::getArray(DataType dataType) const { return array(dataType); } #endif // BORNAGAIN_PYTHON -void IHistogram::reset() -{ +void IHistogram::reset() { m_data.setAllTo(CumulativeValue()); } -IHistogram* IHistogram::createHistogram(const OutputData<double>& source) -{ +IHistogram* IHistogram::createHistogram(const OutputData<double>& source) { if (source.rank() == 1) { return new Histogram1D(source); } else if (source.rank() == 2) { @@ -255,18 +215,15 @@ IHistogram* IHistogram::createHistogram(const OutputData<double>& source) } } -IHistogram* IHistogram::createFrom(const std::string& filename) -{ +IHistogram* IHistogram::createFrom(const std::string& filename) { return IntensityDataIOFactory::readIntensityData(filename); } -IHistogram* IHistogram::createFrom(const std::vector<std::vector<double>>& data) -{ +IHistogram* IHistogram::createFrom(const std::vector<std::vector<double>>& data) { return new Histogram2D(data); } -void IHistogram::check_x_axis() const -{ +void IHistogram::check_x_axis() const { if (rank() < 1) { std::ostringstream message; message << "IHistogram::check_x_axis() -> Error. X-xis does not exist. "; @@ -275,8 +232,7 @@ void IHistogram::check_x_axis() const } } -void IHistogram::check_y_axis() const -{ +void IHistogram::check_y_axis() const { if (rank() < 2) { std::ostringstream message; message << "IHistogram::check_y_axis() -> Error. Y-axis does not exist. "; @@ -285,8 +241,7 @@ void IHistogram::check_y_axis() const } } -void IHistogram::init_from_data(const OutputData<double>& source) -{ +void IHistogram::init_from_data(const OutputData<double>& source) { if (rank() != source.rank()) { std::ostringstream message; message << "IHistogram::IHistogram(const OutputData<double>& data) -> Error. "; @@ -302,8 +257,7 @@ void IHistogram::init_from_data(const OutputData<double>& source) } //! returns data of requested type for globalbin number -double IHistogram::binData(size_t i, IHistogram::DataType dataType) const -{ +double IHistogram::binData(size_t i, IHistogram::DataType dataType) const { if (dataType == DataType::INTEGRAL) { return binContent(i); } else if (dataType == DataType::AVERAGE) { @@ -317,8 +271,7 @@ double IHistogram::binData(size_t i, IHistogram::DataType dataType) const } //! returns vector of values of requested DataType -std::vector<double> IHistogram::getDataVector(IHistogram::DataType dataType) const -{ +std::vector<double> IHistogram::getDataVector(IHistogram::DataType dataType) const { std::vector<double> result; result.resize(getTotalNumberOfBins(), 0.0); for (size_t index = 0; index < getTotalNumberOfBins(); ++index) { @@ -328,8 +281,7 @@ std::vector<double> IHistogram::getDataVector(IHistogram::DataType dataType) con } //! Copy content (but not the axes) from other histogram. Dimensions should be the same. -void IHistogram::copyContentFrom(const IHistogram& other) -{ +void IHistogram::copyContentFrom(const IHistogram& other) { if (!hasSameDimensions(other)) throw Exceptions::LogicErrorException( "IHistogram::copyContentFrom() -> Error. Can't copy the data of different shape."); @@ -340,8 +292,7 @@ void IHistogram::copyContentFrom(const IHistogram& other) } //! creates new OutputData with histogram's shape and put there values corresponding to DataType -OutputData<double>* IHistogram::createOutputData(IHistogram::DataType dataType) const -{ +OutputData<double>* IHistogram::createOutputData(IHistogram::DataType dataType) const { OutputData<double>* result = new OutputData<double>; result->copyShapeFrom(m_data); for (size_t i = 0; i < getTotalNumberOfBins(); ++i) { @@ -350,18 +301,15 @@ OutputData<double>* IHistogram::createOutputData(IHistogram::DataType dataType) return result; } -bool IHistogram::hasSameShape(const IHistogram& other) const -{ +bool IHistogram::hasSameShape(const IHistogram& other) const { return m_data.hasSameShape(other.m_data); } -bool IHistogram::hasSameDimensions(const IHistogram& other) const -{ +bool IHistogram::hasSameDimensions(const IHistogram& other) const { return m_data.hasSameDimensions(other.m_data); } -const IHistogram& IHistogram::operator+=(const IHistogram& right) -{ +const IHistogram& IHistogram::operator+=(const IHistogram& right) { if (!hasSameDimensions(right)) throw Exceptions::LogicErrorException( "IHistogram::operator+=() -> Error. Histograms have different dimension"); @@ -370,8 +318,7 @@ const IHistogram& IHistogram::operator+=(const IHistogram& right) return *this; } -IHistogram* IHistogram::relativeDifferenceHistogram(const IHistogram& rhs) -{ +IHistogram* IHistogram::relativeDifferenceHistogram(const IHistogram& rhs) { if (!hasSameDimensions(rhs)) throw Exceptions::LogicErrorException("IHistogram::relativeDifferenceHistogram() -> Error. " "Histograms have different dimensions"); @@ -386,13 +333,11 @@ IHistogram* IHistogram::relativeDifferenceHistogram(const IHistogram& rhs) return result; } -void IHistogram::save(const std::string& filename) -{ +void IHistogram::save(const std::string& filename) { IntensityDataIOFactory::writeIntensityData(*this, filename); } -void IHistogram::load(const std::string& filename) -{ +void IHistogram::load(const std::string& filename) { const std::unique_ptr<IHistogram> hist(IntensityDataIOFactory::readIntensityData(filename)); copyContentFrom(*hist); } diff --git a/Device/Histo/IHistogram.h b/Device/Histo/IHistogram.h index 09f1e98e967a4131dd15240a386fd41c6577f7f6..373039e8b6d3c976ee0e70e8a21cdf36da0522ae 100644 --- a/Device/Histo/IHistogram.h +++ b/Device/Histo/IHistogram.h @@ -23,8 +23,7 @@ class Histogram1D; //! Base class for 1D and 2D histograms holding values of double type. //! @ingroup tools -class IHistogram -{ +class IHistogram { public: enum DataType { INTEGRAL, AVERAGE, STANDARD_ERROR, NENTRIES }; diff --git a/Device/Histo/IntensityDataIOFactory.cpp b/Device/Histo/IntensityDataIOFactory.cpp index d09d3be5edc8752df34a8250f108f798297ca1c6..2eed627055593886e3977f27aedc1f316c0c6e59 100644 --- a/Device/Histo/IntensityDataIOFactory.cpp +++ b/Device/Histo/IntensityDataIOFactory.cpp @@ -22,8 +22,7 @@ #include <fstream> #include <memory> -OutputData<double>* IntensityDataIOFactory::readOutputData(const std::string& file_name) -{ +OutputData<double>* IntensityDataIOFactory::readOutputData(const std::string& file_name) { if (!FileSystemUtils::IsFileExists(file_name)) return nullptr; std::unique_ptr<OutputDataReader> reader(OutputDataReadFactory::getReader(file_name)); @@ -32,8 +31,7 @@ OutputData<double>* IntensityDataIOFactory::readOutputData(const std::string& fi return nullptr; } -OutputData<double>* IntensityDataIOFactory::readReflectometryData(const std::string& file_name) -{ +OutputData<double>* IntensityDataIOFactory::readReflectometryData(const std::string& file_name) { if (!FileSystemUtils::IsFileExists(file_name)) return nullptr; std::unique_ptr<OutputDataReader> reader( @@ -43,8 +41,7 @@ OutputData<double>* IntensityDataIOFactory::readReflectometryData(const std::str return nullptr; } -IHistogram* IntensityDataIOFactory::readIntensityData(const std::string& file_name) -{ +IHistogram* IntensityDataIOFactory::readIntensityData(const std::string& file_name) { std::unique_ptr<OutputData<double>> data(readOutputData(file_name)); if (!data) throw std::runtime_error("Could not read " + file_name); @@ -52,23 +49,20 @@ IHistogram* IntensityDataIOFactory::readIntensityData(const std::string& file_na } void IntensityDataIOFactory::writeOutputData(const OutputData<double>& data, - const std::string& file_name) -{ + const std::string& file_name) { auto* writer = OutputDataWriteFactory::getWriter(file_name); writer->writeOutputData(data); delete writer; } void IntensityDataIOFactory::writeIntensityData(const IHistogram& histogram, - const std::string& file_name) -{ + const std::string& file_name) { std::unique_ptr<OutputData<double>> data(histogram.createOutputData()); writeOutputData(*data, file_name); } void IntensityDataIOFactory::writeSimulationResult(const SimulationResult& result, - const std::string& file_name) -{ + const std::string& file_name) { auto data = result.data(); writeOutputData(*data, file_name); } diff --git a/Device/Histo/IntensityDataIOFactory.h b/Device/Histo/IntensityDataIOFactory.h index 2a479236d7401d959c72d614b71e63aad9f4686a..247e77e8b889d460190ae3d4f4761509129dc5c3 100644 --- a/Device/Histo/IntensityDataIOFactory.h +++ b/Device/Histo/IntensityDataIOFactory.h @@ -43,8 +43,7 @@ IntensityDataIOFactory.writeIntensityData(histogram, "filename.tif.bz2") \endcode */ -class IntensityDataIOFactory -{ +class IntensityDataIOFactory { public: //! Reads file and returns newly created OutputData object static OutputData<double>* readOutputData(const std::string& file_name); diff --git a/Device/Histo/SimulationResult.cpp b/Device/Histo/SimulationResult.cpp index a620fdda9bad81cbb37be16132ecd875027b1bd2..c04b714384fc14fbd32e6d246fb278323c51d371 100644 --- a/Device/Histo/SimulationResult.cpp +++ b/Device/Histo/SimulationResult.cpp @@ -17,13 +17,11 @@ SimulationResult::SimulationResult(const OutputData<double>& data, const IUnitConverter& unit_converter) - : m_data(data.clone()), m_unit_converter(unit_converter.clone()) -{ + : m_data(data.clone()), m_unit_converter(unit_converter.clone()) { checkDimensions(); } -SimulationResult::SimulationResult(const SimulationResult& other) -{ +SimulationResult::SimulationResult(const SimulationResult& other) { if (!other.m_data || !other.m_unit_converter) throw std::runtime_error("Error in SimulationResult(const SimulationResult& other): " "not initialized"); @@ -32,12 +30,9 @@ SimulationResult::SimulationResult(const SimulationResult& other) } SimulationResult::SimulationResult(SimulationResult&& other) - : m_data(std::move(other.m_data)), m_unit_converter(std::move(other.m_unit_converter)) -{ -} + : m_data(std::move(other.m_data)), m_unit_converter(std::move(other.m_unit_converter)) {} -SimulationResult& SimulationResult::operator=(const SimulationResult& other) -{ +SimulationResult& SimulationResult::operator=(const SimulationResult& other) { if (!other.m_data || !other.m_unit_converter) throw std::runtime_error("Error in SimulationResult(const SimulationResult& other): " "not initialized"); @@ -47,23 +42,20 @@ SimulationResult& SimulationResult::operator=(const SimulationResult& other) return *this; } -SimulationResult& SimulationResult::operator=(SimulationResult&& other) -{ +SimulationResult& SimulationResult::operator=(SimulationResult&& other) { m_data.reset(other.m_data.release()); m_unit_converter.reset(other.m_unit_converter.release()); return *this; } -std::unique_ptr<OutputData<double>> SimulationResult::data(Axes::Units units) const -{ +std::unique_ptr<OutputData<double>> SimulationResult::data(Axes::Units units) const { if (!m_data) throw std::runtime_error( "Error in SimulationResult::data:Attempt to access non-initialized data"); return m_unit_converter->createConvertedData(*m_data, units); } -Histogram2D* SimulationResult::histogram2d(Axes::Units units) const -{ +Histogram2D* SimulationResult::histogram2d(Axes::Units units) const { if (m_data->rank() != 2 || m_unit_converter->dimension() != 2) throw std::runtime_error("Error in SimulationResult::histogram2d: " "dimension of data is not 2. Please use axis(), array() and " @@ -72,8 +64,7 @@ Histogram2D* SimulationResult::histogram2d(Axes::Units units) const return new Histogram2D(*P_data); } -std::vector<AxisInfo> SimulationResult::axisInfo(Axes::Units units) const -{ +std::vector<AxisInfo> SimulationResult::axisInfo(Axes::Units units) const { if (!m_unit_converter) return {}; std::vector<AxisInfo> result; @@ -87,31 +78,26 @@ std::vector<AxisInfo> SimulationResult::axisInfo(Axes::Units units) const return result; } -const IUnitConverter& SimulationResult::converter() const -{ +const IUnitConverter& SimulationResult::converter() const { ASSERT(m_unit_converter); return *m_unit_converter; } -double& SimulationResult::operator[](size_t i) -{ +double& SimulationResult::operator[](size_t i) { ASSERT(m_data); return (*m_data)[i]; } -const double& SimulationResult::operator[](size_t i) const -{ +const double& SimulationResult::operator[](size_t i) const { ASSERT(m_data); return (*m_data)[i]; } -size_t SimulationResult::size() const -{ +size_t SimulationResult::size() const { return m_data ? m_data->getAllocatedSize() : 0; } -double SimulationResult::max() const -{ +double SimulationResult::max() const { ASSERT(m_data); double result = 0; for (size_t i = 0; i < size(); ++i) @@ -121,8 +107,7 @@ double SimulationResult::max() const } #ifdef BORNAGAIN_PYTHON -PyObject* SimulationResult::array(Axes::Units units) const -{ +PyObject* SimulationResult::array(Axes::Units units) const { if (!m_data || !m_unit_converter) throw std::runtime_error( "Error in SimulationResult::array: attempt to access non-initialized data"); @@ -130,13 +115,11 @@ PyObject* SimulationResult::array(Axes::Units units) const } #endif -std::vector<double> SimulationResult::axis(Axes::Units units) const -{ +std::vector<double> SimulationResult::axis(Axes::Units units) const { return axis(0, units); } -std::vector<double> SimulationResult::axis(size_t i_axis, Axes::Units units) const -{ +std::vector<double> SimulationResult::axis(size_t i_axis, Axes::Units units) const { if (i_axis >= m_unit_converter->dimension()) throw std::runtime_error( "Error in SimulationResult::axis: no axis corresponds to passed index."); @@ -144,8 +127,7 @@ std::vector<double> SimulationResult::axis(size_t i_axis, Axes::Units units) con return axis->binCenters(); } -void SimulationResult::checkDimensions() const -{ +void SimulationResult::checkDimensions() const { if (m_data->rank() != m_unit_converter->dimension()) throw std::runtime_error("Error in SimulationResults::checkDimensions(): " "dimensions of data and unit converter don't match"); diff --git a/Device/Histo/SimulationResult.h b/Device/Histo/SimulationResult.h index b538f9caf151f7c1d4ddd2e691dfdaed368a43be..4424d4ff1fb837c4a2b2182ff26f951de8b53042 100644 --- a/Device/Histo/SimulationResult.h +++ b/Device/Histo/SimulationResult.h @@ -37,8 +37,7 @@ struct AxisInfo { //! Wrapper around OutputData<double> that also provides unit conversions. //! @ingroup detector -class SimulationResult -{ +class SimulationResult { public: SimulationResult() = default; SimulationResult(const OutputData<double>& data, const IUnitConverter& unit_converter); diff --git a/Device/InputOutput/DataFormatUtils.cpp b/Device/InputOutput/DataFormatUtils.cpp index 52186cf62a34774e43d29d12e7bf01c2fbd11281..7f3ae56bbbb002903bf674c5393217021f79a540 100644 --- a/Device/InputOutput/DataFormatUtils.cpp +++ b/Device/InputOutput/DataFormatUtils.cpp @@ -22,8 +22,7 @@ #include <iostream> #include <iterator> -namespace -{ +namespace { std::istringstream getAxisStringRepresentation(std::istream& input_stream); template <class Axis> std::unique_ptr<IAxis> createFixedBinLikeAxis(std::istringstream iss); @@ -45,27 +44,23 @@ const std::string TiffExtension = ".tif"; const std::string TiffExtension2 = ".tiff"; } // namespace -bool DataFormatUtils::isCompressed(const std::string& name) -{ +bool DataFormatUtils::isCompressed(const std::string& name) { return isGZipped(name) || isBZipped(name); } //! Does name contain *.gz extension? -bool DataFormatUtils::isGZipped(const std::string& name) -{ +bool DataFormatUtils::isGZipped(const std::string& name) { return FileSystemUtils::extension(name) == GzipExtension; } -bool DataFormatUtils::isBZipped(const std::string& name) -{ +bool DataFormatUtils::isBZipped(const std::string& name) { return FileSystemUtils::extension(name) == BzipExtension; } //! Returns file main extension (without .gz). -std::string DataFormatUtils::GetFileMainExtension(const std::string& name) -{ +std::string DataFormatUtils::GetFileMainExtension(const std::string& name) { std::string stripped_name(name); if (isGZipped(name)) { stripped_name = name.substr(0, name.size() - GzipExtension.size()); @@ -75,20 +70,17 @@ std::string DataFormatUtils::GetFileMainExtension(const std::string& name) return FileSystemUtils::extension(stripped_name); } -bool DataFormatUtils::isIntFile(const std::string& file_name) -{ +bool DataFormatUtils::isIntFile(const std::string& file_name) { return GetFileMainExtension(file_name) == IntExtension; } -bool DataFormatUtils::isTiffFile(const std::string& file_name) -{ +bool DataFormatUtils::isTiffFile(const std::string& file_name) { return (GetFileMainExtension(file_name) == TiffExtension || GetFileMainExtension(file_name) == TiffExtension2); } //! Creates axis of certain type from input stream -std::unique_ptr<IAxis> DataFormatUtils::createAxis(std::istream& input_stream) -{ +std::unique_ptr<IAxis> DataFormatUtils::createAxis(std::istream& input_stream) { auto iss = getAxisStringRepresentation(input_stream); std::string type; if (!(iss >> type)) @@ -104,8 +96,7 @@ std::unique_ptr<IAxis> DataFormatUtils::createAxis(std::istream& input_stream) } //! Fills output data raw buffer from input stream -void DataFormatUtils::fillOutputData(OutputData<double>* data, std::istream& input_stream) -{ +void DataFormatUtils::fillOutputData(OutputData<double>* data, std::istream& input_stream) { std::string line; data->setAllTo(0.0); OutputData<double>::iterator it = data->begin(); @@ -128,8 +119,7 @@ void DataFormatUtils::fillOutputData(OutputData<double>* data, std::istream& inp //! Parse double values from string to vector of double -std::vector<double> DataFormatUtils::parse_doubles(const std::string& str) -{ +std::vector<double> DataFormatUtils::parse_doubles(const std::string& str) { std::vector<double> result; std::istringstream iss(str); DataFormatUtils::readLineOfDoubles(result, iss); @@ -146,17 +136,14 @@ std::vector<double> DataFormatUtils::parse_doubles(const std::string& str) return result; } -void DataFormatUtils::readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss) -{ +void DataFormatUtils::readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss) { iss.imbue(std::locale::classic()); std::copy(std::istream_iterator<double>(iss), std::istream_iterator<double>(), back_inserter(buffer)); } -namespace -{ -std::istringstream getAxisStringRepresentation(std::istream& input_stream) -{ +namespace { +std::istringstream getAxisStringRepresentation(std::istream& input_stream) { std::string line; std::getline(input_stream, line); const std::vector<std::string> to_replace = {",", "\"", "(", ")", "[", "]"}; @@ -168,8 +155,7 @@ std::istringstream getAxisStringRepresentation(std::istream& input_stream) //! FixedBinAxis("axis0", 10, -1, 1) //! ConstKBinAxis("axis0", 10, -1, 1) //! CustomBinAxis("axis0", 10, -1, 1) -template <class Axis> std::unique_ptr<IAxis> createFixedBinLikeAxis(std::istringstream iss) -{ +template <class Axis> std::unique_ptr<IAxis> createFixedBinLikeAxis(std::istringstream iss) { std::string name; size_t nbins(0); if (!(iss >> name >> nbins)) @@ -188,8 +174,7 @@ template <class Axis> std::unique_ptr<IAxis> createFixedBinLikeAxis(std::istring //! Creates VariableBinAxis from string representation //! VariableBinAxis("axis0", 4, [-1, -0.5, 0.5, 1, 2]) -std::unique_ptr<IAxis> createVariableBinAxis(std::istringstream iss) -{ +std::unique_ptr<IAxis> createVariableBinAxis(std::istringstream iss) { std::string name; size_t nbins(0); if (!(iss >> name >> nbins)) @@ -207,8 +192,7 @@ std::unique_ptr<IAxis> createVariableBinAxis(std::istringstream iss) //! Creates createPointwiseAxis from string representation //! PointwiseAxis("axis0", [-0.5, 0.5, 1, 2]) -std::unique_ptr<IAxis> createPointwiseAxis(std::istringstream iss) -{ +std::unique_ptr<IAxis> createPointwiseAxis(std::istringstream iss) { std::string name; if (!(iss >> name)) throw Exceptions::FormatErrorException( diff --git a/Device/InputOutput/DataFormatUtils.h b/Device/InputOutput/DataFormatUtils.h index 6a6b8656bc6db8efec2171b2a730ff226ef4c39d..07fee8ce0aa4121ac379fd5c431912f0c6988c4c 100644 --- a/Device/InputOutput/DataFormatUtils.h +++ b/Device/InputOutput/DataFormatUtils.h @@ -24,8 +24,7 @@ template <class T> class OutputData; //! Utility functions for data input and output. -namespace DataFormatUtils -{ +namespace DataFormatUtils { //! Returns true if name contains *.gz extension bool isCompressed(const std::string& name); diff --git a/Device/InputOutput/OutputDataReadFactory.cpp b/Device/InputOutput/OutputDataReadFactory.cpp index 261fbaab84e00bdae103fb1d7ddfbf53155fe5e7..0c7986042b961fd3e2709a29c92a95bb75b98441 100644 --- a/Device/InputOutput/OutputDataReadFactory.cpp +++ b/Device/InputOutput/OutputDataReadFactory.cpp @@ -16,22 +16,19 @@ #include "Base/Types/Exceptions.h" #include "Device/InputOutput/DataFormatUtils.h" -OutputDataReader* OutputDataReadFactory::getReader(const std::string& file_name) -{ +OutputDataReader* OutputDataReadFactory::getReader(const std::string& file_name) { OutputDataReader* result = new OutputDataReader(file_name); result->setStrategy(getReadStrategy(file_name)); return result; } -OutputDataReader* OutputDataReadFactory::getReflectometryReader(const std::string& file_name) -{ +OutputDataReader* OutputDataReadFactory::getReflectometryReader(const std::string& file_name) { OutputDataReader* result = new OutputDataReader(file_name); result->setStrategy(new OutputDataReadReflectometryStrategy()); return result; } -IOutputDataReadStrategy* OutputDataReadFactory::getReadStrategy(const std::string& file_name) -{ +IOutputDataReadStrategy* OutputDataReadFactory::getReadStrategy(const std::string& file_name) { IOutputDataReadStrategy* result(nullptr); if (DataFormatUtils::isIntFile(file_name)) result = new OutputDataReadINTStrategy(); diff --git a/Device/InputOutput/OutputDataReadFactory.h b/Device/InputOutput/OutputDataReadFactory.h index 3a90a23479d5177f823bd34b4a135d9f81f8c955..f88d91789a8832af098bca9320b011200e1e9ac7 100644 --- a/Device/InputOutput/OutputDataReadFactory.h +++ b/Device/InputOutput/OutputDataReadFactory.h @@ -20,8 +20,7 @@ //! Creates reader appropariate for given type of files. //! @ingroup input_output_internal -class OutputDataReadFactory -{ +class OutputDataReadFactory { public: static OutputDataReader* getReader(const std::string& file_name); static OutputDataReader* getReflectometryReader(const std::string& file_name); diff --git a/Device/InputOutput/OutputDataReadStrategy.cpp b/Device/InputOutput/OutputDataReadStrategy.cpp index 647ff941b4216f25742eced7adf17486a1c3d218..4966b154eb61b41e600a9f53074c6eccd9889777 100644 --- a/Device/InputOutput/OutputDataReadStrategy.cpp +++ b/Device/InputOutput/OutputDataReadStrategy.cpp @@ -20,10 +20,8 @@ #include <map> #include <stdexcept> // need overlooked by g++ 5.4 -namespace -{ -inline std::string trim(const std::string& str, const std::string& whitespace = " \t") -{ +namespace { +inline std::string trim(const std::string& str, const std::string& whitespace = " \t") { const auto strBegin = str.find_first_not_of(whitespace); if (strBegin == std::string::npos) @@ -34,14 +32,12 @@ inline std::string trim(const std::string& str, const std::string& whitespace = return str.substr(strBegin, strRange); } -inline bool isDoubleStartChar(char c) -{ +inline bool isDoubleStartChar(char c) { return isdigit(c) || c == '-' || c == '+'; } } // namespace -OutputData<double>* OutputDataReadINTStrategy::readOutputData(std::istream& input_stream) -{ +OutputData<double>* OutputDataReadINTStrategy::readOutputData(std::istream& input_stream) { OutputData<double>* result = new OutputData<double>; std::string line; @@ -59,8 +55,7 @@ OutputData<double>* OutputDataReadINTStrategy::readOutputData(std::istream& inpu return result; } -OutputData<double>* OutputDataReadReflectometryStrategy::readOutputData(std::istream& fin) -{ +OutputData<double>* OutputDataReadReflectometryStrategy::readOutputData(std::istream& fin) { OutputData<double>* oData = new OutputData<double>(); std::string line; std::vector<std::vector<double>> vecVec; @@ -127,8 +122,7 @@ OutputData<double>* OutputDataReadReflectometryStrategy::readOutputData(std::ist return oData; } -OutputData<double>* OutputDataReadNumpyTXTStrategy::readOutputData(std::istream& input_stream) -{ +OutputData<double>* OutputDataReadNumpyTXTStrategy::readOutputData(std::istream& input_stream) { std::string line; std::vector<std::vector<double>> data; @@ -180,13 +174,11 @@ OutputData<double>* OutputDataReadNumpyTXTStrategy::readOutputData(std::istream& OutputDataReadTiffStrategy::OutputDataReadTiffStrategy() : m_d(new TiffHandler) {} -OutputDataReadTiffStrategy::~OutputDataReadTiffStrategy() -{ +OutputDataReadTiffStrategy::~OutputDataReadTiffStrategy() { delete m_d; } -OutputData<double>* OutputDataReadTiffStrategy::readOutputData(std::istream& input_stream) -{ +OutputData<double>* OutputDataReadTiffStrategy::readOutputData(std::istream& input_stream) { m_d->read(input_stream); return m_d->getOutputData()->clone(); } diff --git a/Device/InputOutput/OutputDataReadStrategy.h b/Device/InputOutput/OutputDataReadStrategy.h index d3b56d20c333e589592cc9c1369048b544798bb5..e85b83aee936e1858b20032a5a8e6df9a0fac7f7 100644 --- a/Device/InputOutput/OutputDataReadStrategy.h +++ b/Device/InputOutput/OutputDataReadStrategy.h @@ -22,8 +22,7 @@ template <class T> class OutputData; //! Interface for reading strategy of OutputData from file. //! @ingroup input_output_internal -class IOutputDataReadStrategy -{ +class IOutputDataReadStrategy { public: virtual ~IOutputDataReadStrategy() = default; virtual OutputData<double>* readOutputData(std::istream& input_stream) = 0; @@ -32,8 +31,7 @@ public: //! Strategy to read BornAgain native IntensityData from ASCII file. //! @ingroup input_output_internal -class OutputDataReadINTStrategy : public IOutputDataReadStrategy -{ +class OutputDataReadINTStrategy : public IOutputDataReadStrategy { public: OutputData<double>* readOutputData(std::istream& input_stream); }; @@ -41,8 +39,7 @@ public: //! Strategy to read Reflectometry data from ASCII file. //! @ingroup input_output_internal -class OutputDataReadReflectometryStrategy : public IOutputDataReadStrategy -{ +class OutputDataReadReflectometryStrategy : public IOutputDataReadStrategy { public: OutputData<double>* readOutputData(std::istream& input_stream); }; @@ -50,8 +47,7 @@ public: //! Strategy to read OutputData from simple ASCII file with the layout as in numpy.savetxt. //! @ingroup input_output_internal -class OutputDataReadNumpyTXTStrategy : public IOutputDataReadStrategy -{ +class OutputDataReadNumpyTXTStrategy : public IOutputDataReadStrategy { public: OutputData<double>* readOutputData(std::istream& input_stream); }; @@ -63,8 +59,7 @@ class TiffHandler; //! Strategy to read a TIFF file. //! @ingroup input_output_internal -class OutputDataReadTiffStrategy : public IOutputDataReadStrategy -{ +class OutputDataReadTiffStrategy : public IOutputDataReadStrategy { public: OutputDataReadTiffStrategy(); virtual ~OutputDataReadTiffStrategy(); diff --git a/Device/InputOutput/OutputDataReader.cpp b/Device/InputOutput/OutputDataReader.cpp index f4e085f76b75e15502b05a108380d6bea0ed2ec2..0148f7dbf761fce4a38b3df4f14228f8c447a72d 100644 --- a/Device/InputOutput/OutputDataReader.cpp +++ b/Device/InputOutput/OutputDataReader.cpp @@ -28,11 +28,9 @@ #include <fstream> -namespace -{ +namespace { -std::stringstream getFromFilteredStream(std::istream& input_stream, const std::string& fname) -{ +std::stringstream getFromFilteredStream(std::istream& input_stream, const std::string& fname) { boost::iostreams::filtering_streambuf<boost::iostreams::input> input_filtered; if (DataFormatUtils::isGZipped(fname)) input_filtered.push(boost::iostreams::gzip_decompressor()); @@ -49,8 +47,7 @@ std::stringstream getFromFilteredStream(std::istream& input_stream, const std::s OutputDataReader::OutputDataReader(const std::string& file_name) : m_file_name(file_name) {} -OutputData<double>* OutputDataReader::getOutputData() -{ +OutputData<double>* OutputDataReader::getOutputData() { using namespace DataFormatUtils; if (!m_read_strategy) throw Exceptions::NullPointerException( @@ -82,7 +79,6 @@ OutputData<double>* OutputDataReader::getOutputData() return result; } -void OutputDataReader::setStrategy(IOutputDataReadStrategy* read_strategy) -{ +void OutputDataReader::setStrategy(IOutputDataReadStrategy* read_strategy) { m_read_strategy.reset(read_strategy); } diff --git a/Device/InputOutput/OutputDataReader.h b/Device/InputOutput/OutputDataReader.h index 2334d482db39d30254a2934e169f1bd00435a34f..c26622e4ea065893cbd346038ddb1b04cf50fa31 100644 --- a/Device/InputOutput/OutputDataReader.h +++ b/Device/InputOutput/OutputDataReader.h @@ -23,8 +23,7 @@ template <class T> class OutputData; //! Reads OutputData from file using different reading strategies. //! @ingroup input_output_internal -class OutputDataReader -{ +class OutputDataReader { public: OutputDataReader(const std::string& file_name); diff --git a/Device/InputOutput/OutputDataWriteFactory.cpp b/Device/InputOutput/OutputDataWriteFactory.cpp index 0d508878689537d6a0f9b53488002a65b0b229b0..e88da3abca0002465c946e799ce8ad14feb0ef85 100644 --- a/Device/InputOutput/OutputDataWriteFactory.cpp +++ b/Device/InputOutput/OutputDataWriteFactory.cpp @@ -15,15 +15,13 @@ #include "Base/Types/Exceptions.h" #include "Device/InputOutput/DataFormatUtils.h" -OutputDataWriter* OutputDataWriteFactory::getWriter(const std::string& file_name) -{ +OutputDataWriter* OutputDataWriteFactory::getWriter(const std::string& file_name) { OutputDataWriter* result = new OutputDataWriter(file_name); result->setStrategy(getWriteStrategy(file_name)); return result; } -IOutputDataWriteStrategy* OutputDataWriteFactory::getWriteStrategy(const std::string& file_name) -{ +IOutputDataWriteStrategy* OutputDataWriteFactory::getWriteStrategy(const std::string& file_name) { IOutputDataWriteStrategy* result(nullptr); if (DataFormatUtils::isIntFile(file_name)) { result = new OutputDataWriteINTStrategy(); diff --git a/Device/InputOutput/OutputDataWriteFactory.h b/Device/InputOutput/OutputDataWriteFactory.h index b1ca0c2530a52f55ac8291dde7f5102d39b03f74..0c0201714e87fc6b83721b90d5f19a53464998cf 100644 --- a/Device/InputOutput/OutputDataWriteFactory.h +++ b/Device/InputOutput/OutputDataWriteFactory.h @@ -20,8 +20,7 @@ //! Creates writer appropariate for given type of files. //! @ingroup input_output_internal -class OutputDataWriteFactory -{ +class OutputDataWriteFactory { public: static OutputDataWriter* getWriter(const std::string& file_name); diff --git a/Device/InputOutput/OutputDataWriteStrategy.cpp b/Device/InputOutput/OutputDataWriteStrategy.cpp index 038d216b0e5522e3d0de5a3b342e226b2830de6e..09cb8ecad0328a28a4e75a22a7c2cd6072908914 100644 --- a/Device/InputOutput/OutputDataWriteStrategy.cpp +++ b/Device/InputOutput/OutputDataWriteStrategy.cpp @@ -18,19 +18,16 @@ #include <cmath> #include <iomanip> -namespace -{ +namespace { const int precision{12}; -double IgnoreDenormalized(double value) -{ +double IgnoreDenormalized(double value) { if (std::fpclassify(value) == FP_SUBNORMAL) return 0.0; return value; } -void Write2DRepresentation(const OutputData<double>& data, std::ostream& output_stream) -{ +void Write2DRepresentation(const OutputData<double>& data, std::ostream& output_stream) { const size_t nrows = data.axis(1).size(); const size_t ncols = data.axis(0).size(); @@ -50,8 +47,7 @@ void Write2DRepresentation(const OutputData<double>& data, std::ostream& output_ } void WriteOutputDataDoubles(const OutputData<double>& data, std::ostream& output_stream, - size_t n_columns) -{ + size_t n_columns) { OutputData<double>::const_iterator it = data.begin(); output_stream.imbue(std::locale::classic()); @@ -68,8 +64,7 @@ void WriteOutputDataDoubles(const OutputData<double>& data, std::ostream& output } } -void Write1DRepresentation(const OutputData<double>& data, std::ostream& output_stream) -{ +void Write1DRepresentation(const OutputData<double>& data, std::ostream& output_stream) { output_stream << "# coordinates intensities" << std::endl; output_stream.imbue(std::locale::classic()); output_stream << std::scientific << std::setprecision(precision); @@ -87,8 +82,7 @@ void Write1DRepresentation(const OutputData<double>& data, std::ostream& output_ // ---------------------------------------------------------------------------- void OutputDataWriteINTStrategy::writeOutputData(const OutputData<double>& data, - std::ostream& output_stream) -{ + std::ostream& output_stream) { output_stream << "# BornAgain Intensity Data\n\n"; for (size_t i = 0; i < data.rank(); ++i) { @@ -111,8 +105,7 @@ void OutputDataWriteINTStrategy::writeOutputData(const OutputData<double>& data, // ---------------------------------------------------------------------------- void OutputDataWriteNumpyTXTStrategy::writeOutputData(const OutputData<double>& data, - std::ostream& output_stream) -{ + std::ostream& output_stream) { output_stream << "# BornAgain Intensity Data" << std::endl; output_stream << "# Simple array suitable for numpy, matlab etc." << std::endl; @@ -138,14 +131,12 @@ void OutputDataWriteNumpyTXTStrategy::writeOutputData(const OutputData<double>& OutputDataWriteTiffStrategy::OutputDataWriteTiffStrategy() : m_d(new TiffHandler) {} -OutputDataWriteTiffStrategy::~OutputDataWriteTiffStrategy() -{ +OutputDataWriteTiffStrategy::~OutputDataWriteTiffStrategy() { delete m_d; } void OutputDataWriteTiffStrategy::writeOutputData(const OutputData<double>& data, - std::ostream& output_stream) -{ + std::ostream& output_stream) { m_d->write(data, output_stream); } diff --git a/Device/InputOutput/OutputDataWriteStrategy.h b/Device/InputOutput/OutputDataWriteStrategy.h index c5740acd3af037065268580291df122aec63e58f..fb31435ecd331c47b20668fdf36bb8f03ffa47a4 100644 --- a/Device/InputOutput/OutputDataWriteStrategy.h +++ b/Device/InputOutput/OutputDataWriteStrategy.h @@ -22,8 +22,7 @@ template <class T> class OutputData; //! Strategy interface to write OututData in file //! @ingroup input_output_internal -class IOutputDataWriteStrategy -{ +class IOutputDataWriteStrategy { public: virtual ~IOutputDataWriteStrategy() = default; @@ -33,8 +32,7 @@ public: //! Strategy to write OutputData to special BornAgain ASCII format //! @ingroup input_output_internal -class OutputDataWriteINTStrategy : public IOutputDataWriteStrategy -{ +class OutputDataWriteINTStrategy : public IOutputDataWriteStrategy { public: virtual void writeOutputData(const OutputData<double>& data, std::ostream& output_stream); }; @@ -42,8 +40,7 @@ public: //! Strategy to write OutputData to simple ASCII file with the layout as in numpy.savetxt //! @ingroup input_output_internal -class OutputDataWriteNumpyTXTStrategy : public IOutputDataWriteStrategy -{ +class OutputDataWriteNumpyTXTStrategy : public IOutputDataWriteStrategy { public: virtual void writeOutputData(const OutputData<double>& data, std::ostream& output_stream); }; @@ -55,8 +52,7 @@ class TiffHandler; //! Strategy to write OutputData to tiff files //! @ingroup input_output_internal -class OutputDataWriteTiffStrategy : public IOutputDataWriteStrategy -{ +class OutputDataWriteTiffStrategy : public IOutputDataWriteStrategy { public: OutputDataWriteTiffStrategy(); virtual ~OutputDataWriteTiffStrategy(); diff --git a/Device/InputOutput/OutputDataWriter.cpp b/Device/InputOutput/OutputDataWriter.cpp index 4baaa3088c493f0e3dc51babd16ea090237ccb2f..b93c022d78449c65b063488bc8c8d43ba64fa78e 100644 --- a/Device/InputOutput/OutputDataWriter.cpp +++ b/Device/InputOutput/OutputDataWriter.cpp @@ -28,8 +28,7 @@ OutputDataWriter::OutputDataWriter(const std::string& file_name) : m_file_name(file_name) {} -void OutputDataWriter::writeOutputData(const OutputData<double>& data) -{ +void OutputDataWriter::writeOutputData(const OutputData<double>& data) { using namespace DataFormatUtils; if (!m_write_strategy) throw Exceptions::NullPointerException("OutputDataWriter::getOutputData() ->" @@ -68,7 +67,6 @@ void OutputDataWriter::writeOutputData(const OutputData<double>& data) fout.close(); } -void OutputDataWriter::setStrategy(IOutputDataWriteStrategy* write_strategy) -{ +void OutputDataWriter::setStrategy(IOutputDataWriteStrategy* write_strategy) { m_write_strategy.reset(write_strategy); } diff --git a/Device/InputOutput/OutputDataWriter.h b/Device/InputOutput/OutputDataWriter.h index 90708cb057934d6fe554065fcce051e49ed33338..0250416acd72ab95fbcc8c85677ee259232340b6 100644 --- a/Device/InputOutput/OutputDataWriter.h +++ b/Device/InputOutput/OutputDataWriter.h @@ -23,8 +23,7 @@ template <class T> class OutputData; //! Write OutputData to file using different witing strategies. //! @ingroup input_output_internal -class OutputDataWriter -{ +class OutputDataWriter { public: OutputDataWriter(const std::string& file_name); diff --git a/Device/InputOutput/TiffHandler.cpp b/Device/InputOutput/TiffHandler.cpp index c7f5655fdb2de440ad103ece0300051564b3db39..1704132757a90c080c087134bb932d3a5f54669e 100644 --- a/Device/InputOutput/TiffHandler.cpp +++ b/Device/InputOutput/TiffHandler.cpp @@ -24,17 +24,13 @@ TiffHandler::TiffHandler() , m_height(0) , m_bitsPerSample(0) , m_samplesPerPixel(0) - , m_sampleFormat(0) -{ -} + , m_sampleFormat(0) {} -TiffHandler::~TiffHandler() -{ +TiffHandler::~TiffHandler() { close(); } -void TiffHandler::read(std::istream& input_stream) -{ +void TiffHandler::read(std::istream& input_stream) { m_tiff = TIFFStreamOpen("MemTIFF", &input_stream); if (!m_tiff) { throw Exceptions::FormatErrorException("TiffHandler::read() -> Can't open the file."); @@ -44,13 +40,11 @@ void TiffHandler::read(std::istream& input_stream) close(); } -const OutputData<double>* TiffHandler::getOutputData() const -{ +const OutputData<double>* TiffHandler::getOutputData() const { return m_data.get(); } -void TiffHandler::write(const OutputData<double>& data, std::ostream& output_stream) -{ +void TiffHandler::write(const OutputData<double>& data, std::ostream& output_stream) { m_data.reset(data.clone()); if (m_data->rank() != 2) throw Exceptions::LogicErrorException("TiffHandler::write -> Error. " @@ -63,8 +57,7 @@ void TiffHandler::write(const OutputData<double>& data, std::ostream& output_str close(); } -void TiffHandler::read_header() -{ +void TiffHandler::read_header() { ASSERT(m_tiff); uint32 width(0); uint32 height(0); @@ -120,8 +113,7 @@ void TiffHandler::read_header() } } -void TiffHandler::read_data() -{ +void TiffHandler::read_data() { ASSERT(m_tiff); ASSERT(0 == m_bitsPerSample % 8); @@ -199,8 +191,7 @@ void TiffHandler::read_data() _TIFFfree(buf); } -void TiffHandler::write_header() -{ +void TiffHandler::write_header() { ASSERT(m_tiff); TIFFSetField(m_tiff, TIFFTAG_ARTIST, "BornAgain.IOFactory"); TIFFSetField(m_tiff, TIFFTAG_DATETIME, SysUtils::getCurrentDateAndTime().c_str()); @@ -221,8 +212,7 @@ void TiffHandler::write_header() TIFFSetField(m_tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); } -void TiffHandler::write_data() -{ +void TiffHandler::write_data() { typedef int sample_t; tmsize_t buf_size = sizeof(sample_t) * m_width; tdata_t buf = _TIFFmalloc(buf_size); @@ -250,8 +240,7 @@ void TiffHandler::write_data() TIFFFlush(m_tiff); } -void TiffHandler::close() -{ +void TiffHandler::close() { if (m_tiff) { TIFFClose(m_tiff); m_tiff = 0; @@ -260,8 +249,7 @@ void TiffHandler::close() } } -void TiffHandler::create_output_data() -{ +void TiffHandler::create_output_data() { ASSERT(m_tiff); m_data.reset(new OutputData<double>); m_data->addAxis("x", m_width, 0.0, double(m_width)); diff --git a/Device/InputOutput/TiffHandler.h b/Device/InputOutput/TiffHandler.h index 5849afed48f3a5f6e450f2e904a5496ca4c03a73..dbf3cae9e54f50cdc59cef916f80097230b708b5 100644 --- a/Device/InputOutput/TiffHandler.h +++ b/Device/InputOutput/TiffHandler.h @@ -24,8 +24,7 @@ //! Reads/write tiff files, should be used through TiffReadStrategy. //! @ingroup input_output_internal -class TiffHandler -{ +class TiffHandler { public: TiffHandler(); ~TiffHandler(); diff --git a/Device/Instrument/ChiSquaredModule.cpp b/Device/Instrument/ChiSquaredModule.cpp index d4a603cc91af31907fd59de439614f44bf5042ea..20054b719adb85f194754f7f0aa5b13020d94f42 100644 --- a/Device/Instrument/ChiSquaredModule.cpp +++ b/Device/Instrument/ChiSquaredModule.cpp @@ -19,8 +19,7 @@ #include <cmath> #include <limits> -double ChiSquaredModule::residual(double a, double b, double weight) -{ +double ChiSquaredModule::residual(double a, double b, double weight) { double value_simu = a; double value_real = b; diff --git a/Device/Instrument/ChiSquaredModule.h b/Device/Instrument/ChiSquaredModule.h index 9f9d6e7c7dbd7748c591a80f7ae963e5f511f562..9f38ccee04f8427af61e4ba45e177d6bb678bcd5 100644 --- a/Device/Instrument/ChiSquaredModule.h +++ b/Device/Instrument/ChiSquaredModule.h @@ -20,8 +20,7 @@ //! Calculation of chi2 between two data sets. //! @ingroup fitting -class ChiSquaredModule : public IChiSquaredModule -{ +class ChiSquaredModule : public IChiSquaredModule { public: ChiSquaredModule() {} ChiSquaredModule(const ChiSquaredModule& other) : IChiSquaredModule(other) {} diff --git a/Device/Instrument/FourierTransform.cpp b/Device/Instrument/FourierTransform.cpp index 396923f3f0956740e32b4e3e7af5b2947d038c6f..d524989146bce88336d9c0de9a63e7fb63d0f802 100644 --- a/Device/Instrument/FourierTransform.cpp +++ b/Device/Instrument/FourierTransform.cpp @@ -24,17 +24,13 @@ FourierTransform::FourierTransform() = default; FourierTransform::Workspace::Workspace() - : h_src(0), w_src(0), h_fftw(0), w_fftw(0), in_src(0), out_fftw(0), p_forw_src(nullptr) -{ -} + : h_src(0), w_src(0), h_fftw(0), w_fftw(0), in_src(0), out_fftw(0), p_forw_src(nullptr) {} -FourierTransform::Workspace::~Workspace() -{ +FourierTransform::Workspace::~Workspace() { clear(); } -void FourierTransform::Workspace::clear() -{ +void FourierTransform::Workspace::clear() { // rows (h) and columns (w) of the input 'source' h_src = 0; w_src = 0; @@ -56,8 +52,7 @@ void FourierTransform::Workspace::clear() /* ************************************************************************* */ // Fourier Transform in 2D /* ************************************************************************* */ -void FourierTransform::fft(const double2d_t& source, double2d_t& result) -{ +void FourierTransform::fft(const double2d_t& source, double2d_t& result) { // rows (h) and columns (w) of the input 'source' int h_src = static_cast<int>(source.size()); int w_src = static_cast<int>((source.size() ? source[0].size() : 0)); @@ -93,8 +88,7 @@ void FourierTransform::fft(const double2d_t& source, double2d_t& result) /* ************************************************************************* */ // Fourier Transform 2D shift - center array around zero frequency /* ************************************************************************* */ -void FourierTransform::fftshift(double2d_t& result) -{ +void FourierTransform::fftshift(double2d_t& result) { // Centering FT around zero frequency size_t row_shift; if (result.size() % 2 == 0) @@ -121,8 +115,7 @@ void FourierTransform::fftshift(double2d_t& result) /* ************************************************************************* */ // Fourier Transform in 1D /* ************************************************************************* */ -void FourierTransform::fft(const double1d_t& source, double1d_t& result) -{ +void FourierTransform::fft(const double1d_t& source, double1d_t& result) { // we simply create 2d arrays with length of first dimension equal to 1, and call 2d FT double2d_t source2d; source2d.push_back(source); @@ -139,8 +132,7 @@ void FourierTransform::fft(const double1d_t& source, double1d_t& result) /* ************************************************************************* */ // Fourier Transform 1D shift - center around zero frequency /* ************************************************************************* */ -void FourierTransform::fftshift(double1d_t& result) -{ +void FourierTransform::fftshift(double1d_t& result) { // Centering FT around zero frequency size_t col_shift; if (result.size() % 2 == 0) @@ -154,8 +146,7 @@ void FourierTransform::fftshift(double1d_t& result) /* ************************************************************************************ */ // initialise input and output arrays in workspace for fast Fourier transformation (fftw) /* ************************************************************************************ */ -void FourierTransform::init(int h_src, int w_src) -{ +void FourierTransform::init(int h_src, int w_src) { if (!h_src || !w_src) { std::ostringstream os; os << "FourierTransform::init() -> Panic! Wrong dimensions " << h_src << " " << w_src @@ -189,8 +180,7 @@ void FourierTransform::init(int h_src, int w_src) // initialise input and output arrays for fast Fourier transformation /* ************************************************************************* */ -void FourierTransform::fftw_forward_FT(const double2d_t& src) -{ +void FourierTransform::fftw_forward_FT(const double2d_t& src) { if (ws.h_fftw <= 0 || ws.w_fftw <= 0) throw Exceptions::RuntimeErrorException( "FourierTransform::fftw_forward_FT() -> Panic! Initialisation is missed."); diff --git a/Device/Instrument/FourierTransform.h b/Device/Instrument/FourierTransform.h index b4441383c6c5d080b5c11ae2254f93487052c6f8..75be1261b9e9abbf695888c243c41fac7b65b1af 100644 --- a/Device/Instrument/FourierTransform.h +++ b/Device/Instrument/FourierTransform.h @@ -31,8 +31,7 @@ //! by Jeremy Fix, May 30, 2011 //! //! @ingroup tools_internal -class FourierTransform -{ +class FourierTransform { public: //! definition of 1D vector of double typedef std::vector<double> double1d_t; @@ -66,8 +65,7 @@ private: //! Workspace contains input (src), intermediate and output (out) //! arrays to run FT via fft; 'source' is our signal //! Output arrays are allocated via fftw3 allocation for maximum performance. - class Workspace - { + class Workspace { public: Workspace(); ~Workspace(); diff --git a/Device/Instrument/IChiSquaredModule.cpp b/Device/Instrument/IChiSquaredModule.cpp index e9c4c0bd257b7053b5501b427dbcf11a65b24c38..68ba170cecf257af8247031b5b8f57bf594117bc 100644 --- a/Device/Instrument/IChiSquaredModule.cpp +++ b/Device/Instrument/IChiSquaredModule.cpp @@ -18,13 +18,11 @@ IChiSquaredModule::IChiSquaredModule() : m_variance_function(new VarianceSimFunction) {} -const IVarianceFunction* IChiSquaredModule::varianceFunction() const -{ +const IVarianceFunction* IChiSquaredModule::varianceFunction() const { return m_variance_function.get(); } -IChiSquaredModule::IChiSquaredModule(const IChiSquaredModule& other) : ICloneable() -{ +IChiSquaredModule::IChiSquaredModule(const IChiSquaredModule& other) : ICloneable() { if (other.m_variance_function) m_variance_function.reset(other.m_variance_function->clone()); @@ -34,17 +32,14 @@ IChiSquaredModule::IChiSquaredModule(const IChiSquaredModule& other) : ICloneabl IChiSquaredModule::~IChiSquaredModule() = default; -void IChiSquaredModule::setVarianceFunction(const IVarianceFunction& variance_function) -{ +void IChiSquaredModule::setVarianceFunction(const IVarianceFunction& variance_function) { m_variance_function.reset(variance_function.clone()); } -const IIntensityFunction* IChiSquaredModule::getIntensityFunction() const -{ +const IIntensityFunction* IChiSquaredModule::getIntensityFunction() const { return m_intensity_function.get(); } -void IChiSquaredModule::setIntensityFunction(const IIntensityFunction& intensity_function) -{ +void IChiSquaredModule::setIntensityFunction(const IIntensityFunction& intensity_function) { m_intensity_function.reset(intensity_function.clone()); } diff --git a/Device/Instrument/IChiSquaredModule.h b/Device/Instrument/IChiSquaredModule.h index b1869f8e1a394cebd741249839740f39bb3cef4f..3e66f788e0da0abbb2fdfd295fb5ff993ae23bf0 100644 --- a/Device/Instrument/IChiSquaredModule.h +++ b/Device/Instrument/IChiSquaredModule.h @@ -24,8 +24,7 @@ class IIntensityFunction; //! Interface residual calculations. //! @ingroup fitting_internal -class IChiSquaredModule : public ICloneable -{ +class IChiSquaredModule : public ICloneable { public: IChiSquaredModule(); virtual ~IChiSquaredModule(); diff --git a/Device/Instrument/Instrument.cpp b/Device/Instrument/Instrument.cpp index c38eb3fb2f2d0001c6584b1a095c4c01c37d031b..6fab0c1e6931e4bafb081cfcc38e844271cbc614 100644 --- a/Device/Instrument/Instrument.cpp +++ b/Device/Instrument/Instrument.cpp @@ -17,15 +17,13 @@ #include "Device/Histo/Histogram2D.h" #include "Device/Resolution/IResolutionFunction2D.h" -Instrument::Instrument() : m_detector(new SphericalDetector), m_beam(Beam::horizontalBeam()) -{ +Instrument::Instrument() : m_detector(new SphericalDetector), m_beam(Beam::horizontalBeam()) { setName("Instrument"); registerChild(m_detector.get()); registerChild(&m_beam); } -Instrument::Instrument(const Instrument& other) : INode(), m_beam(other.m_beam) -{ +Instrument::Instrument(const Instrument& other) : INode(), m_beam(other.m_beam) { if (other.m_detector) setDetector(*other.m_detector); registerChild(&m_beam); @@ -34,8 +32,7 @@ Instrument::Instrument(const Instrument& other) : INode(), m_beam(other.m_beam) Instrument::~Instrument() = default; -Instrument& Instrument::operator=(const Instrument& other) -{ +Instrument& Instrument::operator=(const Instrument& other) { if (this != &other) { m_beam = other.m_beam; registerChild(&m_beam); @@ -45,23 +42,20 @@ Instrument& Instrument::operator=(const Instrument& other) return *this; } -void Instrument::setDetector(const IDetector& detector) -{ +void Instrument::setDetector(const IDetector& detector) { m_detector.reset(detector.clone()); registerChild(m_detector.get()); initDetector(); } -void Instrument::initDetector() -{ +void Instrument::initDetector() { if (!m_detector) throw Exceptions::RuntimeErrorException( "Instrument::initDetector() -> Error. Detector is not initialized."); m_detector->init(beam()); } -std::vector<const INode*> Instrument::getChildren() const -{ +std::vector<const INode*> Instrument::getChildren() const { std::vector<const INode*> result; result.push_back(&m_beam); if (m_detector) @@ -69,75 +63,62 @@ std::vector<const INode*> Instrument::getChildren() const return result; } -void Instrument::setDetectorResolutionFunction(const IResolutionFunction2D& p_resolution_function) -{ +void Instrument::setDetectorResolutionFunction(const IResolutionFunction2D& p_resolution_function) { m_detector->setResolutionFunction(p_resolution_function); } -void Instrument::removeDetectorResolution() -{ +void Instrument::removeDetectorResolution() { m_detector->removeDetectorResolution(); } -void Instrument::applyDetectorResolution(OutputData<double>* p_intensity_map) const -{ +void Instrument::applyDetectorResolution(OutputData<double>* p_intensity_map) const { m_detector->applyDetectorResolution(p_intensity_map); } -void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i) -{ +void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i) { m_beam.setCentralK(wavelength, alpha_i, phi_i); if (m_detector) initDetector(); } -const DetectorMask* Instrument::getDetectorMask() const -{ +const DetectorMask* Instrument::getDetectorMask() const { return m_detector->detectorMask(); } -void Instrument::setBeam(const Beam& beam) -{ +void Instrument::setBeam(const Beam& beam) { m_beam = beam; if (m_detector) initDetector(); } -void Instrument::setBeamIntensity(double intensity) -{ +void Instrument::setBeamIntensity(double intensity) { m_beam.setIntensity(intensity); } -void Instrument::setBeamPolarization(const kvector_t bloch_vector) -{ +void Instrument::setBeamPolarization(const kvector_t bloch_vector) { m_beam.setPolarization(bloch_vector); } -double Instrument::getBeamIntensity() const -{ +double Instrument::getBeamIntensity() const { return m_beam.getIntensity(); } -const IDetector* Instrument::getDetector() const -{ +const IDetector* Instrument::getDetector() const { ASSERT(m_detector); return m_detector.get(); } -const IDetector& Instrument::detector() const -{ +const IDetector& Instrument::detector() const { ASSERT(m_detector); return *m_detector; } -IDetector& Instrument::detector() -{ +IDetector& Instrument::detector() { ASSERT(m_detector); return *m_detector; } -IDetector2D& Instrument::detector2D() -{ +IDetector2D& Instrument::detector2D() { ASSERT(m_detector); IDetector2D* p = dynamic_cast<IDetector2D*>(m_detector.get()); if (!p) @@ -145,8 +126,7 @@ IDetector2D& Instrument::detector2D() return *p; } -const IDetector2D& Instrument::detector2D() const -{ +const IDetector2D& Instrument::detector2D() const { ASSERT(m_detector); IDetector2D* const p = dynamic_cast<IDetector2D* const>(m_detector.get()); if (!p) @@ -154,18 +134,15 @@ const IDetector2D& Instrument::detector2D() const return *p; } -const IAxis& Instrument::getDetectorAxis(size_t index) const -{ +const IAxis& Instrument::getDetectorAxis(size_t index) const { return m_detector->axis(index); } -size_t Instrument::getDetectorDimension() const -{ +size_t Instrument::getDetectorDimension() const { return m_detector->dimension(); } void Instrument::setAnalyzerProperties(const kvector_t direction, double efficiency, - double total_transmission) -{ + double total_transmission) { m_detector->setAnalyzerProperties(direction, efficiency, total_transmission); } diff --git a/Device/Instrument/Instrument.h b/Device/Instrument/Instrument.h index 2ce8d97b0c2b403fd299fdd03068a56a4cf0d4be..18c72d98608eff41f2e4751a3edf488a86a98f85 100644 --- a/Device/Instrument/Instrument.h +++ b/Device/Instrument/Instrument.h @@ -30,8 +30,7 @@ class SimulationElement; //! Assembles beam, detector and their relative positions with respect to the sample. //! @ingroup simulation_internal -class Instrument : public INode -{ +class Instrument : public INode { public: Instrument(); Instrument(const Instrument& other); diff --git a/Device/Instrument/IntensityDataFunctions.cpp b/Device/Instrument/IntensityDataFunctions.cpp index 16fb1b119b8ff50705f3655b90011e8ecef82984..833051be814f3ef52664a9fc9eba292285f60e4b 100644 --- a/Device/Instrument/IntensityDataFunctions.cpp +++ b/Device/Instrument/IntensityDataFunctions.cpp @@ -26,8 +26,7 @@ //! Returns sum of relative differences between each pair of elements: //! (a, b) -> 2*abs(a - b)/(|a| + |b|) ( and zero if a=b=0 within epsilon ) double IntensityDataFunctions::RelativeDifference(const SimulationResult& dat, - const SimulationResult& ref) -{ + const SimulationResult& ref) { if (dat.size() != ref.size()) throw std::runtime_error("Error in IntensityDataFunctions::RelativeDifference: " "different number of elements"); @@ -42,8 +41,7 @@ double IntensityDataFunctions::RelativeDifference(const SimulationResult& dat, //! Returns relative difference between two data sets sum(dat[i] - ref[i])/ref[i]). double IntensityDataFunctions::getRelativeDifference(const OutputData<double>& dat, - const OutputData<double>& ref) -{ + const OutputData<double>& ref) { if (!dat.hasSameDimensions(ref)) throw Exceptions::RuntimeErrorException( "IntensityDataFunctions::getRelativeDifference() -> " @@ -59,8 +57,7 @@ double IntensityDataFunctions::getRelativeDifference(const OutputData<double>& d return diff; } -double IntensityDataFunctions::getRelativeDifference(const IHistogram& dat, const IHistogram& ref) -{ +double IntensityDataFunctions::getRelativeDifference(const IHistogram& dat, const IHistogram& ref) { return getRelativeDifference(*std::unique_ptr<OutputData<double>>(dat.getData().meanValues()), *std::unique_ptr<OutputData<double>>(ref.getData().meanValues())); } @@ -68,8 +65,7 @@ double IntensityDataFunctions::getRelativeDifference(const IHistogram& dat, cons //! Returns true is relative difference is below threshold; prints informative output bool IntensityDataFunctions::checkRelativeDifference(const OutputData<double>& dat, const OutputData<double>& ref, - const double threshold) -{ + const double threshold) { const double diff = getRelativeDifference(dat, ref); if (diff > threshold) { std::cerr << " => FAILED: relative deviation of dat from ref is " << diff @@ -86,8 +82,7 @@ bool IntensityDataFunctions::checkRelativeDifference(const OutputData<double>& d std::unique_ptr<OutputData<double>> IntensityDataFunctions::createRelativeDifferenceData(const OutputData<double>& data, - const OutputData<double>& reference) -{ + const OutputData<double>& reference) { if (!data.hasSameDimensions(reference)) throw Exceptions::RuntimeErrorException( "IntensityDataFunctions::createRelativeDifferenceData() -> " @@ -99,8 +94,7 @@ IntensityDataFunctions::createRelativeDifferenceData(const OutputData<double>& d } std::unique_ptr<OutputData<double>> -IntensityDataFunctions::createRearrangedDataSet(const OutputData<double>& data, int n) -{ +IntensityDataFunctions::createRearrangedDataSet(const OutputData<double>& data, int n) { if (data.rank() != 2) throw Exceptions::LogicErrorException("IntensityDataFunctions::rotateDataByN90Deg()" " -> Error! Works only on two-dimensional data"); @@ -146,8 +140,7 @@ IntensityDataFunctions::createRearrangedDataSet(const OutputData<double>& data, std::unique_ptr<OutputData<double>> IntensityDataFunctions::createClippedDataSet(const OutputData<double>& origin, double x1, double y1, - double x2, double y2) -{ + double x2, double y2) { if (origin.rank() != 2) throw Exceptions::LogicErrorException("IntensityDataFunctions::createClippedData()" " -> Error! Works only on two-dimensional data"); @@ -186,16 +179,14 @@ IntensityDataFunctions::createClippedDataSet(const OutputData<double>& origin, d // (center of non-existing bin #-1). // Used for Mask conversion. -double IntensityDataFunctions::coordinateToBinf(double coordinate, const IAxis& axis) -{ +double IntensityDataFunctions::coordinateToBinf(double coordinate, const IAxis& axis) { size_t index = axis.findClosestIndex(coordinate); Bin1D bin = axis.bin(index); double f = (coordinate - bin.m_lower) / bin.binSize(); return static_cast<double>(index) + f; } -double IntensityDataFunctions::coordinateFromBinf(double value, const IAxis& axis) -{ +double IntensityDataFunctions::coordinateFromBinf(double value, const IAxis& axis) { int index = static_cast<int>(value); double result(0); @@ -213,22 +204,20 @@ double IntensityDataFunctions::coordinateFromBinf(double value, const IAxis& axi return result; } -void IntensityDataFunctions::coordinateToBinf(double& x, double& y, const OutputData<double>& data) -{ +void IntensityDataFunctions::coordinateToBinf(double& x, double& y, + const OutputData<double>& data) { x = coordinateToBinf(x, data.axis(0)); y = coordinateToBinf(y, data.axis(1)); } void IntensityDataFunctions::coordinateFromBinf(double& x, double& y, - const OutputData<double>& data) -{ + const OutputData<double>& data) { x = coordinateFromBinf(x, data.axis(0)); y = coordinateFromBinf(y, data.axis(1)); } std::vector<std::vector<double>> -IntensityDataFunctions::create2DArrayfromOutputData(const OutputData<double>& data) -{ +IntensityDataFunctions::create2DArrayfromOutputData(const OutputData<double>& data) { if (data.rank() != 2) throw Exceptions::LogicErrorException( "IntensityDataFunctions::create2DArrayfromOutputData() -> " @@ -254,8 +243,7 @@ IntensityDataFunctions::create2DArrayfromOutputData(const OutputData<double>& da } std::vector<std::vector<double>> -IntensityDataFunctions::FT2DArray(const std::vector<std::vector<double>>& signal) -{ +IntensityDataFunctions::FT2DArray(const std::vector<std::vector<double>>& signal) { FourierTransform ft; std::vector<std::vector<double>> fft_array; ft.fft(signal, fft_array); @@ -266,8 +254,7 @@ IntensityDataFunctions::FT2DArray(const std::vector<std::vector<double>>& signal } std::unique_ptr<OutputData<double>> IntensityDataFunctions::createOutputDatafrom2DArray( - const std::vector<std::vector<double>>& array_2d) -{ + const std::vector<std::vector<double>>& array_2d) { std::unique_ptr<OutputData<double>> result(new OutputData<double>); size_t nrows = array_2d.size(); size_t ncols = array_2d[0].size(); @@ -288,8 +275,7 @@ std::unique_ptr<OutputData<double>> IntensityDataFunctions::createOutputDatafrom } std::unique_ptr<OutputData<double>> -IntensityDataFunctions::createFFT(const OutputData<double>& data) -{ +IntensityDataFunctions::createFFT(const OutputData<double>& data) { auto array_2d = IntensityDataFunctions::create2DArrayfromOutputData(data); auto fft_array_2d = IntensityDataFunctions::FT2DArray(array_2d); return IntensityDataFunctions::createOutputDatafrom2DArray(fft_array_2d); diff --git a/Device/Instrument/IntensityDataFunctions.h b/Device/Instrument/IntensityDataFunctions.h index 8f934aad954359229ad43f3b97a7f29b34518fa8..f81986a4ff04f27d1c952b354645cec64a7cc953 100644 --- a/Device/Instrument/IntensityDataFunctions.h +++ b/Device/Instrument/IntensityDataFunctions.h @@ -25,8 +25,7 @@ class ISimulation; //! Functions to work with intensity data. //! @ingroup tools -namespace IntensityDataFunctions -{ +namespace IntensityDataFunctions { //! Returns sum of relative differences between each pair of elements: //! (a, b) -> 2*abs(a - b)/(a + b) ( and zero if a-b=0 ) double RelativeDifference(const SimulationResult& dat, const SimulationResult& ref); diff --git a/Device/Instrument/PyArrayImportUtils.cpp b/Device/Instrument/PyArrayImportUtils.cpp index 448dc98bf453280edad720143dacc4b93c355503..7e229a1be38068c5f01f61ef7d18ba12775d73c0 100644 --- a/Device/Instrument/PyArrayImportUtils.cpp +++ b/Device/Instrument/PyArrayImportUtils.cpp @@ -15,13 +15,11 @@ #include "Device/Instrument/PyArrayImportUtils.h" #include "Device/Intensity/ArrayUtils.h" -OutputData<double>* PyArrayImport::importArrayToOutputData(const std::vector<double>& vec) -{ +OutputData<double>* PyArrayImport::importArrayToOutputData(const std::vector<double>& vec) { return ArrayUtils::createData(vec).release(); } OutputData<double>* -PyArrayImport::importArrayToOutputData(const std::vector<std::vector<double>>& vec) -{ +PyArrayImport::importArrayToOutputData(const std::vector<std::vector<double>>& vec) { return ArrayUtils::createData(vec).release(); } diff --git a/Device/Instrument/PyArrayImportUtils.h b/Device/Instrument/PyArrayImportUtils.h index cb9466de10609e35f737e912cf8e905f7868c3cd..0f6d1229a8d0c17a601ab79c5c9e7983b17707be 100644 --- a/Device/Instrument/PyArrayImportUtils.h +++ b/Device/Instrument/PyArrayImportUtils.h @@ -22,8 +22,7 @@ template <class T> class OutputData; //! Functions for numpy array import to OutputData. //! Required solely as a shortcut to produce OutputData from numpy arrays of doubles. -namespace PyArrayImport -{ +namespace PyArrayImport { //! for importing 1D array of doubles from python into OutputData OutputData<double>* importArrayToOutputData(const std::vector<double>& vec); diff --git a/Device/Instrument/PyFmt2.cpp b/Device/Instrument/PyFmt2.cpp index f29689d54c66e584e06af10c8b10a4f8a6f76c84..5bb8f5c49e4e62ad1ece43867c1068b7b1480202 100644 --- a/Device/Instrument/PyFmt2.cpp +++ b/Device/Instrument/PyFmt2.cpp @@ -30,14 +30,12 @@ #include "Param/Varia/PyFmtLimits.h" #include <iomanip> -namespace pyfmt2 -{ +namespace pyfmt2 { //! Returns fixed Python code snippet that defines the function "runSimulation". std::string representShape2D(const std::string& indent, const IShape2D* ishape, bool mask_value, - std::function<std::string(double)> printValueFunc) -{ + std::function<std::string(double)> printValueFunc) { std::ostringstream result; result << std::setprecision(12); @@ -94,8 +92,7 @@ std::string representShape2D(const std::string& indent, const IShape2D* ishape, //! Returns parameter value, followed by its unit multiplicator (like "* nm"). -std::string valueTimesUnit(const RealParameter* par) -{ +std::string valueTimesUnit(const RealParameter* par) { if (par->unit() == "rad") return pyfmt::printDegrees(par->value()); return pyfmt::printDouble(par->value()) + (par->unit() == "" ? "" : ("*" + par->unit())); @@ -103,8 +100,7 @@ std::string valueTimesUnit(const RealParameter* par) //! Returns comma-separated list of parameter values, including unit multiplicator (like "* nm"). -std::string argumentList(const IParameterized* ip) -{ +std::string argumentList(const IParameterized* ip) { std::vector<std::string> args; for (const auto* par : ip->parameterPool()->parameters()) args.push_back(valueTimesUnit(par)); @@ -114,8 +110,7 @@ std::string argumentList(const IParameterized* ip) //! Prints distribution with constructor parameters in given units. //! ba.DistributionGaussian(2.0*deg, 0.02*deg) -std::string printDistribution(const IDistribution1D& par_distr, const std::string& units) -{ +std::string printDistribution(const IDistribution1D& par_distr, const std::string& units) { std::unique_ptr<IDistribution1D> distr(par_distr.clone()); distr->setUnits(units); @@ -125,8 +120,7 @@ std::string printDistribution(const IDistribution1D& par_distr, const std::strin } std::string printParameterDistribution(const ParameterDistribution& par_distr, - const std::string& distVarName, const std::string& units) -{ + const std::string& distVarName, const std::string& units) { std::ostringstream result; result << "ba.ParameterDistribution(" diff --git a/Device/Instrument/PyFmt2.h b/Device/Instrument/PyFmt2.h index e3ff15af1a01aa123cbf2a275500edcd23d136dd..099af771478b5cab98ce7ecf99b43024890b6ead 100644 --- a/Device/Instrument/PyFmt2.h +++ b/Device/Instrument/PyFmt2.h @@ -26,8 +26,7 @@ class ParameterDistribution; //! Utility functions for writing Python code snippets. -namespace pyfmt2 -{ +namespace pyfmt2 { std::string representShape2D(const std::string& indent, const IShape2D* ishape, bool mask_value, std::function<std::string(double)> printValueFunc); diff --git a/Device/Instrument/SpectrumUtils.cpp b/Device/Instrument/SpectrumUtils.cpp index 66f25ec6009819cf127c07f5ce44ddbbcb25c28a..87b192fcd57a42aaff940643bca702089864a803 100644 --- a/Device/Instrument/SpectrumUtils.cpp +++ b/Device/Instrument/SpectrumUtils.cpp @@ -19,8 +19,7 @@ std::vector<std::pair<double, double>> SpectrumUtils::FindPeaks(const Histogram2D& hist, double sigma, const std::string& option, - double threshold) -{ + double threshold) { std::unique_ptr<OutputData<double>> data(hist.createOutputData()); std::vector<std::vector<double>> arr = ArrayUtils::createVector2D(*data); tspectrum::Spectrum2D spec; diff --git a/Device/Instrument/SpectrumUtils.h b/Device/Instrument/SpectrumUtils.h index 66f7d6162dc039987e7a55658829ee3e10157124..a8c897386d0cbe222f64b863edbddd3c1de9c393 100644 --- a/Device/Instrument/SpectrumUtils.h +++ b/Device/Instrument/SpectrumUtils.h @@ -23,8 +23,7 @@ class Histogram2D; //! Collection of utils for 1D and 2D spectrum processing (background, peaks, ets). -namespace SpectrumUtils -{ +namespace SpectrumUtils { std::vector<std::pair<double, double>> FindPeaks(const Histogram2D& hist, double sigma = 2, const std::string& option = {}, diff --git a/Device/Instrument/VarianceFunctions.cpp b/Device/Instrument/VarianceFunctions.cpp index 138fbd3313c22444a061a84faac787ab06041597..ce2901780280308f16cf12d814bbfa68064d72b2 100644 --- a/Device/Instrument/VarianceFunctions.cpp +++ b/Device/Instrument/VarianceFunctions.cpp @@ -19,13 +19,11 @@ // class VarianceConstantFunction // ************************************************************************************************ -VarianceConstantFunction* VarianceConstantFunction::clone() const -{ +VarianceConstantFunction* VarianceConstantFunction::clone() const { return new VarianceConstantFunction(); } -double VarianceConstantFunction::variance(double, double) const -{ +double VarianceConstantFunction::variance(double, double) const { return 1.0; } @@ -35,12 +33,10 @@ double VarianceConstantFunction::variance(double, double) const VarianceSimFunction::VarianceSimFunction(double epsilon) : m_epsilon(epsilon) {} -VarianceSimFunction* VarianceSimFunction::clone() const -{ +VarianceSimFunction* VarianceSimFunction::clone() const { return new VarianceSimFunction(m_epsilon); } -double VarianceSimFunction::variance(double /*exp*/, double sim) const -{ +double VarianceSimFunction::variance(double /*exp*/, double sim) const { return std::max(sim, m_epsilon); } diff --git a/Device/Instrument/VarianceFunctions.h b/Device/Instrument/VarianceFunctions.h index 3d77292f8415537c38880ec67f8d47c2d9ecf111..fb27ea2bdb8331965eec8454f53c046687b356ac 100644 --- a/Device/Instrument/VarianceFunctions.h +++ b/Device/Instrument/VarianceFunctions.h @@ -18,8 +18,7 @@ //! Variance function interface. //! @ingroup fitting_internal -class IVarianceFunction -{ +class IVarianceFunction { public: IVarianceFunction() = default; virtual ~IVarianceFunction() = default; @@ -33,8 +32,7 @@ public: //! Returns 1.0 as variance value //! @ingroup fitting -class VarianceConstantFunction : public IVarianceFunction -{ +class VarianceConstantFunction : public IVarianceFunction { public: VarianceConstantFunction* clone() const override; double variance(double, double) const override; @@ -43,8 +41,7 @@ public: //! Returns max(sim, epsilon) //! @ingroup fitting -class VarianceSimFunction : public IVarianceFunction -{ +class VarianceSimFunction : public IVarianceFunction { public: explicit VarianceSimFunction(double epsilon = 1.0); VarianceSimFunction* clone() const override; diff --git a/Device/Intensity/ArrayUtils.cpp b/Device/Intensity/ArrayUtils.cpp index 91570939d1009662d9ba582285d275aad43caeed..0a896fc49293acaa37e0c4e65a093f181789c9e6 100644 --- a/Device/Intensity/ArrayUtils.cpp +++ b/Device/Intensity/ArrayUtils.cpp @@ -17,8 +17,7 @@ #include "Device/Intensity/ArrayUtils.h" #include "Base/Utils/PythonCore.h" -PyObject* ArrayUtils::createNumpyArray(const std::vector<double>& data) -{ +PyObject* ArrayUtils::createNumpyArray(const std::vector<double>& data) { const size_t ndim(1); npy_int ndim_numpy = ndim; npy_intp* ndimsizes_numpy = new npy_intp[ndim]; diff --git a/Device/Intensity/ArrayUtils.h b/Device/Intensity/ArrayUtils.h index dfdd956c5542bbbbff856cdd01d2b4abaccfe491..9a667484312696da7ec1ba4348f59f13ce4d9e4b 100644 --- a/Device/Intensity/ArrayUtils.h +++ b/Device/Intensity/ArrayUtils.h @@ -22,13 +22,11 @@ //! Array and Numpy utility functions getShape, createNumpyArray. -namespace ArrayUtils -{ +namespace ArrayUtils { //! Returns shape nrows, ncols of 2D array. template <class T> std::pair<size_t, size_t> getShape(const T& data); -class CreateDataImpl -{ +class CreateDataImpl { //! Holds the dimensionality of template argument as the enum value. //! Intended for vectors only. template <typename T> struct nDim { @@ -38,9 +36,7 @@ class CreateDataImpl enum { value = 1 + nDim<T>::value }; }; - template <typename T> struct baseClass { - using value = T; - }; + template <typename T> struct baseClass { using value = T; }; template <typename T, typename A> struct baseClass<std::vector<T, A>> { using value = typename baseClass<T>::value; }; @@ -58,8 +54,7 @@ class CreateDataImpl }; //! Creates OutputData array from input vector. -template <class T> CreateDataImpl::ReturnType<T> createData(const T& vec) -{ +template <class T> CreateDataImpl::ReturnType<T> createData(const T& vec) { constexpr const int size = CreateDataImpl::nDim<T>::value; static_assert( size == 1 || size == 2, @@ -83,8 +78,8 @@ template <class T> decltype(auto) createVector2D(const T& data); } // namespace ArrayUtils template <class T> -std::unique_ptr<OutputData<T>> ArrayUtils::CreateDataImpl::createDataImpl(const std::vector<T>& vec) -{ +std::unique_ptr<OutputData<T>> +ArrayUtils::CreateDataImpl::createDataImpl(const std::vector<T>& vec) { auto result = std::make_unique<OutputData<T>>(); const size_t length = vec.size(); result->addAxis(FixedBinAxis("axis0", length, 0.0, static_cast<double>(length))); @@ -94,8 +89,7 @@ std::unique_ptr<OutputData<T>> ArrayUtils::CreateDataImpl::createDataImpl(const template <class T> std::unique_ptr<OutputData<T>> -ArrayUtils::CreateDataImpl::createDataImpl(const std::vector<std::vector<T>>& vec) -{ +ArrayUtils::CreateDataImpl::createDataImpl(const std::vector<std::vector<T>>& vec) { auto result = std::make_unique<OutputData<T>>(); auto shape = ArrayUtils::getShape(vec); @@ -120,8 +114,7 @@ ArrayUtils::CreateDataImpl::createDataImpl(const std::vector<std::vector<T>>& ve return result; } -template <class T> std::pair<size_t, size_t> ArrayUtils::getShape(const T& data) -{ +template <class T> std::pair<size_t, size_t> ArrayUtils::getShape(const T& data) { size_t nrows = data.size(); size_t ncols(0); if (nrows) @@ -133,8 +126,7 @@ template <class T> std::pair<size_t, size_t> ArrayUtils::getShape(const T& data) return std::make_pair(nrows, ncols); } -template <class T> decltype(auto) ArrayUtils::createVector1D(const T& data) -{ +template <class T> decltype(auto) ArrayUtils::createVector1D(const T& data) { if (data.rank() != 1) throw std::runtime_error("ArrayUtils::createVector1D() -> Error. Not 1D data."); @@ -143,8 +135,7 @@ template <class T> decltype(auto) ArrayUtils::createVector1D(const T& data) return result; } -template <class T> decltype(auto) ArrayUtils::createVector2D(const T& data) -{ +template <class T> decltype(auto) ArrayUtils::createVector2D(const T& data) { using value_type = typename T::value_type; std::vector<std::vector<value_type>> result; diff --git a/Device/Intensity/IIntensityFunction.cpp b/Device/Intensity/IIntensityFunction.cpp index ea31d0abd37835f89d64865e002051bbd91953ad..f55aeda750f3b87fd6b4111ead353d7a0ce6f733 100644 --- a/Device/Intensity/IIntensityFunction.cpp +++ b/Device/Intensity/IIntensityFunction.cpp @@ -18,22 +18,18 @@ IIntensityFunction::~IIntensityFunction() = default; -IntensityFunctionLog* IntensityFunctionLog::clone() const -{ +IntensityFunctionLog* IntensityFunctionLog::clone() const { return new IntensityFunctionLog; } -double IntensityFunctionLog::evaluate(double value) const -{ +double IntensityFunctionLog::evaluate(double value) const { return value > 0 ? std::log(value) : std::numeric_limits<double>::lowest(); } -IntensityFunctionSqrt* IntensityFunctionSqrt::clone() const -{ +IntensityFunctionSqrt* IntensityFunctionSqrt::clone() const { return new IntensityFunctionSqrt; } -double IntensityFunctionSqrt::evaluate(double value) const -{ +double IntensityFunctionSqrt::evaluate(double value) const { return value > 0 ? std::sqrt(value) : std::numeric_limits<double>::lowest(); } diff --git a/Device/Intensity/IIntensityFunction.h b/Device/Intensity/IIntensityFunction.h index eb40ebd745d48864233717abda8e40dadf209b56..fb3efe7d517c3978c84766d71a586e6b87606600 100644 --- a/Device/Intensity/IIntensityFunction.h +++ b/Device/Intensity/IIntensityFunction.h @@ -19,8 +19,7 @@ //! Interface for applying arbitrary function to the measured intensity. //! @ingroup algorithms_internal -class IIntensityFunction -{ +class IIntensityFunction { public: virtual ~IIntensityFunction(); virtual IIntensityFunction* clone() const = 0; @@ -30,8 +29,7 @@ public: //! Algorithm for applying log function to the measured intensity. //! @ingroup algorithms_internal -class IntensityFunctionLog : public IIntensityFunction -{ +class IntensityFunctionLog : public IIntensityFunction { public: virtual IntensityFunctionLog* clone() const; virtual double evaluate(double value) const; @@ -40,8 +38,7 @@ public: //! Algorithm for applying sqrt function to the measured intensity. //! @ingroup algorithms_internal -class IntensityFunctionSqrt : public IIntensityFunction -{ +class IntensityFunctionSqrt : public IIntensityFunction { public: virtual IntensityFunctionSqrt* clone() const; virtual double evaluate(double value) const; diff --git a/Device/Mask/Ellipse.cpp b/Device/Mask/Ellipse.cpp index d8bd8ea2481eec08d884b4ba3d4df78b7eb74bb1..6084c13da94dd4d5a4622f77024c97bf7c19efd6 100644 --- a/Device/Mask/Ellipse.cpp +++ b/Device/Mask/Ellipse.cpp @@ -27,16 +27,14 @@ Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius, , m_yc(ycenter) , m_xr(xradius) , m_yr(yradius) - , m_theta(theta) -{ + , m_theta(theta) { if (xradius <= 0.0 || yradius <= 0.0) throw Exceptions::LogicErrorException( "Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius) " "-> Error. Radius can't be negative\n"); } -bool Ellipse::contains(double x, double y) const -{ +bool Ellipse::contains(double x, double y) const { double u = std::cos(m_theta) * (x - m_xc) + std::sin(m_theta) * (y - m_yc); double v = -std::sin(m_theta) * (x - m_xc) + std::cos(m_theta) * (y - m_yc); double d = (u / m_xr) * (u / m_xr) + (v / m_yr) * (v / m_yr); @@ -45,7 +43,6 @@ bool Ellipse::contains(double x, double y) const //! Returns true if area defined by two bins is inside or on border of ellipse; //! more precisely, if mid point of two bins satisfy this condition. -bool Ellipse::contains(const Bin1D& binx, const Bin1D& biny) const -{ +bool Ellipse::contains(const Bin1D& binx, const Bin1D& biny) const { return contains(binx.center(), biny.center()); } diff --git a/Device/Mask/Ellipse.h b/Device/Mask/Ellipse.h index 2c0559a6e40b0ade220352d4347ffa48aefb948c..9ad77609f644d80e5910ac9d763d020ff589244d 100644 --- a/Device/Mask/Ellipse.h +++ b/Device/Mask/Ellipse.h @@ -20,8 +20,7 @@ //! Ellipse shape. //! @ingroup tools -class Ellipse : public IShape2D -{ +class Ellipse : public IShape2D { public: Ellipse(double xcenter, double ycenter, double xradius, double yradius, double theta = 0.0); Ellipse* clone() const { return new Ellipse(m_xc, m_yc, m_xr, m_yr, m_theta); } diff --git a/Device/Mask/IShape2D.h b/Device/Mask/IShape2D.h index a5e0d71e9fcda8b6115ecfa53a5a19adca1a0558..282648bf736f08c9c29036f9ebf62a0da87e818f 100644 --- a/Device/Mask/IShape2D.h +++ b/Device/Mask/IShape2D.h @@ -23,8 +23,7 @@ struct Bin1D; //! Basic class for all shapes in 2D. //! @ingroup tools -class IShape2D : public ICloneable -{ +class IShape2D : public ICloneable { public: IShape2D(const char* name) : m_name(name) {} virtual IShape2D* clone() const = 0; @@ -36,8 +35,7 @@ public: //! (more precisely, if mid point of two bins satisfy this condition). virtual bool contains(const Bin1D& binx, const Bin1D& biny) const = 0; - friend std::ostream& operator<<(std::ostream& ostr, const IShape2D& shape) - { + friend std::ostream& operator<<(std::ostream& ostr, const IShape2D& shape) { shape.print(ostr); return ostr; } diff --git a/Device/Mask/InfinitePlane.h b/Device/Mask/InfinitePlane.h index e35df2a8b494d1f087dc32e4dc346a8f437f1690..1a767e6c17c2328fe3fc3558574f45cd2b9bb931 100644 --- a/Device/Mask/InfinitePlane.h +++ b/Device/Mask/InfinitePlane.h @@ -20,8 +20,7 @@ //! The infinite plane is used for masking everything once and forever. //! @ingroup tools -class InfinitePlane : public IShape2D -{ +class InfinitePlane : public IShape2D { public: InfinitePlane() : IShape2D("InfinitePlane") {} InfinitePlane* clone() const { return new InfinitePlane(); } diff --git a/Device/Mask/Line.cpp b/Device/Mask/Line.cpp index 5d68e20dd2c0782b52cef0ea9ff06e0447d1d177..6977e00bf785a7eecd666e3106700cba28426c97 100644 --- a/Device/Mask/Line.cpp +++ b/Device/Mask/Line.cpp @@ -27,12 +27,9 @@ typedef model::box<point_t> box_t; typedef model::linestring<point_t> line_t; Line::Line(double x1, double y1, double x2, double y2) - : IShape2D("Line"), m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2) -{ -} + : IShape2D("Line"), m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2) {} -bool Line::contains(double x, double y) const -{ +bool Line::contains(double x, double y) const { point_t p(x, y); line_t line; line.push_back(point_t(m_x1, m_y1)); @@ -45,8 +42,7 @@ bool Line::contains(double x, double y) const // Calculates if line crosses the box made out of our bins. // Ugly implementation, see discussion at http://stackoverflow.com/questions/21408977 -bool Line::contains(const Bin1D& binx, const Bin1D& biny) const -{ +bool Line::contains(const Bin1D& binx, const Bin1D& biny) const { std::vector<point_t> box_points; box_points.push_back(point_t(binx.m_lower, biny.m_lower)); box_points.push_back(point_t(binx.m_lower, biny.m_upper)); @@ -67,13 +63,11 @@ bool Line::contains(const Bin1D& binx, const Bin1D& biny) const //! @param x The value at which it crosses x-axes VerticalLine::VerticalLine(double x) : IShape2D("VerticalLine"), m_x(x) {} -bool VerticalLine::contains(double x, double /*y*/) const -{ +bool VerticalLine::contains(double x, double /*y*/) const { return algo::almostEqual(x, m_x); } -bool VerticalLine::contains(const Bin1D& binx, const Bin1D& /*biny*/) const -{ +bool VerticalLine::contains(const Bin1D& binx, const Bin1D& /*biny*/) const { return m_x >= binx.m_lower && m_x <= binx.m_upper; } @@ -82,12 +76,10 @@ bool VerticalLine::contains(const Bin1D& binx, const Bin1D& /*biny*/) const //! @param y The value at which it crosses y-axes HorizontalLine::HorizontalLine(double y) : IShape2D("HorizontalLine"), m_y(y) {} -bool HorizontalLine::contains(double /*x*/, double y) const -{ +bool HorizontalLine::contains(double /*x*/, double y) const { return algo::almostEqual(y, m_y); } -bool HorizontalLine::contains(const Bin1D& /*binx*/, const Bin1D& biny) const -{ +bool HorizontalLine::contains(const Bin1D& /*binx*/, const Bin1D& biny) const { return m_y >= biny.m_lower && m_y <= biny.m_upper; } diff --git a/Device/Mask/Line.h b/Device/Mask/Line.h index af2ec63bfe62a53f83e923ad71fff771420a3bbc..4e65a401c026976d9b0552c9adc96cd0d4017317 100644 --- a/Device/Mask/Line.h +++ b/Device/Mask/Line.h @@ -20,8 +20,7 @@ //! A line segment. //! @ingroup mask -class Line : public IShape2D -{ +class Line : public IShape2D { public: Line(double x1, double y1, double x2, double y2); Line* clone() const { return new Line(m_x1, m_y1, m_x2, m_y2); } @@ -36,8 +35,7 @@ private: //! An infinite vertical line. //! @ingroup mask -class VerticalLine : public IShape2D -{ +class VerticalLine : public IShape2D { public: VerticalLine(double x); VerticalLine* clone() const { return new VerticalLine(m_x); } @@ -54,8 +52,7 @@ private: //! An infinite horizontal line. //! @ingroup mask -class HorizontalLine : public IShape2D -{ +class HorizontalLine : public IShape2D { public: HorizontalLine(double y); HorizontalLine* clone() const { return new HorizontalLine(m_y); } diff --git a/Device/Mask/Polygon.cpp b/Device/Mask/Polygon.cpp index 81222a23dbfa2269dc0781b89681c65dc5ca7926..e84f449771be55ab9a1ae7ec6857598f855f3e57 100644 --- a/Device/Mask/Polygon.cpp +++ b/Device/Mask/Polygon.cpp @@ -23,8 +23,7 @@ using namespace boost::geometry; //! The private data for polygons to hide boost dependency from the header -class PolygonPrivate -{ +class PolygonPrivate { public: typedef model::d2::point_xy<double> point_t; typedef model::polygon<point_t> polygon_t; @@ -33,8 +32,7 @@ public: void get_points(std::vector<double>& xpos, std::vector<double>& ypos); }; -void PolygonPrivate::init_from(const std::vector<double>& x, const std::vector<double>& y) -{ +void PolygonPrivate::init_from(const std::vector<double>& x, const std::vector<double>& y) { if (x.size() != y.size()) throw Exceptions::LogicErrorException( "Polygon::Polygon(const std::vector<double>& x, const std::vector<double>& y) " @@ -46,8 +44,7 @@ void PolygonPrivate::init_from(const std::vector<double>& x, const std::vector<d correct(polygon); } -void PolygonPrivate::get_points(std::vector<double>& xpos, std::vector<double>& ypos) -{ +void PolygonPrivate::get_points(std::vector<double>& xpos, std::vector<double>& ypos) { xpos.clear(); ypos.clear(); for (auto it = polygon.outer().begin(); it != polygon.outer().end(); ++it) { @@ -63,8 +60,7 @@ void PolygonPrivate::get_points(std::vector<double>& xpos, std::vector<double>& // IMPORTANT Input parameters are not "const reference" to be able to work from python // (auto conversion of python list to vector<double>). Polygon::Polygon(const std::vector<double> x, const std::vector<double> y) - : IShape2D("Polygon"), m_d(new PolygonPrivate) -{ + : IShape2D("Polygon"), m_d(new PolygonPrivate) { m_d->init_from(x, y); } @@ -75,8 +71,7 @@ Polygon::Polygon(const std::vector<double> x, const std::vector<double> y) //! doesn't repeat the first one), it will be closed automatically. //! @param points Two dimensional vector of (x,y) coordinates of polygon points. Polygon::Polygon(const std::vector<std::vector<double>> points) - : IShape2D("Polygon"), m_d(new PolygonPrivate) -{ + : IShape2D("Polygon"), m_d(new PolygonPrivate) { std::vector<double> x; std::vector<double> y; for (size_t i = 0; i < points.size(); ++i) { @@ -92,33 +87,27 @@ Polygon::Polygon(const std::vector<std::vector<double>> points) Polygon::Polygon(const PolygonPrivate* d) : IShape2D("Polygon"), m_d(new PolygonPrivate(*d)) {} -Polygon::~Polygon() -{ +Polygon::~Polygon() { delete m_d; } -bool Polygon::contains(double x, double y) const -{ +bool Polygon::contains(double x, double y) const { // return within(PolygonPrivate::point_t(x, y), m_d->polygon); // not including borders return covered_by(PolygonPrivate::point_t(x, y), m_d->polygon); // including borders } -bool Polygon::contains(const Bin1D& binx, const Bin1D& biny) const -{ +bool Polygon::contains(const Bin1D& binx, const Bin1D& biny) const { return contains(binx.center(), biny.center()); } -double Polygon::getArea() const -{ +double Polygon::getArea() const { return area(m_d->polygon); } -void Polygon::getPoints(std::vector<double>& xpos, std::vector<double>& ypos) const -{ +void Polygon::getPoints(std::vector<double>& xpos, std::vector<double>& ypos) const { m_d->get_points(xpos, ypos); } -void Polygon::print(std::ostream& ostr) const -{ +void Polygon::print(std::ostream& ostr) const { ostr << wkt<PolygonPrivate::polygon_t>(m_d->polygon); } diff --git a/Device/Mask/Polygon.h b/Device/Mask/Polygon.h index cb6eadd906baa936a9c94b6f8bfc708234b63ccf..ac6fff04d438092769858f43535ec2ee9eee5f0b 100644 --- a/Device/Mask/Polygon.h +++ b/Device/Mask/Polygon.h @@ -27,8 +27,7 @@ class PolygonPrivate; //! Sizes of arrays should coincide. If polygon is unclosed (the last point //! doesn't repeat the first one), it will be closed automatically. -class Polygon : public IShape2D -{ +class Polygon : public IShape2D { public: Polygon(const std::vector<double> x, const std::vector<double> y); Polygon(const std::vector<std::vector<double>> points); diff --git a/Device/Mask/Rectangle.cpp b/Device/Mask/Rectangle.cpp index 505b7be4fcc002b974a3f3ae03090f8a36d682d0..c47ac24dcdb90b6ae199e8c62dfc2adbbdd6f283 100644 --- a/Device/Mask/Rectangle.cpp +++ b/Device/Mask/Rectangle.cpp @@ -20,8 +20,7 @@ //! @param ylow y-coordinate of lower left corner //! @param xup x-coordinate of upper right corner //! @param yup y-coordinate of upper right corner -Rectangle::Rectangle(double xlow, double ylow, double xup, double yup) : IShape2D("Rectangle") -{ +Rectangle::Rectangle(double xlow, double ylow, double xup, double yup) : IShape2D("Rectangle") { if (xup <= xlow) { std::ostringstream message; message << "Rectangle(double xlow, double ylow, double xup, double yup) -> Error. "; @@ -40,17 +39,14 @@ Rectangle::Rectangle(double xlow, double ylow, double xup, double yup) : IShape2 m_yup = yup; } -bool Rectangle::contains(double x, double y) const -{ +bool Rectangle::contains(double x, double y) const { return x <= m_xup && x >= m_xlow && y <= m_yup && y >= m_ylow; } -bool Rectangle::contains(const Bin1D& binx, const Bin1D& biny) const -{ +bool Rectangle::contains(const Bin1D& binx, const Bin1D& biny) const { return contains(binx.center(), biny.center()); } -double Rectangle::getArea() const -{ +double Rectangle::getArea() const { return (m_xup - m_xlow) * (m_yup - m_ylow); } diff --git a/Device/Mask/Rectangle.h b/Device/Mask/Rectangle.h index 1eb1583e3c7f469138a6de328d8f0bb0a505fd99..db7d344e698b976f8fdbbece4c3e79ad68063a4c 100644 --- a/Device/Mask/Rectangle.h +++ b/Device/Mask/Rectangle.h @@ -20,8 +20,7 @@ //! The rectangle shape having its axis aligned to the (non-rotated) coordinate system. //! @ingroup mask -class Rectangle : public IShape2D -{ +class Rectangle : public IShape2D { public: Rectangle(double xlow, double ylow, double xup, double yup); Rectangle* clone() const { return new Rectangle(m_xlow, m_ylow, m_xup, m_yup); } diff --git a/Device/Resolution/ConvolutionDetectorResolution.cpp b/Device/Resolution/ConvolutionDetectorResolution.cpp index c93f80f2a129bc504175d18026f41fcf7256df30..3e2e30d83f3a69ba9add36e8ba345e96a83c5be1 100644 --- a/Device/Resolution/ConvolutionDetectorResolution.cpp +++ b/Device/Resolution/ConvolutionDetectorResolution.cpp @@ -16,15 +16,13 @@ #include "Device/Resolution/Convolve.h" ConvolutionDetectorResolution::ConvolutionDetectorResolution(cumulative_DF_1d res_function_1d) - : m_dimension(1), m_res_function_1d(res_function_1d) -{ + : m_dimension(1), m_res_function_1d(res_function_1d) { setName("ConvolutionDetectorResolution"); } ConvolutionDetectorResolution::ConvolutionDetectorResolution( const IResolutionFunction2D& p_res_function_2d) - : m_dimension(2), m_res_function_1d(0) -{ + : m_dimension(2), m_res_function_1d(0) { setName("ConvolutionDetectorResolution"); setResolutionFunction(p_res_function_2d); } @@ -32,8 +30,7 @@ ConvolutionDetectorResolution::ConvolutionDetectorResolution( ConvolutionDetectorResolution::~ConvolutionDetectorResolution() = default; ConvolutionDetectorResolution::ConvolutionDetectorResolution( - const ConvolutionDetectorResolution& other) -{ + const ConvolutionDetectorResolution& other) { m_dimension = other.m_dimension; m_res_function_1d = other.m_res_function_1d; if (other.m_res_function_2d) @@ -41,19 +38,16 @@ ConvolutionDetectorResolution::ConvolutionDetectorResolution( setName(other.getName()); } -ConvolutionDetectorResolution* ConvolutionDetectorResolution::clone() const -{ +ConvolutionDetectorResolution* ConvolutionDetectorResolution::clone() const { return new ConvolutionDetectorResolution(*this); } -std::vector<const INode*> ConvolutionDetectorResolution::getChildren() const -{ +std::vector<const INode*> ConvolutionDetectorResolution::getChildren() const { return std::vector<const INode*>() << m_res_function_2d; } void ConvolutionDetectorResolution::applyDetectorResolution( - OutputData<double>* p_intensity_map) const -{ + OutputData<double>* p_intensity_map) const { if (p_intensity_map->rank() != m_dimension) { throw Exceptions::RuntimeErrorException( "ConvolutionDetectorResolution::applyDetectorResolution() -> Error! " @@ -73,14 +67,12 @@ void ConvolutionDetectorResolution::applyDetectorResolution( } } -void ConvolutionDetectorResolution::setResolutionFunction(const IResolutionFunction2D& resFunc) -{ +void ConvolutionDetectorResolution::setResolutionFunction(const IResolutionFunction2D& resFunc) { m_res_function_2d.reset(resFunc.clone()); registerChild(m_res_function_2d.get()); } -void ConvolutionDetectorResolution::apply1dConvolution(OutputData<double>* p_intensity_map) const -{ +void ConvolutionDetectorResolution::apply1dConvolution(OutputData<double>* p_intensity_map) const { if (m_res_function_1d == 0) throw Exceptions::LogicErrorException( "ConvolutionDetectorResolution::apply1dConvolution() -> Error! " @@ -115,8 +107,7 @@ void ConvolutionDetectorResolution::apply1dConvolution(OutputData<double>* p_int p_intensity_map->setRawDataVector(result); } -void ConvolutionDetectorResolution::apply2dConvolution(OutputData<double>* p_intensity_map) const -{ +void ConvolutionDetectorResolution::apply2dConvolution(OutputData<double>* p_intensity_map) const { if (m_res_function_2d == 0) throw Exceptions::LogicErrorException( "ConvolutionDetectorResolution::apply2dConvolution() -> Error! " @@ -179,8 +170,7 @@ void ConvolutionDetectorResolution::apply2dConvolution(OutputData<double>* p_int (*it) = result_vector[it.getIndex()]; } -double ConvolutionDetectorResolution::getIntegratedPDF1d(double x, double step) const -{ +double ConvolutionDetectorResolution::getIntegratedPDF1d(double x, double step) const { double halfstep = step / 2.0; double xmin = x - halfstep; double xmax = x + halfstep; @@ -189,8 +179,7 @@ double ConvolutionDetectorResolution::getIntegratedPDF1d(double x, double step) } double ConvolutionDetectorResolution::getIntegratedPDF2d(double x, double step_x, double y, - double step_y) const -{ + double step_y) const { double halfstepx = step_x / 2.0; double halfstepy = step_y / 2.0; double xmin = x - halfstepx; diff --git a/Device/Resolution/ConvolutionDetectorResolution.h b/Device/Resolution/ConvolutionDetectorResolution.h index ec30c6155e0a4929cc9332d8ae1ed6ecbed1b07a..715724c3f85fe9b1579d35742f581374d20f9495 100644 --- a/Device/Resolution/ConvolutionDetectorResolution.h +++ b/Device/Resolution/ConvolutionDetectorResolution.h @@ -23,8 +23,7 @@ //! Limitation: this class assumes that the data points are evenly distributed on each axis -class ConvolutionDetectorResolution : public IDetectorResolution -{ +class ConvolutionDetectorResolution : public IDetectorResolution { public: typedef double (*cumulative_DF_1d)(double); @@ -62,8 +61,7 @@ private: std::unique_ptr<IResolutionFunction2D> m_res_function_2d; }; -inline const IResolutionFunction2D* ConvolutionDetectorResolution::getResolutionFunction2D() const -{ +inline const IResolutionFunction2D* ConvolutionDetectorResolution::getResolutionFunction2D() const { return m_res_function_2d.get(); } diff --git a/Device/Resolution/Convolve.cpp b/Device/Resolution/Convolve.cpp index 188a552fb356cb6d128b3f23bf144e6fffc3e4ec..91d348c4e1fd8a5cdfea804bdfc9a700469133c0 100644 --- a/Device/Resolution/Convolve.cpp +++ b/Device/Resolution/Convolve.cpp @@ -18,8 +18,7 @@ #include <sstream> #include <stdexcept> // need overlooked by g++ 5.4 -Convolve::Convolve() : m_mode(FFTW_UNDEFINED) -{ +Convolve::Convolve() : m_mode(FFTW_UNDEFINED) { // storing favorite fftw3 prime factors const size_t FFTW_FACTORS[] = {13, 11, 7, 5, 3, 2}; m_implemented_factors.assign(FFTW_FACTORS, @@ -46,17 +45,13 @@ Convolve::Workspace::Workspace() , w_offset(0) , p_forw_src(nullptr) , p_forw_kernel(nullptr) - , p_back(nullptr) -{ -} + , p_back(nullptr) {} -Convolve::Workspace::~Workspace() -{ +Convolve::Workspace::~Workspace() { clear(); } -void Convolve::Workspace::clear() -{ +void Convolve::Workspace::clear() { h_src = 0; w_src = 0; h_kernel = 0; @@ -100,8 +95,7 @@ void Convolve::Workspace::clear() /* ************************************************************************* */ // convolution in 2d /* ************************************************************************* */ -void Convolve::fftconvolve(const double2d_t& source, const double2d_t& kernel, double2d_t& result) -{ +void Convolve::fftconvolve(const double2d_t& source, const double2d_t& kernel, double2d_t& result) { // set default convolution mode, if not defined if (m_mode == FFTW_UNDEFINED) setMode(FFTW_LINEAR_SAME); @@ -136,8 +130,7 @@ void Convolve::fftconvolve(const double2d_t& source, const double2d_t& kernel, d /* ************************************************************************* */ // convolution in 1d /* ************************************************************************* */ -void Convolve::fftconvolve(const double1d_t& source, const double1d_t& kernel, double1d_t& result) -{ +void Convolve::fftconvolve(const double1d_t& source, const double1d_t& kernel, double1d_t& result) { // we simply create 2d arrays with length of first dimension equal to 1, and call 2d convolution double2d_t source2d, kernel2d; source2d.push_back(source); @@ -153,8 +146,7 @@ void Convolve::fftconvolve(const double1d_t& source, const double1d_t& kernel, d /* ************************************************************************* */ // initialise input and output arrays for fast Fourier transformation /* ************************************************************************* */ -void Convolve::init(int h_src, int w_src, int h_kernel, int w_kernel) -{ +void Convolve::init(int h_src, int w_src, int h_kernel, int w_kernel) { if (!h_src || !w_src || !h_kernel || !w_kernel) { std::ostringstream os; os << "Convolve::init() -> Panic! Wrong dimensions " << h_src << " " << w_src << " " @@ -274,8 +266,7 @@ void Convolve::init(int h_src, int w_src, int h_kernel, int w_kernel) // initialise input and output arrays for fast Fourier transformation /* ************************************************************************* */ -void Convolve::fftw_circular_convolution(const double2d_t& src, const double2d_t& kernel) -{ +void Convolve::fftw_circular_convolution(const double2d_t& src, const double2d_t& kernel) { if (ws.h_fftw <= 0 || ws.w_fftw <= 0) throw Exceptions::RuntimeErrorException( "Convolve::fftw_convolve() -> Panic! Initialisation is missed."); @@ -330,8 +321,7 @@ void Convolve::fftw_circular_convolution(const double2d_t& src, const double2d_t // to fftw3 favorite factorisation /* ************************************************************************* */ -int Convolve::find_closest_factor(int n) -{ +int Convolve::find_closest_factor(int n) { if (is_optimal(n)) { return n; } else { @@ -345,8 +335,7 @@ int Convolve::find_closest_factor(int n) /* ************************************************************************* */ // if a number can be factorised using only favorite fftw3 factors /* ************************************************************************* */ -bool Convolve::is_optimal(int n) -{ +bool Convolve::is_optimal(int n) { if (n == 1) return false; size_t ntest = n; diff --git a/Device/Resolution/Convolve.h b/Device/Resolution/Convolve.h index cf85a39a252a24d8d45f48e459e9aeddd8cc995e..9b5bef7d79acb31a3ceb946b0df4da4c464813d7 100644 --- a/Device/Resolution/Convolve.h +++ b/Device/Resolution/Convolve.h @@ -30,8 +30,7 @@ //! by Jeremy Fix, May 30, 2011 //! //! @ingroup tools_internal -class Convolve -{ +class Convolve { public: //! definition of 1d vector of double typedef std::vector<double> double1d_t; @@ -82,8 +81,7 @@ private: //! it is our resolution function. //! Sizes of input arrays are adjusted; output arrays are alocated via //! fftw3 allocation for maximum performance. - class Workspace - { + class Workspace { public: Workspace(); ~Workspace(); diff --git a/Device/Resolution/IDetectorResolution.h b/Device/Resolution/IDetectorResolution.h index 0f6ee4cecfe9bc37f788667bc5cf375072447090..2159167891a1e8300dee089f6625e753834adc81 100644 --- a/Device/Resolution/IDetectorResolution.h +++ b/Device/Resolution/IDetectorResolution.h @@ -22,8 +22,7 @@ //! Interface for detector resolution algorithms //! @ingroup algorithms_internal -class IDetectorResolution : public ICloneable, public INode -{ +class IDetectorResolution : public ICloneable, public INode { public: virtual ~IDetectorResolution() {} //! Apply the resolution function to the intensity data diff --git a/Device/Resolution/IResolutionFunction2D.cpp b/Device/Resolution/IResolutionFunction2D.cpp index 12411cb28eddc18224eab42237a0912ad44998c2..4dd5a5bab1c6a6305c7ec164190c9189c1f1c350 100644 --- a/Device/Resolution/IResolutionFunction2D.cpp +++ b/Device/Resolution/IResolutionFunction2D.cpp @@ -16,6 +16,4 @@ IResolutionFunction2D::IResolutionFunction2D(const NodeMeta& meta, const std::vector<double>& PValues) - : INode(meta, PValues) -{ -} + : INode(meta, PValues) {} diff --git a/Device/Resolution/IResolutionFunction2D.h b/Device/Resolution/IResolutionFunction2D.h index 77ef3669feefe51487d5c6f9af47f255fe81f352..32f2b4d0ef3b3681a4a96ece5988aba567deff89 100644 --- a/Device/Resolution/IResolutionFunction2D.h +++ b/Device/Resolution/IResolutionFunction2D.h @@ -21,8 +21,7 @@ //! Interface providing two-dimensional resolution function. //! @ingroup algorithms_internal -class IResolutionFunction2D : public ICloneable, public INode -{ +class IResolutionFunction2D : public ICloneable, public INode { public: IResolutionFunction2D() = default; IResolutionFunction2D(const NodeMeta& meta, const std::vector<double>& PValues); diff --git a/Device/Resolution/ResolutionFunction2DGaussian.cpp b/Device/Resolution/ResolutionFunction2DGaussian.cpp index 8f6713d683aa2cd646695eae259aa7d0117c9d78..f83f4d908a4f9256cd2e29d932c025dd2e7cce2a 100644 --- a/Device/Resolution/ResolutionFunction2DGaussian.cpp +++ b/Device/Resolution/ResolutionFunction2DGaussian.cpp @@ -17,15 +17,13 @@ #include "Param/Base/RealParameter.h" ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(double sigma_x, double sigma_y) - : m_sigma_x(sigma_x), m_sigma_y(sigma_y) -{ + : m_sigma_x(sigma_x), m_sigma_y(sigma_y) { setName("ResolutionFunction2D"); registerParameter("SigmaX", &m_sigma_x).setNonnegative(); registerParameter("SigmaY", &m_sigma_y).setNonnegative(); } -double ResolutionFunction2DGaussian::evaluateCDF(double x, double y) const -{ +double ResolutionFunction2DGaussian::evaluateCDF(double x, double y) const { return Math::IntegratedGaussian(x, 0.0, m_sigma_x) * Math::IntegratedGaussian(y, 0.0, m_sigma_y); } diff --git a/Device/Resolution/ResolutionFunction2DGaussian.h b/Device/Resolution/ResolutionFunction2DGaussian.h index e622028c48166a24321bf15f85fcbb76356ed2d1..e542a60b322b3e05a507f970e4a48a31824b4294 100644 --- a/Device/Resolution/ResolutionFunction2DGaussian.h +++ b/Device/Resolution/ResolutionFunction2DGaussian.h @@ -20,15 +20,13 @@ //! Simple gaussian two-dimensional resolution function. //! @ingroup algorithms_internal -class ResolutionFunction2DGaussian : public IResolutionFunction2D -{ +class ResolutionFunction2DGaussian : public IResolutionFunction2D { public: ResolutionFunction2DGaussian(double sigma_x, double sigma_y); virtual double evaluateCDF(double x, double y) const; - ResolutionFunction2DGaussian* clone() const - { + ResolutionFunction2DGaussian* clone() const { return new ResolutionFunction2DGaussian(m_sigma_x, m_sigma_y); } diff --git a/Device/Resolution/ScanResolution.cpp b/Device/Resolution/ScanResolution.cpp index e5c11e7406ff6d7365dcc5a3bf02e1c87860c69d..7dadd1da2962f617c055a2d9876981d26c815765 100644 --- a/Device/Resolution/ScanResolution.cpp +++ b/Device/Resolution/ScanResolution.cpp @@ -16,25 +16,20 @@ #include "Base/Utils/PyFmt.h" #include "Param/Distrib/RangedDistributions.h" -namespace -{ +namespace { void checkIfEmpty(const std::vector<double>& input); std::string printDeltas(const std::vector<double>& deltas); const std::string relative_resolution = "ScanRelativeResolution"; const std::string absolute_resolution = "ScanAbsoluteResolution"; -class ScanSingleRelativeResolution : public ScanResolution -{ +class ScanSingleRelativeResolution : public ScanResolution { public: ScanSingleRelativeResolution(const RangedDistribution& distr, double reldev) - : ScanResolution(distr), m_reldev(reldev) - { - } + : ScanResolution(distr), m_reldev(reldev) {} ~ScanSingleRelativeResolution() override = default; - ScanResolution* clone() const override - { + ScanResolution* clone() const override { return new ScanSingleRelativeResolution(*distribution(), m_reldev); } @@ -51,17 +46,13 @@ private: double m_reldev; //!< deltas for computing resolutions }; -class ScanSingleAbsoluteResolution : public ScanResolution -{ +class ScanSingleAbsoluteResolution : public ScanResolution { public: ScanSingleAbsoluteResolution(const RangedDistribution& distr, double stddev) - : ScanResolution(distr), m_stddev(stddev) - { - } + : ScanResolution(distr), m_stddev(stddev) {} ~ScanSingleAbsoluteResolution() override = default; - ScanResolution* clone() const override - { + ScanResolution* clone() const override { return new ScanSingleAbsoluteResolution(*distribution(), m_stddev); } @@ -78,18 +69,15 @@ private: double m_stddev; //!< deltas for computing resolutions }; -class ScanVectorRelativeResolution : public ScanResolution -{ +class ScanVectorRelativeResolution : public ScanResolution { public: ScanVectorRelativeResolution(const RangedDistribution& distr, const std::vector<double>& reldev) - : ScanResolution(distr), m_reldev(reldev) - { + : ScanResolution(distr), m_reldev(reldev) { checkIfEmpty(m_reldev); } ~ScanVectorRelativeResolution() override = default; - ScanResolution* clone() const override - { + ScanResolution* clone() const override { return new ScanVectorRelativeResolution(*distribution(), m_reldev); } @@ -106,18 +94,15 @@ private: std::vector<double> m_reldev; //!< deltas for computing resolutions }; -class ScanVectorAbsoluteResolution : public ScanResolution -{ +class ScanVectorAbsoluteResolution : public ScanResolution { public: ScanVectorAbsoluteResolution(const RangedDistribution& distr, const std::vector<double>& stddev) - : ScanResolution(distr), m_stddev(stddev) - { + : ScanResolution(distr), m_stddev(stddev) { checkIfEmpty(m_stddev); } ~ScanVectorAbsoluteResolution() override = default; - ScanResolution* clone() const override - { + ScanResolution* clone() const override { return new ScanVectorAbsoluteResolution(*distribution(), m_stddev); } @@ -134,8 +119,7 @@ private: std::vector<double> m_stddev; //!< deltas for computing resolutions }; -class ScanEmptyResolution : public ScanResolution -{ +class ScanEmptyResolution : public ScanResolution { public: ScanEmptyResolution() : ScanResolution() {} @@ -157,43 +141,36 @@ protected: ScanResolution::~ScanResolution() = default; ScanResolution* ScanResolution::scanRelativeResolution(const RangedDistribution& distr, - double stddev) -{ + double stddev) { return new ScanSingleRelativeResolution(distr, stddev); } ScanResolution* ScanResolution::scanRelativeResolution(const RangedDistribution& distr, - const std::vector<double>& stddevs) -{ + const std::vector<double>& stddevs) { return new ScanVectorRelativeResolution(distr, stddevs); } ScanResolution* ScanResolution::scanAbsoluteResolution(const RangedDistribution& distr, - double stddev) -{ + double stddev) { return new ScanSingleAbsoluteResolution(distr, stddev); } ScanResolution* ScanResolution::scanAbsoluteResolution(const RangedDistribution& distr, - const std::vector<double>& stddevs) -{ + const std::vector<double>& stddevs) { return new ScanVectorAbsoluteResolution(distr, stddevs); } -ScanResolution* ScanResolution::scanEmptyResolution() -{ +ScanResolution* ScanResolution::scanEmptyResolution() { return new ScanEmptyResolution(); } -size_t ScanResolution::nSamples() const -{ +size_t ScanResolution::nSamples() const { if (m_distr) return m_distr->nSamples(); return 1; } -std::string ScanResolution::print() const -{ +std::string ScanResolution::print() const { std::stringstream result; result << *m_distr << "\n"; result << pyfmt::indent() << "resolution = "; @@ -210,18 +187,15 @@ ScanResolution::ScanResolution() = default; ScanResolution::ScanResolution(const RangedDistribution& distr) : m_distr(distr.clone()) {} -namespace -{ +namespace { ScanResolution::DistrOutput ScanSingleRelativeResolution::generateSamples(double mean, - size_t n_times) const -{ + size_t n_times) const { const double stddev = mean * m_reldev; return DistrOutput(n_times, distribution()->generateSamples(mean, stddev)); } ScanResolution::DistrOutput -ScanSingleRelativeResolution::generateSamples(const std::vector<double>& mean) const -{ +ScanSingleRelativeResolution::generateSamples(const std::vector<double>& mean) const { checkIfEmpty(mean); DistrOutput result; result.reserve(mean.size()); @@ -230,13 +204,11 @@ ScanSingleRelativeResolution::generateSamples(const std::vector<double>& mean) c return result; } -std::vector<double> ScanSingleRelativeResolution::stdDevs(double mean, size_t n_times) const -{ +std::vector<double> ScanSingleRelativeResolution::stdDevs(double mean, size_t n_times) const { return std::vector<double>(n_times, mean * m_reldev); } -std::vector<double> ScanSingleRelativeResolution::stdDevs(const std::vector<double>& mean) const -{ +std::vector<double> ScanSingleRelativeResolution::stdDevs(const std::vector<double>& mean) const { checkIfEmpty(mean); std::vector<double> result; result.reserve(mean.size()); @@ -246,25 +218,21 @@ std::vector<double> ScanSingleRelativeResolution::stdDevs(const std::vector<doub } ScanResolution::DistrOutput ScanVectorRelativeResolution::generateSamples(double mean, - size_t n_times) const -{ + size_t n_times) const { return generateSamples(std::vector<double>(n_times, mean)); } ScanResolution::DistrOutput -ScanVectorRelativeResolution::generateSamples(const std::vector<double>& mean) const -{ +ScanVectorRelativeResolution::generateSamples(const std::vector<double>& mean) const { const std::vector<double> stddevs = stdDevs(mean); return distribution()->generateSamples(mean, stddevs); } -std::vector<double> ScanVectorRelativeResolution::stdDevs(double mean, size_t n_times) const -{ +std::vector<double> ScanVectorRelativeResolution::stdDevs(double mean, size_t n_times) const { return stdDevs(std::vector<double>(n_times, mean)); } -std::vector<double> ScanVectorRelativeResolution::stdDevs(const std::vector<double>& mean) const -{ +std::vector<double> ScanVectorRelativeResolution::stdDevs(const std::vector<double>& mean) const { const size_t result_size = mean.size(); if (result_size != m_reldev.size()) throw std::runtime_error( @@ -278,14 +246,12 @@ std::vector<double> ScanVectorRelativeResolution::stdDevs(const std::vector<doub } ScanResolution::DistrOutput ScanSingleAbsoluteResolution::generateSamples(double mean, - size_t n_times) const -{ + size_t n_times) const { return DistrOutput(n_times, distribution()->generateSamples(mean, m_stddev)); } ScanResolution::DistrOutput -ScanSingleAbsoluteResolution::generateSamples(const std::vector<double>& mean) const -{ +ScanSingleAbsoluteResolution::generateSamples(const std::vector<double>& mean) const { checkIfEmpty(mean); DistrOutput result; result.reserve(mean.size()); @@ -294,26 +260,22 @@ ScanSingleAbsoluteResolution::generateSamples(const std::vector<double>& mean) c return result; } -std::vector<double> ScanSingleAbsoluteResolution::stdDevs(double, size_t n_times) const -{ +std::vector<double> ScanSingleAbsoluteResolution::stdDevs(double, size_t n_times) const { return std::vector<double>(n_times, m_stddev); } -std::vector<double> ScanSingleAbsoluteResolution::stdDevs(const std::vector<double>& mean) const -{ +std::vector<double> ScanSingleAbsoluteResolution::stdDevs(const std::vector<double>& mean) const { checkIfEmpty(mean); return std::vector<double>(mean.size(), m_stddev); } ScanResolution::DistrOutput ScanVectorAbsoluteResolution::generateSamples(double mean, - size_t n_times) const -{ + size_t n_times) const { return generateSamples(std::vector<double>(n_times, mean)); } ScanResolution::DistrOutput -ScanVectorAbsoluteResolution::generateSamples(const std::vector<double>& mean) const -{ +ScanVectorAbsoluteResolution::generateSamples(const std::vector<double>& mean) const { const size_t result_size = mean.size(); if (result_size != m_stddev.size()) throw std::runtime_error( @@ -322,13 +284,11 @@ ScanVectorAbsoluteResolution::generateSamples(const std::vector<double>& mean) c return distribution()->generateSamples(mean, m_stddev); } -std::vector<double> ScanVectorAbsoluteResolution::stdDevs(double mean, size_t n_times) const -{ +std::vector<double> ScanVectorAbsoluteResolution::stdDevs(double mean, size_t n_times) const { return stdDevs(std::vector<double>(n_times, mean)); } -std::vector<double> ScanVectorAbsoluteResolution::stdDevs(const std::vector<double>& mean) const -{ +std::vector<double> ScanVectorAbsoluteResolution::stdDevs(const std::vector<double>& mean) const { const size_t result_size = mean.size(); if (result_size != m_stddev.size()) throw std::runtime_error( @@ -338,14 +298,12 @@ std::vector<double> ScanVectorAbsoluteResolution::stdDevs(const std::vector<doub } ScanEmptyResolution::DistrOutput ScanEmptyResolution::generateSamples(double mean, - size_t n_times) const -{ + size_t n_times) const { return DistrOutput(n_times, std::vector<ParameterSample>{ParameterSample(mean, 1.)}); } ScanEmptyResolution::DistrOutput -ScanEmptyResolution::generateSamples(const std::vector<double>& mean) const -{ +ScanEmptyResolution::generateSamples(const std::vector<double>& mean) const { DistrOutput result; result.reserve(mean.size()); for (size_t i = 0, size = mean.size(); i < size; ++i) @@ -353,35 +311,29 @@ ScanEmptyResolution::generateSamples(const std::vector<double>& mean) const return result; } -std::vector<double> ScanEmptyResolution::stdDevs(double, size_t n_times) const -{ +std::vector<double> ScanEmptyResolution::stdDevs(double, size_t n_times) const { return std::vector<double>(n_times, 0.0); } -std::vector<double> ScanEmptyResolution::stdDevs(const std::vector<double>& mean) const -{ +std::vector<double> ScanEmptyResolution::stdDevs(const std::vector<double>& mean) const { return std::vector<double>(mean.size(), 0.0); } -std::string ScanEmptyResolution::name() const -{ +std::string ScanEmptyResolution::name() const { throw std::runtime_error( "Error in ScanEmptyResolution::name: attempt to get a name of an empty resolution object."); } -std::string ScanEmptyResolution::printStdDevs() const -{ +std::string ScanEmptyResolution::printStdDevs() const { throw std::runtime_error("Error in ScanEmptyResolution::printStdDevs: attempt to print data " "from empty resolution object."); } -std::string printDeltas(const std::vector<double>&) -{ +std::string printDeltas(const std::vector<double>&) { throw std::runtime_error("Error in printDeltas: function is not implemented"); } -void checkIfEmpty(const std::vector<double>& input) -{ +void checkIfEmpty(const std::vector<double>& input) { if (input.empty()) throw std::runtime_error("Error in ScanResolution: passed vector is empty"); } diff --git a/Device/Resolution/ScanResolution.h b/Device/Resolution/ScanResolution.h index 372bba53193c17278ae93593173e8e6919f2b747..e75f56cabd41a8d569fdd0f5455ec36ddf7e81a2 100644 --- a/Device/Resolution/ScanResolution.h +++ b/Device/Resolution/ScanResolution.h @@ -25,8 +25,7 @@ class RangedDistribution; class RealLimits; //! Container for reflectivity resolution data. -class ScanResolution : public ICloneable -{ +class ScanResolution : public ICloneable { protected: using DistrOutput = std::vector<std::vector<ParameterSample>>; @@ -64,8 +63,7 @@ private: std::unique_ptr<RangedDistribution> m_distr; //!< basic distribution function }; -inline std::ostream& operator<<(std::ostream& os, const ScanResolution& scan_resolution) -{ +inline std::ostream& operator<<(std::ostream& os, const ScanResolution& scan_resolution) { return os << scan_resolution.print(); } diff --git a/Device/Unit/AxisNames.cpp b/Device/Unit/AxisNames.cpp index 886030d50a684a9c1ad9b4c2789d4fb7f0d622c7..e2ff4f806619f5baf402941280f202dc2cbf4986 100644 --- a/Device/Unit/AxisNames.cpp +++ b/Device/Unit/AxisNames.cpp @@ -15,11 +15,9 @@ #include "Device/Unit/AxisNames.h" #include <map> -namespace AxisNames -{ +namespace AxisNames { // For spherical detectors in GISAS simulations -std::map<Axes::Units, std::string> InitSphericalAxis0() -{ +std::map<Axes::Units, std::string> InitSphericalAxis0() { std::map<Axes::Units, std::string> result; result[Axes::Units::NBINS] = "X [nbins]"; result[Axes::Units::RADIANS] = "phi_f [rad]"; @@ -28,8 +26,7 @@ std::map<Axes::Units, std::string> InitSphericalAxis0() result[Axes::Units::QXQY] = "Qx [1/nm]"; return result; } -std::map<Axes::Units, std::string> InitSphericalAxis1() -{ +std::map<Axes::Units, std::string> InitSphericalAxis1() { std::map<Axes::Units, std::string> result; result[Axes::Units::NBINS] = "Y [nbins]"; result[Axes::Units::RADIANS] = "alpha_f [rad]"; @@ -39,8 +36,7 @@ std::map<Axes::Units, std::string> InitSphericalAxis1() return result; } // For rectangular detectors in GISAS simulations -std::map<Axes::Units, std::string> InitRectangularAxis0() -{ +std::map<Axes::Units, std::string> InitRectangularAxis0() { std::map<Axes::Units, std::string> result; result[Axes::Units::NBINS] = "X [nbins]"; result[Axes::Units::RADIANS] = "phi_f [rad]"; @@ -50,8 +46,7 @@ std::map<Axes::Units, std::string> InitRectangularAxis0() result[Axes::Units::QXQY] = "Qx [1/nm]"; return result; } -std::map<Axes::Units, std::string> InitRectangularAxis1() -{ +std::map<Axes::Units, std::string> InitRectangularAxis1() { std::map<Axes::Units, std::string> result; result[Axes::Units::NBINS] = "Y [nbins]"; result[Axes::Units::RADIANS] = "alpha_f [rad]"; @@ -63,16 +58,14 @@ std::map<Axes::Units, std::string> InitRectangularAxis1() } // For off-specular simulations (both spherical and rectangular detectors) // Currently 'mm' is not supported for the y-axis -std::map<Axes::Units, std::string> InitOffSpecAxis0() -{ +std::map<Axes::Units, std::string> InitOffSpecAxis0() { std::map<Axes::Units, std::string> result; result[Axes::Units::NBINS] = "X [nbins]"; result[Axes::Units::RADIANS] = "alpha_i [rad]"; result[Axes::Units::DEGREES] = "alpha_i [deg]"; return result; } -std::map<Axes::Units, std::string> InitOffSpecAxis1() -{ +std::map<Axes::Units, std::string> InitOffSpecAxis1() { std::map<Axes::Units, std::string> result; result[Axes::Units::NBINS] = "Y [nbins]"; result[Axes::Units::RADIANS] = "alpha_f [rad]"; @@ -80,8 +73,7 @@ std::map<Axes::Units, std::string> InitOffSpecAxis1() return result; } -std::map<Axes::Units, std::string> InitSpecAxis() -{ +std::map<Axes::Units, std::string> InitSpecAxis() { std::map<Axes::Units, std::string> result; result[Axes::Units::NBINS] = "X [nbins]"; result[Axes::Units::RADIANS] = "alpha_i [rad]"; @@ -91,8 +83,7 @@ std::map<Axes::Units, std::string> InitSpecAxis() return result; } -std::map<Axes::Units, std::string> InitSpecAxisQ() -{ +std::map<Axes::Units, std::string> InitSpecAxisQ() { std::map<Axes::Units, std::string> result; result[Axes::Units::NBINS] = "X [nbins]"; result[Axes::Units::QSPACE] = "Q [1/nm]"; @@ -106,8 +97,7 @@ std::map<Axes::Units, std::string> InitSpecAxisQ() // converter correspond to inclination angular axis. // For this reason depth axis map returns always // nanometers except for bins. -std::map<Axes::Units, std::string> InitSampleDepthAxis() -{ +std::map<Axes::Units, std::string> InitSampleDepthAxis() { std::map<Axes::Units, std::string> result; result[Axes::Units::NBINS] = "Y [nbins]"; result[Axes::Units::RADIANS] = "Position [nm]"; diff --git a/Device/Unit/AxisNames.h b/Device/Unit/AxisNames.h index 27aa7917d4a2983e299acd6bf4d95c14cf4549db..e83d67c1ad56fbd425f2674dad44ee3ed460d847 100644 --- a/Device/Unit/AxisNames.h +++ b/Device/Unit/AxisNames.h @@ -22,8 +22,7 @@ //! detector types and units //! @ingroup detector -namespace AxisNames -{ +namespace AxisNames { std::map<Axes::Units, std::string> InitSphericalAxis0(); std::map<Axes::Units, std::string> InitSphericalAxis1(); std::map<Axes::Units, std::string> InitRectangularAxis0(); diff --git a/Device/Unit/IUnitConverter.cpp b/Device/Unit/IUnitConverter.cpp index c6b7c624ac4643fec4d24c504b4cdddf757edb2e..ea190dc8468cafdbb6f4baddbdb580911049408c 100644 --- a/Device/Unit/IUnitConverter.cpp +++ b/Device/Unit/IUnitConverter.cpp @@ -17,8 +17,7 @@ IUnitConverter::~IUnitConverter() = default; -std::string IUnitConverter::axisName(size_t i_axis, Axes::Units units_type) const -{ +std::string IUnitConverter::axisName(size_t i_axis, Axes::Units units_type) const { const auto& name_maps = createNameMaps(); if (name_maps.size() <= i_axis) throw std::runtime_error("Error in IUnitConverter::axisName: the size of name map vector " @@ -33,8 +32,7 @@ std::string IUnitConverter::axisName(size_t i_axis, Axes::Units units_type) cons } std::unique_ptr<OutputData<double>> -IUnitConverter::createConvertedData(const OutputData<double>& data, Axes::Units units) const -{ +IUnitConverter::createConvertedData(const OutputData<double>& data, Axes::Units units) const { const size_t dim = data.rank(); std::unique_ptr<OutputData<double>> result(new OutputData<double>); for (size_t i = 0; i < dim; ++i) @@ -43,16 +41,14 @@ IUnitConverter::createConvertedData(const OutputData<double>& data, Axes::Units return result; } -void IUnitConverter::checkIndex(size_t i_axis) const -{ +void IUnitConverter::checkIndex(size_t i_axis) const { if (i_axis < dimension()) return; throw std::runtime_error("Error in IUnitConverter::checkIndex: passed axis index too big: " + std::to_string(static_cast<int>(i_axis))); } -void IUnitConverter::throwUnitsError(std::string method, std::vector<Axes::Units> available) const -{ +void IUnitConverter::throwUnitsError(std::string method, std::vector<Axes::Units> available) const { std::stringstream ss; ss << "Unit type error in " << method << ": unknown or unsupported unit type. Available units " @@ -62,7 +58,6 @@ void IUnitConverter::throwUnitsError(std::string method, std::vector<Axes::Units throw std::runtime_error(ss.str()); } -Axes::Units IUnitConverter::substituteDefaultUnits(Axes::Units units) const -{ +Axes::Units IUnitConverter::substituteDefaultUnits(Axes::Units units) const { return units == Axes::Units::DEFAULT ? defaultUnits() : units; } diff --git a/Device/Unit/IUnitConverter.h b/Device/Unit/IUnitConverter.h index 471e2488f9dcc343c1bbe4454050254168312a7c..c95d4c9891348e2b207977a414c9fc5950d94bdc 100644 --- a/Device/Unit/IUnitConverter.h +++ b/Device/Unit/IUnitConverter.h @@ -28,8 +28,7 @@ template <class T> class OutputData; //! detector axes units in python //! @ingroup detector -class Axes -{ +class Axes { public: enum Units { DEFAULT, NBINS, RADIANS, DEGREES, MM, QSPACE, QXQY, RQ4 }; }; @@ -42,8 +41,7 @@ const std::map<Axes::Units, const char*> axisUnitLabel = { //! Interface to provide axis translations to different units for simulation output //! @ingroup simulation_internal -class IUnitConverter : public ICloneable -{ +class IUnitConverter : public ICloneable { public: virtual ~IUnitConverter(); diff --git a/Examples/cpp/CylindersAndPrisms/CylindersAndPrisms.cpp b/Examples/cpp/CylindersAndPrisms/CylindersAndPrisms.cpp index 583e27ac56c7aee383fd3086a93418bbdb76de70..5f08838594b42d3143ac45c511437039be59eed2 100644 --- a/Examples/cpp/CylindersAndPrisms/CylindersAndPrisms.cpp +++ b/Examples/cpp/CylindersAndPrisms/CylindersAndPrisms.cpp @@ -25,8 +25,7 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/Particle/Particle.h" -int main() -{ +int main() { // Define the sample Material vacuum_material = HomogeneousMaterial("Vacuum", 0., 0.); Material substrate_material = HomogeneousMaterial("Substrate", 6e-6, 2e-8); diff --git a/Fit/Adapter/GSLLevenbergMarquardtMinimizer.cpp b/Fit/Adapter/GSLLevenbergMarquardtMinimizer.cpp index 8b241f55545da7b965b9d513b44df09ba4607fc9..a777f52c8bc3f61db65125a5a571554ff4fa680e 100644 --- a/Fit/Adapter/GSLLevenbergMarquardtMinimizer.cpp +++ b/Fit/Adapter/GSLLevenbergMarquardtMinimizer.cpp @@ -30,11 +30,9 @@ #pragma GCC diagnostic pop #endif -namespace -{ +namespace { -std::map<int, std::string> covmatrixStatusDescription() -{ +std::map<int, std::string> covmatrixStatusDescription() { std::map<int, std::string> result; result[0] = "Covariance matrix was not computed"; result[1] = "Covariance matrix approximate because minimum is not valid"; @@ -46,8 +44,7 @@ std::map<int, std::string> covmatrixStatusDescription() GSLLevenbergMarquardtMinimizer::GSLLevenbergMarquardtMinimizer() : MinimizerAdapter(MinimizerInfo::buildGSLLMAInfo()) - , m_gsl_minimizer(new ROOT::Math::GSLNLSMinimizer(2)) -{ + , m_gsl_minimizer(new ROOT::Math::GSLNLSMinimizer(2)) { addOption("Tolerance", 0.01, "Tolerance on the function value at the minimum"); addOption("PrintLevel", 0, "Minimizer internal print level"); addOption("MaxIterations", 0, "Maximum number of iterations"); @@ -55,43 +52,35 @@ GSLLevenbergMarquardtMinimizer::GSLLevenbergMarquardtMinimizer() GSLLevenbergMarquardtMinimizer::~GSLLevenbergMarquardtMinimizer() = default; -void GSLLevenbergMarquardtMinimizer::setTolerance(double value) -{ +void GSLLevenbergMarquardtMinimizer::setTolerance(double value) { setOptionValue("Tolerance", value); } -double GSLLevenbergMarquardtMinimizer::tolerance() const -{ +double GSLLevenbergMarquardtMinimizer::tolerance() const { return optionValue<double>("Tolerance"); } -void GSLLevenbergMarquardtMinimizer::setPrintLevel(int value) -{ +void GSLLevenbergMarquardtMinimizer::setPrintLevel(int value) { setOptionValue("PrintLevel", value); } -int GSLLevenbergMarquardtMinimizer::printLevel() const -{ +int GSLLevenbergMarquardtMinimizer::printLevel() const { return optionValue<int>("PrintLevel"); } -void GSLLevenbergMarquardtMinimizer::setMaxIterations(int value) -{ +void GSLLevenbergMarquardtMinimizer::setMaxIterations(int value) { setOptionValue("MaxIterations", value); } -int GSLLevenbergMarquardtMinimizer::maxIterations() const -{ +int GSLLevenbergMarquardtMinimizer::maxIterations() const { return optionValue<int>("MaxIterations"); } -std::string GSLLevenbergMarquardtMinimizer::statusToString() const -{ +std::string GSLLevenbergMarquardtMinimizer::statusToString() const { return mumufit::utils::gslErrorDescription(rootMinimizer()->Status()); } -std::map<std::string, std::string> GSLLevenbergMarquardtMinimizer::statusMap() const -{ +std::map<std::string, std::string> GSLLevenbergMarquardtMinimizer::statusMap() const { auto result = MinimizerAdapter::statusMap(); result["Edm"] = mumufit::stringUtils::scientific(rootMinimizer()->Edm()); result["CovMatrixStatus"] = covmatrixStatusDescription()[rootMinimizer()->CovMatrixStatus()]; @@ -99,20 +88,18 @@ std::map<std::string, std::string> GSLLevenbergMarquardtMinimizer::statusMap() c return result; } -void GSLLevenbergMarquardtMinimizer::propagateOptions() -{ +void GSLLevenbergMarquardtMinimizer::propagateOptions() { m_gsl_minimizer->SetTolerance(tolerance()); m_gsl_minimizer->SetPrintLevel(printLevel()); m_gsl_minimizer->SetMaxIterations(static_cast<unsigned int>(maxIterations())); } -const MinimizerAdapter::root_minimizer_t* GSLLevenbergMarquardtMinimizer::rootMinimizer() const -{ +const MinimizerAdapter::root_minimizer_t* GSLLevenbergMarquardtMinimizer::rootMinimizer() const { return m_gsl_minimizer.get(); } -void GSLLevenbergMarquardtMinimizer::setParameter(unsigned int index, const mumufit::Parameter& par) -{ +void GSLLevenbergMarquardtMinimizer::setParameter(unsigned int index, + const mumufit::Parameter& par) { auto limits = par.limits(); if (!limits.isLimitless() && !limits.isFixed()) throw std::runtime_error("GSLLMA minimizer can't handle limited parameters." diff --git a/Fit/Adapter/GSLLevenbergMarquardtMinimizer.h b/Fit/Adapter/GSLLevenbergMarquardtMinimizer.h index b11d0a98eb945b488631f096e0417e7a824d3946..124a051d0494037750cc843e051d4326422fbbb4 100644 --- a/Fit/Adapter/GSLLevenbergMarquardtMinimizer.h +++ b/Fit/Adapter/GSLLevenbergMarquardtMinimizer.h @@ -17,8 +17,7 @@ #include "Fit/Adapter/MinimizerAdapter.h" -namespace ROOT::Math -{ +namespace ROOT::Math { class GSLNLSMinimizer; } @@ -27,8 +26,7 @@ class GSLNLSMinimizer; //! (http://www.gnu.org/software/gsl/manual/html_node/Nonlinear-Least_002dSquares-Fitting.html). //! @ingroup fitting_internal -class GSLLevenbergMarquardtMinimizer : public MinimizerAdapter -{ +class GSLLevenbergMarquardtMinimizer : public MinimizerAdapter { public: GSLLevenbergMarquardtMinimizer(); ~GSLLevenbergMarquardtMinimizer() override; diff --git a/Fit/Adapter/GSLMultiMinimizer.cpp b/Fit/Adapter/GSLMultiMinimizer.cpp index 06d759abcaab6ae9853812dd4568a85a4a289306..084405d999907826047d7810c92e9e0cbce266bc 100644 --- a/Fit/Adapter/GSLMultiMinimizer.cpp +++ b/Fit/Adapter/GSLMultiMinimizer.cpp @@ -30,46 +30,38 @@ GSLMultiMinimizer::GSLMultiMinimizer(const std::string& algorithmName) : MinimizerAdapter(MinimizerInfo::buildGSLMultiMinInfo(algorithmName)) - , m_gsl_minimizer(new ROOT::Math::GSLMinimizer(algorithmName.c_str())) -{ + , m_gsl_minimizer(new ROOT::Math::GSLMinimizer(algorithmName.c_str())) { addOption("PrintLevel", 0, "Minimizer internal print level"); addOption("MaxIterations", 0, "Maximum number of iterations"); } GSLMultiMinimizer::~GSLMultiMinimizer() = default; -void GSLMultiMinimizer::setPrintLevel(int value) -{ +void GSLMultiMinimizer::setPrintLevel(int value) { setOptionValue("PrintLevel", value); } -int GSLMultiMinimizer::printLevel() const -{ +int GSLMultiMinimizer::printLevel() const { return optionValue<int>("PrintLevel"); } -void GSLMultiMinimizer::setMaxIterations(int value) -{ +void GSLMultiMinimizer::setMaxIterations(int value) { setOptionValue("MaxIterations", value); } -int GSLMultiMinimizer::maxIterations() const -{ +int GSLMultiMinimizer::maxIterations() const { return optionValue<int>("MaxIterations"); } -std::string GSLMultiMinimizer::statusToString() const -{ +std::string GSLMultiMinimizer::statusToString() const { return mumufit::utils::gslErrorDescription(rootMinimizer()->Status()); } -void GSLMultiMinimizer::propagateOptions() -{ +void GSLMultiMinimizer::propagateOptions() { m_gsl_minimizer->SetPrintLevel(printLevel()); m_gsl_minimizer->SetMaxIterations(static_cast<unsigned int>(maxIterations())); } -const MinimizerAdapter::root_minimizer_t* GSLMultiMinimizer::rootMinimizer() const -{ +const MinimizerAdapter::root_minimizer_t* GSLMultiMinimizer::rootMinimizer() const { return m_gsl_minimizer.get(); } diff --git a/Fit/Adapter/GSLMultiMinimizer.h b/Fit/Adapter/GSLMultiMinimizer.h index 4cc8a4c75b60a09476776051b17fe990cf12f3d1..ccaae0ed179defb39e2dc3a36182877e9f3e0368 100644 --- a/Fit/Adapter/GSLMultiMinimizer.h +++ b/Fit/Adapter/GSLMultiMinimizer.h @@ -17,16 +17,14 @@ #include "Fit/Adapter/MinimizerAdapter.h" -namespace ROOT::Math -{ +namespace ROOT::Math { class GSLMinimizer; } //! Wrapper for the CERN ROOT facade of the GSL multi minimizer family (gradient descent based). //! @ingroup fitting_internal -class GSLMultiMinimizer : public MinimizerAdapter -{ +class GSLMultiMinimizer : public MinimizerAdapter { public: explicit GSLMultiMinimizer(const std::string& algorithmName = "ConjugateFR"); ~GSLMultiMinimizer(); diff --git a/Fit/Adapter/GeneticMinimizer.cpp b/Fit/Adapter/GeneticMinimizer.cpp index 535c393e684bb653249fc64424a3e857c415ec64..2908fba059d4dafe4c14296314e9f1b4cfa7c499 100644 --- a/Fit/Adapter/GeneticMinimizer.cpp +++ b/Fit/Adapter/GeneticMinimizer.cpp @@ -15,11 +15,9 @@ #include "Fit/Adapter/GeneticMinimizer.h" #include <Math/GeneticMinimizer.h> -namespace -{ +namespace { -std::map<int, std::string> statusDescription() -{ +std::map<int, std::string> statusDescription() { std::map<int, std::string> result; result[0] = "OK, minimum found"; result[1] = "Maximum number of iterations reached"; @@ -29,8 +27,7 @@ std::map<int, std::string> statusDescription() GeneticMinimizer::GeneticMinimizer() : MinimizerAdapter(MinimizerInfo::buildGeneticInfo()) - , m_genetic_minimizer(new ROOT::Math::GeneticMinimizer()) -{ + , m_genetic_minimizer(new ROOT::Math::GeneticMinimizer()) { addOption("Tolerance", 0.01, "Tolerance on the function value at the minimum"); addOption("PrintLevel", 0, "Minimizer internal print level"); addOption("MaxIterations", 3, "Maximum number of iterations"); @@ -50,58 +47,47 @@ GeneticMinimizer::GeneticMinimizer() GeneticMinimizer::~GeneticMinimizer() = default; -void GeneticMinimizer::setTolerance(double value) -{ +void GeneticMinimizer::setTolerance(double value) { setOptionValue("Tolerance", value); } -double GeneticMinimizer::tolerance() const -{ +double GeneticMinimizer::tolerance() const { return optionValue<double>("Tolerance"); } -void GeneticMinimizer::setPrintLevel(int value) -{ +void GeneticMinimizer::setPrintLevel(int value) { setOptionValue("PrintLevel", value); } -int GeneticMinimizer::printLevel() const -{ +int GeneticMinimizer::printLevel() const { return optionValue<int>("PrintLevel"); } -void GeneticMinimizer::setMaxIterations(int value) -{ +void GeneticMinimizer::setMaxIterations(int value) { setOptionValue("MaxIterations", value); } -int GeneticMinimizer::maxIterations() const -{ +int GeneticMinimizer::maxIterations() const { return optionValue<int>("MaxIterations"); } -void GeneticMinimizer::setPopulationSize(int value) -{ +void GeneticMinimizer::setPopulationSize(int value) { setOptionValue("PopSize", value); } -int GeneticMinimizer::populationSize() const -{ +int GeneticMinimizer::populationSize() const { return optionValue<int>("PopSize"); } -void GeneticMinimizer::setRandomSeed(int value) -{ +void GeneticMinimizer::setRandomSeed(int value) { setOptionValue("RandomSeed", value); } -int GeneticMinimizer::randomSeed() const -{ +int GeneticMinimizer::randomSeed() const { return optionValue<int>("RandomSeed"); } -void GeneticMinimizer::setParameter(unsigned int index, const mumufit::Parameter& par) -{ +void GeneticMinimizer::setParameter(unsigned int index, const mumufit::Parameter& par) { if (!par.limits().isFixed() && !par.limits().isLimited()) { std::ostringstream ostr; ostr << "GeneticMinimizer::setParameter() -> Error! " @@ -113,20 +99,17 @@ void GeneticMinimizer::setParameter(unsigned int index, const mumufit::Parameter MinimizerAdapter::setParameter(index, par); } -std::string GeneticMinimizer::statusToString() const -{ +std::string GeneticMinimizer::statusToString() const { return statusDescription()[rootMinimizer()->Status()]; } -std::map<std::string, std::string> GeneticMinimizer::statusMap() const -{ +std::map<std::string, std::string> GeneticMinimizer::statusMap() const { auto result = MinimizerAdapter::statusMap(); result["functionCalls"] = std::to_string(rootMinimizer()->NCalls()); return result; } -void GeneticMinimizer::propagateOptions() -{ +void GeneticMinimizer::propagateOptions() { ROOT::Math::GeneticMinimizerParameters pars; pars.fPopSize = populationSize(); pars.fNsteps = maxIterations(); @@ -140,7 +123,6 @@ void GeneticMinimizer::propagateOptions() m_genetic_minimizer->SetParameters(pars); } -const MinimizerAdapter::root_minimizer_t* GeneticMinimizer::rootMinimizer() const -{ +const MinimizerAdapter::root_minimizer_t* GeneticMinimizer::rootMinimizer() const { return m_genetic_minimizer.get(); } diff --git a/Fit/Adapter/GeneticMinimizer.h b/Fit/Adapter/GeneticMinimizer.h index 4e599542762795f3eaf1ef625c52fad683ea441c..34dcd51a263b9b67ae0d87d0b7f8d66a22b2574f 100644 --- a/Fit/Adapter/GeneticMinimizer.h +++ b/Fit/Adapter/GeneticMinimizer.h @@ -17,16 +17,14 @@ #include "Fit/Adapter/MinimizerAdapter.h" -namespace ROOT::Math -{ +namespace ROOT::Math { class GeneticMinimizer; } //! Wrapper for the CERN ROOT Genetic minimizer. //! @ingroup fitting_internal -class GeneticMinimizer : public MinimizerAdapter -{ +class GeneticMinimizer : public MinimizerAdapter { public: GeneticMinimizer(); ~GeneticMinimizer(); diff --git a/Fit/Adapter/IFunctionAdapter.cpp b/Fit/Adapter/IFunctionAdapter.cpp index 621e3ef6520bf7a10b20fc03b80d2dbae55bcefa..83f575da231ae3d87c12b7068653c63c4f265084 100644 --- a/Fit/Adapter/IFunctionAdapter.cpp +++ b/Fit/Adapter/IFunctionAdapter.cpp @@ -20,12 +20,10 @@ IFunctionAdapter::IFunctionAdapter() : m_number_of_calls(0), m_number_of_gradien IFunctionAdapter::~IFunctionAdapter() = default; -int IFunctionAdapter::numberOfCalls() const -{ +int IFunctionAdapter::numberOfCalls() const { return m_number_of_calls; } -int IFunctionAdapter::numberOfGradientCalls() const -{ +int IFunctionAdapter::numberOfGradientCalls() const { return m_number_of_gradient_calls; } diff --git a/Fit/Adapter/IFunctionAdapter.h b/Fit/Adapter/IFunctionAdapter.h index 29dcf6891c67308ab23d6ee1df92eb7b29f9b976..3d56d5913de9bf17cdb77ab40603a8b389a14789 100644 --- a/Fit/Adapter/IFunctionAdapter.h +++ b/Fit/Adapter/IFunctionAdapter.h @@ -15,14 +15,12 @@ #ifndef BORNAGAIN_FIT_ADAPTER_IFUNCTIONADAPTER_H #define BORNAGAIN_FIT_ADAPTER_IFUNCTIONADAPTER_H -namespace mumufit -{ +namespace mumufit { //! Base class for objective function adapters, which converts user functions //! to minimize into the function which minimization machinery expects. -class IFunctionAdapter -{ +class IFunctionAdapter { public: IFunctionAdapter(); virtual ~IFunctionAdapter(); diff --git a/Fit/Adapter/MinimizerAdapter.cpp b/Fit/Adapter/MinimizerAdapter.cpp index ec9865cd0d2f0683a3c7f66ebc0ca15ada1e203b..67040f04b006e919ff3815595a31bab7610b5c49 100644 --- a/Fit/Adapter/MinimizerAdapter.cpp +++ b/Fit/Adapter/MinimizerAdapter.cpp @@ -25,28 +25,23 @@ using namespace mumufit; MinimizerAdapter::MinimizerAdapter(const MinimizerInfo& minimizerInfo) : m_minimizerInfo(minimizerInfo) , m_adapter(new mumufit::ObjectiveFunctionAdapter) - , m_status(false) -{ -} + , m_status(false) {} MinimizerAdapter::~MinimizerAdapter() = default; -MinimizerResult MinimizerAdapter::minimize_scalar(fcn_scalar_t fcn, Parameters parameters) -{ +MinimizerResult MinimizerAdapter::minimize_scalar(fcn_scalar_t fcn, Parameters parameters) { // Genetic minimizer requires SetFunction before setParameters, others don't care rootMinimizer()->SetFunction(*m_adapter->rootObjectiveFunction(fcn, parameters)); return minimize(parameters); } -MinimizerResult MinimizerAdapter::minimize_residual(fcn_residual_t fcn, Parameters parameters) -{ +MinimizerResult MinimizerAdapter::minimize_residual(fcn_residual_t fcn, Parameters parameters) { // Genetic minimizer requires SetFunction before setParameters, others don't care rootMinimizer()->SetFunction(*m_adapter->rootResidualFunction(fcn, parameters)); return minimize(parameters); } -MinimizerResult MinimizerAdapter::minimize(Parameters parameters) -{ +MinimizerResult MinimizerAdapter::minimize(Parameters parameters) { setParameters(parameters); propagateOptions(); @@ -63,40 +58,33 @@ MinimizerResult MinimizerAdapter::minimize(Parameters parameters) return result; } -std::string MinimizerAdapter::minimizerName() const -{ +std::string MinimizerAdapter::minimizerName() const { return m_minimizerInfo.name(); } -std::string MinimizerAdapter::algorithmName() const -{ +std::string MinimizerAdapter::algorithmName() const { return m_minimizerInfo.algorithmName(); } -void MinimizerAdapter::setParameters(const mumufit::Parameters& parameters) -{ +void MinimizerAdapter::setParameters(const mumufit::Parameters& parameters) { unsigned int index(0); for (const auto& par : parameters) setParameter(index++, par); } -double MinimizerAdapter::minValue() const -{ +double MinimizerAdapter::minValue() const { return rootMinimizer()->MinValue(); } -std::string MinimizerAdapter::statusToString() const -{ +std::string MinimizerAdapter::statusToString() const { return m_status ? "Minimum found" : "Error in solving"; } -bool MinimizerAdapter::providesError() const -{ +bool MinimizerAdapter::providesError() const { return rootMinimizer()->ProvidesError(); } -std::map<std::string, std::string> MinimizerAdapter::statusMap() const -{ +std::map<std::string, std::string> MinimizerAdapter::statusMap() const { std::map<std::string, std::string> result; result["Status"] = statusToString(); @@ -110,15 +98,13 @@ std::map<std::string, std::string> MinimizerAdapter::statusMap() const return result; } -void MinimizerAdapter::setOptions(const std::string& optionString) -{ +void MinimizerAdapter::setOptions(const std::string& optionString) { options().setOptionString(optionString); } //! Propagates results of minimization to fit parameter set -void MinimizerAdapter::propagateResults(mumufit::Parameters& parameters) -{ +void MinimizerAdapter::propagateResults(mumufit::Parameters& parameters) { parameters.setValues(parValuesAtMinimum()); parameters.setErrors(parErrorsAtMinimum()); // sets correlation matrix @@ -136,8 +122,7 @@ void MinimizerAdapter::propagateResults(mumufit::Parameters& parameters) } } -void MinimizerAdapter::setParameter(unsigned int index, const mumufit::Parameter& par) -{ +void MinimizerAdapter::setParameter(unsigned int index, const mumufit::Parameter& par) { bool success; if (par.limits().isFixed()) { success = rootMinimizer()->SetFixedVariable(index, par.name().c_str(), par.value()); @@ -178,15 +163,13 @@ void MinimizerAdapter::setParameter(unsigned int index, const mumufit::Parameter //! Returns number of fit parameters defined (i.e. dimension of the function to be minimized). -size_t MinimizerAdapter::fitDimension() const -{ +size_t MinimizerAdapter::fitDimension() const { return rootMinimizer()->NDim(); } //! Returns value of the variables at minimum. -std::vector<double> MinimizerAdapter::parValuesAtMinimum() const -{ +std::vector<double> MinimizerAdapter::parValuesAtMinimum() const { std::vector<double> result; result.resize(fitDimension(), 0.0); std::copy(rootMinimizer()->X(), rootMinimizer()->X() + fitDimension(), result.begin()); @@ -195,8 +178,7 @@ std::vector<double> MinimizerAdapter::parValuesAtMinimum() const //! Returns errors of the variables at minimum. -std::vector<double> MinimizerAdapter::parErrorsAtMinimum() const -{ +std::vector<double> MinimizerAdapter::parErrorsAtMinimum() const { std::vector<double> result; result.resize(fitDimension(), 0.0); if (rootMinimizer()->Errors() != 0) { @@ -206,8 +188,7 @@ std::vector<double> MinimizerAdapter::parErrorsAtMinimum() const return result; } -MinimizerAdapter::root_minimizer_t* MinimizerAdapter::rootMinimizer() -{ +MinimizerAdapter::root_minimizer_t* MinimizerAdapter::rootMinimizer() { return const_cast<root_minimizer_t*>( static_cast<const MinimizerAdapter*>(this)->rootMinimizer()); } diff --git a/Fit/Adapter/MinimizerAdapter.h b/Fit/Adapter/MinimizerAdapter.h index 6b3f99b4d2b659ee6cc6b5845d3a978550c00e72..4afbff91042f1e6fffaa27d6b9c84468e1e46cad 100644 --- a/Fit/Adapter/MinimizerAdapter.h +++ b/Fit/Adapter/MinimizerAdapter.h @@ -21,24 +21,21 @@ #include <memory> #include <string> -namespace mumufit -{ +namespace mumufit { class Parameters; class Parameter; class ObjectiveFunctionAdapter; class MinimizerResult; } // namespace mumufit -namespace ROOT::Math -{ +namespace ROOT::Math { class Minimizer; } //! Abstract base class that adapts the CERN ROOT minimizer to our IMinimizer. //! @ingroup fitting_internal -class MinimizerAdapter : public IMinimizer -{ +class MinimizerAdapter : public IMinimizer { public: typedef ROOT::Math::Minimizer root_minimizer_t; @@ -107,18 +104,15 @@ private: template <class T> OptionContainer::option_t MinimizerAdapter::addOption(const std::string& optionName, T value, - const std::string& description) -{ + const std::string& description) { return m_options.addOption(optionName, value, description); } -template <class T> void MinimizerAdapter::setOptionValue(const std::string& optionName, T value) -{ +template <class T> void MinimizerAdapter::setOptionValue(const std::string& optionName, T value) { m_options.setOptionValue(optionName, value); } -template <class T> T MinimizerAdapter::optionValue(const std::string& optionName) const -{ +template <class T> T MinimizerAdapter::optionValue(const std::string& optionName) const { return m_options.optionValue<T>(optionName); } diff --git a/Fit/Adapter/Minuit2Minimizer.cpp b/Fit/Adapter/Minuit2Minimizer.cpp index e83fb0d44c49168c7e0c307d0ec41258d83ec53c..2825e9c2fb17ee7e111e523a1a603748c975fc30 100644 --- a/Fit/Adapter/Minuit2Minimizer.cpp +++ b/Fit/Adapter/Minuit2Minimizer.cpp @@ -16,11 +16,9 @@ #include "Fit/Tools/StringUtils.h" #include <Minuit2/Minuit2Minimizer.h> -namespace -{ +namespace { -std::map<int, std::string> statusDescription() -{ +std::map<int, std::string> statusDescription() { std::map<int, std::string> result; result[0] = "OK, valid minimum"; result[1] = "Didn't converge, covariance was made pos defined"; @@ -31,8 +29,7 @@ std::map<int, std::string> statusDescription() return result; } -std::map<int, std::string> covmatrixStatusDescription() -{ +std::map<int, std::string> covmatrixStatusDescription() { std::map<int, std::string> result; result[-1] = "Not available (inversion failed or Hessian failed)"; result[0] = "Available but not positive defined"; @@ -46,8 +43,7 @@ std::map<int, std::string> covmatrixStatusDescription() Minuit2Minimizer::Minuit2Minimizer(const std::string& algorithmName) : MinimizerAdapter(MinimizerInfo::buildMinuit2Info(algorithmName)) - , m_minuit2_minimizer(new ROOT::Minuit2::Minuit2Minimizer(algorithmName.c_str())) -{ + , m_minuit2_minimizer(new ROOT::Minuit2::Minuit2Minimizer(algorithmName.c_str())) { addOption("Strategy", 1, "Minimization strategy (0-low, 1-medium, 2-high quality)"); addOption("ErrorDef", 1.0, "Error definition factor for parameter error calculation"); addOption("Tolerance", 0.01, "Tolerance on the function value at the minimum"); @@ -58,73 +54,59 @@ Minuit2Minimizer::Minuit2Minimizer(const std::string& algorithmName) Minuit2Minimizer::~Minuit2Minimizer() = default; -void Minuit2Minimizer::setStrategy(int value) -{ +void Minuit2Minimizer::setStrategy(int value) { setOptionValue("Strategy", value); } -int Minuit2Minimizer::strategy() const -{ +int Minuit2Minimizer::strategy() const { return optionValue<int>("Strategy"); } -void Minuit2Minimizer::setErrorDefinition(double value) -{ +void Minuit2Minimizer::setErrorDefinition(double value) { setOptionValue("ErrorDef", value); } -double Minuit2Minimizer::errorDefinition() const -{ +double Minuit2Minimizer::errorDefinition() const { return optionValue<double>("ErrorDef"); } -void Minuit2Minimizer::setTolerance(double value) -{ +void Minuit2Minimizer::setTolerance(double value) { setOptionValue("Tolerance", value); } -double Minuit2Minimizer::tolerance() const -{ +double Minuit2Minimizer::tolerance() const { return optionValue<double>("Tolerance"); } -void Minuit2Minimizer::setPrecision(double value) -{ +void Minuit2Minimizer::setPrecision(double value) { setOptionValue("Precision", value); } -double Minuit2Minimizer::precision() const -{ +double Minuit2Minimizer::precision() const { return optionValue<double>("Precision"); } -void Minuit2Minimizer::setPrintLevel(int value) -{ +void Minuit2Minimizer::setPrintLevel(int value) { setOptionValue("PrintLevel", value); } -int Minuit2Minimizer::printLevel() const -{ +int Minuit2Minimizer::printLevel() const { return optionValue<int>("PrintLevel"); } -void Minuit2Minimizer::setMaxFunctionCalls(int value) -{ +void Minuit2Minimizer::setMaxFunctionCalls(int value) { setOptionValue("MaxFunctionCalls", value); } -int Minuit2Minimizer::maxFunctionCalls() const -{ +int Minuit2Minimizer::maxFunctionCalls() const { return optionValue<int>("MaxFunctionCalls"); } -std::string Minuit2Minimizer::statusToString() const -{ +std::string Minuit2Minimizer::statusToString() const { return statusDescription()[rootMinimizer()->Status()]; } -std::map<std::string, std::string> Minuit2Minimizer::statusMap() const -{ +std::map<std::string, std::string> Minuit2Minimizer::statusMap() const { auto result = MinimizerAdapter::statusMap(); result["Edm"] = mumufit::stringUtils::scientific(rootMinimizer()->Edm()); result["CovMatrixStatus"] = covmatrixStatusDescription()[rootMinimizer()->CovMatrixStatus()]; @@ -135,15 +117,13 @@ std::map<std::string, std::string> Minuit2Minimizer::statusMap() const // Fumili algorithm can work only with gradient based objective function, while others can // work with both, gradient based and chi2 based functions. Historically however, we use // simplified approach: if not Fumili, then chi2 only. Think of refactoring TODO. -bool Minuit2Minimizer::requiresResiduals() -{ +bool Minuit2Minimizer::requiresResiduals() { return algorithmName() == "Fumili"; } //! Propagate options down to ROOT's Minuit2Minimizer. -void Minuit2Minimizer::propagateOptions() -{ +void Minuit2Minimizer::propagateOptions() { m_minuit2_minimizer->SetStrategy(strategy()); m_minuit2_minimizer->SetErrorDef(errorDefinition()); m_minuit2_minimizer->SetTolerance(tolerance()); @@ -152,7 +132,6 @@ void Minuit2Minimizer::propagateOptions() m_minuit2_minimizer->SetMaxFunctionCalls(static_cast<unsigned int>(maxFunctionCalls())); } -const MinimizerAdapter::root_minimizer_t* Minuit2Minimizer::rootMinimizer() const -{ +const MinimizerAdapter::root_minimizer_t* Minuit2Minimizer::rootMinimizer() const { return m_minuit2_minimizer.get(); } diff --git a/Fit/Adapter/Minuit2Minimizer.h b/Fit/Adapter/Minuit2Minimizer.h index 335f5365fe05a74a199241814d5a8128f9ae7325..9222196e57302e6684be52a20e982beb7cf5c294 100644 --- a/Fit/Adapter/Minuit2Minimizer.h +++ b/Fit/Adapter/Minuit2Minimizer.h @@ -18,8 +18,7 @@ #include "Fit/Adapter/MinimizerAdapter.h" #include <memory> -namespace ROOT::Minuit2 -{ +namespace ROOT::Minuit2 { class Minuit2Minimizer; } @@ -27,8 +26,7 @@ class Minuit2Minimizer; //! See Minuit2 user manual https://root.cern.ch/root/htmldoc/guides/minuit2/Minuit2.pdf. //! @ingroup fitting_internal -class Minuit2Minimizer : public MinimizerAdapter -{ +class Minuit2Minimizer : public MinimizerAdapter { public: Minuit2Minimizer(const std::string& algorithmName = "Migrad"); ~Minuit2Minimizer(); diff --git a/Fit/Adapter/ObjectiveFunctionAdapter.cpp b/Fit/Adapter/ObjectiveFunctionAdapter.cpp index f2b331eef069652c4d5d7575aac027dad99470db..f175f8bbd912c62534d975c08b1363e0a8a3a893 100644 --- a/Fit/Adapter/ObjectiveFunctionAdapter.cpp +++ b/Fit/Adapter/ObjectiveFunctionAdapter.cpp @@ -25,8 +25,7 @@ ObjectiveFunctionAdapter::ObjectiveFunctionAdapter() = default; ObjectiveFunctionAdapter::~ObjectiveFunctionAdapter() = default; const RootScalarFunction* -ObjectiveFunctionAdapter::rootObjectiveFunction(fcn_scalar_t fcn, const Parameters& parameters) -{ +ObjectiveFunctionAdapter::rootObjectiveFunction(fcn_scalar_t fcn, const Parameters& parameters) { std::unique_ptr<ScalarFunctionAdapter> tem_adapter(new ScalarFunctionAdapter(fcn, parameters)); auto result = tem_adapter->rootObjectiveFunction(); m_adapter.reset(tem_adapter.release()); @@ -34,8 +33,7 @@ ObjectiveFunctionAdapter::rootObjectiveFunction(fcn_scalar_t fcn, const Paramete } const RootResidualFunction* -ObjectiveFunctionAdapter::rootResidualFunction(fcn_residual_t fcn, const Parameters& parameters) -{ +ObjectiveFunctionAdapter::rootResidualFunction(fcn_residual_t fcn, const Parameters& parameters) { std::unique_ptr<ResidualFunctionAdapter> tem_adapter( new ResidualFunctionAdapter(fcn, parameters)); auto result = tem_adapter->rootResidualFunction(); @@ -43,12 +41,10 @@ ObjectiveFunctionAdapter::rootResidualFunction(fcn_residual_t fcn, const Paramet return result; } -int ObjectiveFunctionAdapter::numberOfCalls() const -{ +int ObjectiveFunctionAdapter::numberOfCalls() const { return m_adapter ? m_adapter->numberOfCalls() : 0; } -int ObjectiveFunctionAdapter::numberOfGradientCalls() const -{ +int ObjectiveFunctionAdapter::numberOfGradientCalls() const { return m_adapter ? m_adapter->numberOfGradientCalls() : 0; } diff --git a/Fit/Adapter/ObjectiveFunctionAdapter.h b/Fit/Adapter/ObjectiveFunctionAdapter.h index 3251180470125cde1ae15ee1d939abff4fd78077..2927f93d21e74fdba41a5b50f681063916d9ecda 100644 --- a/Fit/Adapter/ObjectiveFunctionAdapter.h +++ b/Fit/Adapter/ObjectiveFunctionAdapter.h @@ -21,8 +21,7 @@ class RootScalarFunction; class RootResidualFunction; -namespace mumufit -{ +namespace mumufit { class IFunctionAdapter; class Parameters; @@ -30,8 +29,7 @@ class Parameters; //! Converts user objective function to function ROOT expects. //! Handles time of life of function objects. -class ObjectiveFunctionAdapter -{ +class ObjectiveFunctionAdapter { public: ObjectiveFunctionAdapter(); ~ObjectiveFunctionAdapter(); diff --git a/Fit/Adapter/Report.cpp b/Fit/Adapter/Report.cpp index 297a6e1647d75b27ec649ada3b2b77e9278604e3..92e4a2b65383116ca1a72a1f8e08eb24f9453fcc 100644 --- a/Fit/Adapter/Report.cpp +++ b/Fit/Adapter/Report.cpp @@ -18,28 +18,24 @@ #include <iomanip> #include <sstream> -namespace -{ +namespace { const int column_width = 18; -template <typename T> std::string reportValue(const std::string& name, T value) -{ +template <typename T> std::string reportValue(const std::string& name, T value) { std::ostringstream result; result << std::setw(column_width) << std::left << name << ": " << value << std::endl; return result.str(); } -std::string reportDescription(const MinimizerAdapter& minimizer) -{ +std::string reportDescription(const MinimizerAdapter& minimizer) { std::ostringstream result; result << reportValue("MinimizerType", minimizer.minimizerName()); result << reportValue("AlgorithmName", minimizer.algorithmName()); return result.str(); } -std::string reportOption(const MinimizerAdapter& minimizer) -{ +std::string reportOption(const MinimizerAdapter& minimizer) { if (minimizer.options().empty()) return ""; @@ -56,8 +52,7 @@ std::string reportOption(const MinimizerAdapter& minimizer) return result.str(); } -std::string reportStatus(const MinimizerAdapter& minimizer) -{ +std::string reportStatus(const MinimizerAdapter& minimizer) { std::ostringstream result; result << mumufit::utils::sectionString("Status"); @@ -74,8 +69,7 @@ std::string reportStatus(const MinimizerAdapter& minimizer) // implement API // ************************************************************************************************ -std::string mumufit::internal::reportToString(const MinimizerAdapter& minimizer) -{ +std::string mumufit::internal::reportToString(const MinimizerAdapter& minimizer) { std::ostringstream result; result << mumufit::utils::sectionString(); diff --git a/Fit/Adapter/Report.h b/Fit/Adapter/Report.h index 617dd7ec62ec05ce5b4a3eced41337fac4715977..76f9ace9d16d7d8ffca05a5dee957db61453bfb6 100644 --- a/Fit/Adapter/Report.h +++ b/Fit/Adapter/Report.h @@ -21,8 +21,7 @@ class MinimizerAdapter; //! Utility functions to generate reports -namespace mumufit::internal -{ +namespace mumufit::internal { //! Reports results of minimization in the form of multi-line string std::string reportToString(const MinimizerAdapter& minimizer); diff --git a/Fit/Adapter/ResidualFunctionAdapter.cpp b/Fit/Adapter/ResidualFunctionAdapter.cpp index d60f5912d5e4bc030498b3fbac79c28c18ff2d8d..63610fd78b20bf799de873ac16430dca6e9ad47b 100644 --- a/Fit/Adapter/ResidualFunctionAdapter.cpp +++ b/Fit/Adapter/ResidualFunctionAdapter.cpp @@ -17,8 +17,7 @@ #include <cassert> #include <sstream> -namespace -{ +namespace { // step size of derivative calculations const double kEps = 1.0E-9; } // namespace @@ -27,15 +26,13 @@ using namespace mumufit; ResidualFunctionAdapter::ResidualFunctionAdapter(fcn_residual_t func, const mumufit::Parameters& parameters) - : m_datasize(0), m_fcn(func), m_parameters(parameters) -{ + : m_datasize(0), m_fcn(func), m_parameters(parameters) { // single call of user function to get dataset size auto residuals = m_fcn(parameters); m_datasize = residuals.size(); } -const RootResidualFunction* ResidualFunctionAdapter::rootResidualFunction() -{ +const RootResidualFunction* ResidualFunctionAdapter::rootResidualFunction() { gradient_function_t gradient_fun = [&](const std::vector<double>& pars, unsigned int index, std::vector<double>& gradients) { return element_residual(pars, index, gradients); @@ -49,8 +46,7 @@ const RootResidualFunction* ResidualFunctionAdapter::rootResidualFunction() return m_root_objective.get(); } -void ResidualFunctionAdapter::calculate_gradients(const std::vector<double>& pars) -{ +void ResidualFunctionAdapter::calculate_gradients(const std::vector<double>& pars) { m_gradients.clear(); m_gradients.resize(pars.size()); for (size_t i_par = 0; i_par < pars.size(); ++i_par) @@ -70,8 +66,7 @@ void ResidualFunctionAdapter::calculate_gradients(const std::vector<double>& par } } -std::vector<double> ResidualFunctionAdapter::get_residuals(const std::vector<double>& pars) -{ +std::vector<double> ResidualFunctionAdapter::get_residuals(const std::vector<double>& pars) { if (pars.size() != m_parameters.size()) { std::ostringstream ostr; ostr << "ResidualFunctionAdapter::residuals() -> Error. Number of fit parameters " @@ -98,8 +93,8 @@ std::vector<double> ResidualFunctionAdapter::get_residuals(const std::vector<dou //! If index!=0 - cached value of residuals/gradients will be used. double ResidualFunctionAdapter::element_residual(const std::vector<double>& pars, - unsigned int index, std::vector<double>& gradients) -{ + unsigned int index, + std::vector<double>& gradients) { if (index == 0) { m_residuals = get_residuals(pars); } @@ -118,8 +113,7 @@ double ResidualFunctionAdapter::element_residual(const std::vector<double>& pars return m_residuals[index]; } -double ResidualFunctionAdapter::chi2(const std::vector<double>& pars) -{ +double ResidualFunctionAdapter::chi2(const std::vector<double>& pars) { ++m_number_of_calls; double result(0.0); diff --git a/Fit/Adapter/ResidualFunctionAdapter.h b/Fit/Adapter/ResidualFunctionAdapter.h index fc0fecc447323278f4904d21ab315f00b910f61e..9c6ea89216116bd93a5fa33a3a64f32fa7d12c41 100644 --- a/Fit/Adapter/ResidualFunctionAdapter.h +++ b/Fit/Adapter/ResidualFunctionAdapter.h @@ -24,14 +24,12 @@ class RootResidualFunction; -namespace mumufit -{ +namespace mumufit { //! Provides RootResidualFunction which will be minimizer by ROOT. //! Converts ROOT calls to the call of fcn_residual_t. -class ResidualFunctionAdapter : public IFunctionAdapter -{ +class ResidualFunctionAdapter : public IFunctionAdapter { public: ResidualFunctionAdapter(fcn_residual_t func, const Parameters& parameters); diff --git a/Fit/Adapter/RootResidualFunction.cpp b/Fit/Adapter/RootResidualFunction.cpp index e6d39a8beb9634d13942ce48e63958f1e4076728..5dc724d58115ac354d483e1712ac292589512df7 100644 --- a/Fit/Adapter/RootResidualFunction.cpp +++ b/Fit/Adapter/RootResidualFunction.cpp @@ -21,17 +21,13 @@ RootResidualFunction::RootResidualFunction(scalar_function_t objective_fun, , m_objective_fun(objective_fun) , m_gradient_fun(gradient_fun) , m_npars(npars) - , m_datasize(ndatasize) -{ -} + , m_datasize(ndatasize) {} -RootResidualFunction::Type_t RootResidualFunction::Type() const -{ +RootResidualFunction::Type_t RootResidualFunction::Type() const { return ROOT::Math::FitMethodFunction::kLeastSquare; } -ROOT::Math::IMultiGenFunction* RootResidualFunction::Clone() const -{ +ROOT::Math::IMultiGenFunction* RootResidualFunction::Clone() const { return new RootResidualFunction(m_objective_fun, m_gradient_fun, m_npars, m_datasize); } @@ -43,8 +39,7 @@ ROOT::Math::IMultiGenFunction* RootResidualFunction::Clone() const //! @return value of residual for given data element index double RootResidualFunction::DataElement(const double* pars, unsigned int index, - double* gradients) const -{ + double* gradients) const { std::vector<double> par_values; par_values.resize(m_npars, 0.0); std::copy(pars, pars + m_npars, par_values.begin()); @@ -65,8 +60,7 @@ double RootResidualFunction::DataElement(const double* pars, unsigned int index, return result; } -double RootResidualFunction::DoEval(const double* pars) const -{ +double RootResidualFunction::DoEval(const double* pars) const { std::vector<double> par_values; par_values.resize(m_npars, 0.0); std::copy(pars, pars + m_npars, par_values.begin()); diff --git a/Fit/Adapter/RootResidualFunction.h b/Fit/Adapter/RootResidualFunction.h index c3ec0ae5dc332a3c83c868866000fa335f071bff..ff09dbf4d8c2a9378c1bad77564d0a0604349ca8 100644 --- a/Fit/Adapter/RootResidualFunction.h +++ b/Fit/Adapter/RootResidualFunction.h @@ -29,8 +29,7 @@ //! Minimizer function with access to single data element residuals, //! required by Fumili2 and GSLMultiMin minimizers. -class RootResidualFunction : public ROOT::Math::FitMethodFunction -{ +class RootResidualFunction : public ROOT::Math::FitMethodFunction { public: typedef ROOT::Math::BasicFitMethodFunction<ROOT::Math::IMultiGenFunction>::Type_t Type_t; diff --git a/Fit/Adapter/RootScalarFunction.cpp b/Fit/Adapter/RootScalarFunction.cpp index 2dc536406196d43dba67dbf064d145369d101e65..845fa8467a3a49200f4828ed0bf9b5bf40c49567 100644 --- a/Fit/Adapter/RootScalarFunction.cpp +++ b/Fit/Adapter/RootScalarFunction.cpp @@ -15,6 +15,4 @@ #include "Fit/Adapter/RootScalarFunction.h" RootScalarFunction::RootScalarFunction(root_scalar_t fcn, int ndims) - : ROOT::Math::Functor(fcn, static_cast<unsigned int>(ndims)) -{ -} + : ROOT::Math::Functor(fcn, static_cast<unsigned int>(ndims)) {} diff --git a/Fit/Adapter/RootScalarFunction.h b/Fit/Adapter/RootScalarFunction.h index 80bd78d16f31cebdd55b45fa1df2ddf60d27a7f4..dd103552ad1eb59869a1fd3894b77eedde9b4fbc 100644 --- a/Fit/Adapter/RootScalarFunction.h +++ b/Fit/Adapter/RootScalarFunction.h @@ -29,8 +29,7 @@ //! The chi2 function for use in minimizers. //! @ingroup fitting_internal -class RootScalarFunction : public ROOT::Math::Functor -{ +class RootScalarFunction : public ROOT::Math::Functor { public: RootScalarFunction(root_scalar_t fcn, int ndims); }; diff --git a/Fit/Adapter/ScalarFunctionAdapter.cpp b/Fit/Adapter/ScalarFunctionAdapter.cpp index 6e70746a39d2b88fe091cbb46cbf0c7b7c63dbcf..fd15ec513b13fb9df6ae6b79a329edc0921c7908 100644 --- a/Fit/Adapter/ScalarFunctionAdapter.cpp +++ b/Fit/Adapter/ScalarFunctionAdapter.cpp @@ -18,12 +18,9 @@ using namespace mumufit; ScalarFunctionAdapter::ScalarFunctionAdapter(fcn_scalar_t func, const Parameters& parameters) - : m_fcn(func), m_parameters(parameters) -{ -} + : m_fcn(func), m_parameters(parameters) {} -const RootScalarFunction* ScalarFunctionAdapter::rootObjectiveFunction() -{ +const RootScalarFunction* ScalarFunctionAdapter::rootObjectiveFunction() { root_scalar_t rootfun = [&](const double* pars) { std::vector<double> vec; vec.resize(m_parameters.size(), 0.0); diff --git a/Fit/Adapter/ScalarFunctionAdapter.h b/Fit/Adapter/ScalarFunctionAdapter.h index 336e450e2de3b0fbdb748ade53a3cf76f5281564..2e4ff6b06ac1699caeea429e97e8aa21074d39c3 100644 --- a/Fit/Adapter/ScalarFunctionAdapter.h +++ b/Fit/Adapter/ScalarFunctionAdapter.h @@ -24,8 +24,7 @@ class RootScalarFunction; -namespace mumufit -{ +namespace mumufit { //! Converts user objective function to chi2 like function which ROOT expects. @@ -33,8 +32,7 @@ namespace mumufit //! the call of user function std::function<double(std::vector<double>)>, where //! function input parameters will be current values fit parameters. -class ScalarFunctionAdapter : public IFunctionAdapter -{ +class ScalarFunctionAdapter : public IFunctionAdapter { public: ScalarFunctionAdapter(fcn_scalar_t func, const Parameters& parameters); diff --git a/Fit/Adapter/SimAnMinimizer.cpp b/Fit/Adapter/SimAnMinimizer.cpp index 317fccb8a52858505df21034e053a26cebffb086..6d566ad91c700304d53565b86c6eed6f408fd738 100644 --- a/Fit/Adapter/SimAnMinimizer.cpp +++ b/Fit/Adapter/SimAnMinimizer.cpp @@ -29,8 +29,7 @@ SimAnMinimizer::SimAnMinimizer() : MinimizerAdapter(MinimizerInfo::buildGSLSimAnInfo()) - , m_siman_minimizer(new ROOT::Math::GSLSimAnMinimizer()) -{ + , m_siman_minimizer(new ROOT::Math::GSLSimAnMinimizer()) { addOption("PrintLevel", 0, "Minimizer internal print level"); addOption("MaxIterations", 100, "Number of points to try for each step"); addOption("IterationsAtTemp", 10, "Number of iterations at each temperature"); @@ -43,95 +42,77 @@ SimAnMinimizer::SimAnMinimizer() SimAnMinimizer::~SimAnMinimizer() = default; -void SimAnMinimizer::setPrintLevel(int value) -{ +void SimAnMinimizer::setPrintLevel(int value) { setOptionValue("PrintLevel", value); } -int SimAnMinimizer::printLevel() const -{ +int SimAnMinimizer::printLevel() const { return optionValue<int>("PrintLevel"); } -void SimAnMinimizer::setMaxIterations(int value) -{ +void SimAnMinimizer::setMaxIterations(int value) { setOptionValue("MaxIterations", value); } -int SimAnMinimizer::maxIterations() const -{ +int SimAnMinimizer::maxIterations() const { return optionValue<int>("MaxIterations"); } -void SimAnMinimizer::setIterationsAtEachTemp(int value) -{ +void SimAnMinimizer::setIterationsAtEachTemp(int value) { setOptionValue("IterationsAtTemp", value); } -int SimAnMinimizer::iterationsAtEachTemp() const -{ +int SimAnMinimizer::iterationsAtEachTemp() const { return optionValue<int>("IterationsAtTemp"); } -void SimAnMinimizer::setStepSize(double value) -{ +void SimAnMinimizer::setStepSize(double value) { setOptionValue("StepSize", value); } -double SimAnMinimizer::stepSize() const -{ +double SimAnMinimizer::stepSize() const { return optionValue<double>("StepSize"); } -void SimAnMinimizer::setBoltzmannK(double value) -{ +void SimAnMinimizer::setBoltzmannK(double value) { setOptionValue("k", value); } -double SimAnMinimizer::boltzmannK() const -{ +double SimAnMinimizer::boltzmannK() const { return optionValue<double>("k"); } -void SimAnMinimizer::setBoltzmannInitialTemp(double value) -{ +void SimAnMinimizer::setBoltzmannInitialTemp(double value) { setOptionValue("t_init", value); } -double SimAnMinimizer::boltzmannInitialTemp() const -{ +double SimAnMinimizer::boltzmannInitialTemp() const { return optionValue<double>("t_init"); } -void SimAnMinimizer::setBoltzmannMu(double value) -{ +void SimAnMinimizer::setBoltzmannMu(double value) { setOptionValue("mu", value); } -double SimAnMinimizer::boltzmannMu() const -{ +double SimAnMinimizer::boltzmannMu() const { return optionValue<double>("mu"); } -void SimAnMinimizer::setBoltzmannMinTemp(double value) -{ +void SimAnMinimizer::setBoltzmannMinTemp(double value) { setOptionValue("t_min", value); } -double SimAnMinimizer::boltzmannMinTemp() const -{ +double SimAnMinimizer::boltzmannMinTemp() const { return optionValue<double>("t_min"); } -std::map<std::string, std::string> SimAnMinimizer::statusMap() const -{ +std::map<std::string, std::string> SimAnMinimizer::statusMap() const { auto result = MinimizerAdapter::statusMap(); result["functionCalls"] = std::to_string(rootMinimizer()->NCalls()); return result; } -void SimAnMinimizer::propagateOptions() -{ +void SimAnMinimizer::propagateOptions() { ROOT::Math::GSLSimAnParams& pars = m_siman_minimizer->getSolver().Params(); pars.n_tries = maxIterations(); pars.iters_fixed_T = iterationsAtEachTemp(); @@ -142,7 +123,6 @@ void SimAnMinimizer::propagateOptions() pars.t_min = boltzmannMinTemp(); } -const MinimizerAdapter::root_minimizer_t* SimAnMinimizer::rootMinimizer() const -{ +const MinimizerAdapter::root_minimizer_t* SimAnMinimizer::rootMinimizer() const { return m_siman_minimizer.get(); } diff --git a/Fit/Adapter/SimAnMinimizer.h b/Fit/Adapter/SimAnMinimizer.h index f81d44f9c83a3a43c669048738b44f62f0f736c2..986f1a2bc040d872a35a4c4ef4a62f4c3528a57d 100644 --- a/Fit/Adapter/SimAnMinimizer.h +++ b/Fit/Adapter/SimAnMinimizer.h @@ -17,16 +17,14 @@ #include "Fit/Adapter/MinimizerAdapter.h" -namespace ROOT::Math -{ +namespace ROOT::Math { class GSLSimAnMinimizer; } //! Wrapper for the CERN ROOT facade of the GSL simmulated annealing minimizer. //! @ingroup fitting_internal -class SimAnMinimizer : public MinimizerAdapter -{ +class SimAnMinimizer : public MinimizerAdapter { public: SimAnMinimizer(); ~SimAnMinimizer() override; diff --git a/Fit/Kernel/FitOptions.cpp b/Fit/Kernel/FitOptions.cpp index f0a1925f937e77cd5a06e0e07b86b72f0efe4f35..5a32ac231b2aea133408fed56543e3269f7e7524 100644 --- a/Fit/Kernel/FitOptions.cpp +++ b/Fit/Kernel/FitOptions.cpp @@ -16,22 +16,18 @@ FitOptions::FitOptions() : m_deriv_epsilon(1e-09), m_step_factor(0.01) {} -void FitOptions::setStepFactor(double step_factor) -{ +void FitOptions::setStepFactor(double step_factor) { m_step_factor = step_factor; } -double FitOptions::stepFactor() const -{ +double FitOptions::stepFactor() const { return m_step_factor; } -void FitOptions::setDerivEpsilon(double deriv_epsilon) -{ +void FitOptions::setDerivEpsilon(double deriv_epsilon) { m_deriv_epsilon = deriv_epsilon; } -double FitOptions::derivEpsilon() const -{ +double FitOptions::derivEpsilon() const { return m_deriv_epsilon; } diff --git a/Fit/Kernel/FitOptions.h b/Fit/Kernel/FitOptions.h index 0531c161432e8769003827a22c7f74905fa9111c..c7bb84285020d1fb418bc92cc68ff35e293f251a 100644 --- a/Fit/Kernel/FitOptions.h +++ b/Fit/Kernel/FitOptions.h @@ -17,8 +17,7 @@ //! General fitting options. -class FitOptions -{ +class FitOptions { public: FitOptions(); diff --git a/Fit/Kernel/Kernel.cpp b/Fit/Kernel/Kernel.cpp index d38a2b18c24dda12111fccbe23028992ae0603cb..aec6cb79750c7c47187e63bc0a61a7806cd62d1f 100644 --- a/Fit/Kernel/Kernel.cpp +++ b/Fit/Kernel/Kernel.cpp @@ -18,32 +18,27 @@ using namespace mumufit; -namespace -{ +namespace { const std::string default_minimizer = "Minuit2"; const std::string default_algorithm = "Migrad"; } // namespace -Kernel::Kernel() -{ +Kernel::Kernel() { setMinimizer(default_minimizer, default_algorithm); } Kernel::~Kernel() = default; void Kernel::setMinimizer(const std::string& minimizerName, const std::string& algorithmName, - const std::string& options) -{ + const std::string& options) { m_minimizer.reset(MinimizerFactory::createMinimizer(minimizerName, algorithmName, options)); } -void Kernel::setMinimizer(IMinimizer* minimizer) -{ +void Kernel::setMinimizer(IMinimizer* minimizer) { m_minimizer.reset(minimizer); } -MinimizerResult Kernel::minimize(fcn_scalar_t fcn, const Parameters& parameters) -{ +MinimizerResult Kernel::minimize(fcn_scalar_t fcn, const Parameters& parameters) { setParameters(parameters); m_timer.start(); @@ -58,8 +53,7 @@ MinimizerResult Kernel::minimize(fcn_scalar_t fcn, const Parameters& parameters) return result; } -MinimizerResult Kernel::minimize(fcn_residual_t fcn, const Parameters& parameters) -{ +MinimizerResult Kernel::minimize(fcn_residual_t fcn, const Parameters& parameters) { setParameters(parameters); m_timer.start(); @@ -70,7 +64,6 @@ MinimizerResult Kernel::minimize(fcn_residual_t fcn, const Parameters& parameter return result; } -void Kernel::setParameters(const Parameters& parameters) -{ +void Kernel::setParameters(const Parameters& parameters) { m_parameters = parameters; } diff --git a/Fit/Kernel/Kernel.h b/Fit/Kernel/Kernel.h index f9a957a1345717f73b3f2b76d4fba62eeedc340d..5a5740f7d18518eff744b22e1975b19e28faf018 100644 --- a/Fit/Kernel/Kernel.h +++ b/Fit/Kernel/Kernel.h @@ -24,14 +24,12 @@ class IMinimizer; -namespace mumufit -{ +namespace mumufit { //! A main class to run fitting. //! @ingroup fitting -class Kernel -{ +class Kernel { public: Kernel(); ~Kernel(); diff --git a/Fit/Kernel/Minimizer.cpp b/Fit/Kernel/Minimizer.cpp index 737f7d280d8b55a1a5e785d9ef848b2442ee2d2c..ff3abba59c562924a95cb2a8025b2fc6b914b8ed 100644 --- a/Fit/Kernel/Minimizer.cpp +++ b/Fit/Kernel/Minimizer.cpp @@ -21,30 +21,25 @@ using namespace mumufit; Minimizer::Minimizer() : m_kernel(new Kernel) {} void Minimizer::setMinimizer(const std::string& minimizerName, const std::string& algorithmName, - const std::string& options) -{ + const std::string& options) { m_kernel->setMinimizer(minimizerName, algorithmName, options); } -void Minimizer::setMinimizer(IMinimizer* minimizer) -{ +void Minimizer::setMinimizer(IMinimizer* minimizer) { m_kernel->setMinimizer(minimizer); } Minimizer::~Minimizer() = default; -MinimizerResult Minimizer::minimize(fcn_scalar_t fcn, const Parameters& parameters) -{ +MinimizerResult Minimizer::minimize(fcn_scalar_t fcn, const Parameters& parameters) { return m_kernel->minimize(fcn, parameters); } -MinimizerResult Minimizer::minimize(fcn_residual_t fcn, const Parameters& parameters) -{ +MinimizerResult Minimizer::minimize(fcn_residual_t fcn, const Parameters& parameters) { return m_kernel->minimize(fcn, parameters); } -MinimizerResult Minimizer::minimize(PyCallback& callback, const Parameters& parameters) -{ +MinimizerResult Minimizer::minimize(PyCallback& callback, const Parameters& parameters) { if (callback.callback_type() == PyCallback::SCALAR) { fcn_scalar_t fcn = [&](const Parameters& pars) { return callback.call_scalar(pars); }; return minimize(fcn, parameters); diff --git a/Fit/Kernel/Minimizer.h b/Fit/Kernel/Minimizer.h index a0679313ddf46029dc5ebb8b43f178e239e52fe9..f1e55dfa3fc3ef8f66e3a154d991d92d05960f9e 100644 --- a/Fit/Kernel/Minimizer.h +++ b/Fit/Kernel/Minimizer.h @@ -27,16 +27,14 @@ class IMinimizer; //! The multi-library, multi-algorithm fit wrapper library. -namespace mumufit -{ +namespace mumufit { class Kernel; //! A main class to run fitting. //! @ingroup fitting -class Minimizer -{ +class Minimizer { public: Minimizer(); ~Minimizer(); diff --git a/Fit/Kernel/MinimizerFactory.cpp b/Fit/Kernel/MinimizerFactory.cpp index ea74103dc935fecf91e4fb6060a0bb96b8a5ad72..61994fd3a081dc8c0dde2d947094e2af8281cb51 100644 --- a/Fit/Kernel/MinimizerFactory.cpp +++ b/Fit/Kernel/MinimizerFactory.cpp @@ -27,8 +27,7 @@ IMinimizer* MinimizerFactory::createMinimizer(const std::string& minimizerName, const std::string& algorithmType, - const std::string& optionString) -{ + const std::string& optionString) { IMinimizer* result(0); if (minimizerName == "Minuit2") { @@ -72,24 +71,21 @@ IMinimizer* MinimizerFactory::createMinimizer(const std::string& minimizerName, return result; } -void MinimizerFactory::printCatalog() -{ +void MinimizerFactory::printCatalog() { std::cout << catalogToString() << std::endl; } //! Returns multi-line string representing catalog content: minimizer names and list of their //! algorithms. -std::string MinimizerFactory::catalogToString() -{ +std::string MinimizerFactory::catalogToString() { return catalog().toString(); } //! Returns multi-line string representing detailed catalog content: //! minimizer names, list of their algorithms and description, list of minimizer options. -std::string MinimizerFactory::catalogDetailsToString() -{ +std::string MinimizerFactory::catalogDetailsToString() { const int text_width = 80; std::ostringstream result; const std::string fmt("%-20s| %-65s\n"); @@ -127,8 +123,7 @@ std::string MinimizerFactory::catalogDetailsToString() return result.str(); } -const MinimizerCatalog& MinimizerFactory::catalog() -{ +const MinimizerCatalog& MinimizerFactory::catalog() { static MinimizerCatalog s_catalog; return s_catalog; } diff --git a/Fit/Kernel/MinimizerFactory.h b/Fit/Kernel/MinimizerFactory.h index 38f6d1e432616e48ed28a185bc07c352c2a2ae3c..0a45e67d85789b07e2557f3f75a4c3d646fd2ad2 100644 --- a/Fit/Kernel/MinimizerFactory.h +++ b/Fit/Kernel/MinimizerFactory.h @@ -23,8 +23,7 @@ class IMinimizer; //! Factory to create minimizers. //! @ingroup fitting -class MinimizerFactory -{ +class MinimizerFactory { public: static IMinimizer* createMinimizer(const std::string& minimizerName, const std::string& algorithmType = "", diff --git a/Fit/Kernel/PyCallback.cpp b/Fit/Kernel/PyCallback.cpp index b2daed535c30af89fd7e7bce80053416aa313d29..f1a9f9561c32d87d7a6f83c5236f68e08ebc9b2f 100644 --- a/Fit/Kernel/PyCallback.cpp +++ b/Fit/Kernel/PyCallback.cpp @@ -16,19 +16,16 @@ PyCallback::PyCallback(PyCallback::CallbackType callback_type) : m_callback_type(callback_type) {} -PyCallback::CallbackType PyCallback::callback_type() const -{ +PyCallback::CallbackType PyCallback::callback_type() const { return m_callback_type; } PyCallback::~PyCallback() = default; -double PyCallback::call_scalar(mumufit::Parameters) -{ +double PyCallback::call_scalar(mumufit::Parameters) { throw std::runtime_error("PyCallback::call_scalar() -> Error. Not implemented"); } -std::vector<double> PyCallback::call_residuals(mumufit::Parameters) -{ +std::vector<double> PyCallback::call_residuals(mumufit::Parameters) { throw std::runtime_error("PyCallback::call_residuals() -> Error. Not implemented"); } diff --git a/Fit/Kernel/PyCallback.h b/Fit/Kernel/PyCallback.h index b23907a68bf517b216872d4ad6634c6438492ef9..8c61e5d88aa3bb24f49dd415270fb5a497baa5c9 100644 --- a/Fit/Kernel/PyCallback.h +++ b/Fit/Kernel/PyCallback.h @@ -21,8 +21,7 @@ //! Base class to wrap Python callable and pass it to C++. Used in swig interface file, //! intended to be overloaded from Python. -class PyCallback -{ +class PyCallback { public: enum CallbackType { SCALAR, RESIDUAL }; diff --git a/Fit/Minimizer/IMinimizer.cpp b/Fit/Minimizer/IMinimizer.cpp index a57be3f15ece5d60c5034a8d5a69c190d14525e7..df4056ebc9b2d68dbd5870ab1ebb587e76e69c85 100644 --- a/Fit/Minimizer/IMinimizer.cpp +++ b/Fit/Minimizer/IMinimizer.cpp @@ -18,22 +18,18 @@ IMinimizer::IMinimizer() = default; IMinimizer::~IMinimizer() = default; -mumufit::MinimizerResult IMinimizer::minimize_scalar(fcn_scalar_t, mumufit::Parameters) -{ +mumufit::MinimizerResult IMinimizer::minimize_scalar(fcn_scalar_t, mumufit::Parameters) { throw std::runtime_error("IMinimizer::minimize_scalar() -> Not implemented."); } -mumufit::MinimizerResult IMinimizer::minimize_residual(fcn_residual_t, mumufit::Parameters) -{ +mumufit::MinimizerResult IMinimizer::minimize_residual(fcn_residual_t, mumufit::Parameters) { throw std::runtime_error("IMinimizer::minimize_residual() -> Not implemented."); } -double IMinimizer::minValue() const -{ +double IMinimizer::minValue() const { throw std::runtime_error("IMinimizer::minValue() -> Not implemented."); } -void IMinimizer::setOptions(const std::string&) -{ +void IMinimizer::setOptions(const std::string&) { throw std::runtime_error("IMinimizer::setOptions() -> Not implemented."); } diff --git a/Fit/Minimizer/IMinimizer.h b/Fit/Minimizer/IMinimizer.h index d75c2d80ec05e3effcf176e00a79b0c93fa67e0d..a155e9f93a00e38a7229bbec61f770f72f3c3ea6 100644 --- a/Fit/Minimizer/IMinimizer.h +++ b/Fit/Minimizer/IMinimizer.h @@ -19,16 +19,14 @@ #include "Fit/Minimizer/Types.h" #include <string> -namespace mumufit -{ +namespace mumufit { class Parameters; } //! Abstract base class for all kind minimizers. //! @ingroup fitting_internal -class IMinimizer -{ +class IMinimizer { public: IMinimizer(); virtual ~IMinimizer(); diff --git a/Fit/Minimizer/MinimizerCatalog.cpp b/Fit/Minimizer/MinimizerCatalog.cpp index b35199774be2a06719402d9af3f0f29f94766825..1de973df8fbdcd03839c1d20e2b03d25a085fbf6 100644 --- a/Fit/Minimizer/MinimizerCatalog.cpp +++ b/Fit/Minimizer/MinimizerCatalog.cpp @@ -17,8 +17,7 @@ #include <boost/format.hpp> #include <sstream> -MinimizerCatalog::MinimizerCatalog() -{ +MinimizerCatalog::MinimizerCatalog() { addMinimizerInfo(MinimizerInfo::buildMinuit2Info()); addMinimizerInfo(MinimizerInfo::buildGSLMultiMinInfo()); addMinimizerInfo(MinimizerInfo::buildGSLLMAInfo()); @@ -29,8 +28,7 @@ MinimizerCatalog::MinimizerCatalog() //! Returns multiline string representing catalog content. -std::string MinimizerCatalog::toString() const -{ +std::string MinimizerCatalog::toString() const { const int text_width = 80; std::ostringstream result; @@ -45,8 +43,7 @@ std::string MinimizerCatalog::toString() const return result.str(); } -std::vector<std::string> MinimizerCatalog::minimizerNames() const -{ +std::vector<std::string> MinimizerCatalog::minimizerNames() const { std::vector<std::string> result; for (const auto& info : m_minimizers) result.push_back(info.name()); @@ -56,23 +53,20 @@ std::vector<std::string> MinimizerCatalog::minimizerNames() const //! Returns list of algorithms defined for the minimizer with a given name. -std::vector<std::string> MinimizerCatalog::algorithmNames(const std::string& minimizerName) const -{ +std::vector<std::string> MinimizerCatalog::algorithmNames(const std::string& minimizerName) const { return minimizerInfo(minimizerName).algorithmNames(); } //! Returns list of algorithm's descriptions for the minimizer with a given name . std::vector<std::string> -MinimizerCatalog::algorithmDescriptions(const std::string& minimizerName) const -{ +MinimizerCatalog::algorithmDescriptions(const std::string& minimizerName) const { return minimizerInfo(minimizerName).algorithmDescriptions(); } //! Returns info for minimizer with given name. -const MinimizerInfo& MinimizerCatalog::minimizerInfo(const std::string& minimizerName) const -{ +const MinimizerInfo& MinimizerCatalog::minimizerInfo(const std::string& minimizerName) const { for (const auto& info : m_minimizers) if (info.name() == minimizerName) return info; @@ -84,7 +78,6 @@ const MinimizerInfo& MinimizerCatalog::minimizerInfo(const std::string& minimize //! Adds minimizer info to the catalog. -void MinimizerCatalog::addMinimizerInfo(const MinimizerInfo& info) -{ +void MinimizerCatalog::addMinimizerInfo(const MinimizerInfo& info) { m_minimizers.push_back(info); } diff --git a/Fit/Minimizer/MinimizerCatalog.h b/Fit/Minimizer/MinimizerCatalog.h index 3db4c7e2f8014092d7db8f18fe4bb56c8d6be4f5..8aa2de38fb50ae15efc1094f5622be629a219144 100644 --- a/Fit/Minimizer/MinimizerCatalog.h +++ b/Fit/Minimizer/MinimizerCatalog.h @@ -33,8 +33,7 @@ Genetic | Default Test | Default */ -class MinimizerCatalog -{ +class MinimizerCatalog { public: MinimizerCatalog(); diff --git a/Fit/Minimizer/MinimizerInfo.cpp b/Fit/Minimizer/MinimizerInfo.cpp index f008b173996d581260af9b8a49d5249e4a26233e..cfbf902bf13965b4024dcb24cf9a14fd26f9a429 100644 --- a/Fit/Minimizer/MinimizerInfo.cpp +++ b/Fit/Minimizer/MinimizerInfo.cpp @@ -16,8 +16,7 @@ #include <sstream> #include <stdexcept> -void MinimizerInfo::setAlgorithmName(const std::string& algorithmName) -{ +void MinimizerInfo::setAlgorithmName(const std::string& algorithmName) { for (const AlgorithmInfo& algo : m_algorithms) { if (algo.name() == algorithmName) { m_current_algorithm = algorithmName; @@ -36,8 +35,7 @@ void MinimizerInfo::setAlgorithmName(const std::string& algorithmName) //! Return list of defined algorithm names. -std::vector<std::string> MinimizerInfo::algorithmNames() const -{ +std::vector<std::string> MinimizerInfo::algorithmNames() const { std::vector<std::string> result; for (const AlgorithmInfo& algo : m_algorithms) result.push_back(algo.name()); @@ -46,8 +44,7 @@ std::vector<std::string> MinimizerInfo::algorithmNames() const //! Returns list of string with description of all available algorithms. -std::vector<std::string> MinimizerInfo::algorithmDescriptions() const -{ +std::vector<std::string> MinimizerInfo::algorithmDescriptions() const { std::vector<std::string> result; for (const AlgorithmInfo& algo : m_algorithms) result.push_back(algo.description()); @@ -56,8 +53,7 @@ std::vector<std::string> MinimizerInfo::algorithmDescriptions() const //! Creates information for Minuit2Minimizer. -MinimizerInfo MinimizerInfo::buildMinuit2Info(const std::string& defaultAlgo) -{ +MinimizerInfo MinimizerInfo::buildMinuit2Info(const std::string& defaultAlgo) { MinimizerInfo result("Minuit2", "Minuit2 minimizer from ROOT library"); result.addAlgorithm( @@ -85,8 +81,7 @@ MinimizerInfo MinimizerInfo::buildMinuit2Info(const std::string& defaultAlgo) //! Creates information for GSLMultiMinMinimizer. -MinimizerInfo MinimizerInfo::buildGSLMultiMinInfo(const std::string& defaultAlgo) -{ +MinimizerInfo MinimizerInfo::buildGSLMultiMinInfo(const std::string& defaultAlgo) { MinimizerInfo result("GSLMultiMin", "MultiMin minimizer from GSL library"); result.addAlgorithm("SteepestDescent", "Steepest descent"); @@ -105,8 +100,7 @@ MinimizerInfo MinimizerInfo::buildGSLMultiMinInfo(const std::string& defaultAlgo //! Creates information for GSL's Levenberg-Marquardt. -MinimizerInfo MinimizerInfo::buildGSLLMAInfo() -{ +MinimizerInfo MinimizerInfo::buildGSLLMAInfo() { MinimizerInfo result("GSLLMA", "Levenberg-Marquardt from GSL library"); result.addAlgorithm("Default", "Default algorithm"); return result; @@ -114,8 +108,7 @@ MinimizerInfo MinimizerInfo::buildGSLLMAInfo() //! Creates information for GSL's simmulated annealing algorithm. -MinimizerInfo MinimizerInfo::buildGSLSimAnInfo() -{ +MinimizerInfo MinimizerInfo::buildGSLSimAnInfo() { MinimizerInfo result("GSLSimAn", "Simmulated annealing minimizer from GSL library"); result.addAlgorithm("Default", "Default algorithm"); return result; @@ -123,8 +116,7 @@ MinimizerInfo MinimizerInfo::buildGSLSimAnInfo() //! Creates information for TMVA genetic minimizer -MinimizerInfo MinimizerInfo::buildGeneticInfo() -{ +MinimizerInfo MinimizerInfo::buildGeneticInfo() { MinimizerInfo result("Genetic", "Genetic minimizer from TMVA library"); result.addAlgorithm("Default", "Default algorithm"); return result; @@ -132,8 +124,7 @@ MinimizerInfo MinimizerInfo::buildGeneticInfo() //! Creates information for simple test minimizer -MinimizerInfo MinimizerInfo::buildTestMinimizerInfo() -{ +MinimizerInfo MinimizerInfo::buildTestMinimizerInfo() { MinimizerInfo result("Test", "One-shot minimizer to test whole chain"); result.addAlgorithm("Default", "Default algorithm"); return result; @@ -141,14 +132,12 @@ MinimizerInfo MinimizerInfo::buildTestMinimizerInfo() //! Adds minimizer algorithm to the list of defined algorithms. -void MinimizerInfo::addAlgorithm(const AlgorithmInfo& algorithm) -{ +void MinimizerInfo::addAlgorithm(const AlgorithmInfo& algorithm) { m_current_algorithm = algorithm.name(); m_algorithms.push_back(algorithm); } void MinimizerInfo::addAlgorithm(const std::string& algorithmName, - const std::string& algorithmDescription) -{ + const std::string& algorithmDescription) { addAlgorithm(AlgorithmInfo(algorithmName, algorithmDescription)); } diff --git a/Fit/Minimizer/MinimizerInfo.h b/Fit/Minimizer/MinimizerInfo.h index c4e5574fabb52b8b1f9f58481fd830e0d3bc1156..1f80be63bba29da53e14739ed4027165d66ddb24 100644 --- a/Fit/Minimizer/MinimizerInfo.h +++ b/Fit/Minimizer/MinimizerInfo.h @@ -21,14 +21,11 @@ //! A name and a description. //! @ingroup fitting_internal -class AlgorithmInfo -{ +class AlgorithmInfo { public: AlgorithmInfo() = delete; AlgorithmInfo(const std::string& itemName, const std::string& itemDescription) - : m_itemName(itemName), m_itemDescription(itemDescription) - { - } + : m_itemName(itemName), m_itemDescription(itemDescription) {} std::string name() const { return m_itemName; } std::string description() const { return m_itemDescription; } @@ -41,14 +38,11 @@ private: //! Info about a minimizer, including list of defined minimization algorithms. //! @ingroup fitting_internal -class MinimizerInfo -{ +class MinimizerInfo { public: MinimizerInfo() = delete; MinimizerInfo(const std::string& minimizerType, const std::string& minimizerDescription) - : m_name(minimizerType), m_description(minimizerDescription) - { - } + : m_name(minimizerType), m_description(minimizerDescription) {} //! Sets currently active algorithm void setAlgorithmName(const std::string& algorithmName); diff --git a/Fit/Minimizer/MinimizerOptions.cpp b/Fit/Minimizer/MinimizerOptions.cpp index 4d54a85a363dc7e4b9d1ea9fe3f178c0bab9592b..b1d34d593d04f97f5a0bfde7fceeffadab8658c9 100644 --- a/Fit/Minimizer/MinimizerOptions.cpp +++ b/Fit/Minimizer/MinimizerOptions.cpp @@ -18,13 +18,11 @@ #include <sstream> #include <stdexcept> -namespace -{ +namespace { const std::string delimeter = ";"; } -std::string MinimizerOptions::toOptionString() const -{ +std::string MinimizerOptions::toOptionString() const { std::ostringstream result; for (auto option : m_options) { result << option->name() << "=" << option->value() << delimeter; @@ -32,8 +30,7 @@ std::string MinimizerOptions::toOptionString() const return result.str(); } -void MinimizerOptions::setOptionString(const std::string& options) -{ +void MinimizerOptions::setOptionString(const std::string& options) { // splits multiple option string "Strategy=1;Tolerance=0.01;" std::vector<std::string> tokens = mumufit::stringUtils::split(options, delimeter); try { @@ -51,8 +48,7 @@ void MinimizerOptions::setOptionString(const std::string& options) //! Process single option string 'Tolerance=0.01' and sets the value //! to corresponding MultiOption -void MinimizerOptions::processCommand(const std::string& command) -{ +void MinimizerOptions::processCommand(const std::string& command) { std::vector<std::string> tokens = mumufit::stringUtils::split(command, "="); if (tokens.size() != 2) throw std::runtime_error("MinimizerOptions::processOption() -> Can't parse option '" diff --git a/Fit/Minimizer/MinimizerOptions.h b/Fit/Minimizer/MinimizerOptions.h index 5000dfa31060a4bbd57408daed2f69ba74f27000..011bb8bfecbb234c9513ad0a70711d128046b50f 100644 --- a/Fit/Minimizer/MinimizerOptions.h +++ b/Fit/Minimizer/MinimizerOptions.h @@ -20,8 +20,7 @@ //! Collection of internal minimizer settings. //! @ingroup fitting_internal -class MinimizerOptions : public OptionContainer -{ +class MinimizerOptions : public OptionContainer { public: //! Returns string with all options (i.e. "Strategy=1;Tolerance=0.01;") std::string toOptionString() const; diff --git a/Fit/Minimizer/MinimizerResult.cpp b/Fit/Minimizer/MinimizerResult.cpp index 05c34dcccd02324c6097bd15020e540a15fa3d06..2b49b4cff70abe9664d4b4fad1cc30aa7ec3ada1 100644 --- a/Fit/Minimizer/MinimizerResult.cpp +++ b/Fit/Minimizer/MinimizerResult.cpp @@ -17,11 +17,9 @@ #include <boost/format.hpp> #include <sstream> -namespace -{ +namespace { -std::string reportParameters(const mumufit::Parameters& parameters) -{ +std::string reportParameters(const mumufit::Parameters& parameters) { std::ostringstream result; result << mumufit::utils::sectionString("FitParameters"); @@ -57,36 +55,29 @@ std::string reportParameters(const mumufit::Parameters& parameters) using namespace mumufit; MinimizerResult::MinimizerResult() - : m_min_value(0.0), m_number_of_calls(0), m_number_of_gradient_calls(0), m_duration(0.0) -{ -} + : m_min_value(0.0), m_number_of_calls(0), m_number_of_gradient_calls(0), m_duration(0.0) {} -void MinimizerResult::setParameters(const Parameters& parameters) -{ +void MinimizerResult::setParameters(const Parameters& parameters) { m_parameters = parameters; } -Parameters MinimizerResult::parameters() const -{ +Parameters MinimizerResult::parameters() const { return m_parameters; } -void MinimizerResult::setMinValue(double value) -{ +void MinimizerResult::setMinValue(double value) { m_min_value = value; } //! Minimum value of objective function found by minimizer. -double MinimizerResult::minValue() const -{ +double MinimizerResult::minValue() const { return m_min_value; } //! Returns multi-line string representing minimization results. -std::string MinimizerResult::toString() const -{ +std::string MinimizerResult::toString() const { std::ostringstream result; if (m_minimizer_report.empty()) { result << "Don't know anything about external minimizer. " @@ -104,22 +95,18 @@ std::string MinimizerResult::toString() const return result.str(); } -void MinimizerResult::setReport(const std::string& value) -{ +void MinimizerResult::setReport(const std::string& value) { m_minimizer_report = value; } -void MinimizerResult::setDuration(double value) -{ +void MinimizerResult::setDuration(double value) { m_duration = value; } -void MinimizerResult::setNumberOfCalls(int value) -{ +void MinimizerResult::setNumberOfCalls(int value) { m_number_of_calls = value; } -void MinimizerResult::setNumberOfGradientCalls(int value) -{ +void MinimizerResult::setNumberOfGradientCalls(int value) { m_number_of_gradient_calls = value; } diff --git a/Fit/Minimizer/MinimizerResult.h b/Fit/Minimizer/MinimizerResult.h index 4d5fa93d23a3201d7a4d744cb9615a08f2e985b0..e3563b06fc8eadfaac0f8c6f933c29d498d278b0 100644 --- a/Fit/Minimizer/MinimizerResult.h +++ b/Fit/Minimizer/MinimizerResult.h @@ -18,13 +18,11 @@ #include "Fit/Param/Parameters.h" #include <string> -namespace mumufit -{ +namespace mumufit { //! Result of minimization round. -class MinimizerResult -{ +class MinimizerResult { public: MinimizerResult(); diff --git a/Fit/Minimizer/TestMinimizer.cpp b/Fit/Minimizer/TestMinimizer.cpp index 6094c2f2574403f835a2f1072753f5a309a0c77e..326de3de78148683ce416ed1b67d6ea449a17764 100644 --- a/Fit/Minimizer/TestMinimizer.cpp +++ b/Fit/Minimizer/TestMinimizer.cpp @@ -21,13 +21,11 @@ TestMinimizer::TestMinimizer() = default; TestMinimizer::~TestMinimizer() = default; -std::string TestMinimizer::minimizerName() const -{ +std::string TestMinimizer::minimizerName() const { return "Test"; } -MinimizerResult TestMinimizer::minimize_scalar(fcn_scalar_t fcn, mumufit::Parameters parameters) -{ +MinimizerResult TestMinimizer::minimize_scalar(fcn_scalar_t fcn, mumufit::Parameters parameters) { // calling user function once auto min_value = fcn(parameters); diff --git a/Fit/Minimizer/TestMinimizer.h b/Fit/Minimizer/TestMinimizer.h index d2f7506a5ea9eba01d656803b7793b97db60cc75..fe902794b2c6b83dd505c74bbe791297e96e163d 100644 --- a/Fit/Minimizer/TestMinimizer.h +++ b/Fit/Minimizer/TestMinimizer.h @@ -19,8 +19,7 @@ //! A trivial minimizer that calls the objective function once. Used to test the whole chain. -class TestMinimizer : public IMinimizer -{ +class TestMinimizer : public IMinimizer { public: TestMinimizer(); ~TestMinimizer() override; diff --git a/Fit/Minimizer/Types.h b/Fit/Minimizer/Types.h index dd1b82b7faddedf7df52630905ef3e77565dedbe..93ca51f4a68d601d82f6458724a71fde186b744a 100644 --- a/Fit/Minimizer/Types.h +++ b/Fit/Minimizer/Types.h @@ -18,8 +18,7 @@ #include <functional> #include <vector> -namespace mumufit -{ +namespace mumufit { class Parameters; } diff --git a/Fit/Param/AttLimits.cpp b/Fit/Param/AttLimits.cpp index b1d1e1b57e1318bd19175b0d3d531ffb34db8b38..cbf058911c0ac5784a1c70aad885fb1a9713b7cf 100644 --- a/Fit/Param/AttLimits.cpp +++ b/Fit/Param/AttLimits.cpp @@ -19,98 +19,78 @@ AttLimits::AttLimits() : m_limits(RealLimits::limitless()), m_att_fixed(Attributes::free()) {} AttLimits::AttLimits(const RealLimits& limits, const Attributes& fixedAttr) - : m_limits(limits), m_att_fixed(fixedAttr) -{ -} + : m_limits(limits), m_att_fixed(fixedAttr) {} -AttLimits AttLimits::limitless() -{ +AttLimits AttLimits::limitless() { return AttLimits(); } -AttLimits AttLimits::lowerLimited(double bound_value) -{ +AttLimits AttLimits::lowerLimited(double bound_value) { return AttLimits(RealLimits::lowerLimited(bound_value), Attributes::free()); } -AttLimits AttLimits::positive() -{ +AttLimits AttLimits::positive() { return AttLimits(RealLimits::positive(), Attributes::free()); } -AttLimits AttLimits::nonnegative() -{ +AttLimits AttLimits::nonnegative() { return AttLimits(RealLimits::nonnegative(), Attributes::free()); } -AttLimits AttLimits::upperLimited(double bound_value) -{ +AttLimits AttLimits::upperLimited(double bound_value) { return AttLimits(RealLimits::upperLimited(bound_value), Attributes::free()); } -AttLimits AttLimits::limited(double left_bound_value, double right_bound_value) -{ +AttLimits AttLimits::limited(double left_bound_value, double right_bound_value) { return AttLimits(RealLimits::limited(left_bound_value, right_bound_value), Attributes::free()); } -AttLimits AttLimits::fixed() -{ +AttLimits AttLimits::fixed() { return AttLimits(RealLimits::limitless(), Attributes::fixed()); } -bool AttLimits::isFixed() const -{ +bool AttLimits::isFixed() const { return m_att_fixed.isFixed(); } -bool AttLimits::isLimited() const -{ +bool AttLimits::isLimited() const { return m_att_fixed.isFree() && m_limits.hasLowerAndUpperLimits(); } -bool AttLimits::isUpperLimited() const -{ +bool AttLimits::isUpperLimited() const { return m_att_fixed.isFree() && !m_limits.hasLowerLimit() && m_limits.hasUpperLimit(); } -bool AttLimits::isLowerLimited() const -{ +bool AttLimits::isLowerLimited() const { return m_att_fixed.isFree() && m_limits.hasLowerLimit() && !m_limits.hasUpperLimit(); } -bool AttLimits::isLimitless() const -{ +bool AttLimits::isLimitless() const { return m_att_fixed.isFree() && !m_limits.hasLowerLimit() && !m_limits.hasUpperLimit(); } -double AttLimits::lowerLimit() const -{ +double AttLimits::lowerLimit() const { return m_limits.lowerLimit(); } -double AttLimits::upperLimit() const -{ +double AttLimits::upperLimit() const { return m_limits.upperLimit(); } -void AttLimits::setFixed(bool isFixed) -{ +void AttLimits::setFixed(bool isFixed) { m_limits.removeLimits(); m_att_fixed.setFixed(isFixed); } -bool AttLimits::operator==(const AttLimits& other) const -{ +bool AttLimits::operator==(const AttLimits& other) const { return m_limits == other.m_limits && m_att_fixed == other.m_att_fixed; } -bool AttLimits::operator!=(const AttLimits& other) const -{ +bool AttLimits::operator!=(const AttLimits& other) const { return !(*this == other); } -std::string AttLimits::toString() const -{ +std::string AttLimits::toString() const { std::ostringstream result; if (isFixed()) diff --git a/Fit/Param/AttLimits.h b/Fit/Param/AttLimits.h index 8bfea891f2cf48c8b40205f32febafa9e8e35d10..6bbb8c444b2d0069d819736fe3dd6b068c880fbf 100644 --- a/Fit/Param/AttLimits.h +++ b/Fit/Param/AttLimits.h @@ -22,8 +22,7 @@ //! Attributes and limits of a fit parameter, and coupling between these properties. //! @ingroup fitting -class AttLimits -{ +class AttLimits { public: AttLimits(); @@ -51,8 +50,7 @@ public: std::string toString() const; - friend std::ostream& operator<<(std::ostream& ostr, const AttLimits& m) - { + friend std::ostream& operator<<(std::ostream& ostr, const AttLimits& m) { ostr << m.toString(); return ostr; } diff --git a/Fit/Param/Attributes.h b/Fit/Param/Attributes.h index eb2c9d650e3b19e3c1ff0497936552158c86e5cd..e22978ab4793e489e217dabb13f9081e607566fc 100644 --- a/Fit/Param/Attributes.h +++ b/Fit/Param/Attributes.h @@ -20,8 +20,7 @@ //! Attributes for a fit parameter. Currently, the only attribute is fixed/free. //! @ingroup fitting -class Attributes -{ +class Attributes { public: Attributes() : m_is_fixed(false) {} //! Creates a fixed value object @@ -32,8 +31,7 @@ public: bool isFixed() const { return m_is_fixed; } bool isFree() const { return !isFixed(); } - friend std::ostream& operator<<(std::ostream& ostr, const Attributes& m) - { + friend std::ostream& operator<<(std::ostream& ostr, const Attributes& m) { m.print(ostr); return ostr; } @@ -50,8 +48,7 @@ protected: }; //! Prints class -inline void Attributes::print(std::ostream& ostr) const -{ +inline void Attributes::print(std::ostream& ostr) const { if (isFixed()) ostr << "fixed"; else diff --git a/Fit/Param/Parameter.cpp b/Fit/Param/Parameter.cpp index f63b86a9da7e0681973ba56e08017d0074c22448..404d0daf09d2dccd088983f95245519b897a310a 100644 --- a/Fit/Param/Parameter.cpp +++ b/Fit/Param/Parameter.cpp @@ -15,13 +15,11 @@ #include "Fit/Param/Parameter.h" #include <cmath> -namespace -{ +namespace { const double default_step = 0.01; const double step_factor = 0.01; -double step_for_value(double value) -{ +double step_for_value(double value) { return value == 0.0 ? default_step : std::abs(value) * step_factor; } } // namespace @@ -36,48 +34,39 @@ Parameter::Parameter(const std::string& name, double value, const AttLimits& lim , m_value(value) , m_step(step) , m_error(0.0) - , m_limits(limits) -{ + , m_limits(limits) { if (step <= 0.0) m_step = step_for_value(value); } -std::string Parameter::name() const -{ +std::string Parameter::name() const { return m_name; } -double Parameter::startValue() const -{ +double Parameter::startValue() const { return m_start_value; } -AttLimits Parameter::limits() const -{ +AttLimits Parameter::limits() const { return m_limits; } -double Parameter::value() const -{ +double Parameter::value() const { return m_value; } -void Parameter::setValue(double value) -{ +void Parameter::setValue(double value) { m_value = value; } -double Parameter::step() const -{ +double Parameter::step() const { return m_step; } -double Parameter::error() const -{ +double Parameter::error() const { return m_error; } -void Parameter::setError(double value) -{ +void Parameter::setError(double value) { m_error = value; } diff --git a/Fit/Param/Parameter.h b/Fit/Param/Parameter.h index 4439bc1425db497e7eee8bf128488a0398f89684..3ab88899fc0510c21a2c8d5fa1ebeb25d453803a 100644 --- a/Fit/Param/Parameter.h +++ b/Fit/Param/Parameter.h @@ -18,14 +18,12 @@ #include "Fit/Param/AttLimits.h" #include <string> -namespace mumufit -{ +namespace mumufit { //! A fittable parameter with value, error, step, and limits. //! @ingroup fitting -class Parameter -{ +class Parameter { public: Parameter(); diff --git a/Fit/Param/ParameterPlan.h b/Fit/Param/ParameterPlan.h index ad736fa93c8351a8adefc4a86f533e403e866bf2..464986e927404f1d5ae0a6c08f6ee2041e9a3471 100644 --- a/Fit/Param/ParameterPlan.h +++ b/Fit/Param/ParameterPlan.h @@ -20,13 +20,10 @@ //! Defines initial settings of single fit parameter and the final value which has to be found //! in the course of the fit. -class ParameterPlan -{ +class ParameterPlan { public: ParameterPlan(const mumufit::Parameter& param, double expected_value, double tolerance = 0.01) - : m_expected_value(expected_value), m_tolerance(tolerance), m_parameter(param) - { - } + : m_expected_value(expected_value), m_tolerance(tolerance), m_parameter(param) {} mumufit::Parameter fitParameter() const { return m_parameter; } double expectedValue() const { return m_expected_value; } diff --git a/Fit/Param/Parameters.cpp b/Fit/Param/Parameters.cpp index 0b8630f3c94189cc4adf06cc2dbd89613345d536..a79508f845f2b3035ba7b90f1a0990a58b93b8bd 100644 --- a/Fit/Param/Parameters.cpp +++ b/Fit/Param/Parameters.cpp @@ -19,8 +19,7 @@ using namespace mumufit; -void Parameters::add(const Parameter& par) -{ +void Parameters::add(const Parameter& par) { if (exists(par.name())) throw std::runtime_error("Parameters::add() -> Error. Parameter with the name '" + par.name() + "' already exists."); @@ -28,41 +27,34 @@ void Parameters::add(const Parameter& par) m_parameters.push_back(par); } -Parameters::const_iterator Parameters::begin() const -{ +Parameters::const_iterator Parameters::begin() const { return m_parameters.begin(); } -Parameters::const_iterator Parameters::end() const -{ +Parameters::const_iterator Parameters::end() const { return m_parameters.end(); } -Parameters::iterator Parameters::begin() -{ +Parameters::iterator Parameters::begin() { return m_parameters.begin(); } -Parameters::iterator Parameters::end() -{ +Parameters::iterator Parameters::end() { return m_parameters.end(); } -size_t Parameters::size() const -{ +size_t Parameters::size() const { return m_parameters.size(); } -std::vector<double> Parameters::values() const -{ +std::vector<double> Parameters::values() const { std::vector<double> result; for (const auto& par : m_parameters) result.push_back(par.value()); return result; } -void Parameters::setValues(const std::vector<double>& values) -{ +void Parameters::setValues(const std::vector<double>& values) { check_array_size(values); size_t index = 0; @@ -79,24 +71,21 @@ void Parameters::setValues(const std::vector<double>& values) } } -std::vector<double> Parameters::errors() const -{ +std::vector<double> Parameters::errors() const { std::vector<double> result; for (const auto& par : m_parameters) result.push_back(par.error()); return result; } -void Parameters::setErrors(const std::vector<double>& errors) -{ +void Parameters::setErrors(const std::vector<double>& errors) { check_array_size(errors); size_t index = 0; for (auto& par : m_parameters) par.setError(errors[index++]); } -const Parameter& Parameters::operator[](const std::string& name) const -{ +const Parameter& Parameters::operator[](const std::string& name) const { for (const auto& par : m_parameters) if (par.name() == name) return par; @@ -109,18 +98,15 @@ const Parameter& Parameters::operator[](const std::string& name) const throw std::runtime_error(ostr.str()); } -const Parameter& Parameters::operator[](size_t index) const -{ +const Parameter& Parameters::operator[](size_t index) const { return m_parameters[check_index(index)]; } -Parameters::corr_matrix_t Parameters::correlationMatrix() const -{ +Parameters::corr_matrix_t Parameters::correlationMatrix() const { return m_corr_matrix; } -void Parameters::setCorrelationMatrix(const Parameters::corr_matrix_t& matrix) -{ +void Parameters::setCorrelationMatrix(const Parameters::corr_matrix_t& matrix) { if (matrix.size() != size()) throw std::runtime_error("Parameters::setCorrelationMatrix() -> Error. Wrong " "dimension of correlation matrix."); @@ -129,8 +115,7 @@ void Parameters::setCorrelationMatrix(const Parameters::corr_matrix_t& matrix) //! Returns number of free parameters. -size_t Parameters::freeParameterCount() const -{ +size_t Parameters::freeParameterCount() const { size_t result(0); for (const auto& par : m_parameters) if (!par.limits().isFixed()) @@ -138,16 +123,14 @@ size_t Parameters::freeParameterCount() const return result; } -bool Parameters::exists(const std::string& name) const -{ +bool Parameters::exists(const std::string& name) const { for (const auto& par : m_parameters) if (par.name() == name) return true; return false; } -void Parameters::check_array_size(const std::vector<double>& values) const -{ +void Parameters::check_array_size(const std::vector<double>& values) const { if (values.size() != m_parameters.size()) { std::ostringstream ostr; ostr << "Parameters::check_array_size() -> Error. Size of input array " << values.size() @@ -157,8 +140,7 @@ void Parameters::check_array_size(const std::vector<double>& values) const } } -size_t Parameters::check_index(size_t index) const -{ +size_t Parameters::check_index(size_t index) const { if (index >= m_parameters.size()) throw std::runtime_error("Parameters::check_index() -> Index out of bounds"); return index; diff --git a/Fit/Param/Parameters.h b/Fit/Param/Parameters.h index b85b9706cfc9376991d3eb8afdf35a7b6f21fef6..a8e1f65bf0b1efed59f20e2e5235fea300dd4b71 100644 --- a/Fit/Param/Parameters.h +++ b/Fit/Param/Parameters.h @@ -18,14 +18,12 @@ #include "Fit/Param/Parameter.h" #include <vector> -namespace mumufit -{ +namespace mumufit { //! A collection of fit parameters. //! @ingroup fitting -class Parameters -{ +class Parameters { public: using parameters_t = std::vector<Parameter>; using const_iterator = parameters_t::const_iterator; diff --git a/Fit/Param/RealLimits.cpp b/Fit/Param/RealLimits.cpp index 43c12a4150b729b83ff2a084f889a236890eb56c..494d611a038915b5873ab8ef9d4d6f0f693d278a 100644 --- a/Fit/Param/RealLimits.cpp +++ b/Fit/Param/RealLimits.cpp @@ -19,82 +19,66 @@ #include <sstream> RealLimits::RealLimits() - : m_has_lower_limit(false), m_has_upper_limit(false), m_lower_limit(0.), m_upper_limit(0.) -{ -} + : m_has_lower_limit(false), m_has_upper_limit(false), m_lower_limit(0.), m_upper_limit(0.) {} RealLimits::RealLimits(bool has_lower_limit, bool has_upper_limit, double lower_limit, double upper_limit) : m_has_lower_limit(has_lower_limit) , m_has_upper_limit(has_upper_limit) , m_lower_limit(lower_limit) - , m_upper_limit(upper_limit) -{ -} + , m_upper_limit(upper_limit) {} -bool RealLimits::hasLowerLimit() const -{ +bool RealLimits::hasLowerLimit() const { return m_has_lower_limit; } -double RealLimits::lowerLimit() const -{ +double RealLimits::lowerLimit() const { return m_lower_limit; } -void RealLimits::setLowerLimit(double value) -{ +void RealLimits::setLowerLimit(double value) { m_lower_limit = value; m_has_lower_limit = true; } -void RealLimits::removeLowerLimit() -{ +void RealLimits::removeLowerLimit() { m_lower_limit = 0.; m_has_lower_limit = false; } -bool RealLimits::hasUpperLimit() const -{ +bool RealLimits::hasUpperLimit() const { return m_has_upper_limit; } -double RealLimits::upperLimit() const -{ +double RealLimits::upperLimit() const { return m_upper_limit; } -void RealLimits::setUpperLimit(double value) -{ +void RealLimits::setUpperLimit(double value) { m_upper_limit = value; m_has_upper_limit = true; } -void RealLimits::removeUpperLimit() -{ +void RealLimits::removeUpperLimit() { m_upper_limit = 0.; m_has_upper_limit = false; } -bool RealLimits::hasLowerAndUpperLimits() const -{ +bool RealLimits::hasLowerAndUpperLimits() const { return (m_has_lower_limit && m_has_upper_limit); } -void RealLimits::setLimits(double xmin, double xmax) -{ +void RealLimits::setLimits(double xmin, double xmax) { setLowerLimit(xmin); setUpperLimit(xmax); } -void RealLimits::removeLimits() -{ +void RealLimits::removeLimits() { removeLowerLimit(); removeUpperLimit(); } -bool RealLimits::isInRange(double value) const -{ +bool RealLimits::isInRange(double value) const { if (hasLowerLimit() && value < m_lower_limit) return false; if (hasUpperLimit() && value >= m_upper_limit) @@ -102,38 +86,31 @@ bool RealLimits::isInRange(double value) const return true; } -RealLimits RealLimits::lowerLimited(double bound_value) -{ +RealLimits RealLimits::lowerLimited(double bound_value) { return RealLimits(true, false, bound_value, 0.); } -RealLimits RealLimits::positive() -{ +RealLimits RealLimits::positive() { return lowerLimited(std::numeric_limits<double>::min()); } -RealLimits RealLimits::nonnegative() -{ +RealLimits RealLimits::nonnegative() { return lowerLimited(0.); } -RealLimits RealLimits::upperLimited(double bound_value) -{ +RealLimits RealLimits::upperLimited(double bound_value) { return RealLimits(false, true, 0., bound_value); } -RealLimits RealLimits::limited(double left_bound_value, double right_bound_value) -{ +RealLimits RealLimits::limited(double left_bound_value, double right_bound_value) { return RealLimits(true, true, left_bound_value, right_bound_value); } -RealLimits RealLimits::limitless() -{ +RealLimits RealLimits::limitless() { return RealLimits(); } -std::string RealLimits::toString() const -{ +std::string RealLimits::toString() const { std::ostringstream result; if (isLimitless()) @@ -158,45 +135,37 @@ std::string RealLimits::toString() const return result.str(); } -bool RealLimits::operator==(const RealLimits& other) const -{ +bool RealLimits::operator==(const RealLimits& other) const { return (m_has_lower_limit == other.m_has_lower_limit) && (m_has_upper_limit == other.m_has_upper_limit) && (m_lower_limit == other.m_lower_limit) && (m_upper_limit == other.m_upper_limit); } -bool RealLimits::operator!=(const RealLimits& other) const -{ +bool RealLimits::operator!=(const RealLimits& other) const { return !(*this == other); } -bool RealLimits::isLimitless() const -{ +bool RealLimits::isLimitless() const { return !hasLowerLimit() && !hasUpperLimit(); } -bool RealLimits::isPositive() const -{ +bool RealLimits::isPositive() const { return hasLowerLimit() && !hasUpperLimit() && lowerLimit() == std::numeric_limits<double>::min(); } -bool RealLimits::isNonnegative() const -{ +bool RealLimits::isNonnegative() const { return hasLowerLimit() && !hasUpperLimit() && lowerLimit() == 0.0; } -bool RealLimits::isLowerLimited() const -{ +bool RealLimits::isLowerLimited() const { return hasLowerLimit() && !hasUpperLimit(); } -bool RealLimits::isUpperLimited() const -{ +bool RealLimits::isUpperLimited() const { return !hasLowerLimit() && hasUpperLimit(); } -bool RealLimits::isLimited() const -{ +bool RealLimits::isLimited() const { return hasLowerLimit() && hasUpperLimit(); } diff --git a/Fit/Param/RealLimits.h b/Fit/Param/RealLimits.h index acbbb9121c64dc43d4c25f47655cf7a5b7009c07..59b1161cf894e0554141337b2e9ffcb33ffd243e 100644 --- a/Fit/Param/RealLimits.h +++ b/Fit/Param/RealLimits.h @@ -21,8 +21,7 @@ //! Limits for a real fit parameter. //! @ingroup fitting -class RealLimits -{ +class RealLimits { public: RealLimits(); @@ -83,8 +82,7 @@ public: std::string toString() const; //! Prints class - friend std::ostream& operator<<(std::ostream& ostr, const RealLimits& m) - { + friend std::ostream& operator<<(std::ostream& ostr, const RealLimits& m) { ostr << m.toString(); return ostr; } diff --git a/Fit/Test/Functional/Minimizer/ClassicalTestFunctions.cpp b/Fit/Test/Functional/Minimizer/ClassicalTestFunctions.cpp index 2e19b108077b54ff37458004acf98ed974340dbe..ff4a054c0583c35928023aed8dd73de5d32b94ce 100644 --- a/Fit/Test/Functional/Minimizer/ClassicalTestFunctions.cpp +++ b/Fit/Test/Functional/Minimizer/ClassicalTestFunctions.cpp @@ -22,8 +22,7 @@ //! start point: F(-1.2,1.0) = 24.20 //! minimum : F(1.0,1.0) = 0. -double TestFunctions::RosenBrock(const std::vector<double>& par) -{ +double TestFunctions::RosenBrock(const std::vector<double>& par) { assert(par.size() == 2); const double x = par[0]; @@ -42,8 +41,7 @@ double TestFunctions::RosenBrock(const std::vector<double>& par) //! start point: F(-3,-1,-3,-1) = 19192 //! minimum : F(1,1,1,1) = 0. -double TestFunctions::WoodFour(const std::vector<double>& par) -{ +double TestFunctions::WoodFour(const std::vector<double>& par) { assert(par.size() == 4); const double w = par[0]; @@ -64,8 +62,7 @@ double TestFunctions::WoodFour(const std::vector<double>& par) //! Decaying sinus from lmfit tutorial. -double TestFunctions::DecayingSin(double x, const std::vector<double>& par) -{ +double TestFunctions::DecayingSin(double x, const std::vector<double>& par) { assert(par.size() == 4); const double amp = par[0]; diff --git a/Fit/Test/Functional/Minimizer/ClassicalTestFunctions.h b/Fit/Test/Functional/Minimizer/ClassicalTestFunctions.h index b9b7d531951550eb9a5434c111756972302999bd..b8e1944371d25c7783f899bee5c62dd32877335e 100644 --- a/Fit/Test/Functional/Minimizer/ClassicalTestFunctions.h +++ b/Fit/Test/Functional/Minimizer/ClassicalTestFunctions.h @@ -22,8 +22,7 @@ //! @brief Collection of objective functions for minimization library testing. //! Borrowed from StressFit test framework of http://root.cern.ch. -namespace TestFunctions -{ +namespace TestFunctions { double RosenBrock(const std::vector<double>& par); double WoodFour(const std::vector<double>& par); double DecayingSin(double x, const std::vector<double>& par); diff --git a/Fit/Test/Functional/Minimizer/MinimizerTests.cpp b/Fit/Test/Functional/Minimizer/MinimizerTests.cpp index c2b2ee142fa82ae118a4e187d880c086e8c2398c..736b245e33795720f2dbc805b74f4c7ddbd5665c 100644 --- a/Fit/Test/Functional/Minimizer/MinimizerTests.cpp +++ b/Fit/Test/Functional/Minimizer/MinimizerTests.cpp @@ -16,31 +16,25 @@ #include "Fit/Test/Functional/Minimizer/PlanFactory.h" #include "Tests/GTestWrapper/google_test.h" -class Minimize : public ::testing::Test -{ -}; +class Minimize : public ::testing::Test {}; bool run(const std::string& minimizer_name, const std::string& algorithm_name, - const std::string& fit_plan_name, const std::string& options = "") -{ + const std::string& fit_plan_name, const std::string& options = "") { auto plan = PlanFactory().createItemPtr(fit_plan_name); mumufit::Minimizer minimizer; minimizer.setMinimizer(minimizer_name, algorithm_name, options); return plan->checkMinimizer(minimizer); } -TEST_F(Minimize, MinuitTestV1) -{ +TEST_F(Minimize, MinuitTestV1) { EXPECT_TRUE(run("Minuit2", "Migrad", "RosenbrockPlan")); } -TEST_F(Minimize, MinuitTestV2) -{ +TEST_F(Minimize, MinuitTestV2) { EXPECT_TRUE(run("Minuit2", "Migrad", "WoodFourPlan")); } -TEST_F(Minimize, MinuitTestV3) -{ +TEST_F(Minimize, MinuitTestV3) { EXPECT_TRUE(run("Minuit2", "Migrad", "DecayingSinPlan")); } @@ -51,82 +45,66 @@ TEST_F(Minimize, SteepestDescentTestV1) } */ -TEST_F(Minimize, SteepestDescentTestV2) -{ +TEST_F(Minimize, SteepestDescentTestV2) { EXPECT_TRUE(run("GSLMultiMin", "SteepestDescent", "WoodFourPlan")); } -TEST_F(Minimize, ConjugateFRTestV1) -{ +TEST_F(Minimize, ConjugateFRTestV1) { EXPECT_TRUE(run("GSLMultiMin", "ConjugateFR", "RosenbrockPlan")); } -TEST_F(Minimize, ConjugateFRTestV2) -{ +TEST_F(Minimize, ConjugateFRTestV2) { EXPECT_TRUE(run("GSLMultiMin", "ConjugateFR", "WoodFourPlan")); } -TEST_F(Minimize, ConjugatePRTestV1) -{ +TEST_F(Minimize, ConjugatePRTestV1) { EXPECT_TRUE(run("GSLMultiMin", "ConjugatePR", "RosenbrockPlan")); } -TEST_F(Minimize, ConjugatePRTestV2) -{ +TEST_F(Minimize, ConjugatePRTestV2) { EXPECT_TRUE(run("GSLMultiMin", "ConjugatePR", "WoodFourPlan")); } -TEST_F(Minimize, BfgsTestV1) -{ +TEST_F(Minimize, BfgsTestV1) { EXPECT_TRUE(run("GSLMultiMin", "BFGS", "RosenbrockPlan")); } -TEST_F(Minimize, BfgsTestV2) -{ +TEST_F(Minimize, BfgsTestV2) { EXPECT_TRUE(run("GSLMultiMin", "BFGS", "WoodFourPlan")); } -TEST_F(Minimize, Bfgs2TestV1) -{ +TEST_F(Minimize, Bfgs2TestV1) { EXPECT_TRUE(run("GSLMultiMin", "BFGS2", "RosenbrockPlan")); } -TEST_F(Minimize, Bfgs2TestV2) -{ +TEST_F(Minimize, Bfgs2TestV2) { EXPECT_TRUE(run("GSLMultiMin", "BFGS2", "WoodFourPlan")); } -TEST_F(Minimize, GSLSimAnTestV1) -{ +TEST_F(Minimize, GSLSimAnTestV1) { EXPECT_TRUE(run("GSLSimAn", "Default", "EasyRosenbrockPlan")); } -TEST_F(Minimize, GSLSimAnTestV2) -{ +TEST_F(Minimize, GSLSimAnTestV2) { EXPECT_TRUE(run("GSLSimAn", "Default", "EasyWoodFourPlan")); } -TEST_F(Minimize, GeneticTestV1) -{ +TEST_F(Minimize, GeneticTestV1) { EXPECT_TRUE(run("Genetic", "Default", "EasyRosenbrockPlan", "RandomSeed=1")); } -TEST_F(Minimize, GeneticTestV2) -{ +TEST_F(Minimize, GeneticTestV2) { EXPECT_TRUE(run("Genetic", "Default", "EasyWoodFourPlan", "RandomSeed=1")); } -TEST_F(Minimize, FumiliTestV3) -{ +TEST_F(Minimize, FumiliTestV3) { EXPECT_TRUE(run("Minuit2", "Fumili", "DecayingSinPlan", "MaxFunctionCalls=10000")); } -TEST_F(Minimize, LevenbergMarquardtV3) -{ +TEST_F(Minimize, LevenbergMarquardtV3) { EXPECT_TRUE(run("GSLLMA", "Default", "DecayingSinPlanV2")); } -TEST_F(Minimize, TestMinimizerV1) -{ +TEST_F(Minimize, TestMinimizerV1) { EXPECT_TRUE(run("Test", "Default", "TestMinimizerPlan")); } diff --git a/Fit/Test/Functional/Minimizer/PlanCases.cpp b/Fit/Test/Functional/Minimizer/PlanCases.cpp index 05e0a04818f745fac0110f1a87fbe0fd43f0e56c..dea8c69b07583bd70d9ec412199892c7e37c0692 100644 --- a/Fit/Test/Functional/Minimizer/PlanCases.cpp +++ b/Fit/Test/Functional/Minimizer/PlanCases.cpp @@ -15,8 +15,7 @@ #include "Fit/Test/Functional/Minimizer/PlanCases.h" #include "Fit/Test/Functional/Minimizer/ClassicalTestFunctions.h" -namespace -{ +namespace { const double loose_tolerance_on_function_min = 0.1; } @@ -26,16 +25,15 @@ using namespace mumufit; //! start point: F(-1.2,1.0) = 24.20 //! minimum : F(1.0,1.0) = 0. -RosenbrockPlan::RosenbrockPlan() : ScalarTestPlan("RosenbrockPlan", TestFunctions::RosenBrock, 0.0) -{ +RosenbrockPlan::RosenbrockPlan() + : ScalarTestPlan("RosenbrockPlan", TestFunctions::RosenBrock, 0.0) { addParameter(Parameter("par0", -1.2, AttLimits::limited(-5.0, 5.0), 0.01), 1.0); addParameter(Parameter("par1", 1.0, AttLimits::limited(-5.0, 5.0), 0.01), 1.0); } EasyRosenbrockPlan::EasyRosenbrockPlan() : ScalarTestPlan("EasyRosenbrockPlan", TestFunctions::RosenBrock, 0.0, - loose_tolerance_on_function_min) -{ + loose_tolerance_on_function_min) { // narrow parameter limits and big tolerance for stochastic minimizers const double tolerance = 0.1; addParameter(Parameter("par0", 1.1, AttLimits::limited(0.8, 1.2), 0.01), 1.0, tolerance); @@ -46,8 +44,7 @@ EasyRosenbrockPlan::EasyRosenbrockPlan() //! start point: F(-3,-1,-3,-1) = 19192 //! minimum : F(1,1,1,1) = 0. -WoodFourPlan::WoodFourPlan() : ScalarTestPlan("WoodFourPlan", TestFunctions::WoodFour, 0.0) -{ +WoodFourPlan::WoodFourPlan() : ScalarTestPlan("WoodFourPlan", TestFunctions::WoodFour, 0.0) { addParameter(Parameter("par0", -3.0, AttLimits::limited(-5.0, 5.0)), 1.0); addParameter(Parameter("par1", -1.0, AttLimits::limited(-5.0, 5.0)), 1.0); addParameter(Parameter("par2", -3.0, AttLimits::limited(-5.0, 5.0)), 1.0); @@ -56,8 +53,7 @@ WoodFourPlan::WoodFourPlan() : ScalarTestPlan("WoodFourPlan", TestFunctions::Woo EasyWoodFourPlan::EasyWoodFourPlan() : ScalarTestPlan("EasyWoodFourPlan", TestFunctions::WoodFour, 0.0, - loose_tolerance_on_function_min) -{ + loose_tolerance_on_function_min) { // narrow parameter limits and big tolerance for stochastic minimizers const double tolerance = 0.1; addParameter(Parameter("par0", 1.1, AttLimits::limited(0.8, 1.2)), 1.0, tolerance); @@ -66,8 +62,8 @@ EasyWoodFourPlan::EasyWoodFourPlan() addParameter(Parameter("par3", 1.1, AttLimits::limited(0.8, 1.2)), 1.0, tolerance); } -DecayingSinPlan::DecayingSinPlan() : ResidualTestPlan("DecayingSinPlan", TestFunctions::DecayingSin) -{ +DecayingSinPlan::DecayingSinPlan() + : ResidualTestPlan("DecayingSinPlan", TestFunctions::DecayingSin) { addParameter(Parameter("amp", 1.0, AttLimits::nonnegative()), 10.0); addParameter(Parameter("frequency", 1.0, AttLimits::nonnegative()), 4.0); addParameter(Parameter("phase", 0.1, AttLimits::limited(0.0, 3.1)), 1.0); @@ -75,8 +71,7 @@ DecayingSinPlan::DecayingSinPlan() : ResidualTestPlan("DecayingSinPlan", TestFun } DecayingSinPlanV2::DecayingSinPlanV2() - : ResidualTestPlan("DecayingSinPlanV2", TestFunctions::DecayingSin) -{ + : ResidualTestPlan("DecayingSinPlanV2", TestFunctions::DecayingSin) { addParameter(Parameter("amp", 1.0, AttLimits::limitless()), 2.0); addParameter(Parameter("frequency", 1.0, AttLimits::limitless()), 2.0); addParameter(Parameter("phase", 1.0, AttLimits::fixed()), 1.0); @@ -84,8 +79,7 @@ DecayingSinPlanV2::DecayingSinPlanV2() } TestMinimizerPlan::TestMinimizerPlan() - : ScalarTestPlan("TestMinimizerPlan", TestFunctions::RosenBrock, 0.0) -{ + : ScalarTestPlan("TestMinimizerPlan", TestFunctions::RosenBrock, 0.0) { // starting values of fit parameters are already correct addParameter(Parameter("par0", 1.0, AttLimits::limited(-5.0, 5.0), 0.01), 1.0); addParameter(Parameter("par1", 1.0, AttLimits::limited(-5.0, 5.0), 0.01), 1.0); diff --git a/Fit/Test/Functional/Minimizer/PlanCases.h b/Fit/Test/Functional/Minimizer/PlanCases.h index 504ffb7cfac33e51cffd5039b634c6658126ed41..f32129f7c3d1e3f5c7d1f4869eb27424f1d164f6 100644 --- a/Fit/Test/Functional/Minimizer/PlanCases.h +++ b/Fit/Test/Functional/Minimizer/PlanCases.h @@ -20,8 +20,7 @@ //! Setting for standalone fit of Rosenbrock function. -class RosenbrockPlan : public ScalarTestPlan -{ +class RosenbrockPlan : public ScalarTestPlan { public: RosenbrockPlan(); }; @@ -29,16 +28,14 @@ public: //! Setting for standalone fit of Rosenbrock function. Fit parameter limits //! are made small here to help stochastic minimizer to converge in reasonable time. -class EasyRosenbrockPlan : public ScalarTestPlan -{ +class EasyRosenbrockPlan : public ScalarTestPlan { public: EasyRosenbrockPlan(); }; //! Setting for standalone fit of WoodFour function. -class WoodFourPlan : public ScalarTestPlan -{ +class WoodFourPlan : public ScalarTestPlan { public: WoodFourPlan(); }; @@ -46,8 +43,7 @@ public: //! Setting for standalone fit of WoodFour function. Fit parameter limits //! are made small here to help stochastic minimizer to converge in reasonable time. -class EasyWoodFourPlan : public ScalarTestPlan -{ +class EasyWoodFourPlan : public ScalarTestPlan { public: EasyWoodFourPlan(); }; @@ -55,24 +51,21 @@ public: //! Settings for standalone fit using Minimizer's residual interface. //! "Decaying sin" objective function from lmfit tutorial is used. -class DecayingSinPlan : public ResidualTestPlan -{ +class DecayingSinPlan : public ResidualTestPlan { public: DecayingSinPlan(); }; //! Same as DecayingSinPlan with fewer fit parameters -class DecayingSinPlanV2 : public ResidualTestPlan -{ +class DecayingSinPlanV2 : public ResidualTestPlan { public: DecayingSinPlanV2(); }; //! Special plan to test TestMinimizer. -class TestMinimizerPlan : public ScalarTestPlan -{ +class TestMinimizerPlan : public ScalarTestPlan { public: TestMinimizerPlan(); }; diff --git a/Fit/Test/Functional/Minimizer/PlanFactory.cpp b/Fit/Test/Functional/Minimizer/PlanFactory.cpp index 873c287c0248471aad1805b645a43f9c900447b6..148cb1130a1c89b94c6fc6645069dd52d393d6e5 100644 --- a/Fit/Test/Functional/Minimizer/PlanFactory.cpp +++ b/Fit/Test/Functional/Minimizer/PlanFactory.cpp @@ -17,8 +17,7 @@ using mumufit::test::create_new; -PlanFactory::PlanFactory() -{ +PlanFactory::PlanFactory() { registerItem("RosenbrockPlan", create_new<RosenbrockPlan>); registerItem("EasyRosenbrockPlan", create_new<EasyRosenbrockPlan>); registerItem("WoodFourPlan", create_new<WoodFourPlan>); diff --git a/Fit/Test/Functional/Minimizer/PlanFactory.h b/Fit/Test/Functional/Minimizer/PlanFactory.h index 66b2bbb2e20430a91eec61b1f9cabb9632e6492a..7275fa8d4a3232b3224bc71cd10686d9b201ea70 100644 --- a/Fit/Test/Functional/Minimizer/PlanFactory.h +++ b/Fit/Test/Functional/Minimizer/PlanFactory.h @@ -20,8 +20,7 @@ //! Factory to generate plans for fitting objective functions. -class PlanFactory : public mumufit::test::IFactory<std::string, MinimizerTestPlan> -{ +class PlanFactory : public mumufit::test::IFactory<std::string, MinimizerTestPlan> { public: PlanFactory(); }; diff --git a/Fit/Test/Functional/Minimizer/ResidualTestPlan.cpp b/Fit/Test/Functional/Minimizer/ResidualTestPlan.cpp index dc8a0f7dc747cb53657c2dd1d3c30d90680d43e3..e7712e313bf6638adf5aa22a0b87feef485b8d0e 100644 --- a/Fit/Test/Functional/Minimizer/ResidualTestPlan.cpp +++ b/Fit/Test/Functional/Minimizer/ResidualTestPlan.cpp @@ -22,15 +22,13 @@ using namespace mumufit; ResidualTestPlan::ResidualTestPlan(const std::string& name, test_funct_t func) - : MinimizerTestPlan(name), m_test_func(func) -{ + : MinimizerTestPlan(name), m_test_func(func) { m_xvalues.resize(101); for (int i = 0; i <= 100; ++i) m_xvalues[i] = i * 0.1; } -fcn_residual_t ResidualTestPlan::residualFunction() -{ +fcn_residual_t ResidualTestPlan::residualFunction() { fcn_residual_t func = [&](mumufit::Parameters pars) -> std::vector<double> { return evaluate(pars.values()); }; @@ -38,8 +36,7 @@ fcn_residual_t ResidualTestPlan::residualFunction() return func; } -bool ResidualTestPlan::checkMinimizer(Minimizer& minimizer) -{ +bool ResidualTestPlan::checkMinimizer(Minimizer& minimizer) { bool success(true); auto result = minimizer.minimize(residualFunction(), parameters()); @@ -52,8 +49,7 @@ bool ResidualTestPlan::checkMinimizer(Minimizer& minimizer) return success; } -void ResidualTestPlan::init_data_values() -{ +void ResidualTestPlan::init_data_values() { std::vector<double> pars; for (const auto& plan : m_parameter_plan) pars.push_back(plan.expectedValue()); @@ -62,8 +58,7 @@ void ResidualTestPlan::init_data_values() m_data_values.push_back(m_test_func(x, pars)); } -std::vector<double> ResidualTestPlan::evaluate(const std::vector<double>& pars) -{ +std::vector<double> ResidualTestPlan::evaluate(const std::vector<double>& pars) { if (m_data_values.empty()) init_data_values(); diff --git a/Fit/Test/Functional/Minimizer/ResidualTestPlan.h b/Fit/Test/Functional/Minimizer/ResidualTestPlan.h index 2ed0a193bb5a8a6341e0b0c6c70e775635c9d83f..07fba72a587016b5021ed135bdd7f47c43caa3fc 100644 --- a/Fit/Test/Functional/Minimizer/ResidualTestPlan.h +++ b/Fit/Test/Functional/Minimizer/ResidualTestPlan.h @@ -18,8 +18,7 @@ #include "Fit/Minimizer/Types.h" #include "Fit/TestEngine/MinimizerTestPlan.h" -class ResidualTestPlan : public MinimizerTestPlan -{ +class ResidualTestPlan : public MinimizerTestPlan { public: using test_funct_t = std::function<double(double, const std::vector<double>&)>; diff --git a/Fit/Test/Functional/Minimizer/ScalarTestPlan.cpp b/Fit/Test/Functional/Minimizer/ScalarTestPlan.cpp index 563f516967f00c43f513222c728531efb715dbe0..596fbac36e8e8a13ebdf623ceb0ce81e791ca6e1 100644 --- a/Fit/Test/Functional/Minimizer/ScalarTestPlan.cpp +++ b/Fit/Test/Functional/Minimizer/ScalarTestPlan.cpp @@ -25,14 +25,11 @@ ScalarTestPlan::ScalarTestPlan(const std::string& name, scalar_function_t func, : MinimizerTestPlan(name) , m_objective_function(func) , m_expected_minimum(expected_minimum) - , m_tolerance_on_minimum(tolerance) -{ -} + , m_tolerance_on_minimum(tolerance) {} //! Returns true if found minimum of objective function coincide with expected. -bool ScalarTestPlan::minimumAsExpected(double found_minimum, double tolerance) const -{ +bool ScalarTestPlan::minimumAsExpected(double found_minimum, double tolerance) const { bool success(true); double diff = std::abs(found_minimum - m_expected_minimum); @@ -47,8 +44,7 @@ bool ScalarTestPlan::minimumAsExpected(double found_minimum, double tolerance) c return success; } -bool ScalarTestPlan::checkMinimizer(Minimizer& minimizer) -{ +bool ScalarTestPlan::checkMinimizer(Minimizer& minimizer) { bool success(true); auto result = minimizer.minimize(scalarFunction(), parameters()); @@ -63,8 +59,7 @@ bool ScalarTestPlan::checkMinimizer(Minimizer& minimizer) return success; } -fcn_scalar_t ScalarTestPlan::scalarFunction() const -{ +fcn_scalar_t ScalarTestPlan::scalarFunction() const { fcn_scalar_t func = [&](const Parameters& params) { return m_objective_function(params.values()); }; diff --git a/Fit/Test/Functional/Minimizer/ScalarTestPlan.h b/Fit/Test/Functional/Minimizer/ScalarTestPlan.h index bcba6af7d29f338fac8a7cab1c3f9042d76403ba..df4fd34ab9ab781b1b7a1c3a3b857e29a87c8d2a 100644 --- a/Fit/Test/Functional/Minimizer/ScalarTestPlan.h +++ b/Fit/Test/Functional/Minimizer/ScalarTestPlan.h @@ -20,8 +20,7 @@ //! Testing logic for Minimizer and scalar-type objective functions. -class ScalarTestPlan : public MinimizerTestPlan -{ +class ScalarTestPlan : public MinimizerTestPlan { public: ScalarTestPlan(const std::string& name, scalar_function_t func, double expected_minimum, double tolerance = 0.01); diff --git a/Fit/Test/Unit/AttLimitsTest.cpp b/Fit/Test/Unit/AttLimitsTest.cpp index d84f3311eca3c6259fa0984c9a0e09396f363109..20d6d8a1e42711f6cf02f806160c7ff6c49bdade 100644 --- a/Fit/Test/Unit/AttLimitsTest.cpp +++ b/Fit/Test/Unit/AttLimitsTest.cpp @@ -1,12 +1,9 @@ #include "Fit/Param/AttLimits.h" #include "Tests/GTestWrapper/google_test.h" -class AttLimitsTest : public ::testing::Test -{ -}; +class AttLimitsTest : public ::testing::Test {}; -TEST_F(AttLimitsTest, InitialState) -{ +TEST_F(AttLimitsTest, InitialState) { AttLimits limits; EXPECT_FALSE(limits.isFixed()); EXPECT_FALSE(limits.isLimited()); @@ -15,8 +12,7 @@ TEST_F(AttLimitsTest, InitialState) EXPECT_TRUE(limits.isLimitless()); } -TEST_F(AttLimitsTest, LowerLimited) -{ +TEST_F(AttLimitsTest, LowerLimited) { AttLimits limits = AttLimits::lowerLimited(1.0); EXPECT_FALSE(limits.isFixed()); EXPECT_FALSE(limits.isLimited()); @@ -27,8 +23,7 @@ TEST_F(AttLimitsTest, LowerLimited) EXPECT_EQ(0.0, limits.upperLimit()); } -TEST_F(AttLimitsTest, UpperLimited) -{ +TEST_F(AttLimitsTest, UpperLimited) { AttLimits limits = AttLimits::upperLimited(1.0); EXPECT_FALSE(limits.isFixed()); EXPECT_FALSE(limits.isLimited()); @@ -39,8 +34,7 @@ TEST_F(AttLimitsTest, UpperLimited) EXPECT_EQ(1.0, limits.upperLimit()); } -TEST_F(AttLimitsTest, Fixed) -{ +TEST_F(AttLimitsTest, Fixed) { AttLimits limits = AttLimits::fixed(); EXPECT_TRUE(limits.isFixed()); EXPECT_FALSE(limits.isLimited()); @@ -51,8 +45,7 @@ TEST_F(AttLimitsTest, Fixed) EXPECT_EQ(0.0, limits.upperLimit()); } -TEST_F(AttLimitsTest, Limited) -{ +TEST_F(AttLimitsTest, Limited) { AttLimits limits = AttLimits::limited(1.0, 2.0); EXPECT_FALSE(limits.isFixed()); EXPECT_TRUE(limits.isLimited()); diff --git a/Fit/Test/Unit/MinimizerOptionsTest.cpp b/Fit/Test/Unit/MinimizerOptionsTest.cpp index 7af4e98f96130a76e4ba0ac123c6cb455f394f58..1f84e14d9e2579663f10acf10bddfaf0ce2b36b5 100644 --- a/Fit/Test/Unit/MinimizerOptionsTest.cpp +++ b/Fit/Test/Unit/MinimizerOptionsTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <exception> -class MinimizerOptionsTest : public ::testing::Test -{ -}; +class MinimizerOptionsTest : public ::testing::Test {}; -TEST_F(MinimizerOptionsTest, toOptionString) -{ +TEST_F(MinimizerOptionsTest, toOptionString) { MinimizerOptions options; options.addOption("option_1", 99); @@ -17,8 +14,7 @@ TEST_F(MinimizerOptionsTest, toOptionString) EXPECT_EQ(options.toOptionString(), "option_1=99;option_2=1.1;option_3=xxx;"); } -TEST_F(MinimizerOptionsTest, setOptionsFromString) -{ +TEST_F(MinimizerOptionsTest, setOptionsFromString) { MinimizerOptions options; options.addOption("Strategy", 1); diff --git a/Fit/Test/Unit/MultiOptionTest.cpp b/Fit/Test/Unit/MultiOptionTest.cpp index c8f52dc75df06e86937cd5581b5b3f7983e60441..fba4754d86e36d886a7c66b0c818a7fd00d86a18 100644 --- a/Fit/Test/Unit/MultiOptionTest.cpp +++ b/Fit/Test/Unit/MultiOptionTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <string> -class MultiOptionTest : public ::testing::Test -{ -}; +class MultiOptionTest : public ::testing::Test {}; -TEST_F(MultiOptionTest, Variant) -{ +TEST_F(MultiOptionTest, Variant) { MultiOption::variant_t v1(1); EXPECT_EQ(0, v1.which()); @@ -26,8 +23,7 @@ TEST_F(MultiOptionTest, Variant) EXPECT_EQ(text, boost::get<std::string>(v1)); } -TEST_F(MultiOptionTest, Construction) -{ +TEST_F(MultiOptionTest, Construction) { const std::string name("name"); const std::string description("description"); const double double_value(2.0); @@ -45,8 +41,7 @@ TEST_F(MultiOptionTest, Construction) EXPECT_EQ(double_value, opt.getDefault<double>()); } -TEST_F(MultiOptionTest, Copying) -{ +TEST_F(MultiOptionTest, Copying) { const std::string name("name"); const std::string description("description"); const double double_value(2.0); @@ -59,8 +54,7 @@ TEST_F(MultiOptionTest, Copying) EXPECT_EQ(double_value, copy.getDefault<double>()); } -TEST_F(MultiOptionTest, Assignment) -{ +TEST_F(MultiOptionTest, Assignment) { const std::string name("name"); const std::string description("description"); const double double_value(2.0); @@ -78,8 +72,7 @@ TEST_F(MultiOptionTest, Assignment) EXPECT_EQ(double_value, copy.getDefault<double>()); } -TEST_F(MultiOptionTest, SetFromString) -{ +TEST_F(MultiOptionTest, SetFromString) { MultiOption opt("name", 2.0); opt.setFromString("2.1"); EXPECT_EQ(2.1, opt.get<double>()); diff --git a/Fit/Test/Unit/OptionContainerTest.cpp b/Fit/Test/Unit/OptionContainerTest.cpp index f34727872da0c3228c1df037448dcc33a8ecce4b..982c246a93a88c0c5f315fc38e24bbfaf76386c8 100644 --- a/Fit/Test/Unit/OptionContainerTest.cpp +++ b/Fit/Test/Unit/OptionContainerTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <exception> -class OptionContainerTest : public ::testing::Test -{ -}; +class OptionContainerTest : public ::testing::Test {}; -TEST_F(OptionContainerTest, addOption) -{ +TEST_F(OptionContainerTest, addOption) { OptionContainer test; const double option_value(1.0); @@ -32,8 +29,7 @@ TEST_F(OptionContainerTest, addOption) EXPECT_THROW(test.addOption(option_name, 1.0), std::runtime_error); } -TEST_F(OptionContainerTest, getOptionValue) -{ +TEST_F(OptionContainerTest, getOptionValue) { OptionContainer test; test.addOption("option #1", 99, "description #1"); @@ -45,8 +41,7 @@ TEST_F(OptionContainerTest, getOptionValue) EXPECT_EQ("xxx", test.optionValue<std::string>("option #3")); } -TEST_F(OptionContainerTest, setOptionValue) -{ +TEST_F(OptionContainerTest, setOptionValue) { OptionContainer test; test.addOption("option #1", 99, "description #1"); @@ -66,8 +61,7 @@ TEST_F(OptionContainerTest, setOptionValue) EXPECT_THROW(test.setOptionValue("option #1", 99.0), std::runtime_error); } -TEST_F(OptionContainerTest, Copying) -{ +TEST_F(OptionContainerTest, Copying) { OptionContainer test; test.addOption("option #1", 99, "description #1"); @@ -95,8 +89,7 @@ TEST_F(OptionContainerTest, Copying) EXPECT_EQ("xxx", test.optionValue<std::string>("option #3")); } -TEST_F(OptionContainerTest, Assignment) -{ +TEST_F(OptionContainerTest, Assignment) { OptionContainer test; test.addOption("option #1", 99, "description #1"); diff --git a/Fit/Test/Unit/ParameterTest.cpp b/Fit/Test/Unit/ParameterTest.cpp index b5bdc8339b45c1375ea70777a62534663e6567dd..c56cf354ac15cb064ee6fa2fc18e97fb75209a50 100644 --- a/Fit/Test/Unit/ParameterTest.cpp +++ b/Fit/Test/Unit/ParameterTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <string> -class ParameterTest : public ::testing::Test -{ -}; +class ParameterTest : public ::testing::Test {}; -TEST_F(ParameterTest, defaultConstructor) -{ +TEST_F(ParameterTest, defaultConstructor) { mumufit::Parameter par; EXPECT_EQ(par.name(), ""); @@ -19,8 +16,7 @@ TEST_F(ParameterTest, defaultConstructor) EXPECT_EQ(par.limits(), expected); } -TEST_F(ParameterTest, fullConstructor) -{ +TEST_F(ParameterTest, fullConstructor) { AttLimits limits = AttLimits::limited(-10.0, 2.0); mumufit::Parameter par("par0", 2.0, limits, 0.2); @@ -34,8 +30,7 @@ TEST_F(ParameterTest, fullConstructor) EXPECT_EQ(par.limits().upperLimit(), 2.0); } -TEST_F(ParameterTest, defaultStep) -{ +TEST_F(ParameterTest, defaultStep) { const double start_value = 2.0; const double hardcoded_step_factor = 0.01; mumufit::Parameter par("par0", start_value, AttLimits::limitless()); @@ -46,8 +41,7 @@ TEST_F(ParameterTest, defaultStep) EXPECT_EQ(par2.step(), hardcoded_step_factor); } -TEST_F(ParameterTest, setters) -{ +TEST_F(ParameterTest, setters) { mumufit::Parameter par("par0", 2.0, AttLimits::limitless(), 0.2); par.setValue(42.0); EXPECT_EQ(par.value(), 42.0); diff --git a/Fit/Test/Unit/ParametersTest.cpp b/Fit/Test/Unit/ParametersTest.cpp index ac2c9d6625ef55846489f8f2a65bcc8c8193b63d..39fe33af85d101be1ae4c676dde3dd4dcea34fd1 100644 --- a/Fit/Test/Unit/ParametersTest.cpp +++ b/Fit/Test/Unit/ParametersTest.cpp @@ -2,20 +2,16 @@ #include "Tests/GTestWrapper/google_test.h" #include <string> -class ParametersTest : public ::testing::Test -{ -}; +class ParametersTest : public ::testing::Test {}; -TEST_F(ParametersTest, defaultConstructor) -{ +TEST_F(ParametersTest, defaultConstructor) { mumufit::Parameters pars; EXPECT_EQ(pars.size(), 0u); EXPECT_TRUE(pars.values().empty()); EXPECT_TRUE(pars.errors().empty()); } -TEST_F(ParametersTest, addParameter) -{ +TEST_F(ParametersTest, addParameter) { mumufit::Parameters pars; mumufit::Parameter par0("par0", 2.0, AttLimits::limitless(), 0.2); @@ -44,8 +40,7 @@ TEST_F(ParametersTest, addParameter) EXPECT_THROW(pars[2], std::runtime_error); } -TEST_F(ParametersTest, setters) -{ +TEST_F(ParametersTest, setters) { mumufit::Parameters pars; pars.add(mumufit::Parameter("par0", 2.0, AttLimits::limitless(), 0.2)); pars.add(mumufit::Parameter("par1", 3.0, AttLimits::limitless(), 0.2)); @@ -62,8 +57,7 @@ TEST_F(ParametersTest, setters) EXPECT_THROW(pars.setValues(more_values), std::runtime_error); } -TEST_F(ParametersTest, freeParameterCount) -{ +TEST_F(ParametersTest, freeParameterCount) { mumufit::Parameters pars; EXPECT_EQ(pars.freeParameterCount(), 0u); diff --git a/Fit/Test/Unit/RealLimitsTest.cpp b/Fit/Test/Unit/RealLimitsTest.cpp index 3301b5cf01fc337aeea74238ae75fd703ce2d750..c711595881a4fba6fca0a351ca67530cb6714fef 100644 --- a/Fit/Test/Unit/RealLimitsTest.cpp +++ b/Fit/Test/Unit/RealLimitsTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <limits> -class RealLimitsTest : public ::testing::Test -{ -}; +class RealLimitsTest : public ::testing::Test {}; -TEST_F(RealLimitsTest, LimitsInitial) -{ +TEST_F(RealLimitsTest, LimitsInitial) { RealLimits limits; EXPECT_FALSE(limits.hasLowerLimit()); @@ -15,8 +12,7 @@ TEST_F(RealLimitsTest, LimitsInitial) EXPECT_FALSE(limits.hasLowerAndUpperLimits()); } -TEST_F(RealLimitsTest, LimitsSetLimit) -{ +TEST_F(RealLimitsTest, LimitsSetLimit) { RealLimits limits; // set limit [-1.0, 10.0[ @@ -86,8 +82,7 @@ TEST_F(RealLimitsTest, LimitsSetLimit) EXPECT_TRUE(limits.isInRange(std::numeric_limits<double>::infinity())); } -TEST_F(RealLimitsTest, LimitsLowerLimited) -{ +TEST_F(RealLimitsTest, LimitsLowerLimited) { RealLimits limits = RealLimits::lowerLimited(5.0); EXPECT_TRUE(limits.hasLowerLimit()); EXPECT_FALSE(limits.hasUpperLimit()); @@ -97,8 +92,7 @@ TEST_F(RealLimitsTest, LimitsLowerLimited) EXPECT_EQ(0.0, limits.upperLimit()); } -TEST_F(RealLimitsTest, LimitsUpperLimited) -{ +TEST_F(RealLimitsTest, LimitsUpperLimited) { RealLimits limits = RealLimits::upperLimited(5.0); EXPECT_FALSE(limits.hasLowerLimit()); EXPECT_TRUE(limits.hasUpperLimit()); @@ -108,8 +102,7 @@ TEST_F(RealLimitsTest, LimitsUpperLimited) EXPECT_EQ(5.0, limits.upperLimit()); } -TEST_F(RealLimitsTest, LimitsLimited) -{ +TEST_F(RealLimitsTest, LimitsLimited) { RealLimits limits = RealLimits::limited(-10.0, 2.0); EXPECT_TRUE(limits.hasLowerLimit()); EXPECT_TRUE(limits.hasUpperLimit()); @@ -119,8 +112,7 @@ TEST_F(RealLimitsTest, LimitsLimited) EXPECT_EQ(2.0, limits.upperLimit()); } -TEST_F(RealLimitsTest, LimitsLimitless) -{ +TEST_F(RealLimitsTest, LimitsLimitless) { RealLimits limits = RealLimits::limitless(); EXPECT_FALSE(limits.hasLowerLimit()); @@ -128,8 +120,7 @@ TEST_F(RealLimitsTest, LimitsLimitless) EXPECT_FALSE(limits.hasLowerAndUpperLimits()); } -TEST_F(RealLimitsTest, ComparisonOperators) -{ +TEST_F(RealLimitsTest, ComparisonOperators) { RealLimits lim1 = RealLimits::limited(1.0, 2.0); RealLimits lim2 = RealLimits::limited(1.0, 2.0); EXPECT_TRUE(lim1 == lim2); @@ -151,8 +142,7 @@ TEST_F(RealLimitsTest, ComparisonOperators) EXPECT_FALSE(lim7 != lim8); } -TEST_F(RealLimitsTest, CopyConstructor) -{ +TEST_F(RealLimitsTest, CopyConstructor) { RealLimits lim1 = RealLimits::limited(1.0, 2.0); RealLimits lim2 = lim1; EXPECT_TRUE(lim1 == lim2); diff --git a/Fit/Test/Unit/StringUtilsTest.cpp b/Fit/Test/Unit/StringUtilsTest.cpp index 6e722bcee5148a11f70962a1402b3bc168e0713e..354c26cb232d73cb8493dd1e85512c521cb876c2 100644 --- a/Fit/Test/Unit/StringUtilsTest.cpp +++ b/Fit/Test/Unit/StringUtilsTest.cpp @@ -1,19 +1,15 @@ #include "Fit/Tools/StringUtils.h" #include "Tests/GTestWrapper/google_test.h" -class StringUtilsTest : public ::testing::Test -{ -}; +class StringUtilsTest : public ::testing::Test {}; -TEST_F(StringUtilsTest, removeSubstring) -{ +TEST_F(StringUtilsTest, removeSubstring) { std::string target("one two threeone five one"); std::string result = mumufit::stringUtils::removeSubstring(target, "one"); EXPECT_EQ(result, " two three five "); } -TEST_F(StringUtilsTest, toLower) -{ +TEST_F(StringUtilsTest, toLower) { std::string target("QyQz"); EXPECT_EQ(mumufit::stringUtils::to_lower(target), "qyqz"); } diff --git a/Fit/TestEngine/IFactory.h b/Fit/TestEngine/IFactory.h index d9478e6a5a38ac600cfd70aba6c3bf3dd24820c5..226204c0a44e92bbce6a06b726b853675444f6d0 100644 --- a/Fit/TestEngine/IFactory.h +++ b/Fit/TestEngine/IFactory.h @@ -22,14 +22,12 @@ #include <memory> #include <sstream> -namespace mumufit::test -{ +namespace mumufit::test { //! Base class for all factories. //! @ingroup tools_internal -template <class Key, class AbstractProduct> class IFactory -{ +template <class Key, class AbstractProduct> class IFactory { public: //! function which will be used to create object of AbstractProduct base type typedef typename std::function<AbstractProduct*()> CreateItemCallback; @@ -38,29 +36,25 @@ public: typedef std::map<Key, CreateItemCallback> CallbackMap_t; //! Creates object by calling creation function corresponded to given identifier - AbstractProduct* createItem(const Key& item_key) const - { + AbstractProduct* createItem(const Key& item_key) const { auto it = m_callbacks.find(item_key); assert(it != m_callbacks.end()); return (it->second)(); } #ifndef SWIG - std::unique_ptr<AbstractProduct> createItemPtr(const Key& item_key) const - { + std::unique_ptr<AbstractProduct> createItemPtr(const Key& item_key) const { return std::unique_ptr<AbstractProduct>{createItem(item_key)}; } #endif //! Registers object's creation function - bool registerItem(const Key& item_key, CreateItemCallback CreateFn) - { + bool registerItem(const Key& item_key, CreateItemCallback CreateFn) { assert(m_callbacks.find(item_key) == m_callbacks.end()); return m_callbacks.insert(make_pair(item_key, CreateFn)).second; } - bool contains(const Key& item_key) const - { + bool contains(const Key& item_key) const { return m_callbacks.find(item_key) != m_callbacks.end(); } @@ -77,8 +71,7 @@ protected: //! 'create_new<T>', with no function arguments supplied. Equivalently, we could //! use a lambda function '[](){return new T;}'. -template <class T> T* create_new() -{ +template <class T> T* create_new() { return new T(); } diff --git a/Fit/TestEngine/MinimizerTestPlan.cpp b/Fit/TestEngine/MinimizerTestPlan.cpp index 0090933addc1cebd4527105038be26bb4d7cc60b..c995584d4c6d2ac35ccc4d9589bfa1f9a44bac01 100644 --- a/Fit/TestEngine/MinimizerTestPlan.cpp +++ b/Fit/TestEngine/MinimizerTestPlan.cpp @@ -18,12 +18,10 @@ #include <iostream> #include <sstream> -namespace -{ +namespace { //! Returns the safe relative difference, which is 2(|a-b|)/(|a|+|b|) except in special cases. -double relativeDifference(double a, double b) -{ +double relativeDifference(double a, double b) { constexpr double eps = std::numeric_limits<double>::epsilon(); const double avg_abs = (std::abs(a) + std::abs(b)) / 2.0; // return 0.0 if relative error smaller than epsilon @@ -41,15 +39,13 @@ MinimizerTestPlan::MinimizerTestPlan(const std::string& name) : m_name(name) {} MinimizerTestPlan::~MinimizerTestPlan() = default; void MinimizerTestPlan::addParameter(const Parameter& param, double expected_value, - double tolerance) -{ + double tolerance) { m_parameter_plan.push_back(ParameterPlan(param, expected_value, tolerance)); } //! Returns fit parameters which will be used as initial one for the minimization. -Parameters MinimizerTestPlan::parameters() const -{ +Parameters MinimizerTestPlan::parameters() const { Parameters result; for (const auto& plan : m_parameter_plan) result.add(plan.fitParameter()); @@ -59,8 +55,7 @@ Parameters MinimizerTestPlan::parameters() const //! Return vector of expected parameter values. -std::vector<double> MinimizerTestPlan::expectedValues() const -{ +std::vector<double> MinimizerTestPlan::expectedValues() const { std::vector<double> result; for (const auto& plan : m_parameter_plan) result.push_back(plan.expectedValue()); @@ -70,8 +65,7 @@ std::vector<double> MinimizerTestPlan::expectedValues() const //! Returns true if given values coincide with expected fit parameter values. -bool MinimizerTestPlan::valuesAsExpected(const std::vector<double>& values) const -{ +bool MinimizerTestPlan::valuesAsExpected(const std::vector<double>& values) const { bool success(true); if (m_parameter_plan.size() != values.size()) diff --git a/Fit/TestEngine/MinimizerTestPlan.h b/Fit/TestEngine/MinimizerTestPlan.h index 1355a9287a42c412cc8a9a027460fde835b95280..1a48b2a0dbd688bd16b329873b4159655bbbcb97 100644 --- a/Fit/TestEngine/MinimizerTestPlan.h +++ b/Fit/TestEngine/MinimizerTestPlan.h @@ -18,8 +18,7 @@ #include "Fit/Param/ParameterPlan.h" #include <vector> -namespace mumufit -{ +namespace mumufit { class Parameter; class Parameters; class Minimizer; @@ -28,8 +27,7 @@ class Minimizer; //! Defines objective function to fit, expected minimum, initial fit parameters and //! expected values of fit parameters at minimum. -class MinimizerTestPlan -{ +class MinimizerTestPlan { public: MinimizerTestPlan(const std::string& name); diff --git a/Fit/Tools/MinimizerUtils.cpp b/Fit/Tools/MinimizerUtils.cpp index dd23379b48f6117b601bb60f2eebcfd9a1aae7c0..3afc324f872143d9186804ea0b25ca1b55941c61 100644 --- a/Fit/Tools/MinimizerUtils.cpp +++ b/Fit/Tools/MinimizerUtils.cpp @@ -18,8 +18,7 @@ #include <limits> #include <sstream> -std::string mumufit::utils::toString(const std::vector<std::string>& v, const std::string& delim) -{ +std::string mumufit::utils::toString(const std::vector<std::string>& v, const std::string& delim) { std::stringstream s; std::for_each(v.begin(), v.end(), [&s, &delim](const std::string& elem) { s << elem << delim; }); @@ -28,8 +27,7 @@ std::string mumufit::utils::toString(const std::vector<std::string>& v, const st //! Returns translation of GSL error code to string. -std::map<int, std::string> mumufit::utils::gslErrorDescriptionMap() -{ +std::map<int, std::string> mumufit::utils::gslErrorDescriptionMap() { std::map<int, std::string> result; result[0] = "OK, valid minimum"; @@ -69,8 +67,7 @@ std::map<int, std::string> mumufit::utils::gslErrorDescriptionMap() return result; } -std::string mumufit::utils::gslErrorDescription(int errorCode) -{ +std::string mumufit::utils::gslErrorDescription(int errorCode) { static std::map<int, std::string> errorDescription = gslErrorDescriptionMap(); auto it = errorDescription.find(errorCode); @@ -80,8 +77,7 @@ std::string mumufit::utils::gslErrorDescription(int errorCode) return "Unknown error"; } -bool mumufit::utils::numbersDiffer(double a, double b, double tol) -{ +bool mumufit::utils::numbersDiffer(double a, double b, double tol) { constexpr double eps = std::numeric_limits<double>::epsilon(); if (tol < 1) throw std::runtime_error("mumufit::utils::numbersDiffer() -> Error.Not intended for tol<1"); @@ -90,8 +86,7 @@ bool mumufit::utils::numbersDiffer(double a, double b, double tol) //! Returns horizontal line of 80 characters length with section name in it. -std::string mumufit::utils::sectionString(const std::string& sectionName, size_t report_width) -{ +std::string mumufit::utils::sectionString(const std::string& sectionName, size_t report_width) { if (sectionName.empty()) return std::string(report_width, '-') + "\n"; // to make "--- SectionName ------------------------------" diff --git a/Fit/Tools/MinimizerUtils.h b/Fit/Tools/MinimizerUtils.h index 776a57ce7853c474aa305986eb21fbd8472d21c8..0dc0e43dc3b70b85a9a68b23c5bb48562bca0ca5 100644 --- a/Fit/Tools/MinimizerUtils.h +++ b/Fit/Tools/MinimizerUtils.h @@ -21,8 +21,7 @@ //! Utility functions for fit library -namespace mumufit::utils -{ +namespace mumufit::utils { std::string toString(const std::vector<std::string>& v, const std::string& delim = ""); diff --git a/Fit/Tools/MultiOption.cpp b/Fit/Tools/MultiOption.cpp index 650c50126a1cc8ec05ab8f6db8422b56393dec4f..83475129d0bf44ec08ec29123f60d45dd80c87bc 100644 --- a/Fit/Tools/MultiOption.cpp +++ b/Fit/Tools/MultiOption.cpp @@ -17,36 +17,30 @@ MultiOption::MultiOption(const std::string& name) : m_name(name) {} -std::string MultiOption::name() const -{ +std::string MultiOption::name() const { return m_name; } -std::string MultiOption::description() const -{ +std::string MultiOption::description() const { return m_description; } -void MultiOption::setDescription(const std::string& description) -{ +void MultiOption::setDescription(const std::string& description) { m_description = description; } -MultiOption::variant_t& MultiOption::value() -{ +MultiOption::variant_t& MultiOption::value() { return m_value; } -MultiOption::variant_t& MultiOption::defaultValue() -{ +MultiOption::variant_t& MultiOption::defaultValue() { return m_default_value; } //! Sets the value of option from string. //! TODO find more elegant way (without if/else and boost::lexical_cast -void MultiOption::setFromString(const std::string& value) -{ +void MultiOption::setFromString(const std::string& value) { if (m_value.which() == 0) m_value = boost::lexical_cast<int>(value); diff --git a/Fit/Tools/MultiOption.h b/Fit/Tools/MultiOption.h index b8fd3aba2cefb297fd960fd4598dc490b5f6d5d6..5e16658251be4781cc16229fe7ffc0224209b81a 100644 --- a/Fit/Tools/MultiOption.h +++ b/Fit/Tools/MultiOption.h @@ -22,8 +22,7 @@ //! Relies on boost::variant, will be switched to std::variant in C++-17. //! @ingroup fitting_internal -class MultiOption -{ +class MultiOption { public: using variant_t = boost::variant<int, double, std::string>; @@ -56,21 +55,18 @@ private: }; template <typename T> -MultiOption::MultiOption(const std::string& name, const T& t, const std::string& descripion) -{ +MultiOption::MultiOption(const std::string& name, const T& t, const std::string& descripion) { m_name = name; m_description = descripion; m_value = t; m_default_value = t; } -template <typename T> T MultiOption::get() const -{ +template <typename T> T MultiOption::get() const { return boost::get<T>(m_value); } -template <typename T> T MultiOption::getDefault() const -{ +template <typename T> T MultiOption::getDefault() const { return boost::get<T>(m_default_value); } diff --git a/Fit/Tools/OptionContainer.cpp b/Fit/Tools/OptionContainer.cpp index 67ac53cf99d6aa5c58c09253b778e9b0cbbc567a..9500f373a4deb7c7ed3a11cd16611103d519d366 100644 --- a/Fit/Tools/OptionContainer.cpp +++ b/Fit/Tools/OptionContainer.cpp @@ -16,14 +16,12 @@ #include <sstream> //! Returns true if option with such name already exists. -OptionContainer::OptionContainer(const OptionContainer& other) -{ +OptionContainer::OptionContainer(const OptionContainer& other) { for (const auto& option : other.m_options) m_options.push_back(option_t(new MultiOption(*option))); } -OptionContainer& OptionContainer::operator=(const OptionContainer& other) -{ +OptionContainer& OptionContainer::operator=(const OptionContainer& other) { if (this != &other) { OptionContainer tmp(other); tmp.swapContent(*this); @@ -31,8 +29,7 @@ OptionContainer& OptionContainer::operator=(const OptionContainer& other) return *this; } -OptionContainer::option_t OptionContainer::option(const std::string& optionName) -{ +OptionContainer::option_t OptionContainer::option(const std::string& optionName) { for (const auto& option : m_options) { if (option->name() == optionName) return option; @@ -42,8 +39,7 @@ OptionContainer::option_t OptionContainer::option(const std::string& optionName) + optionName + "'."); } -const OptionContainer::option_t OptionContainer::option(const std::string& optionName) const -{ +const OptionContainer::option_t OptionContainer::option(const std::string& optionName) const { for (const auto& option : m_options) { if (option->name() == optionName) return option; @@ -53,8 +49,7 @@ const OptionContainer::option_t OptionContainer::option(const std::string& optio + optionName + "'."); } -bool OptionContainer::exists(const std::string& name) -{ +bool OptionContainer::exists(const std::string& name) { for (const auto& option : m_options) { if (option->name() == name) return true; @@ -62,7 +57,6 @@ bool OptionContainer::exists(const std::string& name) return false; } -void OptionContainer::swapContent(OptionContainer& other) -{ +void OptionContainer::swapContent(OptionContainer& other) { std::swap(m_options, other.m_options); } diff --git a/Fit/Tools/OptionContainer.h b/Fit/Tools/OptionContainer.h index 4ae75fda290a15538aaab604018d26b8d7e39275..32fbdd1ed7327e69fd65f93898f8a9cf6fb7a017 100644 --- a/Fit/Tools/OptionContainer.h +++ b/Fit/Tools/OptionContainer.h @@ -24,8 +24,7 @@ //! Stores multi option (int,double,string) in a container. //! @ingroup fitting_internal -class OptionContainer -{ +class OptionContainer { public: using option_t = std::shared_ptr<MultiOption>; using container_t = std::vector<option_t>; @@ -64,8 +63,7 @@ protected: template <class T> OptionContainer::option_t OptionContainer::addOption(const std::string& optionName, T value, - const std::string& description) -{ + const std::string& description) { if (exists(optionName)) throw std::runtime_error("OptionContainer::addOption() -> Error. Option '" + optionName + "' exists."); @@ -75,13 +73,11 @@ OptionContainer::option_t OptionContainer::addOption(const std::string& optionNa return result; } -template <class T> T OptionContainer::optionValue(const std::string& optionName) const -{ +template <class T> T OptionContainer::optionValue(const std::string& optionName) const { return option(optionName)->get<T>(); } -template <class T> void OptionContainer::setOptionValue(const std::string& optionName, T value) -{ +template <class T> void OptionContainer::setOptionValue(const std::string& optionName, T value) { option(optionName)->value() = value; if (option(optionName)->value().which() != option(optionName)->defaultValue().which()) throw std::runtime_error( diff --git a/Fit/Tools/StringUtils.cpp b/Fit/Tools/StringUtils.cpp index 14af5626b205cd6c12460f6ea4becccf755fa941..9c7a12248d9cd79cff37beb99164989b865246b2 100644 --- a/Fit/Tools/StringUtils.cpp +++ b/Fit/Tools/StringUtils.cpp @@ -16,12 +16,10 @@ #include <boost/algorithm/string.hpp> #include <regex> -namespace mumufit -{ +namespace mumufit { //! Returns true if text matches pattern with wildcards '*' and '?'. -bool stringUtils::matchesPattern(const std::string& text, const std::string& wildcardPattern) -{ +bool stringUtils::matchesPattern(const std::string& text, const std::string& wildcardPattern) { // escape all regex special characters, except '?' and '*' std::string mywildcardPattern = wildcardPattern; boost::replace_all(mywildcardPattern, "\\", "\\\\"); @@ -49,15 +47,13 @@ bool stringUtils::matchesPattern(const std::string& text, const std::string& wil } //! Returns token vector obtained by splitting string at delimiters. -std::vector<std::string> stringUtils::split(const std::string& text, const std::string& delimiter) -{ +std::vector<std::string> stringUtils::split(const std::string& text, const std::string& delimiter) { std::vector<std::string> tokens; boost::split(tokens, text, boost::is_any_of(delimiter)); return tokens; } -std::string stringUtils::removeSubstring(const std::string& text, const std::string& substr) -{ +std::string stringUtils::removeSubstring(const std::string& text, const std::string& substr) { std::string result = text; for (std::string::size_type i = result.find(substr); i != std::string::npos; i = result.find(substr)) @@ -65,8 +61,7 @@ std::string stringUtils::removeSubstring(const std::string& text, const std::str return result; } -std::string stringUtils::to_lower(std::string text) -{ +std::string stringUtils::to_lower(std::string text) { boost::to_lower(text); return text; } diff --git a/Fit/Tools/StringUtils.h b/Fit/Tools/StringUtils.h index 99905277e3b4e009f3eb0368d83a0086b5a8efb6..a276864af3c903226a131488f61cd0835d680cea 100644 --- a/Fit/Tools/StringUtils.h +++ b/Fit/Tools/StringUtils.h @@ -22,8 +22,7 @@ //! Utility functions to analyze or modify strings. -namespace mumufit::stringUtils -{ +namespace mumufit::stringUtils { //! Returns true if text matches pattern with wildcards '*' and '?'. bool matchesPattern(const std::string& text, const std::string& wildcardPattern); @@ -40,8 +39,7 @@ template <typename T> std::string scientific(const T value, int n = 10); //! Returns new string which is lower case of text. std::string to_lower(std::string text); -template <typename T> std::string scientific(const T value, int n) -{ +template <typename T> std::string scientific(const T value, int n) { std::ostringstream out; out << std::scientific << std::setprecision(n) << value; return out.str(); diff --git a/Fit/Tools/WallclockTimer.cpp b/Fit/Tools/WallclockTimer.cpp index aeb4af2d59ae7a3992b66f65a5dbd46e20363ec6..ed02c5f68019b10b767d2f1b49b0219fca9cdd3e 100644 --- a/Fit/Tools/WallclockTimer.cpp +++ b/Fit/Tools/WallclockTimer.cpp @@ -29,20 +29,17 @@ struct WallclockTimerState { WallclockTimer::WallclockTimer() : m_state(new WallclockTimerState) {} WallclockTimer::~WallclockTimer() = default; -void WallclockTimer::start() -{ +void WallclockTimer::start() { m_state->m_is_running = true; m_state->m_start_time = clock_used::now(); } -void WallclockTimer::stop() -{ +void WallclockTimer::stop() { m_state->m_is_running = false; m_state->m_end_time = clock_used::now(); } -double WallclockTimer::runTime() const -{ +double WallclockTimer::runTime() const { duration_unit diff = m_state->m_is_running ? std::chrono::duration_cast<duration_unit>(clock_used::now() - m_state->m_start_time) diff --git a/Fit/Tools/WallclockTimer.h b/Fit/Tools/WallclockTimer.h index 5238892efb43c17d18c393b0fb12d2c9658d59e6..e1f72688ae8f6c4f60ab663841d6bf0c87ce4b48 100644 --- a/Fit/Tools/WallclockTimer.h +++ b/Fit/Tools/WallclockTimer.h @@ -21,8 +21,7 @@ struct WallclockTimerState; //! A timer for measuring real (wall-clock) time spent between 'start' and 'stop' commands. -class WallclockTimer -{ +class WallclockTimer { public: WallclockTimer(); ~WallclockTimer(); diff --git a/GUI/ba3d/def.cpp b/GUI/ba3d/def.cpp index 057e5387c9cf3c76946c7bc15c589c308d230ec4..6c983570967d4acce3099a830f59b24f1816169a 100644 --- a/GUI/ba3d/def.cpp +++ b/GUI/ba3d/def.cpp @@ -17,8 +17,7 @@ static_assert(QT_VERSION >= QT_VERSION_CHECK(5, 5, 1), "requires Qt >= 5.5.1, have " QT_VERSION_STR); -namespace RealSpace -{ +namespace RealSpace { //------------------------------------------------------------------------------ Vector3D::Vector3D() : Vector3D(0, 0, 0) {} @@ -29,61 +28,50 @@ Vector3D::Vector3D(float x_, float y_, float z_) : x(x_), y(y_), z(z_) {} Vector3D::Vector3D(QVector3D const& v) : Vector3D(v.x(), v.y(), v.z()) {} -float Vector3D::length() const -{ +float Vector3D::length() const { return QVector3D(*this).length(); } -Vector3D Vector3D::normalized() const -{ +Vector3D Vector3D::normalized() const { return QVector3D(*this).normalized(); } -Vector3D Vector3D::interpolateTo(const Vector3D& to, float rat) const -{ +Vector3D Vector3D::interpolateTo(const Vector3D& to, float rat) const { return *this * (1 - rat) + to * rat; } -RealSpace::Vector3D::operator QVector3D() const -{ +RealSpace::Vector3D::operator QVector3D() const { return QVector3D(x, y, z); } Vector3D const Vector3D::_0(0, 0, 0), Vector3D::_1(1, 1, 1), Vector3D::_x(1, 0, 0), Vector3D::_y(0, 1, 0), Vector3D::_z(0, 0, 1); -Vector3D cross(const Vector3D& v1, const Vector3D& v2) -{ +Vector3D cross(const Vector3D& v1, const Vector3D& v2) { return QVector3D::crossProduct(v1, v2); } -float dot(const Vector3D& v1, const Vector3D& v2) -{ +float dot(const Vector3D& v1, const Vector3D& v2) { return QVector3D::dotProduct(v1, v2); } -Vector3D operator+(const Vector3D& v) -{ +Vector3D operator+(const Vector3D& v) { return v; } -Vector3D operator-(const Vector3D& v) -{ +Vector3D operator-(const Vector3D& v) { return Vector3D::_0 - v; } -Vector3D operator*(const Vector3D& v, float f) -{ +Vector3D operator*(const Vector3D& v, float f) { return Vector3D(v.x * f, v.y * f, v.z * f); } -Vector3D operator+(const Vector3D& _1, const Vector3D& _2) -{ +Vector3D operator+(const Vector3D& _1, const Vector3D& _2) { return Vector3D(_1.x + _2.x, _1.y + _2.y, _1.z + _2.z); } -Vector3D operator-(const Vector3D& _1, const Vector3D& _2) -{ +Vector3D operator-(const Vector3D& _1, const Vector3D& _2) { return Vector3D(_1.x - _2.x, _1.y - _2.y, _1.z - _2.z); } @@ -91,13 +79,11 @@ Vector3D operator-(const Vector3D& _1, const Vector3D& _2) Range::Range(float r1, float r2) : min(qMin(r1, r2)), max(qMax(r1, r2)) {} -float Range::size() const -{ +float Range::size() const { return max - min; } -float Range::mid() const -{ +float Range::mid() const { return (min + max) / 2; } @@ -106,22 +92,17 @@ float Range::mid() const VectorRange::VectorRange(Range x_, Range y_, Range z_) : x(x_), y(y_), z(z_) {} VectorRange::VectorRange(Vector3D _1, Vector3D _2) - : x(Range(_1.x, _2.x)), y(Range(_1.y, _2.y)), z(Range(_1.z, _2.z)) -{ -} + : x(Range(_1.x, _2.x)), y(Range(_1.y, _2.y)), z(Range(_1.z, _2.z)) {} -Vector3D VectorRange::size() const -{ +Vector3D VectorRange::size() const { return Vector3D(x.size(), y.size(), z.size()); } -Vector3D VectorRange::mid() const -{ +Vector3D VectorRange::mid() const { return Vector3D(x.mid(), y.mid(), z.mid()); } -float VectorRange::length() const -{ +float VectorRange::length() const { return Vector3D(x.size(), y.size(), z.size()).length(); } diff --git a/GUI/ba3d/def.h b/GUI/ba3d/def.h index 46c34086284a2540d4a36953bf9d74ffc64ca6de..62cdbaa27f2e052d90589d0aa46719b5e293dbd6 100644 --- a/GUI/ba3d/def.h +++ b/GUI/ba3d/def.h @@ -26,8 +26,7 @@ #include <QVector3D> -namespace RealSpace -{ +namespace RealSpace { //------------------------------------------------------------------------------ struct Vector3D { diff --git a/GUI/ba3d/model/geometry.cpp b/GUI/ba3d/model/geometry.cpp index b29e0a1308f402ebccf75c4dc8778324eb300ef7..0e9e37c88aad5241664c29d89adfad857b094c58 100644 --- a/GUI/ba3d/model/geometry.cpp +++ b/GUI/ba3d/model/geometry.cpp @@ -16,40 +16,34 @@ #include "Base/Utils/Assert.h" #include "GUI/ba3d/model/model.h" -namespace RealSpace -{ +namespace RealSpace { //------------------------------------------------------------------------------ Geometry::Vert_Normal::Vert_Normal(const Vector3D& v_, const Vector3D& n_) : v(v_), n(n_) {} -void Geometry::Vertices::addVertex(const Vector3D& v, int n) -{ +void Geometry::Vertices::addVertex(const Vector3D& v, int n) { for (int i = 0; i < n; ++i) append(v); } -void Geometry::Vertices::addTriangle(const Vector3D& v1, const Vector3D& v2, const Vector3D& v3) -{ +void Geometry::Vertices::addTriangle(const Vector3D& v1, const Vector3D& v2, const Vector3D& v3) { append(v1); append(v2); append(v3); } void Geometry::Vertices::addQuad(const Vector3D& v1, const Vector3D& v2, const Vector3D& v3, - const Vector3D& v4) -{ + const Vector3D& v4) { addTriangle(v1, v2, v3); addTriangle(v3, v4, v1); } void Geometry::Vertices::addQuad(const Vertices& vs, unsigned i1, unsigned i2, unsigned i3, - unsigned i4) -{ + unsigned i4) { addQuad(vs.at(i1), vs.at(i2), vs.at(i3), vs.at(i4)); } -void Geometry::Vertices::addStrip(const Vertices& vs, const Indices& is) -{ +void Geometry::Vertices::addStrip(const Vertices& vs, const Indices& is) { ASSERT(is.size() >= 3); // at least one triangle for (unsigned i = 0; i + 2 < is.size(); ++i) if (i % 2) @@ -58,8 +52,7 @@ void Geometry::Vertices::addStrip(const Vertices& vs, const Indices& is) addTriangle(vs.at(is.at(i)), vs.at(is.at(2 + i)), vs.at(is.at(1 + i))); } -void Geometry::Vertices::addFan(const Vertices& vs, const Indices& is) -{ +void Geometry::Vertices::addFan(const Vertices& vs, const Indices& is) { ASSERT(is.size() >= 3); // at least one triangle auto& ctr = vs.at(is.at(0)); for (unsigned i = 0; i + 2 < is.size(); ++i) @@ -68,8 +61,7 @@ void Geometry::Vertices::addFan(const Vertices& vs, const Indices& is) //------------------------------------------------------------------------------ -Geometry::Geometry(GeometricID::Key key_) : m_key(key_) -{ +Geometry::Geometry(GeometricID::Key key_) : m_key(key_) { using namespace GeometricID; switch (m_key.id) { @@ -103,14 +95,12 @@ Geometry::Geometry(GeometricID::Key key_) : m_key(key_) } } -Geometry::~Geometry() -{ +Geometry::~Geometry() { // remove self from the store geometryStore().geometryDeleted(*this); } -Geometry::Mesh Geometry::makeMesh(const Vertices& vs, Vertices const* ns) -{ +Geometry::Mesh Geometry::makeMesh(const Vertices& vs, Vertices const* ns) { int nv = vs.count(); ASSERT(0 == nv % 3); ASSERT(!ns || nv == ns->count()); // if normals not given, will be computed @@ -139,15 +129,13 @@ Geometry::Mesh Geometry::makeMesh(const Vertices& vs, Vertices const* ns) return mesh; } -Geometry::Mesh Geometry::makeMesh(const Vertices& vs, const Vertices& ns) -{ +Geometry::Mesh Geometry::makeMesh(const Vertices& vs, const Vertices& ns) { return makeMesh(vs, &ns); } //------------------------------------------------------------------------------ -GeometryHandle GeometryStore::getGeometry(GeometricID::Key key) -{ +GeometryHandle GeometryStore::getGeometry(GeometricID::Key key) { auto it = m_geometries.find(key); if (m_geometries.end() != it) { if (auto g = it->second.lock()) @@ -158,14 +146,12 @@ GeometryHandle GeometryStore::getGeometry(GeometricID::Key key) return g; } -void GeometryStore::geometryDeleted(Geometry const& g) -{ +void GeometryStore::geometryDeleted(Geometry const& g) { emit deletingGeometry(&g); m_geometries.erase(g.m_key); } -GeometryStore& geometryStore() -{ +GeometryStore& geometryStore() { static GeometryStore gs; return gs; } diff --git a/GUI/ba3d/model/geometry.h b/GUI/ba3d/model/geometry.h index 9803e7e79f36bee9c2d0a3e3f33ac5705c579cd7..6505bb3864f9b3fedd44d61c7d1c4386a4cd0b9a 100644 --- a/GUI/ba3d/model/geometry.h +++ b/GUI/ba3d/model/geometry.h @@ -21,14 +21,12 @@ #include <unordered_map> #include <vector> -namespace RealSpace -{ +namespace RealSpace { class Buffer; class GeometryStore; -class Geometry -{ +class Geometry { friend class Buffer; friend class GeometryStore; @@ -94,8 +92,7 @@ private: // a single store keeps existing geometries for sharing -class GeometryStore : public QObject -{ +class GeometryStore : public QObject { Q_OBJECT friend class Geometry; diff --git a/GUI/ba3d/model/geometry/box.cpp b/GUI/ba3d/model/geometry/box.cpp index ce2f0391e9f651887fa23003c9c92eba60800665..27da5e225e903967afb996a9587250e4a2032a37 100644 --- a/GUI/ba3d/model/geometry/box.cpp +++ b/GUI/ba3d/model/geometry/box.cpp @@ -15,11 +15,9 @@ #include "Base/Utils/Assert.h" #include "GUI/ba3d/model/geometry.h" -namespace RealSpace -{ +namespace RealSpace { -Geometry::Mesh Geometry::meshBox() -{ +Geometry::Mesh Geometry::meshBox() { float const D = .5f; Vertices vs_; diff --git a/GUI/ba3d/model/geometry/column.cpp b/GUI/ba3d/model/geometry/column.cpp index 0f4bc4ab8bd74144a8fc5291ade31347c1bd24c1..d8ae0c61231d6e61261f57c64fcc7ff07adaacba 100644 --- a/GUI/ba3d/model/geometry/column.cpp +++ b/GUI/ba3d/model/geometry/column.cpp @@ -16,11 +16,9 @@ #include "GUI/ba3d/model/geometry.h" #include <qmath.h> -namespace RealSpace -{ +namespace RealSpace { -Geometry::Mesh Geometry::meshColumn(float ratio_Rt_Rb, float numSides) -{ +Geometry::Mesh Geometry::meshColumn(float ratio_Rt_Rb, float numSides) { int const sides = qRound(numSides); bool const smooth = (0 == sides); // sides = 0 implies smooth -> e.g. cylinder int const slices = smooth ? SLICES : sides; diff --git a/GUI/ba3d/model/geometry/cuboctahedron.cpp b/GUI/ba3d/model/geometry/cuboctahedron.cpp index 0064aa36bb34753f5803739a69ef8be203b085c7..d190444c127f5eeac48f719e03786bc2a8d4be76 100644 --- a/GUI/ba3d/model/geometry/cuboctahedron.cpp +++ b/GUI/ba3d/model/geometry/cuboctahedron.cpp @@ -16,11 +16,9 @@ #include "GUI/ba3d/model/geometry.h" #include <qmath.h> -namespace RealSpace -{ +namespace RealSpace { -Geometry::Mesh Geometry::meshCuboctahedron(float rH, float alpha, float H) -{ // t/D +Geometry::Mesh Geometry::meshCuboctahedron(float rH, float alpha, float H) { // t/D // alpha is the angle between the common square interface and one of the side faces (alpha for // both the two truncated pyramids is the same) diff --git a/GUI/ba3d/model/geometry/dodecahedron.cpp b/GUI/ba3d/model/geometry/dodecahedron.cpp index e0783cdb356b5374d91f45fa780a8defc4e7fc3d..fc587adf4b170e99cf68191e9bc77a5ec955be57 100644 --- a/GUI/ba3d/model/geometry/dodecahedron.cpp +++ b/GUI/ba3d/model/geometry/dodecahedron.cpp @@ -17,11 +17,9 @@ #include <QQuaternion> #include <qmath.h> -namespace RealSpace -{ +namespace RealSpace { -Geometry::Mesh Geometry::meshDodecahedron() -{ +Geometry::Mesh Geometry::meshDodecahedron() { const float GR = GoldenRatio, G1 = 1 / GR; Vertices vs_; diff --git a/GUI/ba3d/model/geometry/icosahedron.cpp b/GUI/ba3d/model/geometry/icosahedron.cpp index e59612ac44310cf6e219623699ed30dbc73f4782..de3454f04243a357eb9d5feb365ad1450259063b 100644 --- a/GUI/ba3d/model/geometry/icosahedron.cpp +++ b/GUI/ba3d/model/geometry/icosahedron.cpp @@ -17,11 +17,9 @@ #include <QQuaternion> #include <qmath.h> -namespace RealSpace -{ +namespace RealSpace { -Geometry::Mesh Geometry::meshIcosahedron() -{ +Geometry::Mesh Geometry::meshIcosahedron() { Vertices vs_(12); // 12 vertices of the icosahedron retrieved from Icosahedron.cpp const float E = 1.0; // edge diff --git a/GUI/ba3d/model/geometry/plane.cpp b/GUI/ba3d/model/geometry/plane.cpp index eb951d152e1eaf7980371ac7a84532eae9e7cb70..60bfc928180e28b7cbc54c88772d2390c4a02163 100644 --- a/GUI/ba3d/model/geometry/plane.cpp +++ b/GUI/ba3d/model/geometry/plane.cpp @@ -15,11 +15,9 @@ #include "Base/Utils/Assert.h" #include "GUI/ba3d/model/geometry.h" -namespace RealSpace -{ +namespace RealSpace { -Geometry::Mesh Geometry::meshPlane() -{ +Geometry::Mesh Geometry::meshPlane() { float const D = .5f; Vertices vs; diff --git a/GUI/ba3d/model/geometry/ripple.cpp b/GUI/ba3d/model/geometry/ripple.cpp index e65c0199ec6e722158d21f1f5955e0e6d6fd1e40..db1f6c936c8bc88128f02d04d7a431bd82e87201 100644 --- a/GUI/ba3d/model/geometry/ripple.cpp +++ b/GUI/ba3d/model/geometry/ripple.cpp @@ -16,11 +16,9 @@ #include "GUI/ba3d/model/geometry.h" #include <qmath.h> -namespace RealSpace -{ +namespace RealSpace { -Geometry::Mesh Geometry::meshRipple(float numSides, float ratio_asymmetry_W) -{ +Geometry::Mesh Geometry::meshRipple(float numSides, float ratio_asymmetry_W) { int const sides = qRound(numSides); bool const smooth = (0 == sides); // sides = 0 implies smooth -> e.g. cosine ripple int const slices = smooth ? 4 * SLICES : sides; diff --git a/GUI/ba3d/model/geometry/sphere.cpp b/GUI/ba3d/model/geometry/sphere.cpp index 0b28dfd72239903b30ff2074a99cf2312b566058..2561e2a083a52258c39ebb5702bdbbbef9e26e5e 100644 --- a/GUI/ba3d/model/geometry/sphere.cpp +++ b/GUI/ba3d/model/geometry/sphere.cpp @@ -16,13 +16,11 @@ #include "GUI/ba3d/model/geometry.h" #include <qmath.h> -namespace RealSpace -{ +namespace RealSpace { // cut: 0..1 - how much is cut off from the bottom // removedTop - how much fraction of the radius is removed from the top -Geometry::Mesh Geometry::meshSphere(float cut, float baseShift, float removedTop) -{ +Geometry::Mesh Geometry::meshSphere(float cut, float baseShift, float removedTop) { if (1 <= cut) return Mesh(); cut = qMax(0.f, cut); diff --git a/GUI/ba3d/model/geometry/truncbox.cpp b/GUI/ba3d/model/geometry/truncbox.cpp index 25e52672b5483b71881a12709ffa4a13f4a8ddfb..847244f9f0db7695c6a2179754702192f869c2e5 100644 --- a/GUI/ba3d/model/geometry/truncbox.cpp +++ b/GUI/ba3d/model/geometry/truncbox.cpp @@ -15,11 +15,9 @@ #include "Base/Utils/Assert.h" #include "GUI/ba3d/model/geometry.h" -namespace RealSpace -{ +namespace RealSpace { -Geometry::Mesh Geometry::meshTruncBox(float tD) -{ // t/D +Geometry::Mesh Geometry::meshTruncBox(float tD) { // t/D if (tD <= 0) return meshBox(); diff --git a/GUI/ba3d/model/geometry_inc.cpp b/GUI/ba3d/model/geometry_inc.cpp index ed9f53161a3c282c9abb02adcf412e0c23b99999..fe6a7e5b973c8bba8ccb3b7efb0cacdf101e11e4 100644 --- a/GUI/ba3d/model/geometry_inc.cpp +++ b/GUI/ba3d/model/geometry_inc.cpp @@ -16,8 +16,7 @@ #include <cmath> #include <functional> -namespace RealSpace -{ +namespace RealSpace { // Useful constants: const float GoldenRatio = (1.f + std::sqrt(5.f)) / 2.f; @@ -26,17 +25,13 @@ const float DodecahedronL2R = 4.f / std::sqrt(3.f) / (1.f + std::sqrt(5.f)); // Keys and hash: GeometricID::Key::Key(BaseShape id_, float p1_, float p2_, float p3_) - : id(id_), p1(p1_), p2(p2_), p3(p3_) -{ -} + : id(id_), p1(p1_), p2(p2_), p3(p3_) {} -bool GeometricID::Key::operator==(Key const& other) const -{ +bool GeometricID::Key::operator==(Key const& other) const { return id == other.id && p1 == other.p1 && p2 == other.p2; } -std::size_t GeometricID::KeyHash::operator()(const GeometricID::Key& key) const noexcept -{ +std::size_t GeometricID::KeyHash::operator()(const GeometricID::Key& key) const noexcept { { size_t h1 = std::hash<int>{}(static_cast<int>(key.id)); size_t h2 = std::hash<float>{}(key.p1); diff --git a/GUI/ba3d/model/geometry_inc.h b/GUI/ba3d/model/geometry_inc.h index c2f2da955751fc0bf97d44043b6120f4084928a9..b42f04768dbc0ff3161c49a405805cfb95ae3ad2 100644 --- a/GUI/ba3d/model/geometry_inc.h +++ b/GUI/ba3d/model/geometry_inc.h @@ -20,8 +20,7 @@ // include to use geometry basics, without details -namespace RealSpace -{ +namespace RealSpace { //------------------------------------------------------------------------------ class Geometry; @@ -34,8 +33,7 @@ extern const float GoldenRatio; extern const float IcosahedronL2R; // L/R conversion extern const float DodecahedronL2R; -namespace GeometricID -{ +namespace GeometricID { // Enum id for basic shapes enum class BaseShape { diff --git a/GUI/ba3d/model/layer.cpp b/GUI/ba3d/model/layer.cpp index 8ca743e03839cda4a2071c7025fa35a890bd06a3..1853ebddf7aeb458835280d4bc7b26d77b70b0c2 100644 --- a/GUI/ba3d/model/layer.cpp +++ b/GUI/ba3d/model/layer.cpp @@ -14,11 +14,9 @@ #include "GUI/ba3d/model/layer.h" -namespace RealSpace -{ +namespace RealSpace { -Layer::Layer(VectorRange d) : Object(GeometricID::Key(GeometricID::BaseShape::Box)) -{ +Layer::Layer(VectorRange d) : Object(GeometricID::Key(GeometricID::BaseShape::Box)) { transform(d.size(), Vector3D::_0, d.mid()); } } // namespace RealSpace diff --git a/GUI/ba3d/model/layer.h b/GUI/ba3d/model/layer.h index 00e6ba4dfb632b81cb56f79ebc1c7e350c08e0fa..87b4fac71a3880e5957538183dfe27353756abe8 100644 --- a/GUI/ba3d/model/layer.h +++ b/GUI/ba3d/model/layer.h @@ -17,12 +17,10 @@ #include "GUI/ba3d/model/object.h" -namespace RealSpace -{ +namespace RealSpace { // particle layer: a transparent box -class Layer : public Object -{ +class Layer : public Object { public: Layer(VectorRange); }; diff --git a/GUI/ba3d/model/model.cpp b/GUI/ba3d/model/model.cpp index 1c2b825aab42c1e961a4dd2d32409c143d1b103d..8d174bc17328ef50ff2e3602a234c74653463f2f 100644 --- a/GUI/ba3d/model/model.cpp +++ b/GUI/ba3d/model/model.cpp @@ -16,13 +16,11 @@ #include "Base/Utils/Assert.h" #include "GUI/ba3d/model/geometry.h" -namespace RealSpace -{ +namespace RealSpace { Model::Model() : defCamPos(Vector3D::_1, Vector3D::_0, Vector3D::_z) {} -Model::~Model() -{ +Model::~Model() { for (auto o : objects) { o->model = nullptr; delete o; @@ -34,22 +32,19 @@ Model::~Model() } } -void Model::clearOpaque() -{ +void Model::clearOpaque() { while (!objects.isEmpty()) delete objects.first(); emit updated(false); } -void Model::clearBlend() -{ +void Model::clearBlend() { while (!objectsBlend.isEmpty()) delete objectsBlend.first(); emit updated(false); } -Particles::Particle* Model::newParticle(Particles::EShape k, float R) -{ +Particles::Particle* Model::newParticle(Particles::EShape k, float R) { using namespace Particles; float D = 2 * R; @@ -117,24 +112,21 @@ Particles::Particle* Model::newParticle(Particles::EShape k, float R) return nullptr; } -void Model::add(Object* o) -{ +void Model::add(Object* o) { ASSERT(o); ASSERT(!o->model); o->model = this; objects.append(o); } -void Model::addBlend(Object* o) -{ +void Model::addBlend(Object* o) { ASSERT(o); ASSERT(!o->model); o->model = this; objectsBlend.append(o); } -void Model::rem(Object* o) -{ +void Model::rem(Object* o) { int i; if ((i = objects.indexOf(o)) >= 0) objects.remove(i); @@ -147,30 +139,26 @@ void Model::rem(Object* o) o->model = nullptr; } -void Model::releaseGeometries() -{ +void Model::releaseGeometries() { for (auto o : objects) o->releaseGeometry(); for (auto o : objectsBlend) o->releaseGeometry(); } -bool Model::modelIsEmpty() -{ +bool Model::modelIsEmpty() { if (objects.isEmpty() && objectsBlend.isEmpty()) return true; else return false; } -void Model::draw(Canvas& canvas) const -{ +void Model::draw(Canvas& canvas) const { for (auto o : objects) o->draw(canvas); } -void Model::drawBlend(Canvas& canvas) const -{ +void Model::drawBlend(Canvas& canvas) const { for (auto o : objectsBlend) o->draw(canvas); } diff --git a/GUI/ba3d/model/model.h b/GUI/ba3d/model/model.h index 50ec6b8714ed664efddca12d13aaa8365d44a959..e7f9d5249adbbfdadd509014c8473a9164e6d58c 100644 --- a/GUI/ba3d/model/model.h +++ b/GUI/ba3d/model/model.h @@ -19,15 +19,13 @@ #include "GUI/ba3d/view/camera.h" #include <QVector> -namespace RealSpace -{ +namespace RealSpace { //------------------------------------------------------------------------------ class Canvas; class Object; -class Model : public QObject -{ +class Model : public QObject { Q_OBJECT friend class Canvas; friend class Camera; diff --git a/GUI/ba3d/model/object.cpp b/GUI/ba3d/model/object.cpp index 027d95b5d01cfcf0cbe2b7bd584ef2be01f361a8..f43e8fe9dca5754d187ff9ea67c39e0b9b85e407 100644 --- a/GUI/ba3d/model/object.cpp +++ b/GUI/ba3d/model/object.cpp @@ -17,15 +17,13 @@ #include "GUI/ba3d/view/canvas.h" #include <cmath> -namespace -{ +namespace { QQuaternion EulerToQuaternion(const RealSpace::Vector3D& euler); RealSpace::Vector3D QuaternionToEuler(const QQuaternion& q); } // namespace -namespace RealSpace -{ +namespace RealSpace { #ifdef Q_OS_LINUX QColor const clrObject = Qt::lightGray; @@ -33,32 +31,27 @@ QColor const clrObject = Qt::lightGray; QColor const clrObject = Qt::black; #endif -Object::Object(GeometricID::Key gky_) : color(clrObject), isNull(false), model(nullptr), gky(gky_) -{ -} +Object::Object(GeometricID::Key gky_) + : color(clrObject), isNull(false), model(nullptr), gky(gky_) {} -Object::~Object() -{ +Object::~Object() { releaseGeometry(); if (model) model->rem(this); } -void Object::transform(float scale, Vector3D rotate, Vector3D translate) -{ +void Object::transform(float scale, Vector3D rotate, Vector3D translate) { transform(Vector3D(scale, scale, scale), rotate, translate); } -void Object::transform(Vector3D scale, Vector3D rotate, Vector3D translate) -{ +void Object::transform(Vector3D scale, Vector3D rotate, Vector3D translate) { mat.setToIdentity(); mat.translate(translate); mat.rotate(EulerToQuaternion(rotate)); mat.scale(scale); } -void Object::transform(Vector3D turn, Vector3D scale, Vector3D rotate, Vector3D translate) -{ +void Object::transform(Vector3D turn, Vector3D scale, Vector3D rotate, Vector3D translate) { // 1. turn to align with x/y/z as needed // 2. scale to desired x/y/z size // 3. rotate as needed by the scene @@ -73,8 +66,7 @@ void Object::transform(Vector3D turn, Vector3D scale, Vector3D rotate, Vector3D // This method allows the addition of an extrinsic global rotation to an object i.e. // it rotates the object about the global origin of the coordinate system void Object::addExtrinsicRotation(Vector3D turn, Vector3D scale, Vector3D& rotate, - Vector3D rotateExtrinsic, Vector3D& translate) -{ + Vector3D rotateExtrinsic, Vector3D& translate) { mat.setToIdentity(); mat.rotate(EulerToQuaternion(rotateExtrinsic)); mat.translate(translate); @@ -90,13 +82,11 @@ void Object::addExtrinsicRotation(Vector3D turn, Vector3D scale, Vector3D& rotat translate = EulerToQuaternion(rotateExtrinsic).rotatedVector(translate); } -void Object::releaseGeometry() -{ +void Object::releaseGeometry() { geo.reset(); } -void Object::draw(Canvas& canvas) -{ +void Object::draw(Canvas& canvas) { if (isNull) return; @@ -107,10 +97,8 @@ void Object::draw(Canvas& canvas) } // namespace RealSpace -namespace -{ -QQuaternion EulerToQuaternion(const RealSpace::Vector3D& euler) -{ +namespace { +QQuaternion EulerToQuaternion(const RealSpace::Vector3D& euler) { float cpsi2 = std::cos(euler.x / 2.0f); float spsi2 = std::sin(euler.x / 2.0f); float cth2 = std::cos(euler.y / 2.0f); @@ -124,8 +112,7 @@ QQuaternion EulerToQuaternion(const RealSpace::Vector3D& euler) return QQuaternion{a, b, c, d}; } -RealSpace::Vector3D QuaternionToEuler(const QQuaternion& q) -{ +RealSpace::Vector3D QuaternionToEuler(const QQuaternion& q) { auto qvec = q.toVector4D(); float a = qvec.w(); // scalar part of quaternion diff --git a/GUI/ba3d/model/object.h b/GUI/ba3d/model/object.h index a6f92d43420031c65d15d4e6713b22bae2941650..0e2fae02b1999977fad031772134f7631b42f03b 100644 --- a/GUI/ba3d/model/object.h +++ b/GUI/ba3d/model/object.h @@ -19,14 +19,12 @@ #include <QColor> #include <QMatrix4x4> -namespace RealSpace -{ +namespace RealSpace { class Model; class Canvas; -class Object -{ +class Object { friend class Model; public: diff --git a/GUI/ba3d/model/particles.cpp b/GUI/ba3d/model/particles.cpp index 9315c26d1cb8f8c5052a77dc3700e8303e82b084..b2354439256a47e6201dbbc92bc6e9c92bd93e75 100644 --- a/GUI/ba3d/model/particles.cpp +++ b/GUI/ba3d/model/particles.cpp @@ -15,13 +15,10 @@ #include "GUI/ba3d/model/particles.h" #include <cmath> -namespace RealSpace -{ -namespace Particles -{ +namespace RealSpace { +namespace Particles { -QString const& name(EShape k) -{ +QString const& name(EShape k) { static QString names[] = { "", "FullSphere", @@ -62,34 +59,28 @@ using namespace GeometricID; Particle::Particle(Key key) : Object(key), scale(Vector3D::_1) {} -void Particle::set() -{ +void Particle::set() { transform(Vector3D::_0, Vector3D::_0); } -void Particle::transform(Vector3D rotate_, Vector3D translate_) -{ +void Particle::transform(Vector3D rotate_, Vector3D translate_) { Object::transform(turn, scale, (rotate = rotate_), offset + (translate = translate_)); } -void Particle::fancy(Vector3D rotate, float r) -{ +void Particle::fancy(Vector3D rotate, float r) { Object::transform(turn, scale * r, rotate, offset + translate); } -void Particle::addTransform(Vector3D rotate_, Vector3D translate_) -{ +void Particle::addTransform(Vector3D rotate_, Vector3D translate_) { Object::transform(turn, scale, (rotate = rotate + rotate_), offset + (translate = translate + translate_)); } -void Particle::addTranslation(Vector3D translate_) -{ +void Particle::addTranslation(Vector3D translate_) { Object::transform(turn, scale, rotate, offset + (translate = translate + translate_)); } -void Particle::addExtrinsicRotation(Vector3D rotateExtrinsic) -{ +void Particle::addExtrinsicRotation(Vector3D rotateExtrinsic) { Object::addExtrinsicRotation(turn, scale, rotate, rotateExtrinsic, (translate = offset + translate)); } @@ -105,8 +96,7 @@ static float const sqrt3f = std::sqrt(3.f); AnisoPyramid::AnisoPyramid(float L, float W, float H, float alpha) : Particle(Key(BaseShape::Column, - (1.0f - H / (std::sqrt((L * L / 4) + (W * W / 4)) * std::tan(alpha))), 4)) -{ + (1.0f - H / (std::sqrt((L * L / 4) + (W * W / 4)) * std::tan(alpha))), 4)) { isNull = (L <= 0 || W <= 0 || H <= 0 || alpha <= 0); turn = Vector3D(0, 0, 45 * pi / 180.0f); scale = Vector3D(L * sqrt2f, W * sqrt2f, H); @@ -114,8 +104,7 @@ AnisoPyramid::AnisoPyramid(float L, float W, float H, float alpha) set(); } -BarGauss::BarGauss(float L, float W, float H) : Particle(Key(BaseShape::Column, 1.0f, 4)) -{ +BarGauss::BarGauss(float L, float W, float H) : Particle(Key(BaseShape::Column, 1.0f, 4)) { isNull = (L < 0 || W < 0 || H < 0) || (L <= 0 && W <= 0 && H <= 0); turn = Vector3D(0, 0, 45 * pi / 180.0f); scale = Vector3D(L * sqrt2f, W * sqrt2f, H); @@ -123,8 +112,7 @@ BarGauss::BarGauss(float L, float W, float H) : Particle(Key(BaseShape::Column, set(); } -BarLorentz::BarLorentz(float L, float W, float H) : Particle(Key(BaseShape::Column, 1.0f, 4)) -{ +BarLorentz::BarLorentz(float L, float W, float H) : Particle(Key(BaseShape::Column, 1.0f, 4)) { isNull = (L < 0 || W < 0 || H < 0) || (L <= 0 && W <= 0 && H <= 0); turn = Vector3D(0, 0, 45 * pi / 180.0f); scale = Vector3D(L * sqrt2f, W * sqrt2f, H); @@ -132,8 +120,7 @@ BarLorentz::BarLorentz(float L, float W, float H) : Particle(Key(BaseShape::Colu set(); } -Box::Box(float L, float W, float H) : Particle(Key(BaseShape::Column, 1.0f, 4)) -{ +Box::Box(float L, float W, float H) : Particle(Key(BaseShape::Column, 1.0f, 4)) { isNull = (L < 0 || W < 0 || H < 0) || (L <= 0 && W <= 0 && H <= 0); turn = Vector3D(0, 0, 45 * pi / 180.0f); scale = Vector3D(L * sqrt2f, W * sqrt2f, H); @@ -142,8 +129,7 @@ Box::Box(float L, float W, float H) : Particle(Key(BaseShape::Column, 1.0f, 4)) } Cone::Cone(float R, float H, float alpha) - : Particle(Key(BaseShape::Column, (1.0f - H / (R * std::tan(alpha))), 0)) -{ + : Particle(Key(BaseShape::Column, (1.0f - H / (R * std::tan(alpha))), 0)) { isNull = (R <= 0 || H <= 0 || alpha <= 0); scale = Vector3D(R * 2, R * 2, H); offset = Vector3D(0, 0, 0); @@ -151,8 +137,7 @@ Cone::Cone(float R, float H, float alpha) } Cone6::Cone6(float R, float H, float alpha) - : Particle(Key(BaseShape::Column, (1.0f - H / (R * std::tan(alpha))), 6)) -{ + : Particle(Key(BaseShape::Column, (1.0f - H / (R * std::tan(alpha))), 6)) { isNull = (R <= 0 || H <= 0 || alpha <= 0); scale = Vector3D(R * 2, R * 2, H); offset = Vector3D(0, 0, 0); @@ -160,24 +145,21 @@ Cone6::Cone6(float R, float H, float alpha) } Cuboctahedron::Cuboctahedron(float L, float H, float rH, float alpha) - : Particle(Key(BaseShape::Cuboctahedron, rH, alpha, H / L)) -{ + : Particle(Key(BaseShape::Cuboctahedron, rH, alpha, H / L)) { isNull = (L <= 0 || H <= 0 || rH <= 0 || alpha >= pi2f); scale = Vector3D(L, L, L); offset = Vector3D(0, 0, 0); set(); } -Cylinder::Cylinder(float R, float H) : Particle(Key(BaseShape::Column, 1.0f, 0)) -{ +Cylinder::Cylinder(float R, float H) : Particle(Key(BaseShape::Column, 1.0f, 0)) { isNull = (R <= 0 || H <= 0); scale = Vector3D(R * 2, R * 2, H); offset = Vector3D(0, 0, 0); set(); } -Dodecahedron::Dodecahedron(float L) : Particle(Key(BaseShape::Dodecahedron)) -{ +Dodecahedron::Dodecahedron(float L) : Particle(Key(BaseShape::Dodecahedron)) { isNull = (L <= 0); float R = L / DodecahedronL2R; scale = Vector3D(R * 2, R * 2, R * 2); @@ -185,8 +167,7 @@ Dodecahedron::Dodecahedron(float L) : Particle(Key(BaseShape::Dodecahedron)) set(); } -Dot::Dot() : Particle(Key(BaseShape::Sphere, 0, 0.5f)) -{ +Dot::Dot() : Particle(Key(BaseShape::Sphere, 0, 0.5f)) { float R = 1.0f; scale = Vector3D(R * 2); offset = Vector3D(0, 0, 0); @@ -194,24 +175,21 @@ Dot::Dot() : Particle(Key(BaseShape::Sphere, 0, 0.5f)) } EllipsoidalCylinder::EllipsoidalCylinder(float Ra, float Rb, float H) - : Particle(Key(BaseShape::Column, 1.0f, 0)) -{ + : Particle(Key(BaseShape::Column, 1.0f, 0)) { isNull = (Ra <= 0 || Rb <= 0 || H <= 0); scale = Vector3D(Ra * 2, Rb * 2, H); offset = Vector3D(0, 0, 0); set(); } -FullSphere::FullSphere(float R) : Particle(Key(BaseShape::Sphere, 0, 0.5f)) -{ +FullSphere::FullSphere(float R) : Particle(Key(BaseShape::Sphere, 0, 0.5f)) { isNull = (R <= 0); scale = Vector3D(R * 2); offset = Vector3D(0, 0, 0); set(); } -FullSpheroid::FullSpheroid(float R, float H) : Particle(Key(BaseShape::Sphere, 0, 0.5f)) -{ +FullSpheroid::FullSpheroid(float R, float H) : Particle(Key(BaseShape::Sphere, 0, 0.5f)) { isNull = (R <= 0 || H <= 0); scale = Vector3D(R * 2, R * 2, H); offset = Vector3D(0, 0, 0); @@ -219,24 +197,21 @@ FullSpheroid::FullSpheroid(float R, float H) : Particle(Key(BaseShape::Sphere, 0 } HemiEllipsoid::HemiEllipsoid(float Ra, float Rb, float H) - : Particle(Key(BaseShape::Sphere, .5f, 0.0f)) -{ + : Particle(Key(BaseShape::Sphere, .5f, 0.0f)) { isNull = (Ra <= 0 || Rb <= 0 || H <= 0); scale = Vector3D(Ra * 2, Rb * 2, H * 2); offset = Vector3D(0, 0, 0); set(); } -Icosahedron::Icosahedron(float L) : Particle(Key(BaseShape::Icosahedron)) -{ +Icosahedron::Icosahedron(float L) : Particle(Key(BaseShape::Icosahedron)) { isNull = (L <= 0); scale = Vector3D(L, L, L); offset = Vector3D(0, 0, 0); set(); } -Prism3::Prism3(float L, float H) : Particle(Key(BaseShape::Column, 1.0f, 3)) -{ +Prism3::Prism3(float L, float H) : Particle(Key(BaseShape::Column, 1.0f, 3)) { isNull = (L <= 0 || H <= 0); float D = L / sqrt3f; scale = Vector3D(D * 2, D * 2, H); @@ -244,8 +219,7 @@ Prism3::Prism3(float L, float H) : Particle(Key(BaseShape::Column, 1.0f, 3)) set(); } -Prism6::Prism6(float R, float H) : Particle(Key(BaseShape::Column, 1.0f, 6)) -{ +Prism6::Prism6(float R, float H) : Particle(Key(BaseShape::Column, 1.0f, 6)) { isNull = (R <= 0 || H <= 0); scale = Vector3D(R * 2, R * 2, H); offset = Vector3D(0, 0, 0); @@ -253,8 +227,7 @@ Prism6::Prism6(float R, float H) : Particle(Key(BaseShape::Column, 1.0f, 6)) } Pyramid::Pyramid(float L, float H, float alpha) - : Particle(Key(BaseShape::Column, (1.0f - H / (std::sqrt(L * L / 2) * std::tan(alpha))), 4)) -{ + : Particle(Key(BaseShape::Column, (1.0f - H / (std::sqrt(L * L / 2) * std::tan(alpha))), 4)) { isNull = (L <= 0 || H <= 0 || alpha <= 0); float L2 = L * sqrt2f; turn = Vector3D(0, 0, 45 * pi / 180.0f); @@ -263,8 +236,8 @@ Pyramid::Pyramid(float L, float H, float alpha) set(); } -CosineRippleBox::CosineRippleBox(float L, float W, float H) : Particle(Key(BaseShape::Ripple, 0, 0)) -{ +CosineRippleBox::CosineRippleBox(float L, float W, float H) + : Particle(Key(BaseShape::Ripple, 0, 0)) { isNull = (L < 0 || W < 0 || H < 0) || (L <= 0 && W <= 0 && H <= 0); turn = Vector3D(0, 0, 0); scale = Vector3D(L, W, H); @@ -273,8 +246,7 @@ CosineRippleBox::CosineRippleBox(float L, float W, float H) : Particle(Key(BaseS } CosineRippleGauss::CosineRippleGauss(float L, float W, float H) - : Particle(Key(BaseShape::Ripple, 0, 0)) -{ + : Particle(Key(BaseShape::Ripple, 0, 0)) { isNull = (L < 0 || W < 0 || H < 0) || (L <= 0 && W <= 0 && H <= 0); turn = Vector3D(0, 0, 0); scale = Vector3D(L, W, H); @@ -283,8 +255,7 @@ CosineRippleGauss::CosineRippleGauss(float L, float W, float H) } CosineRippleLorentz::CosineRippleLorentz(float L, float W, float H) - : Particle(Key(BaseShape::Ripple, 0, 0)) -{ + : Particle(Key(BaseShape::Ripple, 0, 0)) { isNull = (L < 0 || W < 0 || H < 0) || (L <= 0 && W <= 0 && H <= 0); turn = Vector3D(0, 0, 0); scale = Vector3D(L, W, H); @@ -293,8 +264,7 @@ CosineRippleLorentz::CosineRippleLorentz(float L, float W, float H) } SawtoothRippleBox::SawtoothRippleBox(float L, float W, float H) - : Particle(Key(BaseShape::Ripple, 0, 0)) -{ + : Particle(Key(BaseShape::Ripple, 0, 0)) { isNull = (L < 0 || W < 0 || H < 0) || (L <= 0 && W <= 0 && H <= 0); turn = Vector3D(0, 0, 0); scale = Vector3D(L, W, H); @@ -303,8 +273,7 @@ SawtoothRippleBox::SawtoothRippleBox(float L, float W, float H) } SawtoothRippleGauss::SawtoothRippleGauss(float L, float W, float H) - : Particle(Key(BaseShape::Ripple, 0, 0)) -{ + : Particle(Key(BaseShape::Ripple, 0, 0)) { isNull = (L < 0 || W < 0 || H < 0) || (L <= 0 && W <= 0 && H <= 0); turn = Vector3D(0, 0, 0); scale = Vector3D(L, W, H); @@ -313,8 +282,7 @@ SawtoothRippleGauss::SawtoothRippleGauss(float L, float W, float H) } SawtoothRippleLorentz::SawtoothRippleLorentz(float L, float W, float H) - : Particle(Key(BaseShape::Ripple, 0, 0)) -{ + : Particle(Key(BaseShape::Ripple, 0, 0)) { isNull = (L < 0 || W < 0 || H < 0) || (L <= 0 && W <= 0 && H <= 0); turn = Vector3D(0, 0, 0); scale = Vector3D(L, W, H); @@ -323,8 +291,7 @@ SawtoothRippleLorentz::SawtoothRippleLorentz(float L, float W, float H) } Tetrahedron::Tetrahedron(float L, float H, float alpha) - : Particle(Key(BaseShape::Column, (1.0f - H / (L / sqrt3f * std::tan(alpha))), 3)) -{ + : Particle(Key(BaseShape::Column, (1.0f - H / (L / sqrt3f * std::tan(alpha))), 3)) { isNull = (L <= 0 || H <= 0 || alpha <= 0); float D = L / sqrt3f; scale = Vector3D(D * 2, D * 2, H); @@ -332,8 +299,7 @@ Tetrahedron::Tetrahedron(float L, float H, float alpha) set(); } -TruncatedCube::TruncatedCube(float L, float t) : Particle(Key(BaseShape::TruncatedBox, 2 * t / L)) -{ +TruncatedCube::TruncatedCube(float L, float t) : Particle(Key(BaseShape::TruncatedBox, 2 * t / L)) { isNull = (L <= 0); scale = Vector3D(L, L, L); offset = Vector3D(0, 0, 0); @@ -341,8 +307,7 @@ TruncatedCube::TruncatedCube(float L, float t) : Particle(Key(BaseShape::Truncat } TruncatedSphere::TruncatedSphere(float R, float H, float deltaH) - : Particle(Key(BaseShape::Sphere, 1 - H / R / 2, (H - R) / R / 2, deltaH / R / 2)) -{ + : Particle(Key(BaseShape::Sphere, 1 - H / R / 2, (H - R) / R / 2, deltaH / R / 2)) { isNull = (R <= 0 || H <= 0); scale = Vector3D(R * 2); offset = Vector3D(0, 0, 0); @@ -350,9 +315,8 @@ TruncatedSphere::TruncatedSphere(float R, float H, float deltaH) } TruncatedSpheroid::TruncatedSpheroid(float R, float H, float fp, float deltaH) - : Particle( - Key(BaseShape::Sphere, 1 - H / fp / R / 2, (H - fp * R) / fp / R / 2, deltaH / fp / R / 2)) -{ + : Particle(Key(BaseShape::Sphere, 1 - H / fp / R / 2, (H - fp * R) / fp / R / 2, + deltaH / fp / R / 2)) { isNull = (R <= 0 || H <= 0 || fp <= 0); scale = Vector3D(R * 2, R * 2, fp * R * 2); offset = Vector3D(0, 0, 0); diff --git a/GUI/ba3d/model/particles.h b/GUI/ba3d/model/particles.h index 4e22cfcf5cfd3625d3be4e315dd43f339b9f9eb1..69e20988a3b3fe0715ad927914df7193ce25f00a 100644 --- a/GUI/ba3d/model/particles.h +++ b/GUI/ba3d/model/particles.h @@ -17,10 +17,8 @@ #include "GUI/ba3d/model/object.h" -namespace RealSpace -{ -namespace Particles -{ +namespace RealSpace { +namespace Particles { enum class EShape { None, @@ -58,8 +56,7 @@ QString const& name(EShape); //------------------------------------------------------------------------------ -class Particle : public Object -{ +class Particle : public Object { protected: Particle(GeometricID::Key); Vector3D turn; // turn before scale @@ -84,176 +81,147 @@ public: //------------------------------------------------------------------------------ // follow BornAgain manual, chapter 11, Particle form factors -class FullSphere : public Particle -{ +class FullSphere : public Particle { public: FullSphere(float R); }; -class FullSpheroid : public Particle -{ +class FullSpheroid : public Particle { public: FullSpheroid(float R, float H); }; -class Cylinder : public Particle -{ +class Cylinder : public Particle { public: Cylinder(float R, float H); }; -class TruncatedSphere : public Particle -{ +class TruncatedSphere : public Particle { public: TruncatedSphere(float R, float H, float deltaH = 0.0f); }; -class TruncatedSpheroid : public Particle -{ +class TruncatedSpheroid : public Particle { public: TruncatedSpheroid(float R, float H, float fp, float deltaH = 0.0f); }; -class Cone : public Particle -{ +class Cone : public Particle { public: Cone(float R, float H, float alpha); }; -class Icosahedron : public Particle -{ +class Icosahedron : public Particle { public: Icosahedron(float L); }; -class Dodecahedron : public Particle -{ +class Dodecahedron : public Particle { public: Dodecahedron(float L); }; -class Dot : public Particle -{ +class Dot : public Particle { public: Dot(); }; -class TruncatedCube : public Particle -{ +class TruncatedCube : public Particle { public: TruncatedCube(float L, float t); }; -class Prism6 : public Particle -{ +class Prism6 : public Particle { public: Prism6(float R, float H); }; -class Cone6 : public Particle -{ +class Cone6 : public Particle { public: Cone6(float R, float H, float alpha); }; -class Pyramid : public Particle -{ +class Pyramid : public Particle { public: Pyramid(float L, float H, float alpha); }; -class Cuboctahedron : public Particle -{ +class Cuboctahedron : public Particle { public: Cuboctahedron(float L, float H, float rH, float alpha); }; -class Prism3 : public Particle -{ +class Prism3 : public Particle { public: Prism3(float L, float H); }; -class Tetrahedron : public Particle -{ +class Tetrahedron : public Particle { public: Tetrahedron(float L, float H, float alpha); }; -class EllipsoidalCylinder : public Particle -{ +class EllipsoidalCylinder : public Particle { public: EllipsoidalCylinder(float Ra, float Rb, float H); }; -class BarGauss : public Particle -{ +class BarGauss : public Particle { public: BarGauss(float L, float W, float H); }; -class BarLorentz : public Particle -{ +class BarLorentz : public Particle { public: BarLorentz(float L, float W, float H); }; -class Box : public Particle -{ +class Box : public Particle { public: Box(float L, float W, float H); }; -class HemiEllipsoid : public Particle -{ +class HemiEllipsoid : public Particle { public: HemiEllipsoid(float Ra, float Rb, float H); }; -class CosineRippleBox : public Particle -{ +class CosineRippleBox : public Particle { public: CosineRippleBox(float L, float W, float H); }; -class CosineRippleGauss : public Particle -{ +class CosineRippleGauss : public Particle { public: CosineRippleGauss(float L, float W, float H); }; -class CosineRippleLorentz : public Particle -{ +class CosineRippleLorentz : public Particle { public: CosineRippleLorentz(float L, float W, float H); }; -class SawtoothRippleBox : public Particle -{ +class SawtoothRippleBox : public Particle { public: SawtoothRippleBox(float L, float W, float H); }; -class SawtoothRippleGauss : public Particle -{ +class SawtoothRippleGauss : public Particle { public: SawtoothRippleGauss(float L, float W, float H); }; -class SawtoothRippleLorentz : public Particle -{ +class SawtoothRippleLorentz : public Particle { public: SawtoothRippleLorentz(float L, float W, float H); }; -class SawtoothRipple : public Particle -{ +class SawtoothRipple : public Particle { public: SawtoothRipple(float L, float W, float H, float asymmetry); }; -class AnisoPyramid : public Particle -{ +class AnisoPyramid : public Particle { public: AnisoPyramid(float L, float W, float H, float alpha); }; diff --git a/GUI/ba3d/view/buffer.cpp b/GUI/ba3d/view/buffer.cpp index 753fbcfbb48e4d36a9a7210cf748451d976bfb79..1dd375d97baba59fb3b4035247c94ba89a04fca3 100644 --- a/GUI/ba3d/view/buffer.cpp +++ b/GUI/ba3d/view/buffer.cpp @@ -15,17 +15,14 @@ #include "GUI/ba3d/view/buffer.h" #include "GUI/ba3d/model/geometry.h" -namespace -{ +namespace { const float cx = 120; // multiplication scale for controlling how long the axes shall be in xy const float cz = 100; // multiplication scale for controlling how long the axes shall be in z } // namespace -namespace RealSpace -{ +namespace RealSpace { -Buffer::Buffer(Geometry const& geometry) -{ +Buffer::Buffer(Geometry const& geometry) { initializeOpenGLFunctions(); auto& mesh = geometry.m_mesh; @@ -45,14 +42,12 @@ Buffer::Buffer(Geometry const& geometry) reinterpret_cast<void*>(sizeof(Vector3D))); } -void Buffer::draw() -{ +void Buffer::draw() { QOpenGLVertexArrayObject::Binder __(&m_vao); glDrawArrays(GL_TRIANGLES, 0, m_vertexCount); } -Buffer3DAxes::Buffer3DAxes() -{ +Buffer3DAxes::Buffer3DAxes() { initializeOpenGLFunctions(); QOpenGLVertexArrayObject::Binder __(&m_vao3DAxes); @@ -104,8 +99,7 @@ Buffer3DAxes::Buffer3DAxes() reinterpret_cast<void*>(3 * sizeof(float))); } -void Buffer3DAxes::draw3DAxes() -{ +void Buffer3DAxes::draw3DAxes() { QOpenGLVertexArrayObject::Binder __(&m_vao3DAxes); glLineWidth(1.4f); glDrawArrays(GL_LINES, 0, m_vertexCount3DAxes); diff --git a/GUI/ba3d/view/buffer.h b/GUI/ba3d/view/buffer.h index 57c27201cc4c8d10d5e90b559e308716801c3a49..16151a301aece79f0e120b7c7b254a4a2b4d1948 100644 --- a/GUI/ba3d/view/buffer.h +++ b/GUI/ba3d/view/buffer.h @@ -20,14 +20,12 @@ #include <QOpenGLFunctions> #include <QOpenGLVertexArrayObject> -namespace RealSpace -{ +namespace RealSpace { class Geometry; // GL buffer -class Buffer final : protected QOpenGLFunctions -{ +class Buffer final : protected QOpenGLFunctions { public: Buffer(Geometry const&); void draw(); @@ -39,8 +37,7 @@ private: }; // Buffer for drawing 3D Coordinate Axes on canvas -class Buffer3DAxes final : protected QOpenGLFunctions -{ +class Buffer3DAxes final : protected QOpenGLFunctions { public: Buffer3DAxes(); void draw3DAxes(); diff --git a/GUI/ba3d/view/camera.cpp b/GUI/ba3d/view/camera.cpp index c9f7c0e17f3e9554da84f02ae6179b164753724b..8d69741664227a43d572c2b29aa6c00cbbc5d79a 100644 --- a/GUI/ba3d/view/camera.cpp +++ b/GUI/ba3d/view/camera.cpp @@ -14,8 +14,7 @@ #include "GUI/ba3d/view/camera.h" -namespace RealSpace -{ +namespace RealSpace { const Vector3D LIGHT1 = Vector3D(0.5f, 1.0f, 1.0f) * 1000.0f; const Vector3D LIGHT2 = Vector3D(1.0f, 0.0f, 1.0f) * 1000.0f; @@ -29,8 +28,7 @@ Camera::Camera() , nearPlane(1) , farPlane(10000) , lightPos1(LIGHT1) - , lightPosRotated1(lightPos1) -{ + , lightPosRotated1(lightPos1) { setAspectRatio(1); } @@ -38,32 +36,26 @@ Camera::Position::Position() : eye(), ctr(), up() {} Camera::Position::Position(const Vector3D& eye_, const Vector3D& ctr_, const Vector3D& up_, QQuaternion const& rot_) - : eye(eye_), ctr(ctr_), up(up_), rot(rot_) -{ -} + : eye(eye_), ctr(ctr_), up(up_), rot(rot_) {} -Camera::Position Camera::Position::interpolateTo(const Position& to, float r) const -{ +Camera::Position Camera::Position::interpolateTo(const Position& to, float r) const { return Position(eye.interpolateTo(to.eye, r), ctr.interpolateTo(to.ctr, r), up.interpolateTo(to.up, r), QQuaternion::slerp(rot, to.rot, r)); } -void Camera::lookAt(const Position& pos_) -{ +void Camera::lookAt(const Position& pos_) { pos = pos_; // lightPos = pos.eye; set(); } -void Camera::lookAt3DAxes(const Position& pos3DAxes_) -{ +void Camera::lookAt3DAxes(const Position& pos3DAxes_) { pos3DAxes = pos3DAxes_; set(); } // recalculate dependent params -void Camera::set() -{ +void Camera::set() { // For 3D object matModel.setToIdentity(); matModel.lookAt((pos.eye - pos.ctr) * zoom + pos.ctr, pos.ctr, pos.up); @@ -84,26 +76,22 @@ void Camera::set() emit updated(*this); } -void Camera::setAspectRatio(float ratio) -{ +void Camera::setAspectRatio(float ratio) { matProj.setToIdentity(); matProj.perspective(vertAngle, ratio, nearPlane, farPlane); } -void Camera::turnBy(QQuaternion const& rot) -{ +void Camera::turnBy(QQuaternion const& rot) { addRot = rot; set(); } -void Camera::zoomBy(float zoom_) -{ +void Camera::zoomBy(float zoom_) { zoom = zoom_; set(); } -void Camera::endTransform(bool keep) -{ +void Camera::endTransform(bool keep) { if (keep) { pos.rot = (pos.rot * addRot).normalized(); pos.eye = pos.eye * zoom; // TODO limit diff --git a/GUI/ba3d/view/camera.h b/GUI/ba3d/view/camera.h index 2901cbd95a450bd4d7e3c9b7f1cfe321f754ada7..b970f33d7fa5f1d849e3922603b8519a633ea7a8 100644 --- a/GUI/ba3d/view/camera.h +++ b/GUI/ba3d/view/camera.h @@ -20,14 +20,12 @@ #include <QMatrix4x4> #include <QQuaternion> -namespace RealSpace -{ +namespace RealSpace { class Canvas; class Program; -class Camera : public QObject -{ +class Camera : public QObject { Q_OBJECT friend class Canvas; friend class Program; diff --git a/GUI/ba3d/view/canvas.cpp b/GUI/ba3d/view/canvas.cpp index 27e9158f4f4628a6cdb3c9099a537106acbe099c..332b3d6b83daa6316548b9ea337fb9508ffd0323 100644 --- a/GUI/ba3d/view/canvas.cpp +++ b/GUI/ba3d/view/canvas.cpp @@ -24,16 +24,13 @@ #include <cmath> #include <cstdlib> -namespace -{ -float ZoomInScale() -{ +namespace { +float ZoomInScale() { if (QSysInfo::productType() == "osx") return 1.02f; return 1.25f; } -float ZoomOutScale() -{ +float ZoomOutScale() { if (QSysInfo::productType() == "osx") return 0.98f; return 0.8f; @@ -47,8 +44,7 @@ const float cameraDefaultPosY = -200.0f; // default camera position on Y axis const float cameraDefaultPosZ = 120.0f; // default camera position on Z axis } // namespace -namespace RealSpace -{ +namespace RealSpace { Canvas::Canvas() : aspectRatio(1) @@ -59,40 +55,34 @@ Canvas::Canvas() , camera(nullptr) , program(nullptr) , model(nullptr) - , m_isInitializedGL(false) -{ + , m_isInitializedGL(false) { connect(&geometryStore(), &GeometryStore::deletingGeometry, this, &Canvas::releaseBuffer); } -Canvas::~Canvas() -{ +Canvas::~Canvas() { cleanup(); } -void Canvas::setBgColor(QColor const& c) -{ +void Canvas::setBgColor(QColor const& c) { colorBgR = float(c.redF()); colorBgG = float(c.greenF()); colorBgB = float(c.blueF()); update(); } -void Canvas::setCamera(Camera* c) -{ +void Canvas::setCamera(Camera* c) { camera = c; setCamera(); } -void Canvas::setProgram(Program* p) -{ +void Canvas::setProgram(Program* p) { program = p; if (program) program->needsInit(); update(); } -void Canvas::setModel(Model* m) -{ +void Canvas::setModel(Model* m) { releaseBuffers(); disconnect(modelUpdated); @@ -109,13 +99,11 @@ void Canvas::setModel(Model* m) camera->set(); } -Model* Canvas::getModel() -{ +Model* Canvas::getModel() { return model; } -void Canvas::setCamera(bool full) -{ +void Canvas::setCamera(bool full) { if (camera) { camera->setAspectRatio(aspectRatio); if (full && model) @@ -125,8 +113,7 @@ void Canvas::setCamera(bool full) update(); } -void Canvas::initializeGL() -{ +void Canvas::initializeGL() { setCamera((camera = new Camera)); setProgram((program = new Program)); @@ -138,16 +125,14 @@ void Canvas::initializeGL() m_isInitializedGL = true; } -void Canvas::resizeGL(int w, int h) -{ +void Canvas::resizeGL(int w, int h) { int w1 = qMax(1, w), h1 = qMax(1, h); viewport.setRect(0, 0, w1, h1); aspectRatio = float(w1) / float(h1); setCamera(false); } -void Canvas::paintGL() -{ +void Canvas::paintGL() { glClearColor(colorBgR, colorBgG, colorBgB, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -184,14 +169,12 @@ void Canvas::paintGL() } } -QVector3D Canvas::unproject(QPoint const& p) -{ +QVector3D Canvas::unproject(QPoint const& p) { float x = p.x(), y = viewport.height() - p.y(); return QVector3D(x, y, 1).unproject(matModel, matProj, viewport); } -void Canvas::mousePressEvent(QMouseEvent* e) -{ +void Canvas::mousePressEvent(QMouseEvent* e) { switch (e->button()) { case Qt::LeftButton: mouseButton = btnTURN; @@ -211,8 +194,7 @@ void Canvas::mousePressEvent(QMouseEvent* e) } } -void Canvas::mouseMoveEvent(QMouseEvent* e) -{ +void Canvas::mouseMoveEvent(QMouseEvent* e) { if (camera) { float delta_x = e->pos().x() - e_last.x(); float delta_y = e->pos().y() - e_last.y(); @@ -241,16 +223,14 @@ void Canvas::mouseMoveEvent(QMouseEvent* e) } } -void Canvas::mouseReleaseEvent(QMouseEvent*) -{ +void Canvas::mouseReleaseEvent(QMouseEvent*) { if (camera) { camera->endTransform(true); update(); } } -void Canvas::wheelEvent(QWheelEvent* e) -{ +void Canvas::wheelEvent(QWheelEvent* e) { if (camera) { if (e->angleDelta().y() < 0) { // Zoom in @@ -267,20 +247,17 @@ void Canvas::wheelEvent(QWheelEvent* e) e->accept(); // disabling the event from propagating further to the parent widgets } -void Canvas::releaseBuffer(Geometry const* g) -{ +void Canvas::releaseBuffer(Geometry const* g) { delete buffers.take(g); } -void Canvas::releaseBuffers() -{ +void Canvas::releaseBuffers() { for (auto b : buffers.values()) delete b; buffers.clear(); } -void Canvas::draw(QColor const& color, QMatrix4x4 const& mat, Geometry const& geo) -{ +void Canvas::draw(QColor const& color, QMatrix4x4 const& mat, Geometry const& geo) { auto it = buffers.find(&geo); Buffer* buf; if (buffers.end() == it) @@ -294,8 +271,7 @@ void Canvas::draw(QColor const& color, QMatrix4x4 const& mat, Geometry const& ge buf->draw(); } -void Canvas::cleanup() -{ +void Canvas::cleanup() { makeCurrent(); releaseBuffers(); @@ -309,13 +285,11 @@ void Canvas::cleanup() doneCurrent(); } -bool Canvas::isInitialized() const -{ +bool Canvas::isInitialized() const { return m_isInitializedGL && model != nullptr; } -void Canvas::defaultView() -{ +void Canvas::defaultView() { // Default view if (isInitialized()) { RealSpace::Camera::Position defPos( @@ -333,8 +307,7 @@ void Canvas::defaultView() } } -void Canvas::sideView() -{ +void Canvas::sideView() { // Side view at current zoom level if (isInitialized()) { RealSpace::Vector3D eye(0, cameraDefaultPosY, 0); @@ -359,8 +332,7 @@ void Canvas::sideView() } } -void Canvas::topView() -{ +void Canvas::topView() { // Top view at current zoom level if (isInitialized()) { // Setting a tiny offset in y value of eye such that eye and up vectors are not parallel @@ -386,8 +358,7 @@ void Canvas::topView() } } -void Canvas::horizontalCameraTurn(float angle) -{ +void Canvas::horizontalCameraTurn(float angle) { if (isInitialized()) { float theta = angle * static_cast<float>(M_PI / 180.0); // in radians @@ -432,8 +403,7 @@ void Canvas::horizontalCameraTurn(float angle) } } -void Canvas::verticalCameraTurn(float angle) -{ +void Canvas::verticalCameraTurn(float angle) { if (isInitialized()) { float theta = angle * static_cast<float>(M_PI / 180.0); // in radians diff --git a/GUI/ba3d/view/canvas.h b/GUI/ba3d/view/canvas.h index 52db5b0932532969183f9cf072897fa4f93b6c8a..c2ab397f92855ae37a6cd86d77b5c295b497507b 100644 --- a/GUI/ba3d/view/canvas.h +++ b/GUI/ba3d/view/canvas.h @@ -22,8 +22,7 @@ #include <QOpenGLShaderProgram> #include <QOpenGLWidget> -namespace RealSpace -{ +namespace RealSpace { class Camera; class Program; @@ -32,8 +31,7 @@ class Geometry; class Buffer; class Object; -class Canvas : public QOpenGLWidget, protected QOpenGLFunctions -{ +class Canvas : public QOpenGLWidget, protected QOpenGLFunctions { Q_OBJECT friend class Object; diff --git a/GUI/ba3d/view/program.cpp b/GUI/ba3d/view/program.cpp index aca2011ff97cf159ff9464c4d291f3168e49ec19..7b005351270d84015e7beb7b2ecd47da03d5658c 100644 --- a/GUI/ba3d/view/program.cpp +++ b/GUI/ba3d/view/program.cpp @@ -18,31 +18,26 @@ #include <stdexcept> // The macro call has to be in the global namespace -inline void InitShaderResources() -{ +inline void InitShaderResources() { Q_INIT_RESOURCE(shaders); } static constexpr float AMBIENT = 0.4f; -namespace RealSpace -{ +namespace RealSpace { -Program::Program() -{ +Program::Program() { // make sure our resource file gets initialized InitShaderResources(); needsInit(); } -void Program::needsInit() -{ +void Program::needsInit() { doInit = true; } -void Program::init() -{ +void Program::init() { if (!doInit) return; doInit = false; @@ -75,8 +70,7 @@ void Program::init() release(); } -void Program::set(Camera const& camera) -{ +void Program::set(Camera const& camera) { setUniformValue(ambient, AMBIENT); setUniformValue(locMatProj, camera.matProj); setUniformValue(locMatModel, camera.matModel); @@ -84,23 +78,19 @@ void Program::set(Camera const& camera) setUniformValue(eye, camera.getPos().eye); } -void Program::set(QColor const& color) -{ +void Program::set(QColor const& color) { setUniformValue(locColor, color); } -void Program::set(QMatrix4x4 const& mat) -{ +void Program::set(QMatrix4x4 const& mat) { setUniformValue(locMatObject, mat); } -void Program::setMatModel(QMatrix4x4 const& mat) -{ +void Program::setMatModel(QMatrix4x4 const& mat) { setUniformValue(locMatModel, mat); } -void Program::setAxis(bool const& axis_) -{ +void Program::setAxis(bool const& axis_) { setUniformValue(locAxis, axis_); } diff --git a/GUI/ba3d/view/program.h b/GUI/ba3d/view/program.h index 1874f0280f453ba0a39d836248131ad435618d6e..de38a4feaf044c639225537957f0c63f90bc2199 100644 --- a/GUI/ba3d/view/program.h +++ b/GUI/ba3d/view/program.h @@ -18,14 +18,12 @@ #include "GUI/ba3d/def.h" #include <QOpenGLShaderProgram> -namespace RealSpace -{ +namespace RealSpace { class Camera; class Canvas; -class Program : public QOpenGLShaderProgram -{ +class Program : public QOpenGLShaderProgram { friend class Canvas; public: diff --git a/GUI/ba3d/widget.cpp b/GUI/ba3d/widget.cpp index 38cd689f3de162566ba3689dcc27fcfa3f94dc0e..a79225d1b30b850e118642c6d0492598d487f094 100644 --- a/GUI/ba3d/widget.cpp +++ b/GUI/ba3d/widget.cpp @@ -19,12 +19,10 @@ #include <QBoxLayout> -namespace RealSpace -{ +namespace RealSpace { //------------------------------------------------------------------------------ -Widget3D::Widget3D() : canvas(nullptr) -{ +Widget3D::Widget3D() : canvas(nullptr) { auto box = new QHBoxLayout; setLayout(box); box->setMargin(0); @@ -33,38 +31,31 @@ Widget3D::Widget3D() : canvas(nullptr) Widget3D::~Widget3D() = default; -Camera& Widget3D::cam() -{ +Camera& Widget3D::cam() { return *canvas->cam(); } -void Widget3D::setBackground(QColor const& color) -{ +void Widget3D::setBackground(QColor const& color) { canvas->setBgColor(color); } -void Widget3D::setModel(Model* model) -{ +void Widget3D::setModel(Model* model) { canvas->setModel(model); } -void Widget3D::defaultView() -{ +void Widget3D::defaultView() { canvas->defaultView(); } -void Widget3D::sideView() -{ +void Widget3D::sideView() { canvas->sideView(); } -void Widget3D::topView() -{ +void Widget3D::topView() { canvas->topView(); } -Model* Widget3D::model() -{ +Model* Widget3D::model() { return canvas->getModel(); } diff --git a/GUI/ba3d/widget.h b/GUI/ba3d/widget.h index 0f3a1e15f2cecf7b227d4fc452c7414dc74e9561..fa93cb8785230e852c1cdd4df6235902cd88667b 100644 --- a/GUI/ba3d/widget.h +++ b/GUI/ba3d/widget.h @@ -18,8 +18,7 @@ #include "GUI/ba3d/def.h" #include <QWidget> -namespace RealSpace -{ +namespace RealSpace { //------------------------------------------------------------------------------ class Model; @@ -27,8 +26,7 @@ class Canvas; class Camera; class Program; -class Widget3D : public QWidget -{ +class Widget3D : public QWidget { Q_OBJECT public: Widget3D(); diff --git a/GUI/coregui/Models/ApplicationModels.cpp b/GUI/coregui/Models/ApplicationModels.cpp index d0f16db161d5b2a1ef910ace83f97e56c3cae15d..bdeb6cef3e39b5164ca2ad226b8691cf13683192 100644 --- a/GUI/coregui/Models/ApplicationModels.cpp +++ b/GUI/coregui/Models/ApplicationModels.cpp @@ -42,8 +42,7 @@ ApplicationModels::ApplicationModels(QObject* parent) , m_sampleModel(nullptr) , m_realDataModel(nullptr) , m_jobModel(nullptr) - , m_materialPropertyController(new MaterialPropertyController(this)) -{ + , m_materialPropertyController(new MaterialPropertyController(this)) { createModels(); // createTestSample(); // createTestJob(); @@ -51,39 +50,32 @@ ApplicationModels::ApplicationModels(QObject* parent) ApplicationModels::~ApplicationModels() = default; -DocumentModel* ApplicationModels::documentModel() -{ +DocumentModel* ApplicationModels::documentModel() { return m_documentModel; } -MaterialModel* ApplicationModels::materialModel() -{ +MaterialModel* ApplicationModels::materialModel() { return m_materialModel; } -InstrumentModel* ApplicationModels::instrumentModel() -{ +InstrumentModel* ApplicationModels::instrumentModel() { return m_instrumentModel; } -SampleModel* ApplicationModels::sampleModel() -{ +SampleModel* ApplicationModels::sampleModel() { return m_sampleModel; } -RealDataModel* ApplicationModels::realDataModel() -{ +RealDataModel* ApplicationModels::realDataModel() { return m_realDataModel; } -JobModel* ApplicationModels::jobModel() -{ +JobModel* ApplicationModels::jobModel() { return m_jobModel; } //! reset all models to initial state -void ApplicationModels::resetModels() -{ +void ApplicationModels::resetModels() { m_documentModel->clear(); m_documentModel->insertNewItem("SimulationOptions"); @@ -105,8 +97,7 @@ void ApplicationModels::resetModels() } //! creates and initializes models, order is important -void ApplicationModels::createModels() -{ +void ApplicationModels::createModels() { createDocumentModel(); createMaterialModel(); createSampleModel(); @@ -118,51 +109,44 @@ void ApplicationModels::createModels() m_materialPropertyController->setModels(materialModel(), sampleModel()); } -void ApplicationModels::createDocumentModel() -{ +void ApplicationModels::createDocumentModel() { delete m_documentModel; m_documentModel = new DocumentModel(this); connectModel(m_documentModel); } -void ApplicationModels::createMaterialModel() -{ +void ApplicationModels::createMaterialModel() { delete m_materialModel; m_materialModel = new MaterialModel(this); connectModel(m_materialModel); } -void ApplicationModels::createSampleModel() -{ +void ApplicationModels::createSampleModel() { ASSERT(m_materialModel); delete m_sampleModel; m_sampleModel = new SampleModel(this); connectModel(m_sampleModel); } -void ApplicationModels::createInstrumentModel() -{ +void ApplicationModels::createInstrumentModel() { delete m_instrumentModel; m_instrumentModel = new InstrumentModel(this); connectModel(m_instrumentModel); } -void ApplicationModels::createRealDataModel() -{ +void ApplicationModels::createRealDataModel() { delete m_realDataModel; m_realDataModel = new RealDataModel(this); connectModel(m_realDataModel); } -void ApplicationModels::createJobModel() -{ +void ApplicationModels::createJobModel() { delete m_jobModel; m_jobModel = new JobModel(this); connectModel(m_jobModel); } -void ApplicationModels::createTestSample() -{ +void ApplicationModels::createTestSample() { SampleBuilderFactory factory; const std::unique_ptr<MultiLayer> P_sample( factory.createSampleByName("CylindersAndPrismsBuilder")); @@ -174,8 +158,7 @@ void ApplicationModels::createTestSample() GUIObjectBuilder::populateInstrumentModel(m_instrumentModel, *simulation); } -void ApplicationModels::createTestJob() -{ +void ApplicationModels::createTestJob() { SimulationOptionsItem* optionsItem = m_documentModel->simulationOptionsItem(); JobItem* jobItem = m_jobModel->addJob(m_sampleModel->multiLayerItem(), @@ -183,8 +166,7 @@ void ApplicationModels::createTestJob() m_jobModel->runJob(jobItem->index()); } -void ApplicationModels::createTestRealData() -{ +void ApplicationModels::createTestRealData() { auto realDataItem = dynamic_cast<RealDataItem*>(m_realDataModel->insertNewItem("RealData")); realDataItem->setItemName("realdata"); @@ -196,14 +178,12 @@ void ApplicationModels::createTestRealData() //! Writes all model in file one by one -void ApplicationModels::writeTo(QXmlStreamWriter* writer) -{ +void ApplicationModels::writeTo(QXmlStreamWriter* writer) { for (auto model : modelList()) model->writeTo(writer); } -void ApplicationModels::readFrom(QXmlStreamReader* reader, MessageService* messageService) -{ +void ApplicationModels::readFrom(QXmlStreamReader* reader, MessageService* messageService) { for (auto model : modelList()) { if (model->getModelTag() == reader->name()) { model->readFrom(reader, messageService); @@ -216,8 +196,7 @@ void ApplicationModels::readFrom(QXmlStreamReader* reader, MessageService* messa //! Returns the list of all GUI models -QList<SessionModel*> ApplicationModels::modelList() -{ +QList<SessionModel*> ApplicationModels::modelList() { QList<SessionModel*> result; result.append(m_documentModel); result.append(m_materialModel); @@ -228,15 +207,13 @@ QList<SessionModel*> ApplicationModels::modelList() return result; } -QVector<SessionItem*> ApplicationModels::nonXMLData() const -{ +QVector<SessionItem*> ApplicationModels::nonXMLData() const { ASSERT(m_realDataModel && m_jobModel && m_instrumentModel); return QVector<SessionItem*>() << m_realDataModel->nonXMLData() << m_jobModel->nonXMLData() << m_instrumentModel->nonXMLData(); } -void ApplicationModels::disconnectModel(SessionModel* model) -{ +void ApplicationModels::disconnectModel(SessionModel* model) { if (model) { disconnect(model, &SessionModel::dataChanged, this, &ApplicationModels::modelChanged); disconnect(model, &SessionModel::rowsRemoved, this, &ApplicationModels::modelChanged); @@ -244,8 +221,7 @@ void ApplicationModels::disconnectModel(SessionModel* model) } } -void ApplicationModels::connectModel(SessionModel* model) -{ +void ApplicationModels::connectModel(SessionModel* model) { if (model) { connect(model, &SessionModel::dataChanged, this, &ApplicationModels::modelChanged, Qt::UniqueConnection); diff --git a/GUI/coregui/Models/ApplicationModels.h b/GUI/coregui/Models/ApplicationModels.h index 3e23958fa9838c24546838dc656b2e0c3b657cf7..aa1b7298ab2d4cfc2e9c042a18621ef62741fcd8 100644 --- a/GUI/coregui/Models/ApplicationModels.h +++ b/GUI/coregui/Models/ApplicationModels.h @@ -28,8 +28,7 @@ class JobModel; class MaterialPropertyController; class MessageService; -class ApplicationModels : public QObject -{ +class ApplicationModels : public QObject { Q_OBJECT public: explicit ApplicationModels(QObject* parent = nullptr); diff --git a/GUI/coregui/Models/AxesItems.cpp b/GUI/coregui/Models/AxesItems.cpp index 6345af709dbad5cb7786c0db1ae1e37e7c7cac8f..c6ea463a7fd492a6a7be09ca86ee7136a90b9b25 100644 --- a/GUI/coregui/Models/AxesItems.cpp +++ b/GUI/coregui/Models/AxesItems.cpp @@ -24,13 +24,11 @@ const QString BasicAxisItem::P_TITLE_IS_VISIBLE = "Title Visibility"; const int max_detector_pixels = 65536; -BasicAxisItem::BasicAxisItem(const QString& type) : SessionItem(type) -{ +BasicAxisItem::BasicAxisItem(const QString& type) : SessionItem(type) { register_basic_properties(); } -std::unique_ptr<IAxis> BasicAxisItem::createAxis(double scale) const -{ +std::unique_ptr<IAxis> BasicAxisItem::createAxis(double scale) const { return std::make_unique<FixedBinAxis>( getItemValue(P_TITLE).toString().toStdString(), getItemValue(P_NBINS).toInt(), getItemValue(P_MIN_DEG).toDouble() * scale, getItemValue(P_MAX_DEG).toDouble() * scale); @@ -38,8 +36,7 @@ std::unique_ptr<IAxis> BasicAxisItem::createAxis(double scale) const BasicAxisItem::~BasicAxisItem() = default; -void BasicAxisItem::register_basic_properties() -{ +void BasicAxisItem::register_basic_properties() { addProperty(P_IS_VISIBLE, true)->setVisible(false); addProperty(P_NBINS, 100)->setLimits(RealLimits::limited(1, max_detector_pixels)); addProperty(P_MIN_DEG, 0.0)->setDecimals(3); @@ -55,8 +52,7 @@ void BasicAxisItem::register_basic_properties() const QString AmplitudeAxisItem::P_IS_LOGSCALE = "log10"; const QString AmplitudeAxisItem::P_LOCK_MIN_MAX = "Lock (min, max)"; -AmplitudeAxisItem::AmplitudeAxisItem() : BasicAxisItem("AmplitudeAxis") -{ +AmplitudeAxisItem::AmplitudeAxisItem() : BasicAxisItem("AmplitudeAxis") { addProperty(P_LOCK_MIN_MAX, false)->setVisible(false); addProperty(P_IS_LOGSCALE, true); getItem(BasicAxisItem::P_TITLE)->setVisible(false); @@ -75,8 +71,7 @@ AmplitudeAxisItem::AmplitudeAxisItem() : BasicAxisItem("AmplitudeAxis") //! Sets editor for min, max values of axes -void AmplitudeAxisItem::setMinMaxEditor(const QString& editorType) -{ +void AmplitudeAxisItem::setMinMaxEditor(const QString& editorType) { getItem(BasicAxisItem::P_MIN_DEG)->setEditorType(editorType); getItem(BasicAxisItem::P_MAX_DEG)->setEditorType(editorType); } diff --git a/GUI/coregui/Models/AxesItems.h b/GUI/coregui/Models/AxesItems.h index a9c173bb906cdea471847f4caae7c40841222f62..38e625b5236029ff438769003d2f300ad48b2cf1 100644 --- a/GUI/coregui/Models/AxesItems.h +++ b/GUI/coregui/Models/AxesItems.h @@ -20,8 +20,7 @@ class IAxis; -class BA_CORE_API_ BasicAxisItem : public SessionItem -{ +class BA_CORE_API_ BasicAxisItem : public SessionItem { public: static const QString P_IS_VISIBLE; static const QString P_NBINS; @@ -39,8 +38,7 @@ protected: void register_basic_properties(); }; -class BA_CORE_API_ AmplitudeAxisItem : public BasicAxisItem -{ +class BA_CORE_API_ AmplitudeAxisItem : public BasicAxisItem { public: static const QString P_IS_LOGSCALE; static const QString P_LOCK_MIN_MAX; diff --git a/GUI/coregui/Models/BackgroundItems.cpp b/GUI/coregui/Models/BackgroundItems.cpp index babbc9182a72b167dab8a7ac981c2c538c4bb2ac..55024ef11a4d3f27bede9e97b0f04159bbec0c1f 100644 --- a/GUI/coregui/Models/BackgroundItems.cpp +++ b/GUI/coregui/Models/BackgroundItems.cpp @@ -23,41 +23,35 @@ BackgroundItem::BackgroundItem(const QString& model_type) : SessionItem(model_ty BackgroundNoneItem::BackgroundNoneItem() : BackgroundItem("NoBackground") {} -std::unique_ptr<IBackground> BackgroundNoneItem::createBackground() const -{ +std::unique_ptr<IBackground> BackgroundNoneItem::createBackground() const { return {}; } // Constant background /* ------------------------------------------------ */ -namespace -{ +namespace { const QString constant_background_value_tooltip = "Constant background value [counts/pixel]"; } const QString ConstantBackgroundItem::P_VALUE = QString::fromStdString("BackgroundValue"); -ConstantBackgroundItem::ConstantBackgroundItem() : BackgroundItem("ConstantBackground") -{ +ConstantBackgroundItem::ConstantBackgroundItem() : BackgroundItem("ConstantBackground") { addProperty(P_VALUE, 0.0) ->setLimits(RealLimits::nonnegative()) .setToolTip(constant_background_value_tooltip); } -std::unique_ptr<IBackground> ConstantBackgroundItem::createBackground() const -{ +std::unique_ptr<IBackground> ConstantBackgroundItem::createBackground() const { return std::make_unique<ConstantBackground>(getItemValue(P_VALUE).toDouble()); } // Background consisting of Poisson noise /* ------------------------------------------------ */ -PoissonNoiseBackgroundItem::PoissonNoiseBackgroundItem() : BackgroundItem("PoissonNoiseBackground") -{ -} +PoissonNoiseBackgroundItem::PoissonNoiseBackgroundItem() + : BackgroundItem("PoissonNoiseBackground") {} -std::unique_ptr<IBackground> PoissonNoiseBackgroundItem::createBackground() const -{ +std::unique_ptr<IBackground> PoissonNoiseBackgroundItem::createBackground() const { return std::make_unique<PoissonNoiseBackground>(); } diff --git a/GUI/coregui/Models/BackgroundItems.h b/GUI/coregui/Models/BackgroundItems.h index 651bf4e5f49c9dcaa9ed610fcc1968d2ec51ff1a..a5ce5a0cbfd6b9871d60fbcb787cedac8e9f579b 100644 --- a/GUI/coregui/Models/BackgroundItems.h +++ b/GUI/coregui/Models/BackgroundItems.h @@ -19,23 +19,20 @@ class IBackground; -class BA_CORE_API_ BackgroundItem : public SessionItem -{ +class BA_CORE_API_ BackgroundItem : public SessionItem { public: explicit BackgroundItem(const QString& model_type); virtual std::unique_ptr<IBackground> createBackground() const = 0; }; -class BA_CORE_API_ BackgroundNoneItem : public BackgroundItem -{ +class BA_CORE_API_ BackgroundNoneItem : public BackgroundItem { public: BackgroundNoneItem(); std::unique_ptr<IBackground> createBackground() const; }; -class BA_CORE_API_ ConstantBackgroundItem : public BackgroundItem -{ +class BA_CORE_API_ ConstantBackgroundItem : public BackgroundItem { public: static const QString P_VALUE; @@ -43,8 +40,7 @@ public: std::unique_ptr<IBackground> createBackground() const; }; -class BA_CORE_API_ PoissonNoiseBackgroundItem : public BackgroundItem -{ +class BA_CORE_API_ PoissonNoiseBackgroundItem : public BackgroundItem { public: PoissonNoiseBackgroundItem(); std::unique_ptr<IBackground> createBackground() const; diff --git a/GUI/coregui/Models/BeamAngleItems.cpp b/GUI/coregui/Models/BeamAngleItems.cpp index 6f028c30a22379c53e38549609498082069cabe6..291b88e1898007cdf6c84e7c7b0f1ba4242d8ce4 100644 --- a/GUI/coregui/Models/BeamAngleItems.cpp +++ b/GUI/coregui/Models/BeamAngleItems.cpp @@ -16,8 +16,7 @@ #include "Base/Const/Units.h" BeamAzimuthalAngleItem::BeamAzimuthalAngleItem() - : BeamDistributionItem("BeamAzimuthalAngle", m_show_mean) -{ + : BeamDistributionItem("BeamAzimuthalAngle", m_show_mean) { register_distribution_group("Distribution extended group"); SessionItem* valueItem = getGroupItem(P_DISTRIBUTION)->getItem(DistributionNoneItem::P_MEAN); @@ -30,21 +29,18 @@ BeamAzimuthalAngleItem::BeamAzimuthalAngleItem() //! Returns beam azimuthal angle. In the case of distribution applied, returns its mean. -double BeamAzimuthalAngleItem::azimuthalAngle() const -{ +double BeamAzimuthalAngleItem::azimuthalAngle() const { return BeamDistributionItem::meanValue(); } -double BeamAzimuthalAngleItem::scaleFactor() const -{ +double BeamAzimuthalAngleItem::scaleFactor() const { return Units::deg; } // ------------------------------------------------------------------------------------------------ BeamInclinationAngleItem::BeamInclinationAngleItem() - : BeamDistributionItem("BeamInclinationAngle", m_show_mean) -{ + : BeamDistributionItem("BeamInclinationAngle", m_show_mean) { register_distribution_group("Distribution extended group"); SessionItem* valueItem = getGroupItem(P_DISTRIBUTION)->getItem(DistributionNoneItem::P_MEAN); @@ -57,12 +53,10 @@ BeamInclinationAngleItem::BeamInclinationAngleItem() //! Returns beam inclination angle. In the case of distribution applied, returns its mean. -double BeamInclinationAngleItem::inclinationAngle() const -{ +double BeamInclinationAngleItem::inclinationAngle() const { return BeamDistributionItem::meanValue(); } -double BeamInclinationAngleItem::scaleFactor() const -{ +double BeamInclinationAngleItem::scaleFactor() const { return Units::deg; } diff --git a/GUI/coregui/Models/BeamAngleItems.h b/GUI/coregui/Models/BeamAngleItems.h index fe6f924357d5fbf8f5f6ad2f6dd53f6f813a7e3b..ec8f4f6ed77e66dc99ef339a06265a2d3be193ab 100644 --- a/GUI/coregui/Models/BeamAngleItems.h +++ b/GUI/coregui/Models/BeamAngleItems.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/BeamDistributionItem.h" -class BA_CORE_API_ BeamAzimuthalAngleItem : public BeamDistributionItem -{ +class BA_CORE_API_ BeamAzimuthalAngleItem : public BeamDistributionItem { public: BeamAzimuthalAngleItem(); @@ -30,8 +29,7 @@ private: static const bool m_show_mean = true; }; -class BA_CORE_API_ BeamInclinationAngleItem : public BeamDistributionItem -{ +class BA_CORE_API_ BeamInclinationAngleItem : public BeamDistributionItem { public: BeamInclinationAngleItem(); diff --git a/GUI/coregui/Models/BeamDistributionItem.cpp b/GUI/coregui/Models/BeamDistributionItem.cpp index c707b50c97e179b7963725f243e2de3c3641e65f..db5362160f669ed9b3be985ef50c020ec5eda3ec 100644 --- a/GUI/coregui/Models/BeamDistributionItem.cpp +++ b/GUI/coregui/Models/BeamDistributionItem.cpp @@ -22,8 +22,8 @@ const QString BeamDistributionItem::P_DISTRIBUTION = "Distribution"; -BeamDistributionItem::BeamDistributionItem(const QString& name, bool show_mean) : SessionItem(name) -{ +BeamDistributionItem::BeamDistributionItem(const QString& name, bool show_mean) + : SessionItem(name) { addTranslator(DistributionNoneTranslator()); mapper()->setOnChildPropertyChange([this, show_mean](SessionItem* item, const QString&) { @@ -34,8 +34,7 @@ BeamDistributionItem::BeamDistributionItem(const QString& name, bool show_mean) //! returns parameter distribution to add into the ISimulation std::unique_ptr<ParameterDistribution> -BeamDistributionItem::getParameterDistributionForName(const std::string& parameter_name) const -{ +BeamDistributionItem::getParameterDistributionForName(const std::string& parameter_name) const { std::unique_ptr<ParameterDistribution> P_par_distr{}; if (auto distributionItem = dynamic_cast<DistributionItem*>(getGroupItem(P_DISTRIBUTION))) { auto P_distribution = createDistribution1D(); @@ -64,8 +63,7 @@ BeamDistributionItem::getParameterDistributionForName(const std::string& paramet //! Propagates the value and limits stored in DistributionNone type into alls distributions. -void BeamDistributionItem::initDistributionItem(bool show_mean) -{ +void BeamDistributionItem::initDistributionItem(bool show_mean) { GroupItem* groupItem = dynamic_cast<GroupItem*>(getItem(P_DISTRIBUTION)); ASSERT(groupItem); @@ -106,8 +104,7 @@ void BeamDistributionItem::initDistributionItem(bool show_mean) //! Returns mean value of the distribution. -double BeamDistributionItem::meanValue() const -{ +double BeamDistributionItem::meanValue() const { std::unique_ptr<IDistribution1D> domainDistr = createDistribution1D(); if (domainDistr) return domainDistr->getMean() / scaleFactor(); @@ -115,8 +112,7 @@ double BeamDistributionItem::meanValue() const return getGroupItem(P_DISTRIBUTION)->getItemValue(DistributionNoneItem::P_MEAN).toDouble(); } -void BeamDistributionItem::resetToValue(double value) -{ +void BeamDistributionItem::resetToValue(double value) { SessionItem* distributionItem = setGroupProperty(BeamDistributionItem::P_DISTRIBUTION, "DistributionNone"); ASSERT(distributionItem); @@ -126,20 +122,17 @@ void BeamDistributionItem::resetToValue(double value) //! Scales the values provided by distribution (to perform deg->rad conversion in the case //! of AngleDistributionItems. -double BeamDistributionItem::scaleFactor() const -{ +double BeamDistributionItem::scaleFactor() const { return 1.0; } -void BeamDistributionItem::register_distribution_group(const QString& group_type) -{ +void BeamDistributionItem::register_distribution_group(const QString& group_type) { ASSERT(group_type == "Distribution extended group" || group_type == "Symmetric distribution group"); addGroupProperty(P_DISTRIBUTION, group_type); } -std::unique_ptr<IDistribution1D> BeamDistributionItem::createDistribution1D() const -{ +std::unique_ptr<IDistribution1D> BeamDistributionItem::createDistribution1D() const { if (auto distItem = dynamic_cast<DistributionItem*>(getGroupItem(P_DISTRIBUTION))) return distItem->createDistribution(scaleFactor()); diff --git a/GUI/coregui/Models/BeamDistributionItem.h b/GUI/coregui/Models/BeamDistributionItem.h index 426fb2d1da88c6830758fdee23e601e058c71afe..0577b3b3733590357e2099384a8f3ac66a1eb783 100644 --- a/GUI/coregui/Models/BeamDistributionItem.h +++ b/GUI/coregui/Models/BeamDistributionItem.h @@ -22,8 +22,7 @@ class ParameterDistribution; //! The BeamDistributionItem handles wavelength, inclination and azimuthal parameter //! distribution for BeamItem -class BA_CORE_API_ BeamDistributionItem : public SessionItem -{ +class BA_CORE_API_ BeamDistributionItem : public SessionItem { public: static const QString P_DISTRIBUTION; explicit BeamDistributionItem(const QString& name, bool show_mean); diff --git a/GUI/coregui/Models/BeamItems.cpp b/GUI/coregui/Models/BeamItems.cpp index 802051edecdaba73e37edd3e0d22132ec509998f..151336dab966aca4b7749d2456cb5ace0821dbca 100644 --- a/GUI/coregui/Models/BeamItems.cpp +++ b/GUI/coregui/Models/BeamItems.cpp @@ -29,8 +29,7 @@ using SessionItemUtils::GetVectorItem; -namespace -{ +namespace { const QString polarization_tooltip = "Polarization of the beam, given as the Bloch vector"; // defines wavelength limits according to given maximum q value @@ -43,8 +42,7 @@ const QString BeamItem::P_INCLINATION_ANGLE = QString::fromStdString("Inclinatio const QString BeamItem::P_AZIMUTHAL_ANGLE = QString::fromStdString("AzimuthalAngle"); const QString BeamItem::P_POLARIZATION = "Polarization"; -BeamItem::BeamItem(const QString& beam_model) : SessionItem(beam_model) -{ +BeamItem::BeamItem(const QString& beam_model) : SessionItem(beam_model) { addProperty(P_INTENSITY, 1e+08) ->setLimits(RealLimits::limited(0.0, 1e+32)) .setToolTip("Beam intensity in neutrons (or gammas) per sec.") @@ -58,52 +56,44 @@ BeamItem::BeamItem(const QString& beam_model) : SessionItem(beam_model) BeamItem::~BeamItem() = default; -double BeamItem::getIntensity() const -{ +double BeamItem::getIntensity() const { return getItemValue(P_INTENSITY).toDouble(); } -void BeamItem::setIntensity(double value) -{ +void BeamItem::setIntensity(double value) { setItemValue(P_INTENSITY, value); } -double BeamItem::getWavelength() const -{ +double BeamItem::getWavelength() const { BeamWavelengthItem* beamWavelength = dynamic_cast<BeamWavelengthItem*>(getItem(P_WAVELENGTH)); return beamWavelength->wavelength(); } -void BeamItem::setWavelength(double value) -{ +void BeamItem::setWavelength(double value) { auto beam_wavelength = dynamic_cast<BeamWavelengthItem*>(getItem(P_WAVELENGTH)); ASSERT(beam_wavelength); beam_wavelength->resetToValue(value); } -void BeamItem::setInclinationAngle(double value) -{ +void BeamItem::setInclinationAngle(double value) { auto angleItem = dynamic_cast<BeamDistributionItem*>(getItem(P_INCLINATION_ANGLE)); ASSERT(angleItem); angleItem->resetToValue(value); } -double BeamItem::getAzimuthalAngle() const -{ +double BeamItem::getAzimuthalAngle() const { const auto inclination = dynamic_cast<BeamAzimuthalAngleItem*>(getItem(P_AZIMUTHAL_ANGLE)); ASSERT(inclination); return inclination->azimuthalAngle(); } -void BeamItem::setAzimuthalAngle(double value) -{ +void BeamItem::setAzimuthalAngle(double value) { auto angleItem = dynamic_cast<BeamDistributionItem*>(getItem(P_AZIMUTHAL_ANGLE)); ASSERT(angleItem); angleItem->resetToValue(value); } -std::unique_ptr<Beam> BeamItem::createBeam() const -{ +std::unique_ptr<Beam> BeamItem::createBeam() const { double lambda = getWavelength(); double inclination_angle = Units::deg2rad(getInclinationAngle()); double azimuthal_angle = Units::deg2rad(getAzimuthalAngle()); @@ -116,13 +106,11 @@ std::unique_ptr<Beam> BeamItem::createBeam() const return result; } -void BeamItem::setInclinationProperty(const QString& inclination_type) -{ +void BeamItem::setInclinationProperty(const QString& inclination_type) { addGroupProperty(P_INCLINATION_ANGLE, inclination_type); } -void BeamItem::setWavelengthProperty(const QString& wavelength_type) -{ +void BeamItem::setWavelengthProperty(const QString& wavelength_type) { addGroupProperty(P_WAVELENGTH, wavelength_type); } @@ -133,8 +121,7 @@ const QString SpecularBeamItem::P_FOOPTPRINT = "Footprint"; const QString footprint_group_label("Type"); -SpecularBeamItem::SpecularBeamItem() : BeamItem("SpecularBeam") -{ +SpecularBeamItem::SpecularBeamItem() : BeamItem("SpecularBeam") { setInclinationProperty("SpecularBeamInclinationAxis"); setWavelengthProperty("SpecularBeamWavelength"); @@ -161,41 +148,34 @@ SpecularBeamItem::SpecularBeamItem() : BeamItem("SpecularBeam") SpecularBeamItem::~SpecularBeamItem() = default; -double SpecularBeamItem::getInclinationAngle() const -{ +double SpecularBeamItem::getInclinationAngle() const { return 0.0; } -void SpecularBeamItem::setInclinationAngle(double value) -{ +void SpecularBeamItem::setInclinationAngle(double value) { ASSERT(value == 0.0); value = 0.0; BeamItem::setInclinationAngle(value); } -GroupItem* SpecularBeamItem::inclinationAxisGroup() -{ +GroupItem* SpecularBeamItem::inclinationAxisGroup() { return dynamic_cast<GroupItem*>( getItem(P_INCLINATION_ANGLE)->getItem(SpecularBeamInclinationItem::P_ALPHA_AXIS)); } -BasicAxisItem* SpecularBeamItem::currentInclinationAxisItem() -{ +BasicAxisItem* SpecularBeamItem::currentInclinationAxisItem() { return dynamic_cast<BasicAxisItem*>(inclinationAxisGroup()->currentItem()); } -FootprintItem* SpecularBeamItem::currentFootprintItem() const -{ +FootprintItem* SpecularBeamItem::currentFootprintItem() const { return &groupItem<FootprintItem>(P_FOOPTPRINT); } -void SpecularBeamItem::updateFileName(const QString& filename) -{ +void SpecularBeamItem::updateFileName(const QString& filename) { item<SpecularBeamInclinationItem>(BeamItem::P_INCLINATION_ANGLE).updateFileName(filename); } -void SpecularBeamItem::updateToData(const IAxis& axis, QString units) -{ +void SpecularBeamItem::updateToData(const IAxis& axis, QString units) { if (units == "nbins") { inclinationAxisGroup()->setCurrentType("BasicAxis"); auto axis_item = currentInclinationAxisItem(); @@ -210,8 +190,7 @@ void SpecularBeamItem::updateToData(const IAxis& axis, QString units) axis_item->updateIndicators(); } -void SpecularBeamItem::updateWavelength() -{ +void SpecularBeamItem::updateWavelength() { auto item = inclinationAxisGroup()->currentItem(); auto wl_item = static_cast<SpecularBeamWavelengthItem*>(getItem(P_WAVELENGTH)); if (auto axis_item = dynamic_cast<PointwiseAxisItem*>(item)) { @@ -225,25 +204,21 @@ void SpecularBeamItem::updateWavelength() // GISAS beam item /* ------------------------------------------------------------------------- */ -GISASBeamItem::GISASBeamItem() : BeamItem("GISASBeam") -{ +GISASBeamItem::GISASBeamItem() : BeamItem("GISASBeam") { setInclinationProperty("BeamInclinationAngle"); setWavelengthProperty("BeamWavelength"); } GISASBeamItem::~GISASBeamItem() = default; -double GISASBeamItem::getInclinationAngle() const -{ +double GISASBeamItem::getInclinationAngle() const { const auto inclination = dynamic_cast<BeamInclinationAngleItem*>(getItem(P_INCLINATION_ANGLE)); ASSERT(inclination); return inclination->inclinationAngle(); } -namespace -{ -RealLimits getLimits(double max_q) -{ +namespace { +RealLimits getLimits(double max_q) { double upper_lim = std::nextafter(4.0 * M_PI / max_q, 0.0); RealLimits result = RealLimits::positive(); result.setUpperLimit(upper_lim); diff --git a/GUI/coregui/Models/BeamItems.h b/GUI/coregui/Models/BeamItems.h index 704a029056bd55687966dd7b2aad891bb23e420d..67e5374ed0ab7d081578657832832498f927ddf7 100644 --- a/GUI/coregui/Models/BeamItems.h +++ b/GUI/coregui/Models/BeamItems.h @@ -23,8 +23,7 @@ class FootprintItem; class GroupItem; class IAxis; -class BA_CORE_API_ BeamItem : public SessionItem -{ +class BA_CORE_API_ BeamItem : public SessionItem { public: static const QString P_INTENSITY; static const QString P_WAVELENGTH; @@ -55,8 +54,7 @@ protected: void setWavelengthProperty(const QString& wavelength_type); }; -class BA_CORE_API_ SpecularBeamItem : public BeamItem -{ +class BA_CORE_API_ SpecularBeamItem : public BeamItem { public: static const QString P_FOOPTPRINT; @@ -77,8 +75,7 @@ private: void updateWavelength(); }; -class BA_CORE_API_ GISASBeamItem : public BeamItem -{ +class BA_CORE_API_ GISASBeamItem : public BeamItem { public: GISASBeamItem(); ~GISASBeamItem() override; diff --git a/GUI/coregui/Models/BeamWavelengthItem.cpp b/GUI/coregui/Models/BeamWavelengthItem.cpp index f63640df120c886e7afc584951cc7582858c27b6..d18344c6323011ff7e1932cb72600a2e5405b028 100644 --- a/GUI/coregui/Models/BeamWavelengthItem.cpp +++ b/GUI/coregui/Models/BeamWavelengthItem.cpp @@ -14,14 +14,12 @@ #include "GUI/coregui/Models/BeamWavelengthItem.h" -namespace -{ +namespace { const double default_wl = 0.1; } BeamWavelengthItem::BeamWavelengthItem(const QString& model_type, const QString& distribution_group) - : BeamDistributionItem(model_type, m_show_mean) -{ + : BeamDistributionItem(model_type, m_show_mean) { register_distribution_group(distribution_group); SessionItem* valueItem = getGroupItem(P_DISTRIBUTION)->getItem(DistributionNoneItem::P_MEAN); @@ -35,18 +33,14 @@ BeamWavelengthItem::BeamWavelengthItem(const QString& model_type, const QString& //! Returns wavelength. In the case of distribution applied, returns its mean. -double BeamWavelengthItem::wavelength() const -{ +double BeamWavelengthItem::wavelength() const { return BeamDistributionItem::meanValue(); } SpecularBeamWavelengthItem::SpecularBeamWavelengthItem() - : BeamWavelengthItem("SpecularBeamWavelength", "Symmetric distribution group") -{ -} + : BeamWavelengthItem("SpecularBeamWavelength", "Symmetric distribution group") {} -void SpecularBeamWavelengthItem::setToRange(const RealLimits& limits) -{ +void SpecularBeamWavelengthItem::setToRange(const RealLimits& limits) { SessionItem* valueItem = getGroupItem(P_DISTRIBUTION)->getItem(SymmetricDistributionItem::P_MEAN); if (!limits.isInRange(wavelength())) { diff --git a/GUI/coregui/Models/BeamWavelengthItem.h b/GUI/coregui/Models/BeamWavelengthItem.h index b7d4f796982ded83c4e5b3e9b01ef4d957bfc79d..f4a89dfba36ceacd4e625c3601d081019f680587 100644 --- a/GUI/coregui/Models/BeamWavelengthItem.h +++ b/GUI/coregui/Models/BeamWavelengthItem.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/BeamDistributionItem.h" -class BA_CORE_API_ BeamWavelengthItem : public BeamDistributionItem -{ +class BA_CORE_API_ BeamWavelengthItem : public BeamDistributionItem { public: BeamWavelengthItem(const QString& model_type = "BeamWavelength", const QString& distribution_group = "Distribution extended group"); @@ -29,8 +28,7 @@ private: static const bool m_show_mean = true; }; -class BA_CORE_API_ SpecularBeamWavelengthItem : public BeamWavelengthItem -{ +class BA_CORE_API_ SpecularBeamWavelengthItem : public BeamWavelengthItem { public: SpecularBeamWavelengthItem(); void setToRange(const RealLimits& limits); diff --git a/GUI/coregui/Models/ComboProperty.cpp b/GUI/coregui/Models/ComboProperty.cpp index e81e631d2ec3f573989901348e7ab4604eaf9e98..507dd9fa300da0a44c635417477705236c9b1707 100644 --- a/GUI/coregui/Models/ComboProperty.cpp +++ b/GUI/coregui/Models/ComboProperty.cpp @@ -16,8 +16,7 @@ #include "Base/Utils/Assert.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { const QString value_separator = ";"; const QString selection_separator = ","; } // namespace @@ -26,8 +25,7 @@ ComboProperty::ComboProperty() = default; ComboProperty::ComboProperty(QStringList values) : m_values(std::move(values)) {} -ComboProperty ComboProperty::fromList(const QStringList& values, const QString& current_value) -{ +ComboProperty ComboProperty::fromList(const QStringList& values, const QString& current_value) { ComboProperty result(values); if (!current_value.isEmpty()) @@ -36,13 +34,11 @@ ComboProperty ComboProperty::fromList(const QStringList& values, const QString& return result; } -QString ComboProperty::getValue() const -{ +QString ComboProperty::getValue() const { return currentIndex() < 0 ? QString() : m_values.at(currentIndex()); } -void ComboProperty::setValue(const QString& name) -{ +void ComboProperty::setValue(const QString& name) { if (!m_values.contains(name)) throw GUIHelpers::Error("ComboProperty::setValue() -> Error. Combo doesn't contain " "value " @@ -50,15 +46,13 @@ void ComboProperty::setValue(const QString& name) setCurrentIndex(m_values.indexOf(name)); } -QStringList ComboProperty::getValues() const -{ +QStringList ComboProperty::getValues() const { return m_values; } //! Sets new list of values. Current value will be preserved, if exists in a new list. -void ComboProperty::setValues(const QStringList& values) -{ +void ComboProperty::setValues(const QStringList& values) { ASSERT(values.size()); QString current = getValue(); m_values = values; @@ -66,23 +60,19 @@ void ComboProperty::setValues(const QStringList& values) } //! returns list of tool tips for all values -QStringList ComboProperty::toolTips() const -{ +QStringList ComboProperty::toolTips() const { return m_tooltips; } -void ComboProperty::setToolTips(const QStringList& tooltips) -{ +void ComboProperty::setToolTips(const QStringList& tooltips) { m_tooltips = tooltips; } -int ComboProperty::currentIndex() const -{ +int ComboProperty::currentIndex() const { return m_selected_indices.empty() ? -1 : m_selected_indices.at(0); } -void ComboProperty::setCurrentIndex(int index) -{ +void ComboProperty::setCurrentIndex(int index) { if (index < 0 || index >= m_values.size()) throw GUIHelpers::Error("ComboProperty::setCurrentIndex(int index) -> Error. " "Invalid index"); @@ -90,24 +80,21 @@ void ComboProperty::setCurrentIndex(int index) m_selected_indices.push_back(index); } -ComboProperty& ComboProperty::operator<<(const QString& str) -{ +ComboProperty& ComboProperty::operator<<(const QString& str) { m_values.append(str); if (!m_values.empty()) setCurrentIndex(0); return *this; } -ComboProperty& ComboProperty::operator<<(const QStringList& str) -{ +ComboProperty& ComboProperty::operator<<(const QStringList& str) { m_values.append(str); if (!m_values.empty()) setCurrentIndex(0); return *this; } -bool ComboProperty::operator==(const ComboProperty& other) const -{ +bool ComboProperty::operator==(const ComboProperty& other) const { if (m_selected_indices != other.m_selected_indices) return false; if (m_values != other.m_values) @@ -115,28 +102,24 @@ bool ComboProperty::operator==(const ComboProperty& other) const return true; } -bool ComboProperty::operator!=(const ComboProperty& other) const -{ +bool ComboProperty::operator!=(const ComboProperty& other) const { return !(*this == other); } -bool ComboProperty::operator<(const ComboProperty& other) const -{ +bool ComboProperty::operator<(const ComboProperty& other) const { return m_selected_indices.size() < other.m_selected_indices.size() && m_values.size() < other.m_values.size(); } //! Returns a single string containing values delimited with ';'. -QString ComboProperty::stringOfValues() const -{ +QString ComboProperty::stringOfValues() const { return m_values.join(value_separator); } //! Sets values from the string containing delimeter ';'. -void ComboProperty::setStringOfValues(const QString& values) -{ +void ComboProperty::setStringOfValues(const QString& values) { QString current = getValue(); m_values = values.split(value_separator); setCurrentIndex(m_values.contains(current) ? m_values.indexOf(current) : 0); @@ -144,8 +127,7 @@ void ComboProperty::setStringOfValues(const QString& values) //! Constructs variant enclosing given ComboProperty. -QVariant ComboProperty::variant() const -{ +QVariant ComboProperty::variant() const { QVariant result; result.setValue(*this); return result; @@ -153,15 +135,13 @@ QVariant ComboProperty::variant() const //! Returns vector of selected indices. -QVector<int> ComboProperty::selectedIndices() const -{ +QVector<int> ComboProperty::selectedIndices() const { return m_selected_indices; } //! Returns list of string with selected values; -QStringList ComboProperty::selectedValues() const -{ +QStringList ComboProperty::selectedValues() const { QStringList result; for (auto index : m_selected_indices) result.append(m_values.at(index)); @@ -171,8 +151,7 @@ QStringList ComboProperty::selectedValues() const //! Sets given index selection flag. //! If false, index will be excluded from selection. -void ComboProperty::setSelected(int index, bool value) -{ +void ComboProperty::setSelected(int index, bool value) { if (index < 0 || index >= m_values.size()) return; @@ -185,15 +164,13 @@ void ComboProperty::setSelected(int index, bool value) std::sort(m_selected_indices.begin(), m_selected_indices.end()); } -void ComboProperty::setSelected(const QString& name, bool value) -{ +void ComboProperty::setSelected(const QString& name, bool value) { setSelected(m_values.indexOf(name), value); } //! Return string with coma separated list of selected indices. -QString ComboProperty::stringOfSelections() const -{ +QString ComboProperty::stringOfSelections() const { QStringList text; for (auto index : m_selected_indices) text.append(QString::number(index)); @@ -202,8 +179,7 @@ QString ComboProperty::stringOfSelections() const //! Sets selected indices from string. -void ComboProperty::setStringOfSelections(const QString& values) -{ +void ComboProperty::setStringOfSelections(const QString& values) { m_selected_indices.clear(); if (values.isEmpty()) return; @@ -218,8 +194,7 @@ void ComboProperty::setStringOfSelections(const QString& values) //! Returns the label to show -QString ComboProperty::label() const -{ +QString ComboProperty::label() const { if (m_selected_indices.size() > 1) { return "Multiple"; } else if (m_selected_indices.size() == 1) { diff --git a/GUI/coregui/Models/ComboProperty.h b/GUI/coregui/Models/ComboProperty.h index 1e59e95db9f745bf20399049cd36ec55ee4fcc38..accffe6a5b61f5256d5587593761a165b4c7e9ed 100644 --- a/GUI/coregui/Models/ComboProperty.h +++ b/GUI/coregui/Models/ComboProperty.h @@ -22,8 +22,7 @@ //! Custom property to define list of string values with multiple selections. //! Intended for QVariant. -class ComboProperty -{ +class ComboProperty { public: ComboProperty(); diff --git a/GUI/coregui/Models/ComponentProxyModel.cpp b/GUI/coregui/Models/ComponentProxyModel.cpp index e33b79ff6220cbb426861248cd7e29be8419628c..d4fc815e166fa55c36d830e47ecdc01ae5869142 100644 --- a/GUI/coregui/Models/ComponentProxyModel.cpp +++ b/GUI/coregui/Models/ComponentProxyModel.cpp @@ -23,12 +23,9 @@ ComponentProxyModel::ComponentProxyModel(QObject* parent) : QAbstractProxyModel(parent) , m_model(nullptr) // , m_proxyStrategy(new IndentityProxyStrategy) - , m_proxyStrategy(new ComponentProxyStrategy) -{ -} + , m_proxyStrategy(new ComponentProxyStrategy) {} -void ComponentProxyModel::setSessionModel(SessionModel* model) -{ +void ComponentProxyModel::setSessionModel(SessionModel* model) { beginResetModel(); if (sourceModel()) { @@ -57,36 +54,31 @@ void ComponentProxyModel::setSessionModel(SessionModel* model) buildModelMap(); } -void ComponentProxyModel::setRootIndex(const QModelIndex& sourceRootIndex) -{ +void ComponentProxyModel::setRootIndex(const QModelIndex& sourceRootIndex) { m_proxyStrategy->setRootIndex(sourceRootIndex); buildModelMap(); } -void ComponentProxyModel::setProxyStrategy(ProxyModelStrategy* strategy) -{ +void ComponentProxyModel::setProxyStrategy(ProxyModelStrategy* strategy) { m_proxyStrategy.reset(strategy); buildModelMap(); } -QModelIndex ComponentProxyModel::mapToSource(const QModelIndex& proxyIndex) const -{ +QModelIndex ComponentProxyModel::mapToSource(const QModelIndex& proxyIndex) const { if (!proxyIndex.isValid()) return QModelIndex(); return m_proxyStrategy->sourceToProxy().key(proxyIndex); } -QModelIndex ComponentProxyModel::mapFromSource(const QModelIndex& sourceIndex) const -{ +QModelIndex ComponentProxyModel::mapFromSource(const QModelIndex& sourceIndex) const { if (!sourceIndex.isValid()) return QModelIndex(); return m_proxyStrategy->sourceToProxy().value(sourceIndex); } -QModelIndex ComponentProxyModel::index(int row, int column, const QModelIndex& parent) const -{ +QModelIndex ComponentProxyModel::index(int row, int column, const QModelIndex& parent) const { QModelIndex sourceParent; if (parent.isValid()) sourceParent = mapToSource(parent); @@ -101,8 +93,7 @@ QModelIndex ComponentProxyModel::index(int row, int column, const QModelIndex& p return QModelIndex(); } -QModelIndex ComponentProxyModel::parent(const QModelIndex& child) const -{ +QModelIndex ComponentProxyModel::parent(const QModelIndex& child) const { QModelIndex sourceParent = m_proxyStrategy->proxySourceParent().value(child); if (sourceParent.isValid()) return mapFromSource(sourceParent); @@ -110,8 +101,7 @@ QModelIndex ComponentProxyModel::parent(const QModelIndex& child) const return QModelIndex(); } -int ComponentProxyModel::rowCount(const QModelIndex& parent) const -{ +int ComponentProxyModel::rowCount(const QModelIndex& parent) const { QModelIndex sourceParent; if (parent.isValid()) sourceParent = mapToSource(parent); @@ -127,15 +117,13 @@ int ComponentProxyModel::rowCount(const QModelIndex& parent) const return rows.size(); } -int ComponentProxyModel::columnCount(const QModelIndex& parent) const -{ +int ComponentProxyModel::columnCount(const QModelIndex& parent) const { if (parent.isValid() && parent.column() != 0) return 0; return SessionFlags::MAX_COLUMNS; } -bool ComponentProxyModel::hasChildren(const QModelIndex& parent) const -{ +bool ComponentProxyModel::hasChildren(const QModelIndex& parent) const { QModelIndex source_parent = mapToSource(parent); if (parent.isValid() && !source_parent.isValid()) return false; @@ -145,8 +133,7 @@ bool ComponentProxyModel::hasChildren(const QModelIndex& parent) const void ComponentProxyModel::sourceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, - const QVector<int>& roles) -{ + const QVector<int>& roles) { ASSERT(topLeft.isValid() ? topLeft.model() == sourceModel() : true); ASSERT(bottomRight.isValid() ? bottomRight.model() == sourceModel() : true); @@ -157,16 +144,14 @@ void ComponentProxyModel::sourceDataChanged(const QModelIndex& topLeft, dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight), roles); } -void ComponentProxyModel::sourceRowsInserted(const QModelIndex& parent, int start, int end) -{ +void ComponentProxyModel::sourceRowsInserted(const QModelIndex& parent, int start, int end) { Q_UNUSED(parent); Q_UNUSED(start); Q_UNUSED(end); buildModelMap(); } -void ComponentProxyModel::sourceRowsRemoved(const QModelIndex& parent, int start, int end) -{ +void ComponentProxyModel::sourceRowsRemoved(const QModelIndex& parent, int start, int end) { Q_UNUSED(parent); Q_UNUSED(start); Q_UNUSED(end); @@ -175,15 +160,13 @@ void ComponentProxyModel::sourceRowsRemoved(const QModelIndex& parent, int start //! Main method to build the map of persistent indeses. -void ComponentProxyModel::buildModelMap() -{ +void ComponentProxyModel::buildModelMap() { if (!m_model) return; m_proxyStrategy->buildModelMap(m_model, this); layoutChanged(); } -void ComponentProxyModel::updateModelMap() -{ +void ComponentProxyModel::updateModelMap() { m_proxyStrategy->onDataChanged(m_model, this); } diff --git a/GUI/coregui/Models/ComponentProxyModel.h b/GUI/coregui/Models/ComponentProxyModel.h index aefac8f26fd638d0b2556c9dc00d62cc07bdb383..9991a4ab39468415f013d1aaa47e0cec0e089563 100644 --- a/GUI/coregui/Models/ComponentProxyModel.h +++ b/GUI/coregui/Models/ComponentProxyModel.h @@ -30,8 +30,7 @@ class ProxyModelStrategy; //! The model hides GroupPropertyItem children and shows grand-children of currently selected item //! one level up. -class ComponentProxyModel : public QAbstractProxyModel -{ +class ComponentProxyModel : public QAbstractProxyModel { Q_OBJECT friend class ProxyModelStrategy; diff --git a/GUI/coregui/Models/ComponentProxyStrategy.cpp b/GUI/coregui/Models/ComponentProxyStrategy.cpp index 32a432d62f83926dcd79d78d12d6ca916ccdc626..d6dacfab26da032e5908f2990eda4345fcc4886c 100644 --- a/GUI/coregui/Models/ComponentProxyStrategy.cpp +++ b/GUI/coregui/Models/ComponentProxyStrategy.cpp @@ -20,14 +20,12 @@ #include "GUI/coregui/Models/SessionModel.h" #include "GUI/coregui/Views/PropertyEditor/ComponentUtils.h" -void ComponentProxyStrategy::onDataChanged(SessionModel* source, ComponentProxyModel* proxy) -{ +void ComponentProxyStrategy::onDataChanged(SessionModel* source, ComponentProxyModel* proxy) { buildModelMap(source, proxy); proxy->layoutChanged(); } -bool ComponentProxyStrategy::processSourceIndex(const QModelIndex& index) -{ +bool ComponentProxyStrategy::processSourceIndex(const QModelIndex& index) { QPersistentModelIndex sourceIndex = {index}; SessionItem* item = m_source->itemForIndex(index); @@ -58,8 +56,7 @@ bool ComponentProxyStrategy::processSourceIndex(const QModelIndex& index) //! Returns true if item is property related to exclude top level items (ParticleLayout, Particle //! etc from the tree). -bool ComponentProxyStrategy::isPropertyRelated(SessionItem* item) -{ +bool ComponentProxyStrategy::isPropertyRelated(SessionItem* item) { static QStringList propertyRelated = ComponentUtils::propertyRelatedTypes(); if (m_sourceRootIndex.isValid() && item->parent()->index() == m_sourceRootIndex @@ -72,16 +69,14 @@ bool ComponentProxyStrategy::isPropertyRelated(SessionItem* item) //! Returns true if item should become new root item. //! This is used when we want to show single item (Layer, Particle) on top of the tree. -bool ComponentProxyStrategy::isNewRootItem(SessionItem* item) -{ +bool ComponentProxyStrategy::isNewRootItem(SessionItem* item) { return item->index() == m_sourceRootIndex; } //! Makes SessionItem to become the only one item in a tree. void ComponentProxyStrategy::processRootItem(SessionItem* item, - const QPersistentModelIndex& sourceIndex) -{ + const QPersistentModelIndex& sourceIndex) { const int nrows = 0; // invisible root item will contain only single item QPersistentModelIndex proxyIndex = createProxyIndex(nrows, sourceIndex.column(), item); m_sourceToProxy.insert(sourceIndex, proxyIndex); @@ -90,8 +85,7 @@ void ComponentProxyStrategy::processRootItem(SessionItem* item, //! Returns true if item is a group property which in turn is inside of another group property. -bool ComponentProxyStrategy::isSubGroup(SessionItem* item) -{ +bool ComponentProxyStrategy::isSubGroup(SessionItem* item) { const SessionItem* ancestor = ModelPath::ancestor(item->parent(), "GroupProperty"); if (item->modelType() == "GroupProperty" && ancestor && ancestor->modelType() == "GroupProperty") { @@ -103,8 +97,7 @@ bool ComponentProxyStrategy::isSubGroup(SessionItem* item) //! Returns true if item is a children/grandchildrent of some group item. -bool ComponentProxyStrategy::isGroupChildren(SessionItem* item) -{ +bool ComponentProxyStrategy::isGroupChildren(SessionItem* item) { if (item->parent() && item->parent()->modelType() == "GroupProperty") return true; @@ -119,8 +112,7 @@ bool ComponentProxyStrategy::isGroupChildren(SessionItem* item) //! All properties of current item of group item void ComponentProxyStrategy::processGroupItem(SessionItem* item, - const QPersistentModelIndex& sourceIndex) -{ + const QPersistentModelIndex& sourceIndex) { if (const SessionItem* ancestor = ModelPath::ancestor(item, "GroupProperty")) { if (ancestor == item) return; @@ -139,8 +131,7 @@ void ComponentProxyStrategy::processGroupItem(SessionItem* item, //! Process group property which is inside of other group property. void ComponentProxyStrategy::processSubGroupItem(SessionItem* item, - const QPersistentModelIndex& sourceIndex) -{ + const QPersistentModelIndex& sourceIndex) { if (const SessionItem* ancestor = ModelPath::ancestor(item->parent(), "GroupProperty")) { auto groupItem = dynamic_cast<const GroupItem*>(ancestor); @@ -155,8 +146,7 @@ void ComponentProxyStrategy::processSubGroupItem(SessionItem* item, } void ComponentProxyStrategy::processDefaultItem(SessionItem* item, - const QPersistentModelIndex& sourceIndex) -{ + const QPersistentModelIndex& sourceIndex) { ASSERT(item); if (!item->isVisible()) return; @@ -173,8 +163,7 @@ void ComponentProxyStrategy::processDefaultItem(SessionItem* item, m_proxySourceParent.insert(proxyIndex, sourceParent); } -int ComponentProxyStrategy::parentVisibleRow(const SessionItem& item) -{ +int ComponentProxyStrategy::parentVisibleRow(const SessionItem& item) { int result(-1); if (!item.parent() || !item.isVisible()) diff --git a/GUI/coregui/Models/ComponentProxyStrategy.h b/GUI/coregui/Models/ComponentProxyStrategy.h index 63fe7cfa5bf25107f7be1c2fd3a005a88b6f38b4..1df21033e68cc23c73f095ede24be47d2b04150f 100644 --- a/GUI/coregui/Models/ComponentProxyStrategy.h +++ b/GUI/coregui/Models/ComponentProxyStrategy.h @@ -19,8 +19,7 @@ //! Strategy for ComponentProxyModel which hides extra level of GroupProperty. -class ComponentProxyStrategy : public ProxyModelStrategy -{ +class ComponentProxyStrategy : public ProxyModelStrategy { public: void onDataChanged(SessionModel* source, ComponentProxyModel* proxy); diff --git a/GUI/coregui/Models/Data1DViewItem.cpp b/GUI/coregui/Models/Data1DViewItem.cpp index cc8953836a82cf018863ef8084cddf3837d2790a..5e92ebfd3c30cbbecf79bcfdc62b68b6cbcb61c7 100644 --- a/GUI/coregui/Models/Data1DViewItem.cpp +++ b/GUI/coregui/Models/Data1DViewItem.cpp @@ -22,8 +22,7 @@ #include "GUI/coregui/Models/JobItem.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { const QString x_axis_default_name = "X [nbins]"; const QString y_axis_default_name = "Signal [a.u.]"; @@ -37,8 +36,7 @@ const QString Data1DViewItem::P_YAXIS = "y-axis"; const QString Data1DViewItem::P_AXES_UNITS = "Axes Units"; const QString Data1DViewItem::T_DATA_PROPERTIES = "Data property container"; -Data1DViewItem::Data1DViewItem() : SessionItem("Data1DViewItem"), m_job_item(nullptr) -{ +Data1DViewItem::Data1DViewItem() : SessionItem("Data1DViewItem"), m_job_item(nullptr) { addProperty(P_TITLE, QString())->setVisible(false); SessionItem* item = addGroupProperty(P_XAXIS, "BasicAxis"); @@ -72,59 +70,48 @@ Data1DViewItem::Data1DViewItem() : SessionItem("Data1DViewItem"), m_job_item(nul setYaxisTitle(y_axis_default_name); } -int Data1DViewItem::getNbins() const -{ +int Data1DViewItem::getNbins() const { return xAxisItem()->getItemValue(BasicAxisItem::P_NBINS).toInt(); } -double Data1DViewItem::getLowerX() const -{ +double Data1DViewItem::getLowerX() const { return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_MIN_DEG).toDouble(); } -double Data1DViewItem::getUpperX() const -{ +double Data1DViewItem::getUpperX() const { return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_MAX_DEG).toDouble(); } -double Data1DViewItem::getLowerY() const -{ +double Data1DViewItem::getLowerY() const { return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_MIN_DEG).toDouble(); } -double Data1DViewItem::getUpperY() const -{ +double Data1DViewItem::getUpperY() const { return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_MAX_DEG).toDouble(); } -bool Data1DViewItem::isLog() const -{ +bool Data1DViewItem::isLog() const { return getItem(P_YAXIS)->getItemValue(AmplitudeAxisItem::P_IS_LOGSCALE).toBool(); } -QString Data1DViewItem::getXaxisTitle() const -{ +QString Data1DViewItem::getXaxisTitle() const { return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_TITLE).toString(); } -QString Data1DViewItem::getYaxisTitle() const -{ +QString Data1DViewItem::getYaxisTitle() const { return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_TITLE).toString(); } -void Data1DViewItem::setXaxisTitle(QString xtitle) -{ +void Data1DViewItem::setXaxisTitle(QString xtitle) { getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_TITLE, xtitle); } -void Data1DViewItem::setYaxisTitle(QString ytitle) -{ +void Data1DViewItem::setYaxisTitle(QString ytitle) { getItem(P_YAXIS)->setItemValue(AmplitudeAxisItem::P_TITLE, ytitle); } //! set zoom range of x,y axes to axes of input data -void Data1DViewItem::setAxesRangeToData() -{ +void Data1DViewItem::setAxesRangeToData() { const auto data = DataViewUtils::getTranslatedData(this, propertyContainerItem()->basicDataItem()); @@ -141,14 +128,12 @@ void Data1DViewItem::setAxesRangeToData() setUpperY(data_range.second); } -void Data1DViewItem::resetToDefault() -{ +void Data1DViewItem::resetToDefault() { // TODO: implement when applying DataITem1DView in ImportView throw GUIHelpers::Error("Error in DataItem1DView::resetToDefault: not implemented"); } -QPair<QVector<double>, QVector<double>> Data1DViewItem::graphData(Data1DProperties* property_item) -{ +QPair<QVector<double>, QVector<double>> Data1DViewItem::graphData(Data1DProperties* property_item) { const auto data = DataViewUtils::getTranslatedData(this, property_item->dataItem()); if (!data) return {}; @@ -164,8 +149,7 @@ QPair<QVector<double>, QVector<double>> Data1DViewItem::graphData(Data1DProperti #endif } -JobItem* Data1DViewItem::jobItem() -{ +JobItem* Data1DViewItem::jobItem() { if (m_job_item != nullptr) return m_job_item; // returning preset job item @@ -180,48 +164,39 @@ JobItem* Data1DViewItem::jobItem() "Error in DataItem1DView::jobItem: passed item is not owned by any job item"); } -void Data1DViewItem::setLowerX(double xmin) -{ +void Data1DViewItem::setLowerX(double xmin) { getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_MIN_DEG, xmin); } -void Data1DViewItem::setUpperX(double xmax) -{ +void Data1DViewItem::setUpperX(double xmax) { getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_MAX_DEG, xmax); } -void Data1DViewItem::setLowerY(double ymin) -{ +void Data1DViewItem::setLowerY(double ymin) { getItem(P_YAXIS)->setItemValue(AmplitudeAxisItem::P_MIN_DEG, ymin); } -void Data1DViewItem::setUpperY(double ymax) -{ +void Data1DViewItem::setUpperY(double ymax) { getItem(P_YAXIS)->setItemValue(AmplitudeAxisItem::P_MAX_DEG, ymax); } -void Data1DViewItem::setLog(bool log_flag) -{ +void Data1DViewItem::setLog(bool log_flag) { getItem(P_YAXIS)->setItemValue(AmplitudeAxisItem::P_IS_LOGSCALE, log_flag); } -DataPropertyContainer* Data1DViewItem::propertyContainerItem() -{ +DataPropertyContainer* Data1DViewItem::propertyContainerItem() { return dynamic_cast<DataPropertyContainer*>(getItem(T_DATA_PROPERTIES)); } -const BasicAxisItem* Data1DViewItem::xAxisItem() const -{ +const BasicAxisItem* Data1DViewItem::xAxisItem() const { return dynamic_cast<const BasicAxisItem*>(getItem(P_XAXIS)); } -BasicAxisItem* Data1DViewItem::xAxisItem() -{ +BasicAxisItem* Data1DViewItem::xAxisItem() { return const_cast<BasicAxisItem*>(static_cast<const Data1DViewItem*>(this)->xAxisItem()); } -const AmplitudeAxisItem* Data1DViewItem::yAxisItem() const -{ +const AmplitudeAxisItem* Data1DViewItem::yAxisItem() const { auto result = dynamic_cast<const AmplitudeAxisItem*>(getItem(P_YAXIS)); ASSERT(result); return result; @@ -229,14 +204,12 @@ const AmplitudeAxisItem* Data1DViewItem::yAxisItem() const //! Set axes viewport to original data. -void Data1DViewItem::resetView() -{ +void Data1DViewItem::resetView() { setAxesRangeToData(); } //! Init ymin, ymax to match the intensity values range. -QPair<double, double> Data1DViewItem::dataRange(const OutputData<double>* data) const -{ +QPair<double, double> Data1DViewItem::dataRange(const OutputData<double>* data) const { if (!data) return QPair<double, double>(default_min, default_max); diff --git a/GUI/coregui/Models/Data1DViewItem.h b/GUI/coregui/Models/Data1DViewItem.h index 5152396651eb8477c76ad671a0d247b04ceb62d0..0ab0fec5d75f27b3e00629c7a7596de8c588fcdd 100644 --- a/GUI/coregui/Models/Data1DViewItem.h +++ b/GUI/coregui/Models/Data1DViewItem.h @@ -29,8 +29,7 @@ template <class T> class OutputData; //! at once. In current implementation the first of carried //! items determines axes' limits. -class BA_CORE_API_ Data1DViewItem : public SessionItem -{ +class BA_CORE_API_ Data1DViewItem : public SessionItem { public: static const QString P_TITLE; static const QString P_XAXIS; diff --git a/GUI/coregui/Models/DataItem.cpp b/GUI/coregui/Models/DataItem.cpp index 2d848ace854398b03ac6eef11aa91e7eca09162d..088f3472bf5592f72c35ad85c2823c531d36e12b 100644 --- a/GUI/coregui/Models/DataItem.cpp +++ b/GUI/coregui/Models/DataItem.cpp @@ -21,14 +21,12 @@ const QString DataItem::P_FILE_NAME = "FileName"; const QString DataItem::P_AXES_UNITS = "Axes Units"; -void DataItem::setOutputData(OutputData<double>* data) -{ +void DataItem::setOutputData(OutputData<double>* data) { std::unique_lock<std::mutex> lock(m_update_data_mutex); m_data.reset(data); } -void DataItem::setRawDataVector(std::vector<double> data) -{ +void DataItem::setRawDataVector(std::vector<double> data) { if (m_data->getAllocatedSize() != data.size()) throw GUIHelpers::Error("DataItem::setRawDataVector() -> Error. " "Different data size."); @@ -37,23 +35,19 @@ void DataItem::setRawDataVector(std::vector<double> data) emitDataChanged(); } -QString DataItem::fileName() const -{ +QString DataItem::fileName() const { return getItemValue(DataItem::P_FILE_NAME).toString(); } -QDateTime DataItem::lastModified() const -{ +QDateTime DataItem::lastModified() const { return m_last_modified; } -bool DataItem::containsNonXMLData() const -{ +bool DataItem::containsNonXMLData() const { return static_cast<bool>(m_data); } -bool DataItem::load(const QString& projectDir) -{ +bool DataItem::load(const QString& projectDir) { QString filename = fileName(projectDir); auto data = IntensityDataIOFactory::readOutputData(filename.toStdString()); if (!data) @@ -62,8 +56,7 @@ bool DataItem::load(const QString& projectDir) return true; } -bool DataItem::save(const QString& projectDir) -{ +bool DataItem::save(const QString& projectDir) { if (!containsNonXMLData()) return false; @@ -74,19 +67,16 @@ bool DataItem::save(const QString& projectDir) return true; } -void DataItem::setLastModified(const QDateTime& dtime) -{ +void DataItem::setLastModified(const QDateTime& dtime) { m_last_modified = dtime; } -QString DataItem::selectedAxesUnits() const -{ +QString DataItem::selectedAxesUnits() const { ComboProperty combo = getItemValue(DataItem::P_AXES_UNITS).value<ComboProperty>(); return combo.getValue(); } -DataItem::DataItem(const QString& modelType) : SessionItem(modelType) -{ +DataItem::DataItem(const QString& modelType) : SessionItem(modelType) { // name of the file used to serialize given IntensityDataItem addProperty(P_FILE_NAME, "undefined")->setVisible(false); diff --git a/GUI/coregui/Models/DataItem.h b/GUI/coregui/Models/DataItem.h index c78342be5aced52bf3ffec97de24a590ed9927b3..435c6c465adbd70bb1ca93cebf39bf67d849e3b8 100644 --- a/GUI/coregui/Models/DataItem.h +++ b/GUI/coregui/Models/DataItem.h @@ -26,8 +26,7 @@ class InstrumentItem; //! Provides common functionality for IntensityDataItem and SpecularDataItem -class BA_CORE_API_ DataItem : public SessionItem, public SaveLoadInterface -{ +class BA_CORE_API_ DataItem : public SessionItem, public SaveLoadInterface { public: static const QString P_FILE_NAME; static const QString P_AXES_UNITS; diff --git a/GUI/coregui/Models/DataItemUtils.cpp b/GUI/coregui/Models/DataItemUtils.cpp index 77354e03de007243410bc5c5dd727554da5acf2b..aa9ff498e223d5987829e02733da912892af9767 100644 --- a/GUI/coregui/Models/DataItemUtils.cpp +++ b/GUI/coregui/Models/DataItemUtils.cpp @@ -19,10 +19,8 @@ #include "GUI/coregui/Models/SpecularDataItem.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ -template <class DataItemType> DataItemType* dataItem(SessionItem* parent) -{ +namespace { +template <class DataItemType> DataItemType* dataItem(SessionItem* parent) { ASSERT(parent && "Assertion failed in DataItemUtils::dataItem: nullptr passed."); if (parent->modelType() == "JobItem") @@ -36,12 +34,10 @@ template <class DataItemType> DataItemType* dataItem(SessionItem* parent) } } // namespace -IntensityDataItem* DataItemUtils::intensityDataItem(SessionItem* parent) -{ +IntensityDataItem* DataItemUtils::intensityDataItem(SessionItem* parent) { return dataItem<IntensityDataItem>(parent); } -SpecularDataItem* DataItemUtils::specularDataItem(SessionItem* parent) -{ +SpecularDataItem* DataItemUtils::specularDataItem(SessionItem* parent) { return dataItem<SpecularDataItem>(parent); } diff --git a/GUI/coregui/Models/DataItemUtils.h b/GUI/coregui/Models/DataItemUtils.h index b7d149030459e235027fd0beb6a9c0c14ef813ef..aaa10b2719890fc1fea58ef56015e5f1a167bcfe 100644 --- a/GUI/coregui/Models/DataItemUtils.h +++ b/GUI/coregui/Models/DataItemUtils.h @@ -21,8 +21,7 @@ class SpecularDataItem; //! Utility functions for Intensity and Specular DataItems -namespace DataItemUtils -{ +namespace DataItemUtils { //! Returns IntensityDataItem contained as a child in givent parent. IntensityDataItem* intensityDataItem(SessionItem* parent); diff --git a/GUI/coregui/Models/DataProperties.cpp b/GUI/coregui/Models/DataProperties.cpp index 00fd0ba3f07c430a73ccb01accf59f9c23c63c09..ddb8b5afae59ff716e1b51a056018cc207ee2038 100644 --- a/GUI/coregui/Models/DataProperties.cpp +++ b/GUI/coregui/Models/DataProperties.cpp @@ -19,8 +19,7 @@ #include "GUI/coregui/Models/SessionModel.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { // set of simple colors for representation of 1D graphs const std::vector<std::pair<QString, Qt::GlobalColor>> color_queue = { {"Black", Qt::GlobalColor::black}, {"Blue", Qt::GlobalColor::blue}, @@ -29,8 +28,7 @@ const std::vector<std::pair<QString, Qt::GlobalColor>> color_queue = { struct ColorNameComparator { ColorNameComparator(const QString& value_to_comp) : m_value_to_comp(value_to_comp) {} - bool operator()(const std::pair<QString, Qt::GlobalColor>& value) const - { + bool operator()(const std::pair<QString, Qt::GlobalColor>& value) const { return value.first == m_value_to_comp; } @@ -42,19 +40,16 @@ ComboProperty defaultColorCombo(); const QString DataProperties::P_DATALINK = "data link"; -DataProperties::DataProperties(const QString& model_type) : SessionItem(model_type) -{ +DataProperties::DataProperties(const QString& model_type) : SessionItem(model_type) { addProperty(P_DATALINK, ""); } -void DataProperties::setDataItem(DataItem* item) -{ +void DataProperties::setDataItem(DataItem* item) { const QString& path = ModelPath::getPathFromIndex(item->index()); setItemValue(P_DATALINK, path); } -DataItem* DataProperties::dataItem() -{ +DataItem* DataProperties::dataItem() { SessionModel* hosting_model = this->model(); const QString& path = getItemValue(P_DATALINK).toString(); auto item_index = ModelPath::getIndexFromPath(hosting_model, path); @@ -70,13 +65,11 @@ DataItem* DataProperties::dataItem() const QString Data1DProperties::P_COLOR = "Color"; -Data1DProperties::Data1DProperties() : DataProperties("DataItem1DProperties") -{ +Data1DProperties::Data1DProperties() : DataProperties("DataItem1DProperties") { addProperty(P_COLOR, defaultColorCombo().variant()); } -QColor Data1DProperties::color() -{ +QColor Data1DProperties::color() { const QString& color_name = getItemValue(P_COLOR).value<ComboProperty>().getValue(); auto iter = std::find_if(color_queue.begin(), color_queue.end(), ColorNameComparator(color_name)); @@ -85,8 +78,7 @@ QColor Data1DProperties::color() return QColor(iter->second); } -const QString& Data1DProperties::nextColorName(Data1DProperties* properties) -{ +const QString& Data1DProperties::nextColorName(Data1DProperties* properties) { if (!properties) return color_queue.front().first; const auto& current_color = properties->getItemValue(P_COLOR).value<ComboProperty>().getValue(); @@ -97,17 +89,14 @@ const QString& Data1DProperties::nextColorName(Data1DProperties* properties) return (++iter)->first; } -void Data1DProperties::setColorProperty(const QString& color_name) -{ +void Data1DProperties::setColorProperty(const QString& color_name) { auto color_combo = defaultColorCombo(); color_combo.setValue(color_name); setItemValue(P_COLOR, color_combo.variant()); } -namespace -{ -ComboProperty defaultColorCombo() -{ +namespace { +ComboProperty defaultColorCombo() { ComboProperty result; for (auto& color : color_queue) result << color.first; diff --git a/GUI/coregui/Models/DataProperties.h b/GUI/coregui/Models/DataProperties.h index 6c1f16f9852cad9e2fe7dc2261d13ea3b52dc8f0..ab94ece03dca5b450cefcadfb3a88524896f3700 100644 --- a/GUI/coregui/Models/DataProperties.h +++ b/GUI/coregui/Models/DataProperties.h @@ -22,8 +22,7 @@ class DataItem; //! Implements a link to DataItem. If path name //! of a DataItem changes, the link becomes invalid. //! Also serves as a base for Data1DProperties -class BA_CORE_API_ DataProperties : public SessionItem -{ +class BA_CORE_API_ DataProperties : public SessionItem { public: static const QString P_DATALINK; @@ -35,8 +34,7 @@ protected: }; //! Holds data required for 1D DataItem representation -class BA_CORE_API_ Data1DProperties : public DataProperties -{ +class BA_CORE_API_ Data1DProperties : public DataProperties { public: static const QString P_COLOR; diff --git a/GUI/coregui/Models/DataPropertyContainer.cpp b/GUI/coregui/Models/DataPropertyContainer.cpp index 92bd96320590baeda15e78440e232f732bb993ec..39bba16f9e39f9b770a5970cd00a22cda2f65638 100644 --- a/GUI/coregui/Models/DataPropertyContainer.cpp +++ b/GUI/coregui/Models/DataPropertyContainer.cpp @@ -19,14 +19,12 @@ const QString DataPropertyContainer::T_CHILDREN = "data links"; -DataPropertyContainer::DataPropertyContainer() : SessionItem("DataPropertyContainer") -{ +DataPropertyContainer::DataPropertyContainer() : SessionItem("DataPropertyContainer") { registerTag(T_CHILDREN, 0, -1, QStringList() << "DataItem1DProperties"); setDefaultTag(T_CHILDREN); } -QVector<Data1DProperties*> DataPropertyContainer::propertyItems() -{ +QVector<Data1DProperties*> DataPropertyContainer::propertyItems() { QVector<Data1DProperties*> result; auto source = getItems(); std::transform(source.begin(), source.end(), std::back_inserter(result), @@ -34,8 +32,7 @@ QVector<Data1DProperties*> DataPropertyContainer::propertyItems() return result; } -Data1DProperties* DataPropertyContainer::propertyItem(size_t i) const -{ +Data1DProperties* DataPropertyContainer::propertyItem(size_t i) const { auto children = getItems(); if (children.empty()) return nullptr; @@ -44,16 +41,14 @@ Data1DProperties* DataPropertyContainer::propertyItem(size_t i) const return property_item; } -DataItem* DataPropertyContainer::basicDataItem() -{ +DataItem* DataPropertyContainer::basicDataItem() { auto basic_property_item = propertyItem(0); if (!basic_property_item) return nullptr; return basic_property_item->dataItem(); } -void DataPropertyContainer::addItem(DataItem* data_item) -{ +void DataPropertyContainer::addItem(DataItem* data_item) { if (this->model() != data_item->model()) throw GUIHelpers::Error( "Error in DataPropertyContainer::addItem: hosting models are different"); @@ -69,8 +64,7 @@ void DataPropertyContainer::addItem(DataItem* data_item) property_item->setColorProperty(Data1DProperties::nextColorName(previous_item)); } -std::vector<DataItem*> DataPropertyContainer::dataItems() -{ +std::vector<DataItem*> DataPropertyContainer::dataItems() { std::vector<DataItem*> result; auto items = propertyItems(); std::transform(items.begin(), items.end(), std::back_inserter(result), @@ -82,7 +76,6 @@ std::vector<DataItem*> DataPropertyContainer::dataItems() return result; } -DataItem* DataPropertyContainer::dataItem(size_t i) const -{ +DataItem* DataPropertyContainer::dataItem(size_t i) const { return propertyItem(i)->dataItem(); } diff --git a/GUI/coregui/Models/DataPropertyContainer.h b/GUI/coregui/Models/DataPropertyContainer.h index f535b523df2c9f1c9732fc4fa1ff466aaa6c31ee..ccc31e36b011d7c50459cc1fb2b66ebf13b42f0a 100644 --- a/GUI/coregui/Models/DataPropertyContainer.h +++ b/GUI/coregui/Models/DataPropertyContainer.h @@ -22,8 +22,7 @@ class DataProperties; class Data1DProperties; template <class T> class OutputData; -class BA_CORE_API_ DataPropertyContainer : public SessionItem -{ +class BA_CORE_API_ DataPropertyContainer : public SessionItem { static const QString T_CHILDREN; public: diff --git a/GUI/coregui/Models/DataViewUtils.cpp b/GUI/coregui/Models/DataViewUtils.cpp index e3efedc248d805efac5c7b7045d1984afb6ff9fd..cdb7d12544a43231bbb61e1132e22741cc20d991 100644 --- a/GUI/coregui/Models/DataViewUtils.cpp +++ b/GUI/coregui/Models/DataViewUtils.cpp @@ -21,26 +21,22 @@ #include "GUI/coregui/Models/JobItem.h" #include "GUI/coregui/Models/JobItemUtils.h" -namespace -{ -std::unique_ptr<IUnitConverter> getConverter(Data1DViewItem* view_item) -{ +namespace { +std::unique_ptr<IUnitConverter> getConverter(Data1DViewItem* view_item) { auto job_item = view_item->jobItem(); ASSERT(job_item->instrumentItem()); return DomainObjectBuilder::createUnitConverter(job_item->instrumentItem()); } -Axes::Units selectedUnits(Data1DViewItem* view_item) -{ +Axes::Units selectedUnits(Data1DViewItem* view_item) { auto current_unit_name = view_item->getItemValue(Data1DViewItem::P_AXES_UNITS).value<ComboProperty>().getValue(); return JobItemUtils::axesUnitsFromName(current_unit_name); } } // namespace -void DataViewUtils::updateAxesTitle(Data1DViewItem* view_item) -{ +void DataViewUtils::updateAxesTitle(Data1DViewItem* view_item) { auto converter = getConverter(view_item); if (!converter) return; @@ -51,8 +47,7 @@ void DataViewUtils::updateAxesTitle(Data1DViewItem* view_item) } std::unique_ptr<OutputData<double>> DataViewUtils::getTranslatedData(Data1DViewItem* view_item, - DataItem* data_item) -{ + DataItem* data_item) { std::unique_ptr<OutputData<double>> result; if (!data_item || !data_item->getOutputData()) return result; diff --git a/GUI/coregui/Models/DataViewUtils.h b/GUI/coregui/Models/DataViewUtils.h index b1bf02355313de5e43dad9cf799c1d3057611299..c726a04ddec79c57879476af8019a24d512ff3e6 100644 --- a/GUI/coregui/Models/DataViewUtils.h +++ b/GUI/coregui/Models/DataViewUtils.h @@ -24,8 +24,7 @@ class Data1DViewItem; class JobItem; template <class T> class OutputData; -namespace DataViewUtils -{ +namespace DataViewUtils { void updateAxesTitle(Data1DViewItem* view_item); std::unique_ptr<OutputData<double>> getTranslatedData(Data1DViewItem* view_item, diff --git a/GUI/coregui/Models/DepthProbeInstrumentItem.cpp b/GUI/coregui/Models/DepthProbeInstrumentItem.cpp index ffdf251183ba52d5aeefcb6fa7c35b4714dff68a..d856299084dc733165c1d3eedc9bee4303abec9e 100644 --- a/GUI/coregui/Models/DepthProbeInstrumentItem.cpp +++ b/GUI/coregui/Models/DepthProbeInstrumentItem.cpp @@ -24,8 +24,7 @@ const QString DepthProbeInstrumentItem::P_BEAM = "Beam"; const QString DepthProbeInstrumentItem::P_Z_AXIS = "Z axis"; -DepthProbeInstrumentItem::DepthProbeInstrumentItem() : InstrumentItem("DepthProbeInstrument") -{ +DepthProbeInstrumentItem::DepthProbeInstrumentItem() : InstrumentItem("DepthProbeInstrument") { setItemName("DepthProbeInstrument"); addGroupProperty(P_BEAM, "SpecularBeam"); @@ -46,28 +45,23 @@ DepthProbeInstrumentItem::DepthProbeInstrumentItem() : InstrumentItem("DepthProb axis->getItem(BasicAxisItem::P_MAX_DEG)->setToolTip("Ending value above sample horizont in nm"); } -SpecularBeamItem* DepthProbeInstrumentItem::beamItem() const -{ +SpecularBeamItem* DepthProbeInstrumentItem::beamItem() const { return &item<SpecularBeamItem>(P_BEAM); } -std::unique_ptr<Instrument> DepthProbeInstrumentItem::createInstrument() const -{ +std::unique_ptr<Instrument> DepthProbeInstrumentItem::createInstrument() const { throw std::runtime_error("DepthProbeInstrumentItem::createInstrument()"); } -std::vector<int> DepthProbeInstrumentItem::shape() const -{ +std::vector<int> DepthProbeInstrumentItem::shape() const { return std::vector<int>(); // no certain shape to avoid linking to real data } -void DepthProbeInstrumentItem::updateToRealData(const RealDataItem*) -{ +void DepthProbeInstrumentItem::updateToRealData(const RealDataItem*) { throw std::runtime_error("DepthProbeInstrumentItem::updateToRealData()"); } -std::unique_ptr<DepthProbeSimulation> DepthProbeInstrumentItem::createSimulation() const -{ +std::unique_ptr<DepthProbeSimulation> DepthProbeInstrumentItem::createSimulation() const { std::unique_ptr<DepthProbeSimulation> simulation = std::make_unique<DepthProbeSimulation>(); const auto axis_item = beamItem()->currentInclinationAxisItem(); @@ -93,7 +87,6 @@ std::unique_ptr<DepthProbeSimulation> DepthProbeInstrumentItem::createSimulation return simulation; } -std::unique_ptr<IUnitConverter> DepthProbeInstrumentItem::createUnitConverter() const -{ +std::unique_ptr<IUnitConverter> DepthProbeInstrumentItem::createUnitConverter() const { return createSimulation()->createUnitConverter(); } diff --git a/GUI/coregui/Models/DepthProbeInstrumentItem.h b/GUI/coregui/Models/DepthProbeInstrumentItem.h index fd77716aaafb5f58d2ce6e4ebbc63b22bc174e75..7ef8f5d5834e3cbcdd8f00099e9704fa0199ca1e 100644 --- a/GUI/coregui/Models/DepthProbeInstrumentItem.h +++ b/GUI/coregui/Models/DepthProbeInstrumentItem.h @@ -21,8 +21,7 @@ class DepthProbeSimulation; //! Depth probe instrument. -class BA_CORE_API_ DepthProbeInstrumentItem : public InstrumentItem -{ +class BA_CORE_API_ DepthProbeInstrumentItem : public InstrumentItem { public: static const QString P_BEAM; static const QString P_Z_AXIS; diff --git a/GUI/coregui/Models/DetectorItems.cpp b/GUI/coregui/Models/DetectorItems.cpp index 1a7ffe91ecef9b1f02879ff28c5fdf5ec617d2b5..bc3cbbbf698b322eeed331a4e7db3c51b4dfcb30 100644 --- a/GUI/coregui/Models/DetectorItems.cpp +++ b/GUI/coregui/Models/DetectorItems.cpp @@ -23,8 +23,7 @@ using SessionItemUtils::GetVectorItem; -namespace -{ +namespace { const QString res_func_group_label = "Type"; const QString analyzer_direction_tooltip = "Direction of the polarization analysis"; const QString analyzer_efficiency_tooltip = "Efficiency of the polarization analysis"; @@ -37,8 +36,7 @@ const QString DetectorItem::P_ANALYZER_DIRECTION = "Analyzer direction"; const QString DetectorItem::P_ANALYZER_EFFICIENCY = QString::fromStdString("Efficiency"); const QString DetectorItem::P_ANALYZER_TOTAL_TRANSMISSION = QString::fromStdString("Transmission"); -DetectorItem::DetectorItem(const QString& modelType) : SessionItem(modelType) -{ +DetectorItem::DetectorItem(const QString& modelType) : SessionItem(modelType) { registerTag(T_MASKS, 0, -1, QStringList() << "MaskContainer"); setDefaultTag(T_MASKS); @@ -59,8 +57,7 @@ DetectorItem::DetectorItem(const QString& modelType) : SessionItem(modelType) }); } -std::unique_ptr<IDetector2D> DetectorItem::createDetector() const -{ +std::unique_ptr<IDetector2D> DetectorItem::createDetector() const { auto result = createDomainDetector(); addMasksToDomain(result.get()); @@ -76,40 +73,34 @@ std::unique_ptr<IDetector2D> DetectorItem::createDetector() const return result; } -void DetectorItem::clearMasks() -{ +void DetectorItem::clearMasks() { if (auto maskContainer = maskContainerItem()) delete takeRow(rowOfChild(maskContainer)); } -MaskContainerItem* DetectorItem::maskContainerItem() const -{ +MaskContainerItem* DetectorItem::maskContainerItem() const { return dynamic_cast<MaskContainerItem*>(getItem(T_MASKS)); } -void DetectorItem::createMaskContainer() -{ +void DetectorItem::createMaskContainer() { if (!maskContainerItem()) model()->insertNewItem("MaskContainer", this->index()); } -void DetectorItem::importMasks(const MaskContainerItem* maskContainer) -{ +void DetectorItem::importMasks(const MaskContainerItem* maskContainer) { clearMasks(); if (maskContainer) model()->copyItem(maskContainer, this, T_MASKS); } -void DetectorItem::register_resolution_function() -{ +void DetectorItem::register_resolution_function() { auto item = addGroupProperty(P_RESOLUTION_FUNCTION, "Resolution function group"); item->setDisplayName(res_func_group_label); item->setToolTip("Detector resolution function"); } -void DetectorItem::update_resolution_function_tooltips() -{ +void DetectorItem::update_resolution_function_tooltips() { auto& resfuncItem = groupItem<ResolutionFunctionItem>(DetectorItem::P_RESOLUTION_FUNCTION); if (resfuncItem.modelType() == "ResolutionFunction2DGaussian") { @@ -122,14 +113,12 @@ void DetectorItem::update_resolution_function_tooltips() } } -std::unique_ptr<IResolutionFunction2D> DetectorItem::createResolutionFunction() const -{ +std::unique_ptr<IResolutionFunction2D> DetectorItem::createResolutionFunction() const { auto& resfuncItem = groupItem<ResolutionFunctionItem>(DetectorItem::P_RESOLUTION_FUNCTION); return resfuncItem.createResolutionFunction(axesToDomainUnitsFactor()); } -void DetectorItem::addMasksToDomain(IDetector2D* detector) const -{ +void DetectorItem::addMasksToDomain(IDetector2D* detector) const { auto maskContainer = maskContainerItem(); if (!maskContainer) diff --git a/GUI/coregui/Models/DetectorItems.h b/GUI/coregui/Models/DetectorItems.h index 6198f3f3602536066323dce4547731421cd17626..9e40a0d987bf489a702116f8b4250b5676e484ac 100644 --- a/GUI/coregui/Models/DetectorItems.h +++ b/GUI/coregui/Models/DetectorItems.h @@ -22,8 +22,7 @@ class IDetector2D; class IResolutionFunction2D; class DetectorItem; -class BA_CORE_API_ DetectorItem : public SessionItem -{ +class BA_CORE_API_ DetectorItem : public SessionItem { public: static const QString T_MASKS; static const QString P_RESOLUTION_FUNCTION; diff --git a/GUI/coregui/Models/DistributionItems.cpp b/GUI/coregui/Models/DistributionItems.cpp index 3dff6bfe25361e31ebb157b33dd133c38e7bdcff..ed9c5159869c7634e3ec02ca27b4b8c97405d63e 100644 --- a/GUI/coregui/Models/DistributionItems.cpp +++ b/GUI/coregui/Models/DistributionItems.cpp @@ -18,8 +18,7 @@ #include "Param/Distrib/RangedDistributions.h" #include <cmath> -namespace -{ +namespace { template <class DistrType> std::unique_ptr<RangedDistribution> createRangedDistribution(const SymmetricDistributionItem& distr_item, double scale); @@ -30,8 +29,7 @@ const QString DistributionItem::P_SIGMA_FACTOR = "Sigma factor"; const QString DistributionItem::P_IS_INITIALIZED = "is initialized"; const QString DistributionItem::P_LIMITS = "Limits"; -DistributionItem::DistributionItem(const QString& name) : SessionItem(name) -{ +DistributionItem::DistributionItem(const QString& name) : SessionItem(name) { addProperty(P_IS_INITIALIZED, false)->setVisible(false); } @@ -39,8 +37,7 @@ DistributionItem::DistributionItem(const QString& name) : SessionItem(name) //! Used by beamDistributionItem to propagate value from DistributionNone to the distribution //! currently selected by GroupItem. -void DistributionItem::init_parameters(double value, const RealLimits& limits) -{ +void DistributionItem::init_parameters(double value, const RealLimits& limits) { if (getItemValue(P_IS_INITIALIZED).toBool()) return; @@ -49,8 +46,7 @@ void DistributionItem::init_parameters(double value, const RealLimits& limits) setItemValue(P_IS_INITIALIZED, true); } -void DistributionItem::init_limits_group(const RealLimits& limits, double factor) -{ +void DistributionItem::init_limits_group(const RealLimits& limits, double factor) { if (!isTag(P_LIMITS)) return; if (limits.isLimitless()) { @@ -72,18 +68,15 @@ void DistributionItem::init_limits_group(const RealLimits& limits, double factor } } -void DistributionItem::register_number_of_samples() -{ +void DistributionItem::register_number_of_samples() { addProperty(P_NUMBER_OF_SAMPLES, 5)->setLimits(RealLimits::lowerLimited(1.0)); } -void DistributionItem::register_sigma_factor() -{ +void DistributionItem::register_sigma_factor() { addProperty(P_SIGMA_FACTOR, 2.0); } -void DistributionItem::register_limits() -{ +void DistributionItem::register_limits() { addGroupProperty(P_LIMITS, "RealLimits group"); setGroupProperty(P_LIMITS, "RealLimitsLimitless"); } @@ -92,41 +85,34 @@ void DistributionItem::register_limits() const QString SymmetricDistributionItem::P_MEAN = QString::fromStdString("Mean"); -SymmetricDistributionItem::SymmetricDistributionItem(const QString& name) : DistributionItem(name) -{ -} +SymmetricDistributionItem::SymmetricDistributionItem(const QString& name) + : DistributionItem(name) {} -void SymmetricDistributionItem::showMean(bool flag) -{ +void SymmetricDistributionItem::showMean(bool flag) { getItem(P_MEAN)->setVisible(flag); } // --------------------------------------------------------------------------------------------- // -DistributionNoneItem::DistributionNoneItem() : SymmetricDistributionItem("DistributionNone") -{ +DistributionNoneItem::DistributionNoneItem() : SymmetricDistributionItem("DistributionNone") { addProperty(P_MEAN, 0.1)->setLimits(RealLimits::limitless()).setDisplayName("Value"); getItem(P_MEAN)->setDecimals(4); } -std::unique_ptr<IDistribution1D> DistributionNoneItem::createDistribution(double scale) const -{ +std::unique_ptr<IDistribution1D> DistributionNoneItem::createDistribution(double scale) const { Q_UNUSED(scale); return nullptr; } -std::unique_ptr<RangedDistribution> DistributionNoneItem::createRangedDistribution(double) const -{ +std::unique_ptr<RangedDistribution> DistributionNoneItem::createRangedDistribution(double) const { return nullptr; } -double DistributionNoneItem::deviation(double) const -{ +double DistributionNoneItem::deviation(double) const { return 0.0; } -void DistributionNoneItem::init_distribution(double value) -{ +void DistributionNoneItem::init_distribution(double value) { setItemValue(DistributionNoneItem::P_MEAN, value); } @@ -135,8 +121,7 @@ void DistributionNoneItem::init_distribution(double value) const QString DistributionGateItem::P_MIN = QString::fromStdString("Min"); const QString DistributionGateItem::P_MAX = QString::fromStdString("Max"); -DistributionGateItem::DistributionGateItem() : DistributionItem("DistributionGate") -{ +DistributionGateItem::DistributionGateItem() : DistributionItem("DistributionGate") { addProperty(P_MIN, 0.0)->setLimits(RealLimits::limitless()); addProperty(P_MAX, 1.0)->setLimits(RealLimits::limitless()); register_number_of_samples(); @@ -144,15 +129,13 @@ DistributionGateItem::DistributionGateItem() : DistributionItem("DistributionGat getItem(P_LIMITS)->setVisible(false); } -std::unique_ptr<IDistribution1D> DistributionGateItem::createDistribution(double scale) const -{ +std::unique_ptr<IDistribution1D> DistributionGateItem::createDistribution(double scale) const { double min = getItemValue(P_MIN).toDouble(); double max = getItemValue(P_MAX).toDouble(); return std::make_unique<DistributionGate>(scale * min, scale * max); } -void DistributionGateItem::init_distribution(double value) -{ +void DistributionGateItem::init_distribution(double value) { double sigma(0.1 * std::abs(value)); if (sigma == 0.0) sigma = 0.1; @@ -165,8 +148,7 @@ void DistributionGateItem::init_distribution(double value) const QString DistributionLorentzItem::P_HWHM = QString::fromStdString("HWHM"); DistributionLorentzItem::DistributionLorentzItem() - : SymmetricDistributionItem("DistributionLorentz") -{ + : SymmetricDistributionItem("DistributionLorentz") { addProperty(P_MEAN, 1.0)->setLimits(RealLimits::limitless()); addProperty(P_HWHM, 1.0); register_number_of_samples(); @@ -174,26 +156,22 @@ DistributionLorentzItem::DistributionLorentzItem() register_limits(); } -std::unique_ptr<IDistribution1D> DistributionLorentzItem::createDistribution(double scale) const -{ +std::unique_ptr<IDistribution1D> DistributionLorentzItem::createDistribution(double scale) const { double mean = getItemValue(P_MEAN).toDouble(); double hwhm = getItemValue(P_HWHM).toDouble(); return std::make_unique<DistributionLorentz>(scale * mean, scale * hwhm); } std::unique_ptr<RangedDistribution> -DistributionLorentzItem::createRangedDistribution(double scale) const -{ +DistributionLorentzItem::createRangedDistribution(double scale) const { return ::createRangedDistribution<RangedDistributionLorentz>(*this, scale); } -double DistributionLorentzItem::deviation(double scale) const -{ +double DistributionLorentzItem::deviation(double scale) const { return getItemValue(P_HWHM).toDouble() * scale; } -void DistributionLorentzItem::init_distribution(double value) -{ +void DistributionLorentzItem::init_distribution(double value) { double sigma(0.1 * std::abs(value)); if (sigma == 0.0) sigma = 0.1; @@ -208,8 +186,7 @@ void DistributionLorentzItem::init_distribution(double value) const QString DistributionGaussianItem::P_STD_DEV = QString::fromStdString("StdDev"); DistributionGaussianItem::DistributionGaussianItem() - : SymmetricDistributionItem("DistributionGaussian") -{ + : SymmetricDistributionItem("DistributionGaussian") { addProperty(P_MEAN, 1.0)->setLimits(RealLimits::limitless()); addProperty(P_STD_DEV, 1.0); register_number_of_samples(); @@ -217,26 +194,22 @@ DistributionGaussianItem::DistributionGaussianItem() register_limits(); } -std::unique_ptr<IDistribution1D> DistributionGaussianItem::createDistribution(double scale) const -{ +std::unique_ptr<IDistribution1D> DistributionGaussianItem::createDistribution(double scale) const { double mean = getItemValue(P_MEAN).toDouble(); double std_dev = getItemValue(P_STD_DEV).toDouble(); return std::make_unique<DistributionGaussian>(scale * mean, scale * std_dev); } std::unique_ptr<RangedDistribution> -DistributionGaussianItem::createRangedDistribution(double scale) const -{ +DistributionGaussianItem::createRangedDistribution(double scale) const { return ::createRangedDistribution<RangedDistributionGaussian>(*this, scale); } -double DistributionGaussianItem::deviation(double scale) const -{ +double DistributionGaussianItem::deviation(double scale) const { return getItemValue(P_STD_DEV).toDouble() * scale; } -void DistributionGaussianItem::init_distribution(double value) -{ +void DistributionGaussianItem::init_distribution(double value) { double sigma(0.1 * std::abs(value)); if (sigma == 0.0) sigma = 0.1; @@ -251,8 +224,7 @@ void DistributionGaussianItem::init_distribution(double value) const QString DistributionLogNormalItem::P_MEDIAN = QString::fromStdString("Median"); const QString DistributionLogNormalItem::P_SCALE_PAR = QString::fromStdString("ScaleParameter"); -DistributionLogNormalItem::DistributionLogNormalItem() : DistributionItem("DistributionLogNormal") -{ +DistributionLogNormalItem::DistributionLogNormalItem() : DistributionItem("DistributionLogNormal") { addProperty(P_MEDIAN, 1.0); addProperty(P_SCALE_PAR, 1.0); register_number_of_samples(); @@ -260,15 +232,13 @@ DistributionLogNormalItem::DistributionLogNormalItem() : DistributionItem("Distr register_limits(); } -std::unique_ptr<IDistribution1D> DistributionLogNormalItem::createDistribution(double scale) const -{ +std::unique_ptr<IDistribution1D> DistributionLogNormalItem::createDistribution(double scale) const { double median = getItemValue(P_MEDIAN).toDouble(); double scale_par = getItemValue(P_SCALE_PAR).toDouble(); return std::make_unique<DistributionLogNormal>(scale * median, scale_par); } -void DistributionLogNormalItem::init_distribution(double value) -{ +void DistributionLogNormalItem::init_distribution(double value) { double sigma(0.1 * std::abs(value)); if (sigma == 0.0) sigma = 0.1; @@ -278,8 +248,7 @@ void DistributionLogNormalItem::init_distribution(double value) getItem(P_SCALE_PAR)->setLimits(RealLimits::lowerLimited(0.0)); } -void DistributionLogNormalItem::showMean(bool flag) -{ +void DistributionLogNormalItem::showMean(bool flag) { getItem(P_MEDIAN)->setVisible(flag); } @@ -287,8 +256,7 @@ void DistributionLogNormalItem::showMean(bool flag) const QString DistributionCosineItem::P_SIGMA = QString::fromStdString("Sigma"); -DistributionCosineItem::DistributionCosineItem() : SymmetricDistributionItem("DistributionCosine") -{ +DistributionCosineItem::DistributionCosineItem() : SymmetricDistributionItem("DistributionCosine") { addProperty(P_MEAN, 1.0)->setLimits(RealLimits::limitless()); addProperty(P_SIGMA, 1.0); register_number_of_samples(); @@ -296,26 +264,22 @@ DistributionCosineItem::DistributionCosineItem() : SymmetricDistributionItem("Di register_limits(); } -std::unique_ptr<IDistribution1D> DistributionCosineItem::createDistribution(double scale) const -{ +std::unique_ptr<IDistribution1D> DistributionCosineItem::createDistribution(double scale) const { double mean = getItemValue(P_MEAN).toDouble(); double sigma = getItemValue(P_SIGMA).toDouble(); return std::make_unique<DistributionCosine>(scale * mean, scale * sigma); } std::unique_ptr<RangedDistribution> -DistributionCosineItem::createRangedDistribution(double scale) const -{ +DistributionCosineItem::createRangedDistribution(double scale) const { return ::createRangedDistribution<RangedDistributionCosine>(*this, scale); } -double DistributionCosineItem::deviation(double scale) const -{ +double DistributionCosineItem::deviation(double scale) const { return getItemValue(P_SIGMA).toDouble() * scale; } -void DistributionCosineItem::init_distribution(double value) -{ +void DistributionCosineItem::init_distribution(double value) { double sigma(0.1 * std::abs(value)); if (sigma == 0.0) sigma = 0.1; @@ -332,8 +296,7 @@ const QString DistributionTrapezoidItem::P_LEFTWIDTH = QString::fromStdString("L const QString DistributionTrapezoidItem::P_MIDDLEWIDTH = QString::fromStdString("MiddleWidth"); const QString DistributionTrapezoidItem::P_RIGHTWIDTH = QString::fromStdString("RightWidth"); -DistributionTrapezoidItem::DistributionTrapezoidItem() : DistributionItem("DistributionTrapezoid") -{ +DistributionTrapezoidItem::DistributionTrapezoidItem() : DistributionItem("DistributionTrapezoid") { addProperty(P_CENTER, 1.0)->setLimits(RealLimits::limitless()); addProperty(P_LEFTWIDTH, 1.0); addProperty(P_MIDDLEWIDTH, 1.0); @@ -342,8 +305,7 @@ DistributionTrapezoidItem::DistributionTrapezoidItem() : DistributionItem("Distr register_limits(); } -std::unique_ptr<IDistribution1D> DistributionTrapezoidItem::createDistribution(double scale) const -{ +std::unique_ptr<IDistribution1D> DistributionTrapezoidItem::createDistribution(double scale) const { double center = getItemValue(P_CENTER).toDouble(); double left = getItemValue(P_LEFTWIDTH).toDouble(); double middle = getItemValue(P_MIDDLEWIDTH).toDouble(); @@ -352,8 +314,7 @@ std::unique_ptr<IDistribution1D> DistributionTrapezoidItem::createDistribution(d scale * right); } -void DistributionTrapezoidItem::init_distribution(double value) -{ +void DistributionTrapezoidItem::init_distribution(double value) { double width(0.1 * std::abs(value)); if (width == 0.0) width = 0.1; @@ -363,17 +324,14 @@ void DistributionTrapezoidItem::init_distribution(double value) setItemValue(P_RIGHTWIDTH, width); } -void DistributionTrapezoidItem::showMean(bool flag) -{ +void DistributionTrapezoidItem::showMean(bool flag) { getItem(P_CENTER)->setVisible(flag); } -namespace -{ +namespace { template <class DistrType> std::unique_ptr<RangedDistribution> -createRangedDistribution(const SymmetricDistributionItem& distr_item, double scale) -{ +createRangedDistribution(const SymmetricDistributionItem& distr_item, double scale) { int n_samples = distr_item.getItemValue(SymmetricDistributionItem::P_NUMBER_OF_SAMPLES).toInt(); double n_sig = distr_item.getItemValue(SymmetricDistributionItem::P_SIGMA_FACTOR).toDouble(); diff --git a/GUI/coregui/Models/DistributionItems.h b/GUI/coregui/Models/DistributionItems.h index 6f5b1b005aaf85e7252ce306e708640acb625940..577901bcfda38e2ae3d87d0c97c9b6317aa372f2 100644 --- a/GUI/coregui/Models/DistributionItems.h +++ b/GUI/coregui/Models/DistributionItems.h @@ -20,8 +20,7 @@ class IDistribution1D; class RangedDistribution; -class BA_CORE_API_ DistributionItem : public SessionItem -{ +class BA_CORE_API_ DistributionItem : public SessionItem { public: static const QString P_NUMBER_OF_SAMPLES; static const QString P_SIGMA_FACTOR; @@ -41,8 +40,7 @@ protected: void register_limits(); }; -class BA_CORE_API_ SymmetricDistributionItem : public DistributionItem -{ +class BA_CORE_API_ SymmetricDistributionItem : public DistributionItem { public: static const QString P_MEAN; @@ -53,8 +51,7 @@ public: virtual double deviation(double scale) const = 0; }; -class BA_CORE_API_ DistributionNoneItem : public SymmetricDistributionItem -{ +class BA_CORE_API_ DistributionNoneItem : public SymmetricDistributionItem { public: DistributionNoneItem(); @@ -65,8 +62,7 @@ public: void init_distribution(double value) override; }; -class BA_CORE_API_ DistributionGateItem : public DistributionItem -{ +class BA_CORE_API_ DistributionGateItem : public DistributionItem { public: static const QString P_MIN; static const QString P_MAX; @@ -77,8 +73,7 @@ public: void showMean(bool) override {} }; -class BA_CORE_API_ DistributionLorentzItem : public SymmetricDistributionItem -{ +class BA_CORE_API_ DistributionLorentzItem : public SymmetricDistributionItem { public: static const QString P_HWHM; DistributionLorentzItem(); @@ -89,8 +84,7 @@ public: void init_distribution(double value) override; }; -class BA_CORE_API_ DistributionGaussianItem : public SymmetricDistributionItem -{ +class BA_CORE_API_ DistributionGaussianItem : public SymmetricDistributionItem { public: static const QString P_STD_DEV; DistributionGaussianItem(); @@ -101,8 +95,7 @@ public: void init_distribution(double value) override; }; -class BA_CORE_API_ DistributionLogNormalItem : public DistributionItem -{ +class BA_CORE_API_ DistributionLogNormalItem : public DistributionItem { public: static const QString P_MEDIAN; @@ -114,8 +107,7 @@ public: void showMean(bool flag) override; }; -class BA_CORE_API_ DistributionCosineItem : public SymmetricDistributionItem -{ +class BA_CORE_API_ DistributionCosineItem : public SymmetricDistributionItem { public: static const QString P_SIGMA; DistributionCosineItem(); @@ -126,8 +118,7 @@ public: void init_distribution(double value) override; }; -class BA_CORE_API_ DistributionTrapezoidItem : public DistributionItem -{ +class BA_CORE_API_ DistributionTrapezoidItem : public DistributionItem { public: static const QString P_CENTER; static const QString P_LEFTWIDTH; diff --git a/GUI/coregui/Models/DocumentModel.cpp b/GUI/coregui/Models/DocumentModel.cpp index 6cb3ad078fde3c14e5d9dcf1b372393e222c8d27..054daebba64ae78f4f92f316c5aca84da71b2e06 100644 --- a/GUI/coregui/Models/DocumentModel.cpp +++ b/GUI/coregui/Models/DocumentModel.cpp @@ -15,12 +15,10 @@ #include "GUI/coregui/Models/DocumentModel.h" #include "GUI/coregui/Models/SimulationOptionsItem.h" -DocumentModel::DocumentModel(QObject* parent) : SessionModel(SessionXML::DocumentModelTag, parent) -{ +DocumentModel::DocumentModel(QObject* parent) : SessionModel(SessionXML::DocumentModelTag, parent) { setObjectName(SessionXML::DocumentModelTag); } -SimulationOptionsItem* DocumentModel::simulationOptionsItem() -{ +SimulationOptionsItem* DocumentModel::simulationOptionsItem() { return topItem<SimulationOptionsItem>(); } diff --git a/GUI/coregui/Models/DocumentModel.h b/GUI/coregui/Models/DocumentModel.h index fff4314bacc6209e0cb3273236ffc6c66bc2a89d..93ea02f862ae5b72332ce84b51128d53ba47200d 100644 --- a/GUI/coregui/Models/DocumentModel.h +++ b/GUI/coregui/Models/DocumentModel.h @@ -22,8 +22,7 @@ class SimulationOptionsItem; //! The DocumentModel class is a model with GUI settings related to the opened project. //! Can be the place to store splitter position, etc. -class DocumentModel : public SessionModel -{ +class DocumentModel : public SessionModel { Q_OBJECT public: diff --git a/GUI/coregui/Models/DomainObjectBuilder.cpp b/GUI/coregui/Models/DomainObjectBuilder.cpp index f63f3942ccd0ce28c0e6a6d13e0e8f1c4e52fc45..36f137bcfc104d49872ca06c03741dd80d7fa638 100644 --- a/GUI/coregui/Models/DomainObjectBuilder.cpp +++ b/GUI/coregui/Models/DomainObjectBuilder.cpp @@ -29,8 +29,8 @@ #include "GUI/coregui/Models/TransformToDomain.h" #include "GUI/coregui/utils/GUIHelpers.h" -std::unique_ptr<MultiLayer> DomainObjectBuilder::buildMultiLayer(const SessionItem& multilayer_item) -{ +std::unique_ptr<MultiLayer> +DomainObjectBuilder::buildMultiLayer(const SessionItem& multilayer_item) { auto P_multilayer = TransformToDomain::createMultiLayer(multilayer_item); QVector<SessionItem*> children = multilayer_item.children(); for (int i = 0; i < children.size(); ++i) { @@ -51,8 +51,7 @@ std::unique_ptr<MultiLayer> DomainObjectBuilder::buildMultiLayer(const SessionIt return P_multilayer; } -std::unique_ptr<Layer> DomainObjectBuilder::buildLayer(const SessionItem& item) -{ +std::unique_ptr<Layer> DomainObjectBuilder::buildLayer(const SessionItem& item) { auto P_layer = TransformToDomain::createLayer(item); QVector<SessionItem*> children = item.children(); for (int i = 0; i < children.size(); ++i) { @@ -66,8 +65,7 @@ std::unique_ptr<Layer> DomainObjectBuilder::buildLayer(const SessionItem& item) return P_layer; } -std::unique_ptr<ParticleLayout> DomainObjectBuilder::buildParticleLayout(const SessionItem& item) -{ +std::unique_ptr<ParticleLayout> DomainObjectBuilder::buildParticleLayout(const SessionItem& item) { auto P_layout = TransformToDomain::createParticleLayout(item); QVector<SessionItem*> children = item.getItems(); for (int i = 0; i < children.size(); ++i) { @@ -117,22 +115,19 @@ std::unique_ptr<ParticleLayout> DomainObjectBuilder::buildParticleLayout(const S } std::unique_ptr<IInterferenceFunction> -DomainObjectBuilder::buildInterferenceFunction(const SessionItem& item) -{ +DomainObjectBuilder::buildInterferenceFunction(const SessionItem& item) { auto iffItem = dynamic_cast<const InterferenceFunctionItem*>(&item); ASSERT(iffItem); return iffItem->createInterferenceFunction(); } std::unique_ptr<Instrument> -DomainObjectBuilder::buildInstrument(const InstrumentItem& instrumentItem) -{ +DomainObjectBuilder::buildInstrument(const InstrumentItem& instrumentItem) { return instrumentItem.createInstrument(); } std::unique_ptr<IUnitConverter> -DomainObjectBuilder::createUnitConverter(const InstrumentItem* instrumentItem) -{ +DomainObjectBuilder::createUnitConverter(const InstrumentItem* instrumentItem) { if (auto specular_instrument = dynamic_cast<const SpecularInstrumentItem*>(instrumentItem)) return specular_instrument->createUnitConverter(); else if (auto depth_instrument = dynamic_cast<const DepthProbeInstrumentItem*>(instrumentItem)) diff --git a/GUI/coregui/Models/DomainObjectBuilder.h b/GUI/coregui/Models/DomainObjectBuilder.h index bc866202f4c9e76669179d2d43497efd62020a23..0b95f746f2d1fc121c2ece92f5ad8ce4965cdb0e 100644 --- a/GUI/coregui/Models/DomainObjectBuilder.h +++ b/GUI/coregui/Models/DomainObjectBuilder.h @@ -26,8 +26,7 @@ class SessionItem; class InstrumentItem; class IUnitConverter; -namespace DomainObjectBuilder -{ +namespace DomainObjectBuilder { std::unique_ptr<MultiLayer> buildMultiLayer(const SessionItem& multilayer_item); std::unique_ptr<Layer> buildLayer(const SessionItem& item); std::unique_ptr<ParticleLayout> buildParticleLayout(const SessionItem& item); diff --git a/GUI/coregui/Models/DomainSimulationBuilder.cpp b/GUI/coregui/Models/DomainSimulationBuilder.cpp index f10edd4ff72ab46f6f6497751cf2717787080a92..253542281c4489a865198ef21127a3aa1db718e4 100644 --- a/GUI/coregui/Models/DomainSimulationBuilder.cpp +++ b/GUI/coregui/Models/DomainSimulationBuilder.cpp @@ -33,8 +33,7 @@ #include "GUI/coregui/Models/TransformToDomain.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { void addBackgroundToSimulation(const InstrumentItem& instrument, ISimulation& simulation); std::unique_ptr<GISASSimulation> createGISASSimulation(std::unique_ptr<MultiLayer> P_multilayer, @@ -61,8 +60,7 @@ createDepthProbeSimulation(std::unique_ptr<MultiLayer> P_multilayer, std::unique_ptr<ISimulation> DomainSimulationBuilder::createSimulation(const MultiLayerItem* sampleItem, const InstrumentItem* instrumentItem, - const SimulationOptionsItem* optionsItem) -{ + const SimulationOptionsItem* optionsItem) { if (sampleItem == nullptr || instrumentItem == nullptr) { QString message("DomainSimulationBuilder::getSimulation() -> Error. Either MultiLayerItem " " or InstrumentItem is not defined."); @@ -84,10 +82,8 @@ DomainSimulationBuilder::createSimulation(const MultiLayerItem* sampleItem, "DomainSimulationBuilder::createSimulation() -> Error. Not yet implemented"); } -namespace -{ -void addBackgroundToSimulation(const InstrumentItem& instrument, ISimulation& simulation) -{ +namespace { +void addBackgroundToSimulation(const InstrumentItem& instrument, ISimulation& simulation) { auto P_background = instrument.backgroundItem()->createBackground(); if (P_background) simulation.setBackground(*P_background); @@ -95,8 +91,7 @@ void addBackgroundToSimulation(const InstrumentItem& instrument, ISimulation& si std::unique_ptr<GISASSimulation> createGISASSimulation(std::unique_ptr<MultiLayer> P_multilayer, const GISASInstrumentItem* instrument, - const SimulationOptionsItem* optionsItem) -{ + const SimulationOptionsItem* optionsItem) { std::unique_ptr<GISASSimulation> ret(new GISASSimulation); auto P_instrument = DomainObjectBuilder::buildInstrument(*instrument); ret->setSample(*P_multilayer); @@ -112,10 +107,10 @@ std::unique_ptr<GISASSimulation> createGISASSimulation(std::unique_ptr<MultiLaye return ret; } -std::unique_ptr<OffSpecSimulation> createOffSpecSimulation(std::unique_ptr<MultiLayer> P_multilayer, - const OffSpecInstrumentItem* instrument, - const SimulationOptionsItem* optionsItem) -{ +std::unique_ptr<OffSpecSimulation> +createOffSpecSimulation(std::unique_ptr<MultiLayer> P_multilayer, + const OffSpecInstrumentItem* instrument, + const SimulationOptionsItem* optionsItem) { std::unique_ptr<OffSpecSimulation> ret(new OffSpecSimulation); auto P_instrument = DomainObjectBuilder::buildInstrument(*instrument); ret->setSample(*P_multilayer); @@ -143,8 +138,7 @@ std::unique_ptr<OffSpecSimulation> createOffSpecSimulation(std::unique_ptr<Multi std::unique_ptr<SpecularSimulation> createSpecularSimulation(std::unique_ptr<MultiLayer> P_multilayer, const SpecularInstrumentItem* instrument, - const SimulationOptionsItem* options_item) -{ + const SimulationOptionsItem* options_item) { std::unique_ptr<SpecularSimulation> ret = std::make_unique<SpecularSimulation>(); ret->setSample(*P_multilayer); @@ -172,8 +166,7 @@ createSpecularSimulation(std::unique_ptr<MultiLayer> P_multilayer, std::unique_ptr<DepthProbeSimulation> createDepthProbeSimulation(std::unique_ptr<MultiLayer> P_multilayer, const DepthProbeInstrumentItem* instrument, - const SimulationOptionsItem* options_item) -{ + const SimulationOptionsItem* options_item) { std::unique_ptr<DepthProbeSimulation> ret = instrument->createSimulation(); ret->setSample(*P_multilayer); diff --git a/GUI/coregui/Models/DomainSimulationBuilder.h b/GUI/coregui/Models/DomainSimulationBuilder.h index 73241d00e78eb2bfefc4e627911f90927b083f0a..ef334e2f98cd4f76553d5fc16e0d2b5b3b2d5f03 100644 --- a/GUI/coregui/Models/DomainSimulationBuilder.h +++ b/GUI/coregui/Models/DomainSimulationBuilder.h @@ -24,8 +24,7 @@ class SimulationOptionsItem; //! Contains functions to build the domain simulation from instrument and sample models. -namespace DomainSimulationBuilder -{ +namespace DomainSimulationBuilder { //! Creates domain simulation from sample and instrument items. diff --git a/GUI/coregui/Models/FTDecayFunctionItems.cpp b/GUI/coregui/Models/FTDecayFunctionItems.cpp index 4dedecaf00c33d8c1f8b77448a5eae93d96c89f6..7affc9055531415ef099f50292657eb3806b65fb 100644 --- a/GUI/coregui/Models/FTDecayFunctionItems.cpp +++ b/GUI/coregui/Models/FTDecayFunctionItems.cpp @@ -21,8 +21,7 @@ const QString FTDecayFunction1DItem::P_DECAY_LENGTH = QString::fromStdString("De FTDecayFunction1DItem::FTDecayFunction1DItem(const QString& name) : SessionItem(name) {} -void FTDecayFunction1DItem::add_decay_property() -{ +void FTDecayFunction1DItem::add_decay_property() { addProperty(P_DECAY_LENGTH, 1000.0) ->setToolTip("Decay length (half-width of the distribution in nanometers)"); } @@ -30,42 +29,36 @@ void FTDecayFunction1DItem::add_decay_property() // --------------------------------------------------------------------------------------------- // FTDecayFunction1DCauchyItem::FTDecayFunction1DCauchyItem() - : FTDecayFunction1DItem("FTDecayFunction1DCauchy") -{ + : FTDecayFunction1DItem("FTDecayFunction1DCauchy") { setToolTip("One-dimensional Cauchy decay function"); add_decay_property(); } -std::unique_ptr<IFTDecayFunction1D> FTDecayFunction1DCauchyItem::createFTDecayFunction() const -{ +std::unique_ptr<IFTDecayFunction1D> FTDecayFunction1DCauchyItem::createFTDecayFunction() const { return std::make_unique<FTDecayFunction1DCauchy>(getItemValue(P_DECAY_LENGTH).toDouble()); } // --------------------------------------------------------------------------------------------- // FTDecayFunction1DGaussItem::FTDecayFunction1DGaussItem() - : FTDecayFunction1DItem("FTDecayFunction1DGauss") -{ + : FTDecayFunction1DItem("FTDecayFunction1DGauss") { setToolTip("One-dimensional Gauss decay function"); add_decay_property(); } -std::unique_ptr<IFTDecayFunction1D> FTDecayFunction1DGaussItem::createFTDecayFunction() const -{ +std::unique_ptr<IFTDecayFunction1D> FTDecayFunction1DGaussItem::createFTDecayFunction() const { return std::make_unique<FTDecayFunction1DGauss>(getItemValue(P_DECAY_LENGTH).toDouble()); } // --------------------------------------------------------------------------------------------- // FTDecayFunction1DTriangleItem::FTDecayFunction1DTriangleItem() - : FTDecayFunction1DItem("FTDecayFunction1DTriangle") -{ + : FTDecayFunction1DItem("FTDecayFunction1DTriangle") { setToolTip("One-dimensional triangle decay function"); add_decay_property(); } -std::unique_ptr<IFTDecayFunction1D> FTDecayFunction1DTriangleItem::createFTDecayFunction() const -{ +std::unique_ptr<IFTDecayFunction1D> FTDecayFunction1DTriangleItem::createFTDecayFunction() const { return std::make_unique<FTDecayFunction1DTriangle>(getItemValue(P_DECAY_LENGTH).toDouble()); } @@ -74,8 +67,7 @@ std::unique_ptr<IFTDecayFunction1D> FTDecayFunction1DTriangleItem::createFTDecay const QString FTDecayFunction1DVoigtItem::P_ETA = QString::fromStdString("Eta"); FTDecayFunction1DVoigtItem::FTDecayFunction1DVoigtItem() - : FTDecayFunction1DItem("FTDecayFunction1DVoigt") -{ + : FTDecayFunction1DItem("FTDecayFunction1DVoigt") { setToolTip("One-dimensional pseudo-Voigt decay function"); add_decay_property(); addProperty(P_ETA, 0.5) @@ -83,8 +75,7 @@ FTDecayFunction1DVoigtItem::FTDecayFunction1DVoigtItem() .setToolTip("Parameter [0,1] to balance between Cauchy (eta=0.0) and Gauss (eta=1.0)"); } -std::unique_ptr<IFTDecayFunction1D> FTDecayFunction1DVoigtItem::createFTDecayFunction() const -{ +std::unique_ptr<IFTDecayFunction1D> FTDecayFunction1DVoigtItem::createFTDecayFunction() const { return std::make_unique<FTDecayFunction1DVoigt>(getItemValue(P_DECAY_LENGTH).toDouble(), getItemValue(P_ETA).toDouble()); } @@ -98,8 +89,7 @@ const QString FTDecayFunction2DItem::P_DELTA = QString::fromStdString("Delta"); FTDecayFunction2DItem::FTDecayFunction2DItem(const QString& name) : SessionItem(name) {} -void FTDecayFunction2DItem::add_decay_property() -{ +void FTDecayFunction2DItem::add_decay_property() { addProperty(P_DECAY_LENGTH_X, 1000.0) ->setToolTip("Decay length (half-width of the distribution in nanometers) " "\nalong x-axis of the distribution"); @@ -108,8 +98,7 @@ void FTDecayFunction2DItem::add_decay_property() "\nalong y-axis of the distribution"); } -void FTDecayFunction2DItem::add_gammadelta_property() -{ +void FTDecayFunction2DItem::add_gammadelta_property() { addProperty(P_GAMMA, 0.0) ->setToolTip( "Distribution orientation with respect to the first lattice vector in degrees"); @@ -119,15 +108,13 @@ void FTDecayFunction2DItem::add_gammadelta_property() // --------------------------------------------------------------------------------------------- // FTDecayFunction2DCauchyItem::FTDecayFunction2DCauchyItem() - : FTDecayFunction2DItem("FTDecayFunction2DCauchy") -{ + : FTDecayFunction2DItem("FTDecayFunction2DCauchy") { setToolTip("Two-dimensional Cauchy decay function"); add_decay_property(); add_gammadelta_property(); } -std::unique_ptr<IFTDecayFunction2D> FTDecayFunction2DCauchyItem::createFTDecayFunction() const -{ +std::unique_ptr<IFTDecayFunction2D> FTDecayFunction2DCauchyItem::createFTDecayFunction() const { return std::make_unique<FTDecayFunction2DCauchy>( getItemValue(P_DECAY_LENGTH_X).toDouble(), getItemValue(P_DECAY_LENGTH_Y).toDouble(), Units::deg2rad(getItemValue(P_GAMMA).toDouble())); @@ -136,15 +123,13 @@ std::unique_ptr<IFTDecayFunction2D> FTDecayFunction2DCauchyItem::createFTDecayFu // --------------------------------------------------------------------------------------------- // FTDecayFunction2DGaussItem::FTDecayFunction2DGaussItem() - : FTDecayFunction2DItem("FTDecayFunction2DGauss") -{ + : FTDecayFunction2DItem("FTDecayFunction2DGauss") { setToolTip("Two-dimensional Gauss decay function"); add_decay_property(); add_gammadelta_property(); } -std::unique_ptr<IFTDecayFunction2D> FTDecayFunction2DGaussItem::createFTDecayFunction() const -{ +std::unique_ptr<IFTDecayFunction2D> FTDecayFunction2DGaussItem::createFTDecayFunction() const { return std::make_unique<FTDecayFunction2DGauss>( getItemValue(P_DECAY_LENGTH_X).toDouble(), getItemValue(P_DECAY_LENGTH_Y).toDouble(), Units::deg2rad(getItemValue(P_GAMMA).toDouble())); @@ -155,8 +140,7 @@ std::unique_ptr<IFTDecayFunction2D> FTDecayFunction2DGaussItem::createFTDecayFun const QString FTDecayFunction2DVoigtItem::P_ETA = QString::fromStdString("Eta"); FTDecayFunction2DVoigtItem::FTDecayFunction2DVoigtItem() - : FTDecayFunction2DItem("FTDecayFunction2DVoigt") -{ + : FTDecayFunction2DItem("FTDecayFunction2DVoigt") { setToolTip("Two-dimensional pseudo-Voigt decay function"); add_decay_property(); addProperty(P_ETA, 0.5) @@ -165,8 +149,7 @@ FTDecayFunction2DVoigtItem::FTDecayFunction2DVoigtItem() add_gammadelta_property(); } -std::unique_ptr<IFTDecayFunction2D> FTDecayFunction2DVoigtItem::createFTDecayFunction() const -{ +std::unique_ptr<IFTDecayFunction2D> FTDecayFunction2DVoigtItem::createFTDecayFunction() const { return std::make_unique<FTDecayFunction2DVoigt>( getItemValue(P_DECAY_LENGTH_X).toDouble(), getItemValue(P_DECAY_LENGTH_Y).toDouble(), getItemValue(P_ETA).toDouble(), Units::deg2rad(getItemValue(P_GAMMA).toDouble())); diff --git a/GUI/coregui/Models/FTDecayFunctionItems.h b/GUI/coregui/Models/FTDecayFunctionItems.h index 44cd8517ebe9365487f4a064de0189c864316ebd..27dfa31a773c3991b4686c44be16620aac376687 100644 --- a/GUI/coregui/Models/FTDecayFunctionItems.h +++ b/GUI/coregui/Models/FTDecayFunctionItems.h @@ -19,8 +19,7 @@ #include "Sample/Correlations/FTDecay1D.h" #include "Sample/Correlations/FTDecay2D.h" -class BA_CORE_API_ FTDecayFunction1DItem : public SessionItem -{ +class BA_CORE_API_ FTDecayFunction1DItem : public SessionItem { public: static const QString P_DECAY_LENGTH; explicit FTDecayFunction1DItem(const QString& name); @@ -31,29 +30,25 @@ protected: void add_decay_property(); }; -class BA_CORE_API_ FTDecayFunction1DCauchyItem : public FTDecayFunction1DItem -{ +class BA_CORE_API_ FTDecayFunction1DCauchyItem : public FTDecayFunction1DItem { public: FTDecayFunction1DCauchyItem(); std::unique_ptr<IFTDecayFunction1D> createFTDecayFunction() const; }; -class BA_CORE_API_ FTDecayFunction1DGaussItem : public FTDecayFunction1DItem -{ +class BA_CORE_API_ FTDecayFunction1DGaussItem : public FTDecayFunction1DItem { public: FTDecayFunction1DGaussItem(); std::unique_ptr<IFTDecayFunction1D> createFTDecayFunction() const; }; -class BA_CORE_API_ FTDecayFunction1DTriangleItem : public FTDecayFunction1DItem -{ +class BA_CORE_API_ FTDecayFunction1DTriangleItem : public FTDecayFunction1DItem { public: FTDecayFunction1DTriangleItem(); std::unique_ptr<IFTDecayFunction1D> createFTDecayFunction() const; }; -class BA_CORE_API_ FTDecayFunction1DVoigtItem : public FTDecayFunction1DItem -{ +class BA_CORE_API_ FTDecayFunction1DVoigtItem : public FTDecayFunction1DItem { public: static const QString P_ETA; FTDecayFunction1DVoigtItem(); @@ -62,8 +57,7 @@ public: // --------------------------------------------------------------------------------------------- // -class BA_CORE_API_ FTDecayFunction2DItem : public SessionItem -{ +class BA_CORE_API_ FTDecayFunction2DItem : public SessionItem { public: static const QString P_DECAY_LENGTH_X; static const QString P_DECAY_LENGTH_Y; @@ -78,22 +72,19 @@ protected: void add_gammadelta_property(); }; -class BA_CORE_API_ FTDecayFunction2DCauchyItem : public FTDecayFunction2DItem -{ +class BA_CORE_API_ FTDecayFunction2DCauchyItem : public FTDecayFunction2DItem { public: FTDecayFunction2DCauchyItem(); std::unique_ptr<IFTDecayFunction2D> createFTDecayFunction() const; }; -class BA_CORE_API_ FTDecayFunction2DGaussItem : public FTDecayFunction2DItem -{ +class BA_CORE_API_ FTDecayFunction2DGaussItem : public FTDecayFunction2DItem { public: FTDecayFunction2DGaussItem(); std::unique_ptr<IFTDecayFunction2D> createFTDecayFunction() const; }; -class BA_CORE_API_ FTDecayFunction2DVoigtItem : public FTDecayFunction2DItem -{ +class BA_CORE_API_ FTDecayFunction2DVoigtItem : public FTDecayFunction2DItem { public: static const QString P_ETA; FTDecayFunction2DVoigtItem(); diff --git a/GUI/coregui/Models/FTDistributionItems.cpp b/GUI/coregui/Models/FTDistributionItems.cpp index 878149cd9277dbaed3b89c4a99429f3466f935b0..a36ebc15fbe6b8f86c6b6ba414c76a9bff45d97f 100644 --- a/GUI/coregui/Models/FTDistributionItems.cpp +++ b/GUI/coregui/Models/FTDistributionItems.cpp @@ -19,77 +19,67 @@ const QString FTDistribution1DItem::P_OMEGA = QString::fromStdString("Omega"); FTDistribution1DItem::FTDistribution1DItem(const QString& name) : SessionItem(name) {} -void FTDistribution1DItem::add_omega_property() -{ +void FTDistribution1DItem::add_omega_property() { addProperty(P_OMEGA, 1.0)->setToolTip("Half-width of the distribution in nanometers"); } // --------------------------------------------------------------------------------------------- // FTDistribution1DCauchyItem::FTDistribution1DCauchyItem() - : FTDistribution1DItem("FTDistribution1DCauchy") -{ + : FTDistribution1DItem("FTDistribution1DCauchy") { setToolTip("One-dimensional Cauchy probability distribution"); add_omega_property(); } -std::unique_ptr<IFTDistribution1D> FTDistribution1DCauchyItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution1D> FTDistribution1DCauchyItem::createFTDistribution() const { return std::make_unique<FTDistribution1DCauchy>(getItemValue(P_OMEGA).toDouble()); } // --------------------------------------------------------------------------------------------- // FTDistribution1DGaussItem::FTDistribution1DGaussItem() - : FTDistribution1DItem("FTDistribution1DGauss") -{ + : FTDistribution1DItem("FTDistribution1DGauss") { setToolTip("One-dimensional Gauss probability distribution"); add_omega_property(); } -std::unique_ptr<IFTDistribution1D> FTDistribution1DGaussItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution1D> FTDistribution1DGaussItem::createFTDistribution() const { return std::make_unique<FTDistribution1DGauss>(getItemValue(P_OMEGA).toDouble()); } // --------------------------------------------------------------------------------------------- // -FTDistribution1DGateItem::FTDistribution1DGateItem() : FTDistribution1DItem("FTDistribution1DGate") -{ +FTDistribution1DGateItem::FTDistribution1DGateItem() + : FTDistribution1DItem("FTDistribution1DGate") { setToolTip("One-dimensional Gate probability distribution"); add_omega_property(); } -std::unique_ptr<IFTDistribution1D> FTDistribution1DGateItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution1D> FTDistribution1DGateItem::createFTDistribution() const { return std::make_unique<FTDistribution1DGate>(getItemValue(P_OMEGA).toDouble()); } // --------------------------------------------------------------------------------------------- // FTDistribution1DTriangleItem::FTDistribution1DTriangleItem() - : FTDistribution1DItem("FTDistribution1DTriangle") -{ + : FTDistribution1DItem("FTDistribution1DTriangle") { setToolTip("One-dimensional triangle probability distribution"); add_omega_property(); } -std::unique_ptr<IFTDistribution1D> FTDistribution1DTriangleItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution1D> FTDistribution1DTriangleItem::createFTDistribution() const { return std::make_unique<FTDistribution1DTriangle>(getItemValue(P_OMEGA).toDouble()); } // --------------------------------------------------------------------------------------------- // FTDistribution1DCosineItem::FTDistribution1DCosineItem() - : FTDistribution1DItem("FTDistribution1DCosine") -{ + : FTDistribution1DItem("FTDistribution1DCosine") { setToolTip("One-dimensional Cosine probability distribution"); add_omega_property(); } -std::unique_ptr<IFTDistribution1D> FTDistribution1DCosineItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution1D> FTDistribution1DCosineItem::createFTDistribution() const { return std::make_unique<FTDistribution1DCosine>(getItemValue(P_OMEGA).toDouble()); } @@ -98,8 +88,7 @@ std::unique_ptr<IFTDistribution1D> FTDistribution1DCosineItem::createFTDistribut const QString FTDistribution1DVoigtItem::P_ETA = QString::fromStdString("Eta"); FTDistribution1DVoigtItem::FTDistribution1DVoigtItem() - : FTDistribution1DItem("FTDistribution1DVoigt") -{ + : FTDistribution1DItem("FTDistribution1DVoigt") { setToolTip("One-dimensional pseudo-Voigt probability distribution"); add_omega_property(); addProperty(P_ETA, 0.5) @@ -107,8 +96,7 @@ FTDistribution1DVoigtItem::FTDistribution1DVoigtItem() .setToolTip("Parameter [0,1] to balance between Cauchy (eta=0.0) and Gauss (eta=1.0)"); } -std::unique_ptr<IFTDistribution1D> FTDistribution1DVoigtItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution1D> FTDistribution1DVoigtItem::createFTDistribution() const { return std::make_unique<FTDistribution1DVoigt>(getItemValue(P_OMEGA).toDouble(), getItemValue(P_ETA).toDouble()); } @@ -121,23 +109,20 @@ const QString FTDistribution2DItem::P_GAMMA = QString::fromStdString("Gamma"); FTDistribution2DItem::FTDistribution2DItem(const QString& name) : SessionItem(name) {} -void FTDistribution2DItem::add_omega_properties() -{ +void FTDistribution2DItem::add_omega_properties() { addProperty(P_OMEGA_X, 1.0) ->setToolTip("Half-width of the distribution along its x-axis in nanometers"); addProperty(P_OMEGA_Y, 1.0) ->setToolTip("Half-width of the distribution along its y-axis in nanometers"); } -void FTDistribution2DItem::add_gamma_property() -{ +void FTDistribution2DItem::add_gamma_property() { addProperty(P_GAMMA, 0.0) ->setToolTip("Angle in direct space between " "first lattice vector \nand x-axis of the distribution in degrees"); } -void FTDistribution2DItem::add_properties() -{ +void FTDistribution2DItem::add_properties() { add_omega_properties(); add_gamma_property(); } @@ -145,14 +130,12 @@ void FTDistribution2DItem::add_properties() // --------------------------------------------------------------------------------------------- // FTDistribution2DCauchyItem::FTDistribution2DCauchyItem() - : FTDistribution2DItem("FTDistribution2DCauchy") -{ + : FTDistribution2DItem("FTDistribution2DCauchy") { setToolTip("Two-dimensional Cauchy probability distribution"); add_properties(); } -std::unique_ptr<IFTDistribution2D> FTDistribution2DCauchyItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution2D> FTDistribution2DCauchyItem::createFTDistribution() const { return std::make_unique<FTDistribution2DCauchy>( getItemValue(P_OMEGA_X).toDouble(), getItemValue(P_OMEGA_Y).toDouble(), Units::deg2rad(getItemValue(P_GAMMA).toDouble())); @@ -161,14 +144,12 @@ std::unique_ptr<IFTDistribution2D> FTDistribution2DCauchyItem::createFTDistribut // --------------------------------------------------------------------------------------------- // FTDistribution2DGaussItem::FTDistribution2DGaussItem() - : FTDistribution2DItem("FTDistribution2DGauss") -{ + : FTDistribution2DItem("FTDistribution2DGauss") { setToolTip("Two-dimensional Gauss probability distribution"); add_properties(); } -std::unique_ptr<IFTDistribution2D> FTDistribution2DGaussItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution2D> FTDistribution2DGaussItem::createFTDistribution() const { return std::make_unique<FTDistribution2DGauss>( getItemValue(P_OMEGA_X).toDouble(), getItemValue(P_OMEGA_Y).toDouble(), Units::deg2rad(getItemValue(P_GAMMA).toDouble())); @@ -176,14 +157,13 @@ std::unique_ptr<IFTDistribution2D> FTDistribution2DGaussItem::createFTDistributi // --------------------------------------------------------------------------------------------- // -FTDistribution2DGateItem::FTDistribution2DGateItem() : FTDistribution2DItem("FTDistribution2DGate") -{ +FTDistribution2DGateItem::FTDistribution2DGateItem() + : FTDistribution2DItem("FTDistribution2DGate") { setToolTip("Two-dimensional Gate probability distribution"); add_properties(); } -std::unique_ptr<IFTDistribution2D> FTDistribution2DGateItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution2D> FTDistribution2DGateItem::createFTDistribution() const { return std::make_unique<FTDistribution2DGate>(getItemValue(P_OMEGA_X).toDouble(), getItemValue(P_OMEGA_Y).toDouble(), Units::deg2rad(getItemValue(P_GAMMA).toDouble())); @@ -191,14 +171,13 @@ std::unique_ptr<IFTDistribution2D> FTDistribution2DGateItem::createFTDistributio // --------------------------------------------------------------------------------------------- // -FTDistribution2DConeItem::FTDistribution2DConeItem() : FTDistribution2DItem("FTDistribution2DCone") -{ +FTDistribution2DConeItem::FTDistribution2DConeItem() + : FTDistribution2DItem("FTDistribution2DCone") { setToolTip("Two-dimensional Cone probability distribution"); add_properties(); } -std::unique_ptr<IFTDistribution2D> FTDistribution2DConeItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution2D> FTDistribution2DConeItem::createFTDistribution() const { return std::make_unique<FTDistribution2DCone>(getItemValue(P_OMEGA_X).toDouble(), getItemValue(P_OMEGA_Y).toDouble(), Units::deg2rad(getItemValue(P_GAMMA).toDouble())); @@ -209,8 +188,7 @@ std::unique_ptr<IFTDistribution2D> FTDistribution2DConeItem::createFTDistributio const QString FTDistribution2DVoigtItem::P_ETA = QString::fromStdString("Eta"); FTDistribution2DVoigtItem::FTDistribution2DVoigtItem() - : FTDistribution2DItem("FTDistribution2DVoigt") -{ + : FTDistribution2DItem("FTDistribution2DVoigt") { setToolTip("Two-dimensional pseudo-Voigt probability distribution"); add_omega_properties(); @@ -220,8 +198,7 @@ FTDistribution2DVoigtItem::FTDistribution2DVoigtItem() add_gamma_property(); } -std::unique_ptr<IFTDistribution2D> FTDistribution2DVoigtItem::createFTDistribution() const -{ +std::unique_ptr<IFTDistribution2D> FTDistribution2DVoigtItem::createFTDistribution() const { return std::make_unique<FTDistribution2DVoigt>( getItemValue(P_OMEGA_X).toDouble(), getItemValue(P_OMEGA_Y).toDouble(), getItemValue(P_ETA).toDouble(), Units::deg2rad(getItemValue(P_GAMMA).toDouble())); diff --git a/GUI/coregui/Models/FTDistributionItems.h b/GUI/coregui/Models/FTDistributionItems.h index 9d6876110804b01cb836c65a704193b4277829cb..3d325823e78ca7db15497fc5e27f07c4b116a6d5 100644 --- a/GUI/coregui/Models/FTDistributionItems.h +++ b/GUI/coregui/Models/FTDistributionItems.h @@ -19,8 +19,7 @@ #include "Sample/Correlations/FTDistributions1D.h" #include "Sample/Correlations/FTDistributions2D.h" -class BA_CORE_API_ FTDistribution1DItem : public SessionItem -{ +class BA_CORE_API_ FTDistribution1DItem : public SessionItem { public: static const QString P_OMEGA; explicit FTDistribution1DItem(const QString& name); @@ -31,43 +30,37 @@ protected: void add_omega_property(); }; -class BA_CORE_API_ FTDistribution1DCauchyItem : public FTDistribution1DItem -{ +class BA_CORE_API_ FTDistribution1DCauchyItem : public FTDistribution1DItem { public: FTDistribution1DCauchyItem(); std::unique_ptr<IFTDistribution1D> createFTDistribution() const; }; -class BA_CORE_API_ FTDistribution1DGaussItem : public FTDistribution1DItem -{ +class BA_CORE_API_ FTDistribution1DGaussItem : public FTDistribution1DItem { public: FTDistribution1DGaussItem(); std::unique_ptr<IFTDistribution1D> createFTDistribution() const; }; -class BA_CORE_API_ FTDistribution1DGateItem : public FTDistribution1DItem -{ +class BA_CORE_API_ FTDistribution1DGateItem : public FTDistribution1DItem { public: FTDistribution1DGateItem(); std::unique_ptr<IFTDistribution1D> createFTDistribution() const; }; -class BA_CORE_API_ FTDistribution1DTriangleItem : public FTDistribution1DItem -{ +class BA_CORE_API_ FTDistribution1DTriangleItem : public FTDistribution1DItem { public: FTDistribution1DTriangleItem(); std::unique_ptr<IFTDistribution1D> createFTDistribution() const; }; -class BA_CORE_API_ FTDistribution1DCosineItem : public FTDistribution1DItem -{ +class BA_CORE_API_ FTDistribution1DCosineItem : public FTDistribution1DItem { public: FTDistribution1DCosineItem(); std::unique_ptr<IFTDistribution1D> createFTDistribution() const; }; -class BA_CORE_API_ FTDistribution1DVoigtItem : public FTDistribution1DItem -{ +class BA_CORE_API_ FTDistribution1DVoigtItem : public FTDistribution1DItem { public: static const QString P_ETA; FTDistribution1DVoigtItem(); @@ -76,8 +69,7 @@ public: // --------------------------------------------------------------------------------------------- // -class BA_CORE_API_ FTDistribution2DItem : public SessionItem -{ +class BA_CORE_API_ FTDistribution2DItem : public SessionItem { public: static const QString P_OMEGA_X; static const QString P_OMEGA_Y; @@ -91,36 +83,31 @@ protected: void add_properties(); }; -class BA_CORE_API_ FTDistribution2DCauchyItem : public FTDistribution2DItem -{ +class BA_CORE_API_ FTDistribution2DCauchyItem : public FTDistribution2DItem { public: FTDistribution2DCauchyItem(); std::unique_ptr<IFTDistribution2D> createFTDistribution() const; }; -class BA_CORE_API_ FTDistribution2DGaussItem : public FTDistribution2DItem -{ +class BA_CORE_API_ FTDistribution2DGaussItem : public FTDistribution2DItem { public: FTDistribution2DGaussItem(); std::unique_ptr<IFTDistribution2D> createFTDistribution() const; }; -class BA_CORE_API_ FTDistribution2DGateItem : public FTDistribution2DItem -{ +class BA_CORE_API_ FTDistribution2DGateItem : public FTDistribution2DItem { public: FTDistribution2DGateItem(); std::unique_ptr<IFTDistribution2D> createFTDistribution() const; }; -class BA_CORE_API_ FTDistribution2DConeItem : public FTDistribution2DItem -{ +class BA_CORE_API_ FTDistribution2DConeItem : public FTDistribution2DItem { public: FTDistribution2DConeItem(); std::unique_ptr<IFTDistribution2D> createFTDistribution() const; }; -class BA_CORE_API_ FTDistribution2DVoigtItem : public FTDistribution2DItem -{ +class BA_CORE_API_ FTDistribution2DVoigtItem : public FTDistribution2DItem { public: static const QString P_ETA; diff --git a/GUI/coregui/Models/FilterPropertyProxy.cpp b/GUI/coregui/Models/FilterPropertyProxy.cpp index 82cc763e71c5ffb2a5ccc5fcbb2cb69142f918ef..64c66290fcbaffb9709a92e6f8d2e05088bc2999 100644 --- a/GUI/coregui/Models/FilterPropertyProxy.cpp +++ b/GUI/coregui/Models/FilterPropertyProxy.cpp @@ -15,14 +15,12 @@ #include "GUI/coregui/Models/FilterPropertyProxy.h" #include "GUI/coregui/Models/SessionModel.h" -int FilterPropertyProxy::columnCount(const QModelIndex& parent) const -{ +int FilterPropertyProxy::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); return m_columns; } -QModelIndex FilterPropertyProxy::toSourceIndex(QModelIndex index) -{ +QModelIndex FilterPropertyProxy::toSourceIndex(QModelIndex index) { FilterPropertyProxy* proxy = dynamic_cast<FilterPropertyProxy*>(const_cast<QAbstractItemModel*>(index.model())); if (proxy) @@ -30,8 +28,7 @@ QModelIndex FilterPropertyProxy::toSourceIndex(QModelIndex index) return index; } -bool FilterPropertyProxy::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const -{ +bool FilterPropertyProxy::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const { QModelIndex index = sourceModel()->index(sourceRow, 1, sourceParent); if (!sourceParent.isValid()) return true; diff --git a/GUI/coregui/Models/FilterPropertyProxy.h b/GUI/coregui/Models/FilterPropertyProxy.h index eed480e8b0559329867c8f8a06057b9611f8e292..c8e5311b643f214d2edc583242f37bb1c890b89f 100644 --- a/GUI/coregui/Models/FilterPropertyProxy.h +++ b/GUI/coregui/Models/FilterPropertyProxy.h @@ -21,15 +21,12 @@ //! SessionModel to have only top level items //! -class FilterPropertyProxy : public QSortFilterProxyModel -{ +class FilterPropertyProxy : public QSortFilterProxyModel { Q_OBJECT public: FilterPropertyProxy(int columns, QObject* parent = 0) - : QSortFilterProxyModel(parent), m_columns(columns) - { - } + : QSortFilterProxyModel(parent), m_columns(columns) {} int columnCount(const QModelIndex& parent) const; static QModelIndex toSourceIndex(QModelIndex index); diff --git a/GUI/coregui/Models/FitParameterHelper.cpp b/GUI/coregui/Models/FitParameterHelper.cpp index 6ff7079545390c4e1d0360eb6e88d0015da683b5..f25ebd6dd2dfcfb9a086a392815428fa6b28a179 100644 --- a/GUI/coregui/Models/FitParameterHelper.cpp +++ b/GUI/coregui/Models/FitParameterHelper.cpp @@ -23,8 +23,7 @@ //! of ParameterItem, copies link. void FitParameterHelper::createFitParameter(FitParameterContainerItem* container, - ParameterItem* parameterItem) -{ + ParameterItem* parameterItem) { ASSERT(container); ASSERT(parameterItem); @@ -44,8 +43,7 @@ void FitParameterHelper::createFitParameter(FitParameterContainerItem* container //! Removes link to given parameterItem from fit parameters void FitParameterHelper::removeFromFitParameters(FitParameterContainerItem* container, - ParameterItem* parameterItem) -{ + ParameterItem* parameterItem) { FitParameterItem* fitParItem = getFitParameterItem(container, parameterItem); if (fitParItem) { @@ -63,8 +61,8 @@ void FitParameterHelper::removeFromFitParameters(FitParameterContainerItem* cont //! If parameterItem is already linked with another fitParameter, it will be relinked void FitParameterHelper::addToFitParameter(FitParameterContainerItem* container, - ParameterItem* parameterItem, const QString& fitParName) -{ + ParameterItem* parameterItem, + const QString& fitParName) { ASSERT(container); removeFromFitParameters(container, parameterItem); @@ -80,16 +78,14 @@ void FitParameterHelper::addToFitParameter(FitParameterContainerItem* container, //! Returns fFitParameterItem corresponding to given ParameterItem FitParameterItem* FitParameterHelper::getFitParameterItem(FitParameterContainerItem* container, - ParameterItem* parameterItem) -{ + ParameterItem* parameterItem) { ASSERT(container); return container->fitParameterItem(getParameterItemPath(parameterItem)); } //! Returns list of fit parameter display names -QStringList FitParameterHelper::getFitParameterNames(FitParameterContainerItem* container) -{ +QStringList FitParameterHelper::getFitParameterNames(FitParameterContainerItem* container) { ASSERT(container); QStringList result; for (auto item : container->getItems(FitParameterContainerItem::T_FIT_PARAMETERS)) { @@ -100,8 +96,7 @@ QStringList FitParameterHelper::getFitParameterNames(FitParameterContainerItem* //! return path to given item in the ParameterTreeContainer -QString FitParameterHelper::getParameterItemPath(const ParameterItem* parameterItem) -{ +QString FitParameterHelper::getParameterItemPath(const ParameterItem* parameterItem) { QString result = ModelPath::getPathFromIndex(parameterItem->index()); QString containerPrefix = "Parameter Container/"; int containerEnd = result.indexOf(containerPrefix) + containerPrefix.size(); @@ -113,8 +108,7 @@ QString FitParameterHelper::getParameterItemPath(const ParameterItem* parameterI //! Link is relative to ParameterContainerItem, so first we have to find it ParameterItem* FitParameterHelper::getParameterItem(FitParameterContainerItem* container, - const QString& link) -{ + const QString& link) { SessionItem* cur = container; while (cur && cur->modelType() != "JobItem") { cur = cur->parent(); diff --git a/GUI/coregui/Models/FitParameterHelper.h b/GUI/coregui/Models/FitParameterHelper.h index ee417dfe0dbe6739edc0be699ef585d04e109110..e66b63dcfad40c751028b178416e352809deb112 100644 --- a/GUI/coregui/Models/FitParameterHelper.h +++ b/GUI/coregui/Models/FitParameterHelper.h @@ -24,8 +24,7 @@ class FitParameterContainerItem; //! The FitParameterHelper class contains set of convenience static methods to handle //! various fitting items in given JobItem. -class FitParameterHelper -{ +class FitParameterHelper { public: static void createFitParameter(FitParameterContainerItem* container, ParameterItem* parameterItem); diff --git a/GUI/coregui/Models/FitParameterItems.cpp b/GUI/coregui/Models/FitParameterItems.cpp index eeb2acfc9a66ded576d518024cec922bb37055e5..b60a67b988d9877c5d13b0c0d1ed309e14b2a9c2 100644 --- a/GUI/coregui/Models/FitParameterItems.cpp +++ b/GUI/coregui/Models/FitParameterItems.cpp @@ -21,11 +21,9 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include <cmath> -namespace -{ +namespace { -ComboProperty fitParameterTypeCombo() -{ +ComboProperty fitParameterTypeCombo() { QStringList tooltips = QStringList() << "Fixed at given value" << "Limited in the range [min, max]" << "Limited at lower bound [min, inf]" @@ -51,8 +49,7 @@ const double range_factor = 0.5; const QString FitParameterLinkItem::P_LINK = "Link"; const QString FitParameterLinkItem::P_DOMAIN = "Domain"; -FitParameterLinkItem::FitParameterLinkItem() : SessionItem("FitParameterLink") -{ +FitParameterLinkItem::FitParameterLinkItem() : SessionItem("FitParameterLink") { addProperty(P_LINK, ""); addProperty(P_DOMAIN, ""); } @@ -65,8 +62,7 @@ const QString FitParameterItem::P_MIN = "Min"; const QString FitParameterItem::P_MAX = "Max"; const QString FitParameterItem::T_LINK = "Link tag"; -FitParameterItem::FitParameterItem() : SessionItem("FitParameter") -{ +FitParameterItem::FitParameterItem() : SessionItem("FitParameter") { addProperty(P_TYPE, fitParameterTypeCombo().variant()); addProperty(P_START_VALUE, 0.0)->setEditorType("ScientificSpinBox"); addProperty(P_MIN, 0.0)->setEditorType("ScientificSpinBox"); @@ -88,8 +84,7 @@ FitParameterItem::FitParameterItem() : SessionItem("FitParameter") //! Inits P_MIN and P_MAX taking into account current value and external limits -void FitParameterItem::initMinMaxValues(const RealLimits& limits) -{ +void FitParameterItem::initMinMaxValues(const RealLimits& limits) { double value = getItemValue(P_START_VALUE).toDouble(); double dr(0); @@ -118,8 +113,7 @@ void FitParameterItem::initMinMaxValues(const RealLimits& limits) //! Constructs Limits correspodning to current GUI settings. -AttLimits FitParameterItem::attLimits() const -{ +AttLimits FitParameterItem::attLimits() const { if (isFixed()) { return AttLimits::fixed(); } @@ -145,8 +139,7 @@ AttLimits FitParameterItem::attLimits() const } } -bool FitParameterItem::isValid() const -{ +bool FitParameterItem::isValid() const { if (isFixed() || isFree()) return true; @@ -161,16 +154,14 @@ bool FitParameterItem::isValid() const return min <= value && value <= max; } -QString FitParameterItem::parameterType() const -{ +QString FitParameterItem::parameterType() const { ComboProperty partype = getItemValue(P_TYPE).value<ComboProperty>(); return partype.getValue(); } //! Enables/disables min, max properties on FitParameterItem's type -void FitParameterItem::onTypeChange() -{ +void FitParameterItem::onTypeChange() { if (isFixed()) { setLimitEnabled(P_MIN, false); setLimitEnabled(P_MAX, false); @@ -199,8 +190,7 @@ void FitParameterItem::onTypeChange() //! Set limit property with given name to the enabled state -void FitParameterItem::setLimitEnabled(const QString& name, bool enabled) -{ +void FitParameterItem::setLimitEnabled(const QString& name, bool enabled) { if (isTag(name)) { SessionItem* propertyItem = getItem(name); ASSERT(propertyItem); @@ -209,28 +199,23 @@ void FitParameterItem::setLimitEnabled(const QString& name, bool enabled) } } -bool FitParameterItem::isLimited() const -{ +bool FitParameterItem::isLimited() const { return parameterType() == "limited"; } -bool FitParameterItem::isFree() const -{ +bool FitParameterItem::isFree() const { return parameterType() == "free"; } -bool FitParameterItem::isLowerLimited() const -{ +bool FitParameterItem::isLowerLimited() const { return parameterType() == "lower limited"; } -bool FitParameterItem::isUpperLimited() const -{ +bool FitParameterItem::isUpperLimited() const { return parameterType() == "upper limited"; } -bool FitParameterItem::isFixed() const -{ +bool FitParameterItem::isFixed() const { return parameterType() == "fixed"; } @@ -238,16 +223,14 @@ bool FitParameterItem::isFixed() const const QString FitParameterContainerItem::T_FIT_PARAMETERS = "Data tag"; -FitParameterContainerItem::FitParameterContainerItem() : SessionItem("FitParameterContainer") -{ +FitParameterContainerItem::FitParameterContainerItem() : SessionItem("FitParameterContainer") { registerTag(T_FIT_PARAMETERS, 0, -1, QStringList() << "FitParameter"); setDefaultTag(T_FIT_PARAMETERS); } //! returns FitParameterItem for given link (path in model) -FitParameterItem* FitParameterContainerItem::fitParameterItem(const QString& link) -{ +FitParameterItem* FitParameterContainerItem::fitParameterItem(const QString& link) { for (auto item : getItems(T_FIT_PARAMETERS)) { for (auto linkItem : item->getItems(FitParameterItem::T_LINK)) { if (link == linkItem->getItemValue(FitParameterLinkItem::P_LINK)) @@ -257,24 +240,21 @@ FitParameterItem* FitParameterContainerItem::fitParameterItem(const QString& lin return nullptr; } -QVector<FitParameterItem*> FitParameterContainerItem::fitParameterItems() -{ +QVector<FitParameterItem*> FitParameterContainerItem::fitParameterItems() { QVector<FitParameterItem*> result; for (auto parItem : getItems(T_FIT_PARAMETERS)) result.push_back(dynamic_cast<FitParameterItem*>(parItem)); return result; } -bool FitParameterContainerItem::isEmpty() -{ +bool FitParameterContainerItem::isEmpty() { return getItems(T_FIT_PARAMETERS).isEmpty(); } //! Propagate values to the corresponding parameter tree items of parameterContainer. void FitParameterContainerItem::setValuesInParameterContainer( - const QVector<double>& values, ParameterContainerItem* parameterContainer) -{ + const QVector<double>& values, ParameterContainerItem* parameterContainer) { ASSERT(parameterContainer); QVector<SessionItem*> fitPars = getItems(FitParameterContainerItem::T_FIT_PARAMETERS); @@ -295,8 +275,7 @@ void FitParameterContainerItem::setValuesInParameterContainer( } } -mumufit::Parameters FitParameterContainerItem::createParameters() const -{ +mumufit::Parameters FitParameterContainerItem::createParameters() const { mumufit::Parameters result; int index(0); diff --git a/GUI/coregui/Models/FitParameterItems.h b/GUI/coregui/Models/FitParameterItems.h index 8c79dca16ae46491ea1a46eab4a5afd8d4aac2c6..d471dc572bf3cab8ba7e850771119a5b06240e01 100644 --- a/GUI/coregui/Models/FitParameterItems.h +++ b/GUI/coregui/Models/FitParameterItems.h @@ -22,8 +22,7 @@ //! The FitParameterLinkItem class holds a link to ParameterItem in tuning tree. -class BA_CORE_API_ FitParameterLinkItem : public SessionItem -{ +class BA_CORE_API_ FitParameterLinkItem : public SessionItem { public: static const QString P_LINK; @@ -34,8 +33,7 @@ public: //! The FitParameterItem class represents a fit parameter in GUI. Contains links to corresponding //! ParameterItem's in a tuning tree. -class BA_CORE_API_ FitParameterItem : public SessionItem -{ +class BA_CORE_API_ FitParameterItem : public SessionItem { public: static const QString P_TYPE; @@ -64,13 +62,11 @@ private: //! The FitParameterContainerItem class is a collection of all defined fit parameters in JobItem. -namespace mumufit -{ +namespace mumufit { class Parameters; } -class BA_CORE_API_ FitParameterContainerItem : public SessionItem -{ +class BA_CORE_API_ FitParameterContainerItem : public SessionItem { public: static const QString T_FIT_PARAMETERS; diff --git a/GUI/coregui/Models/FitParameterProxyModel.cpp b/GUI/coregui/Models/FitParameterProxyModel.cpp index b430a895f5dc6774351d0cb6e2fa88b1e5a370b2..90eea00549e62eeebc0cf43eca8e56a796dba0e6 100644 --- a/GUI/coregui/Models/FitParameterProxyModel.cpp +++ b/GUI/coregui/Models/FitParameterProxyModel.cpp @@ -25,8 +25,7 @@ using SessionItemUtils::ParentRow; FitParameterProxyModel::FitParameterProxyModel(FitParameterContainerItem* fitParContainer, QObject* parent) - : QAbstractItemModel(parent), m_root_item(fitParContainer) -{ + : QAbstractItemModel(parent), m_root_item(fitParContainer) { addColumn(PAR_NAME, "Name", "Name of fit parameter"); addColumn(PAR_TYPE, FitParameterItem::P_TYPE, "Fit parameter limits type"); addColumn(PAR_VALUE, FitParameterItem::P_START_VALUE, "Starting value of fit parameter"); @@ -47,15 +46,13 @@ FitParameterProxyModel::FitParameterProxyModel(FitParameterContainerItem* fitPar this); } -FitParameterProxyModel::~FitParameterProxyModel() -{ +FitParameterProxyModel::~FitParameterProxyModel() { if (m_root_item) { m_root_item->mapper()->unsubscribe(this); } } -Qt::ItemFlags FitParameterProxyModel::flags(const QModelIndex& index) const -{ +Qt::ItemFlags FitParameterProxyModel::flags(const QModelIndex& index) const { if (!m_root_item) return Qt::NoItemFlags; @@ -85,8 +82,7 @@ Qt::ItemFlags FitParameterProxyModel::flags(const QModelIndex& index) const return returnVal; } -QModelIndex FitParameterProxyModel::index(int row, int column, const QModelIndex& parent) const -{ +QModelIndex FitParameterProxyModel::index(int row, int column, const QModelIndex& parent) const { if (!m_root_item || row < 0 || column < 0 || column >= columnCount(QModelIndex()) || (parent.isValid() && parent.column() != 0)) return QModelIndex(); @@ -113,8 +109,7 @@ QModelIndex FitParameterProxyModel::index(int row, int column, const QModelIndex return QModelIndex(); } -QModelIndex FitParameterProxyModel::parent(const QModelIndex& child) const -{ +QModelIndex FitParameterProxyModel::parent(const QModelIndex& child) const { if (!m_root_item) return QModelIndex(); @@ -136,8 +131,7 @@ QModelIndex FitParameterProxyModel::parent(const QModelIndex& child) const return QModelIndex(); } -int FitParameterProxyModel::rowCount(const QModelIndex& parent) const -{ +int FitParameterProxyModel::rowCount(const QModelIndex& parent) const { if (!m_root_item) return 0; @@ -156,8 +150,7 @@ int FitParameterProxyModel::rowCount(const QModelIndex& parent) const return 0; } -int FitParameterProxyModel::columnCount(const QModelIndex& parent) const -{ +int FitParameterProxyModel::columnCount(const QModelIndex& parent) const { if (!m_root_item) return 0; @@ -177,8 +170,7 @@ int FitParameterProxyModel::columnCount(const QModelIndex& parent) const return 0; } -QVariant FitParameterProxyModel::data(const QModelIndex& index, int role) const -{ +QVariant FitParameterProxyModel::data(const QModelIndex& index, int role) const { if (!m_root_item) return QVariant(); @@ -201,8 +193,7 @@ QVariant FitParameterProxyModel::data(const QModelIndex& index, int role) const return QVariant(); } -bool FitParameterProxyModel::setData(const QModelIndex& index, const QVariant& value, int role) -{ +bool FitParameterProxyModel::setData(const QModelIndex& index, const QVariant& value, int role) { if (!m_root_item) return false; @@ -218,15 +209,13 @@ bool FitParameterProxyModel::setData(const QModelIndex& index, const QVariant& v return false; } -QStringList FitParameterProxyModel::mimeTypes() const -{ +QStringList FitParameterProxyModel::mimeTypes() const { QStringList types; types << SessionXML::LinkMimeType; return types; } -QMimeData* FitParameterProxyModel::mimeData(const QModelIndexList& indexes) const -{ +QMimeData* FitParameterProxyModel::mimeData(const QModelIndexList& indexes) const { QMimeData* mimeData = new QMimeData(); QModelIndex index = indexes.first(); if (index.isValid()) { @@ -239,8 +228,7 @@ QMimeData* FitParameterProxyModel::mimeData(const QModelIndexList& indexes) cons } bool FitParameterProxyModel::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, - int column, const QModelIndex& parent) const -{ + int column, const QModelIndex& parent) const { Q_UNUSED(data); Q_UNUSED(action); Q_UNUSED(row); @@ -253,8 +241,7 @@ bool FitParameterProxyModel::canDropMimeData(const QMimeData* data, Qt::DropActi } bool FitParameterProxyModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, - int column, const QModelIndex& parent) -{ + int column, const QModelIndex& parent) { Q_UNUSED(action); Q_UNUSED(row); Q_UNUSED(column); @@ -277,8 +264,7 @@ bool FitParameterProxyModel::dropMimeData(const QMimeData* data, Qt::DropAction } QVariant FitParameterProxyModel::headerData(int section, Qt::Orientation orientation, - int role) const -{ + int role) const { if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { return m_columnNames.value(section); } else if (role == Qt::ToolTipRole) { @@ -289,8 +275,7 @@ QVariant FitParameterProxyModel::headerData(int section, Qt::Orientation orienta void FitParameterProxyModel::onSourceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, - const QVector<int>& roles) -{ + const QVector<int>& roles) { Q_UNUSED(bottomRight); JobModel* sourceModel = qobject_cast<JobModel*>(sender()); @@ -303,8 +288,7 @@ void FitParameterProxyModel::onSourceDataChanged(const QModelIndex& topLeft, emit dataChanged(itemIndex, itemIndex, roles); } -void FitParameterProxyModel::onSourceRowsRemoved(const QModelIndex& parent, int first, int last) -{ +void FitParameterProxyModel::onSourceRowsRemoved(const QModelIndex& parent, int first, int last) { Q_UNUSED(parent); Q_UNUSED(first); Q_UNUSED(last); @@ -312,16 +296,14 @@ void FitParameterProxyModel::onSourceRowsRemoved(const QModelIndex& parent, int endResetModel(); } -void FitParameterProxyModel::onSourceAboutToBeReset() -{ +void FitParameterProxyModel::onSourceAboutToBeReset() { if (!m_root_item) return; beginResetModel(); endResetModel(); } -void FitParameterProxyModel::connectModel(QAbstractItemModel* sourceModel, bool isConnect) -{ +void FitParameterProxyModel::connectModel(QAbstractItemModel* sourceModel, bool isConnect) { ASSERT(sourceModel); if (isConnect) { connect(sourceModel, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector<int>)), this, @@ -340,14 +322,12 @@ void FitParameterProxyModel::connectModel(QAbstractItemModel* sourceModel, bool } void FitParameterProxyModel::addColumn(FitParameterProxyModel::EColumn id, const QString& name, - const QString& tooltip) -{ + const QString& tooltip) { m_columnNames[id] = name; m_columnToolTips[id] = tooltip; } -QModelIndex FitParameterProxyModel::indexOfItem(SessionItem* item) const -{ +QModelIndex FitParameterProxyModel::indexOfItem(SessionItem* item) const { if (!m_root_item) return QModelIndex(); @@ -371,8 +351,7 @@ QModelIndex FitParameterProxyModel::indexOfItem(SessionItem* item) const return QModelIndex(); } -SessionItem* FitParameterProxyModel::itemForIndex(const QModelIndex& index) const -{ +SessionItem* FitParameterProxyModel::itemForIndex(const QModelIndex& index) const { if (!m_root_item) return 0; @@ -388,15 +367,13 @@ SessionItem* FitParameterProxyModel::itemForIndex(const QModelIndex& index) cons return m_root_item; } -SessionModel* FitParameterProxyModel::sourceModel() const -{ +SessionModel* FitParameterProxyModel::sourceModel() const { ASSERT(m_root_item); return m_root_item->model(); } //! Returns true if given item still exists in source model -bool FitParameterProxyModel::isValidSourceItem(SessionItem* item) const -{ +bool FitParameterProxyModel::isValidSourceItem(SessionItem* item) const { if (item == m_root_item) return true; if (sourceModel() && ModelPath::isValidItem(sourceModel(), item, m_root_item->index())) diff --git a/GUI/coregui/Models/FitParameterProxyModel.h b/GUI/coregui/Models/FitParameterProxyModel.h index 11887e0e1cef9a1dbb5f31238909c82d4f1dfd61..8d1c0aa86f2467917913f5505c4b937b366076c9 100644 --- a/GUI/coregui/Models/FitParameterProxyModel.h +++ b/GUI/coregui/Models/FitParameterProxyModel.h @@ -26,8 +26,7 @@ class SessionItem; //! in 5 column tree view. //! It is derived from QAbstractItemModel (and not from QAbstractProxyModel). -class FitParameterProxyModel : public QAbstractItemModel -{ +class FitParameterProxyModel : public QAbstractItemModel { Q_OBJECT public: @@ -79,13 +78,11 @@ private: QMap<int, QString> m_columnToolTips; }; -inline Qt::DropActions FitParameterProxyModel::supportedDragActions() const -{ +inline Qt::DropActions FitParameterProxyModel::supportedDragActions() const { return Qt::MoveAction | Qt::CopyAction; } -inline Qt::DropActions FitParameterProxyModel::supportedDropActions() const -{ +inline Qt::DropActions FitParameterProxyModel::supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } diff --git a/GUI/coregui/Models/FitSuiteItem.cpp b/GUI/coregui/Models/FitSuiteItem.cpp index 567e1fd306cad3fa23604ef0301c55cdd7bb7979..01a650ed32be8b92fcc14e2f034ce3bb83caa223 100644 --- a/GUI/coregui/Models/FitSuiteItem.cpp +++ b/GUI/coregui/Models/FitSuiteItem.cpp @@ -22,8 +22,7 @@ const QString FitSuiteItem::P_CHI2 = "Chi2"; const QString FitSuiteItem::T_FIT_PARAMETERS_CONTAINER = "Fit parameters container"; const QString FitSuiteItem::T_MINIMIZER = "Minimizer settings"; -FitSuiteItem::FitSuiteItem() : SessionItem("FitSuite") -{ +FitSuiteItem::FitSuiteItem() : SessionItem("FitSuite") { addProperty(P_UPDATE_INTERVAL, 10); addProperty(P_ITERATION_COUNT, 0); addProperty(P_CHI2, 0.0); @@ -32,13 +31,11 @@ FitSuiteItem::FitSuiteItem() : SessionItem("FitSuite") registerTag(T_MINIMIZER, 1, 1, QStringList() << "MinimizerContainer"); } -FitParameterContainerItem* FitSuiteItem::fitParameterContainerItem() -{ +FitParameterContainerItem* FitSuiteItem::fitParameterContainerItem() { return dynamic_cast<FitParameterContainerItem*>( getItem(FitSuiteItem::T_FIT_PARAMETERS_CONTAINER)); } -MinimizerContainerItem* FitSuiteItem::minimizerContainerItem() -{ +MinimizerContainerItem* FitSuiteItem::minimizerContainerItem() { return dynamic_cast<MinimizerContainerItem*>(getItem(FitSuiteItem::T_MINIMIZER)); } diff --git a/GUI/coregui/Models/FitSuiteItem.h b/GUI/coregui/Models/FitSuiteItem.h index 87f85a8812ece6878cd45a5eb18754e685620c3f..75bd52b8f52c6de44eeea5c67742c0fa8c3bdf36 100644 --- a/GUI/coregui/Models/FitSuiteItem.h +++ b/GUI/coregui/Models/FitSuiteItem.h @@ -20,8 +20,7 @@ class FitParameterContainerItem; class MinimizerContainerItem; -class BA_CORE_API_ FitSuiteItem : public SessionItem -{ +class BA_CORE_API_ FitSuiteItem : public SessionItem { public: static const QString P_UPDATE_INTERVAL; diff --git a/GUI/coregui/Models/FootprintItems.cpp b/GUI/coregui/Models/FootprintItems.cpp index af5bf250e40448c637b99ddf8b03cd9227aad640..c3a455b993c1b416e22d5c6cb5854d1ec12a3eda 100644 --- a/GUI/coregui/Models/FootprintItems.cpp +++ b/GUI/coregui/Models/FootprintItems.cpp @@ -16,8 +16,7 @@ #include "Device/Beam/FootprintGauss.h" #include "Device/Beam/FootprintSquare.h" -namespace -{ +namespace { const QString footprint_value_name = "Width ratio"; const QString footprint_value_tooltip = "The ratio of beam and sample full widths"; } // namespace @@ -36,8 +35,7 @@ FootprintNoneItem::FootprintNoneItem() : FootprintItem("NoFootprint") {} FootprintNoneItem::~FootprintNoneItem() = default; -std::unique_ptr<IFootprintFactor> FootprintNoneItem::createFootprint() const -{ +std::unique_ptr<IFootprintFactor> FootprintNoneItem::createFootprint() const { return {}; } @@ -46,8 +44,7 @@ std::unique_ptr<IFootprintFactor> FootprintNoneItem::createFootprint() const const QString FootprintGaussianItem::P_VALUE = footprint_value_name; -FootprintGaussianItem::FootprintGaussianItem() : FootprintItem("GaussianFootrpint") -{ +FootprintGaussianItem::FootprintGaussianItem() : FootprintItem("GaussianFootrpint") { addProperty(P_VALUE, 0.0) ->setLimits(RealLimits::nonnegative()) .setToolTip(footprint_value_tooltip); @@ -55,8 +52,7 @@ FootprintGaussianItem::FootprintGaussianItem() : FootprintItem("GaussianFootrpin FootprintGaussianItem::~FootprintGaussianItem() = default; -std::unique_ptr<IFootprintFactor> FootprintGaussianItem::createFootprint() const -{ +std::unique_ptr<IFootprintFactor> FootprintGaussianItem::createFootprint() const { return std::make_unique<FootprintGauss>(getItemValue(P_VALUE).toDouble()); } @@ -65,8 +61,7 @@ std::unique_ptr<IFootprintFactor> FootprintGaussianItem::createFootprint() const const QString FootprintSquareItem::P_VALUE = footprint_value_name; -FootprintSquareItem::FootprintSquareItem() : FootprintItem("SquareFootprint") -{ +FootprintSquareItem::FootprintSquareItem() : FootprintItem("SquareFootprint") { addProperty(P_VALUE, 0.0) ->setLimits(RealLimits::nonnegative()) .setToolTip(footprint_value_tooltip); @@ -74,7 +69,6 @@ FootprintSquareItem::FootprintSquareItem() : FootprintItem("SquareFootprint") FootprintSquareItem::~FootprintSquareItem() = default; -std::unique_ptr<IFootprintFactor> FootprintSquareItem::createFootprint() const -{ +std::unique_ptr<IFootprintFactor> FootprintSquareItem::createFootprint() const { return std::make_unique<FootprintSquare>(getItemValue(P_VALUE).toDouble()); } diff --git a/GUI/coregui/Models/FootprintItems.h b/GUI/coregui/Models/FootprintItems.h index a6751cc5ad98d524b3e1cde814d3482945d9fb5b..4409d01a3aab80a5dd9582d98cd25b0448cdd914 100644 --- a/GUI/coregui/Models/FootprintItems.h +++ b/GUI/coregui/Models/FootprintItems.h @@ -19,8 +19,7 @@ class IFootprintFactor; -class BA_CORE_API_ FootprintItem : public SessionItem -{ +class BA_CORE_API_ FootprintItem : public SessionItem { public: virtual ~FootprintItem(); virtual std::unique_ptr<IFootprintFactor> createFootprint() const = 0; @@ -29,16 +28,14 @@ protected: explicit FootprintItem(const QString& model_type); }; -class BA_CORE_API_ FootprintNoneItem : public FootprintItem -{ +class BA_CORE_API_ FootprintNoneItem : public FootprintItem { public: FootprintNoneItem(); virtual ~FootprintNoneItem(); std::unique_ptr<IFootprintFactor> createFootprint() const override; }; -class BA_CORE_API_ FootprintGaussianItem : public FootprintItem -{ +class BA_CORE_API_ FootprintGaussianItem : public FootprintItem { public: static const QString P_VALUE; @@ -47,8 +44,7 @@ public: std::unique_ptr<IFootprintFactor> createFootprint() const override; }; -class BA_CORE_API_ FootprintSquareItem : public FootprintItem -{ +class BA_CORE_API_ FootprintSquareItem : public FootprintItem { public: static const QString P_VALUE; diff --git a/GUI/coregui/Models/FormFactorItems.cpp b/GUI/coregui/Models/FormFactorItems.cpp index c32331aeca02a1926ef8c69709163a5d453881ec..913968de168573901f6bcbf2c945bf6e62f2e6cd 100644 --- a/GUI/coregui/Models/FormFactorItems.cpp +++ b/GUI/coregui/Models/FormFactorItems.cpp @@ -24,8 +24,7 @@ const QString AnisoPyramidItem::P_WIDTH("Width"); const QString AnisoPyramidItem::P_HEIGHT("Height"); const QString AnisoPyramidItem::P_ALPHA("Alpha"); -AnisoPyramidItem::AnisoPyramidItem() : FormFactorItem("AnisoPyramid") -{ +AnisoPyramidItem::AnisoPyramidItem() : FormFactorItem("AnisoPyramid") { setToolTip("A truncated pyramid with a rectangular base"); addProperty(P_LENGTH, 20.0)->setToolTip("Length of the rectangular base in nanometers"); addProperty(P_WIDTH, 16.0)->setToolTip("Width of the rectangular base in nanometers"); @@ -33,8 +32,7 @@ AnisoPyramidItem::AnisoPyramidItem() : FormFactorItem("AnisoPyramid") addProperty(P_ALPHA, 60.0)->setToolTip("Dihedral angle in degrees between base and facet"); } -std::unique_ptr<IFormFactor> AnisoPyramidItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> AnisoPyramidItem::createFormFactor() const { return std::make_unique<FormFactorAnisoPyramid>( getItemValue(P_LENGTH).toDouble(), getItemValue(P_WIDTH).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_ALPHA).toDouble() * Units::deg); @@ -46,16 +44,14 @@ const QString BarGaussItem::P_LENGTH("Length"); const QString BarGaussItem::P_WIDTH("Width"); const QString BarGaussItem::P_HEIGHT("Height"); -BarGaussItem::BarGaussItem() : FormFactorItem("BarGauss") -{ +BarGaussItem::BarGaussItem() : FormFactorItem("BarGauss") { setToolTip("Rectangular cuboid"); addProperty(P_LENGTH, 20.0)->setToolTip("Length of the base in nanometers"); addProperty(P_WIDTH, 16.0)->setToolTip("Width of the base in nanometers"); addProperty(P_HEIGHT, 13.0)->setToolTip("Height of the box in nanometers"); } -std::unique_ptr<IFormFactor> BarGaussItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> BarGaussItem::createFormFactor() const { return std::make_unique<FormFactorBarGauss>(getItemValue(P_LENGTH).toDouble(), getItemValue(P_WIDTH).toDouble(), getItemValue(P_HEIGHT).toDouble()); @@ -67,16 +63,14 @@ const QString BarLorentzItem::P_LENGTH("Length"); const QString BarLorentzItem::P_WIDTH("Width"); const QString BarLorentzItem::P_HEIGHT("Height"); -BarLorentzItem::BarLorentzItem() : FormFactorItem("BarLorentz") -{ +BarLorentzItem::BarLorentzItem() : FormFactorItem("BarLorentz") { setToolTip("Rectangular cuboid"); addProperty(P_LENGTH, 20.0)->setToolTip("Length of the base in nanometers"); addProperty(P_WIDTH, 16.0)->setToolTip("Width of the base in nanometers"); addProperty(P_HEIGHT, 13.0)->setToolTip("Height of the box in nanometers"); } -std::unique_ptr<IFormFactor> BarLorentzItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> BarLorentzItem::createFormFactor() const { return std::make_unique<FormFactorBarLorentz>(getItemValue(P_LENGTH).toDouble(), getItemValue(P_WIDTH).toDouble(), getItemValue(P_HEIGHT).toDouble()); @@ -88,16 +82,14 @@ const QString BoxItem::P_LENGTH("Length"); const QString BoxItem::P_WIDTH("Width"); const QString BoxItem::P_HEIGHT("Height"); -BoxItem::BoxItem() : FormFactorItem("Box") -{ +BoxItem::BoxItem() : FormFactorItem("Box") { setToolTip("Rectangular cuboid"); addProperty(P_LENGTH, 20.0)->setToolTip("Length of the base in nanometers"); addProperty(P_WIDTH, 16.0)->setToolTip("Width of the base in nanometers"); addProperty(P_HEIGHT, 13.0)->setToolTip("Height of the box in nanometers"); } -std::unique_ptr<IFormFactor> BoxItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> BoxItem::createFormFactor() const { return std::make_unique<FormFactorBox>(getItemValue(P_LENGTH).toDouble(), getItemValue(P_WIDTH).toDouble(), getItemValue(P_HEIGHT).toDouble()); @@ -109,8 +101,7 @@ const QString ConeItem::P_RADIUS("Radius"); const QString ConeItem::P_HEIGHT("Height"); const QString ConeItem::P_ALPHA("Alpha"); -ConeItem::ConeItem() : FormFactorItem("Cone") -{ +ConeItem::ConeItem() : FormFactorItem("Cone") { setToolTip("Truncated cone with circular base"); addProperty(P_RADIUS, 10.0)->setToolTip("Radius of the base in nanometers"); addProperty(P_HEIGHT, 13.0)->setToolTip("Height of the cone in nanometers"); @@ -118,8 +109,7 @@ ConeItem::ConeItem() : FormFactorItem("Cone") ->setToolTip("Angle between the base and the side surface in degrees"); } -std::unique_ptr<IFormFactor> ConeItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> ConeItem::createFormFactor() const { return std::make_unique<FormFactorCone>(getItemValue(P_RADIUS).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_ALPHA).toDouble() * Units::deg); @@ -131,16 +121,14 @@ const QString Cone6Item::P_BASEEDGE("BaseEdge"); const QString Cone6Item::P_HEIGHT("Height"); const QString Cone6Item::P_ALPHA("Alpha"); -Cone6Item::Cone6Item() : FormFactorItem("Cone6") -{ +Cone6Item::Cone6Item() : FormFactorItem("Cone6") { setToolTip("A truncated pyramid, based on a regular hexagon"); addProperty(P_BASEEDGE, 10.0)->setToolTip("Edge of the regular hexagonal base in nanometers"); addProperty(P_HEIGHT, 13.0)->setToolTip("Height of a truncated pyramid in nanometers"); addProperty(P_ALPHA, 60.0)->setToolTip("Dihedral angle in degrees between base and facet"); } -std::unique_ptr<IFormFactor> Cone6Item::createFormFactor() const -{ +std::unique_ptr<IFormFactor> Cone6Item::createFormFactor() const { return std::make_unique<FormFactorCone6>(getItemValue(P_BASEEDGE).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_ALPHA).toDouble() * Units::deg); @@ -153,8 +141,7 @@ const QString CuboctahedronItem::P_HEIGHT("Height"); const QString CuboctahedronItem::P_HEIGHT_RATIO("HeightRatio"); const QString CuboctahedronItem::P_ALPHA("Alpha"); -CuboctahedronItem::CuboctahedronItem() : FormFactorItem("Cuboctahedron") -{ +CuboctahedronItem::CuboctahedronItem() : FormFactorItem("Cuboctahedron") { setToolTip("Compound of two truncated pyramids with a common square base \n" "and opposite orientations"); addProperty(P_LENGTH, 20.0)->setToolTip("Side length of the common square base in nanometers"); @@ -165,8 +152,7 @@ CuboctahedronItem::CuboctahedronItem() : FormFactorItem("Cuboctahedron") addProperty(P_ALPHA, 60.0)->setToolTip("Dihedral angle in degrees between base and facets"); } -std::unique_ptr<IFormFactor> CuboctahedronItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> CuboctahedronItem::createFormFactor() const { return std::make_unique<FormFactorCuboctahedron>( getItemValue(P_LENGTH).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_HEIGHT_RATIO).toDouble(), getItemValue(P_ALPHA).toDouble() * Units::deg); @@ -177,15 +163,13 @@ std::unique_ptr<IFormFactor> CuboctahedronItem::createFormFactor() const const QString CylinderItem::P_RADIUS("Radius"); const QString CylinderItem::P_HEIGHT("Height"); -CylinderItem::CylinderItem() : FormFactorItem("Cylinder") -{ +CylinderItem::CylinderItem() : FormFactorItem("Cylinder") { setToolTip("Cylinder with a circular base"); addProperty(P_RADIUS, 8.0)->setToolTip("Radius of the circular base in nanometers"); addProperty(P_HEIGHT, 16.0)->setToolTip("Height of the cylinder in nanometers"); } -std::unique_ptr<IFormFactor> CylinderItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> CylinderItem::createFormFactor() const { return std::make_unique<FormFactorCylinder>(getItemValue(P_RADIUS).toDouble(), getItemValue(P_HEIGHT).toDouble()); } @@ -194,14 +178,12 @@ std::unique_ptr<IFormFactor> CylinderItem::createFormFactor() const const QString DodecahedronItem::P_EDGE("Edge"); -DodecahedronItem::DodecahedronItem() : FormFactorItem("Dodecahedron") -{ +DodecahedronItem::DodecahedronItem() : FormFactorItem("Dodecahedron") { setToolTip("Dodecahedron"); addProperty(P_EDGE, 10.0)->setToolTip("Length of the edge in nanometers"); } -std::unique_ptr<IFormFactor> DodecahedronItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> DodecahedronItem::createFormFactor() const { return std::make_unique<FormFactorDodecahedron>(getItemValue(P_EDGE).toDouble()); } @@ -209,14 +191,12 @@ std::unique_ptr<IFormFactor> DodecahedronItem::createFormFactor() const const QString DotItem::P_RADIUS("Radius"); -DotItem::DotItem() : FormFactorItem("Dot") -{ +DotItem::DotItem() : FormFactorItem("Dot") { setToolTip("A dot, with constant formfactor F(q)=4pi/3 R^3"); addProperty(P_RADIUS, 8.0)->setToolTip("Radius of reference sphere in nanometers"); } -std::unique_ptr<IFormFactor> DotItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> DotItem::createFormFactor() const { return std::make_unique<FormFactorDot>(getItemValue(P_RADIUS).toDouble()); } @@ -226,8 +206,7 @@ const QString EllipsoidalCylinderItem::P_RADIUS_X("RadiusX"); const QString EllipsoidalCylinderItem::P_RADIUS_Y("RadiusY"); const QString EllipsoidalCylinderItem::P_HEIGHT("Height"); -EllipsoidalCylinderItem::EllipsoidalCylinderItem() : FormFactorItem("EllipsoidalCylinder") -{ +EllipsoidalCylinderItem::EllipsoidalCylinderItem() : FormFactorItem("EllipsoidalCylinder") { setToolTip("Cylinder with an ellipse cross section"); addProperty(P_RADIUS_X, 8.0) ->setToolTip("Radius of the ellipse base in the x-direction, in nanometers"); @@ -236,8 +215,7 @@ EllipsoidalCylinderItem::EllipsoidalCylinderItem() : FormFactorItem("Ellipsoidal addProperty(P_HEIGHT, 16.0)->setToolTip("Height of the ellipsoidal cylinder in nanometers"); } -std::unique_ptr<IFormFactor> EllipsoidalCylinderItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> EllipsoidalCylinderItem::createFormFactor() const { return std::make_unique<FormFactorEllipsoidalCylinder>(getItemValue(P_RADIUS_X).toDouble(), getItemValue(P_RADIUS_Y).toDouble(), getItemValue(P_HEIGHT).toDouble()); @@ -247,14 +225,12 @@ std::unique_ptr<IFormFactor> EllipsoidalCylinderItem::createFormFactor() const const QString FullSphereItem::P_RADIUS("Radius"); -FullSphereItem::FullSphereItem() : FormFactorItem("FullSphere") -{ +FullSphereItem::FullSphereItem() : FormFactorItem("FullSphere") { setToolTip("Full sphere"); addProperty(P_RADIUS, 8.0)->setToolTip("Radius of the sphere in nanometers"); } -std::unique_ptr<IFormFactor> FullSphereItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> FullSphereItem::createFormFactor() const { return std::make_unique<FormFactorFullSphere>(getItemValue(P_RADIUS).toDouble()); } @@ -263,15 +239,13 @@ std::unique_ptr<IFormFactor> FullSphereItem::createFormFactor() const const QString FullSpheroidItem::P_RADIUS("Radius"); const QString FullSpheroidItem::P_HEIGHT("Height"); -FullSpheroidItem::FullSpheroidItem() : FormFactorItem("FullSpheroid") -{ +FullSpheroidItem::FullSpheroidItem() : FormFactorItem("FullSpheroid") { setToolTip("Full spheroid, generated by rotating an ellipse around the vertical axis"); addProperty(P_RADIUS, 10.0)->setToolTip("Radius of the circular cross section in nanometers"); addProperty(P_HEIGHT, 13.0)->setToolTip("Height of the full spheroid in nanometers"); } -std::unique_ptr<IFormFactor> FullSpheroidItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> FullSpheroidItem::createFormFactor() const { return std::make_unique<FormFactorFullSpheroid>(getItemValue(P_RADIUS).toDouble(), getItemValue(P_HEIGHT).toDouble()); } @@ -282,8 +256,7 @@ const QString HemiEllipsoidItem::P_RADIUS_X("RadiusX"); const QString HemiEllipsoidItem::P_RADIUS_Y("RadiusY"); const QString HemiEllipsoidItem::P_HEIGHT("Height"); -HemiEllipsoidItem::HemiEllipsoidItem() : FormFactorItem("HemiEllipsoid") -{ +HemiEllipsoidItem::HemiEllipsoidItem() : FormFactorItem("HemiEllipsoid") { setToolTip("An horizontally oriented ellipsoid, truncated at the central plane"); addProperty(P_RADIUS_X, 10.0) ->setToolTip("Radius of the ellipse base in the x-direction, in nanometers"); @@ -292,8 +265,7 @@ HemiEllipsoidItem::HemiEllipsoidItem() : FormFactorItem("HemiEllipsoid") addProperty(P_HEIGHT, 8.0)->setToolTip("Height of the hemi ellipsoid in nanometers"); } -std::unique_ptr<IFormFactor> HemiEllipsoidItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> HemiEllipsoidItem::createFormFactor() const { return std::make_unique<FormFactorHemiEllipsoid>(getItemValue(P_RADIUS_X).toDouble(), getItemValue(P_RADIUS_Y).toDouble(), getItemValue(P_HEIGHT).toDouble()); @@ -303,14 +275,12 @@ std::unique_ptr<IFormFactor> HemiEllipsoidItem::createFormFactor() const const QString IcosahedronItem::P_EDGE("Edge"); -IcosahedronItem::IcosahedronItem() : FormFactorItem("Icosahedron") -{ +IcosahedronItem::IcosahedronItem() : FormFactorItem("Icosahedron") { setToolTip("Icosahedron"); addProperty(P_EDGE, 10.0)->setToolTip("Length of the edge in nanometers"); } -std::unique_ptr<IFormFactor> IcosahedronItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> IcosahedronItem::createFormFactor() const { return std::make_unique<FormFactorIcosahedron>(getItemValue(P_EDGE).toDouble()); } @@ -319,15 +289,13 @@ std::unique_ptr<IFormFactor> IcosahedronItem::createFormFactor() const const QString Prism3Item::P_BASEEDGE("BaseEdge"); const QString Prism3Item::P_HEIGHT("Height"); -Prism3Item::Prism3Item() : FormFactorItem("Prism3") -{ +Prism3Item::Prism3Item() : FormFactorItem("Prism3") { setToolTip("Prism with an equilaterial triangle base"); addProperty(P_BASEEDGE, 10.0)->setToolTip("Length of the base edge in nanometers"); addProperty(P_HEIGHT, 13.0)->setToolTip("Height in nanometers"); } -std::unique_ptr<IFormFactor> Prism3Item::createFormFactor() const -{ +std::unique_ptr<IFormFactor> Prism3Item::createFormFactor() const { return std::make_unique<FormFactorPrism3>(getItemValue(P_BASEEDGE).toDouble(), getItemValue(P_HEIGHT).toDouble()); } @@ -337,15 +305,13 @@ std::unique_ptr<IFormFactor> Prism3Item::createFormFactor() const const QString Prism6Item::P_BASEEDGE("BaseEdge"); const QString Prism6Item::P_HEIGHT("Height"); -Prism6Item::Prism6Item() : FormFactorItem("Prism6") -{ +Prism6Item::Prism6Item() : FormFactorItem("Prism6") { setToolTip("Prism with a regular hexagonal base"); addProperty(P_BASEEDGE, 5.0)->setToolTip("Length of the hexagonal base in nanometers"); addProperty(P_HEIGHT, 11.0)->setToolTip("Height in nanometers"); } -std::unique_ptr<IFormFactor> Prism6Item::createFormFactor() const -{ +std::unique_ptr<IFormFactor> Prism6Item::createFormFactor() const { return std::make_unique<FormFactorPrism6>(getItemValue(P_BASEEDGE).toDouble(), getItemValue(P_HEIGHT).toDouble()); } @@ -356,8 +322,7 @@ const QString PyramidItem::P_BASEEDGE("BaseEdge"); const QString PyramidItem::P_HEIGHT("Height"); const QString PyramidItem::P_ALPHA("Alpha"); -PyramidItem::PyramidItem() : FormFactorItem("Pyramid") -{ +PyramidItem::PyramidItem() : FormFactorItem("Pyramid") { setToolTip("Truncated pyramid with a square base"); addProperty(P_BASEEDGE, 18.0)->setToolTip("Length of the square base in nanometers"); addProperty(P_HEIGHT, 13.0)->setToolTip("Height of the pyramid in nanometers"); @@ -365,8 +330,7 @@ PyramidItem::PyramidItem() : FormFactorItem("Pyramid") ->setToolTip("Dihedral angle between the base and a side face in degrees"); } -std::unique_ptr<IFormFactor> PyramidItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> PyramidItem::createFormFactor() const { return std::make_unique<FormFactorPyramid>(getItemValue(P_BASEEDGE).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_ALPHA).toDouble() * Units::deg); @@ -378,16 +342,14 @@ const QString CosineRippleBoxItem::P_LENGTH("Length"); const QString CosineRippleBoxItem::P_WIDTH("Width"); const QString CosineRippleBoxItem::P_HEIGHT("Height"); -CosineRippleBoxItem::CosineRippleBoxItem() : FormFactorItem("CosineRippleBox") -{ +CosineRippleBoxItem::CosineRippleBoxItem() : FormFactorItem("CosineRippleBox") { setToolTip("Particle with a cosine profile and a rectangular base"); addProperty(P_LENGTH, 27.0)->setToolTip("Length of the rectangular base in nanometers"); addProperty(P_WIDTH, 20.0)->setToolTip("Width of the rectangular base in nanometers"); addProperty(P_HEIGHT, 14.0)->setToolTip("Height of the ripple in nanometers"); } -std::unique_ptr<IFormFactor> CosineRippleBoxItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> CosineRippleBoxItem::createFormFactor() const { return std::make_unique<FormFactorCosineRippleBox>(getItemValue(P_LENGTH).toDouble(), getItemValue(P_WIDTH).toDouble(), getItemValue(P_HEIGHT).toDouble()); @@ -399,16 +361,14 @@ const QString CosineRippleGaussItem::P_LENGTH("Length"); const QString CosineRippleGaussItem::P_WIDTH("Width"); const QString CosineRippleGaussItem::P_HEIGHT("Height"); -CosineRippleGaussItem::CosineRippleGaussItem() : FormFactorItem("CosineRippleGauss") -{ +CosineRippleGaussItem::CosineRippleGaussItem() : FormFactorItem("CosineRippleGauss") { setToolTip("Particle with a cosine profile and a rectangular base"); addProperty(P_LENGTH, 27.0)->setToolTip("Length of the rectangular base in nanometers"); addProperty(P_WIDTH, 20.0)->setToolTip("Width of the rectangular base in nanometers"); addProperty(P_HEIGHT, 14.0)->setToolTip("Height of the ripple in nanometers"); } -std::unique_ptr<IFormFactor> CosineRippleGaussItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> CosineRippleGaussItem::createFormFactor() const { return std::make_unique<FormFactorCosineRippleGauss>(getItemValue(P_LENGTH).toDouble(), getItemValue(P_WIDTH).toDouble(), getItemValue(P_HEIGHT).toDouble()); @@ -420,16 +380,14 @@ const QString CosineRippleLorentzItem::P_LENGTH("Length"); const QString CosineRippleLorentzItem::P_WIDTH("Width"); const QString CosineRippleLorentzItem::P_HEIGHT("Height"); -CosineRippleLorentzItem::CosineRippleLorentzItem() : FormFactorItem("CosineRippleLorentz") -{ +CosineRippleLorentzItem::CosineRippleLorentzItem() : FormFactorItem("CosineRippleLorentz") { setToolTip("Particle with a cosine profile and a rectangular base"); addProperty(P_LENGTH, 27.0)->setToolTip("Length of the rectangular base in nanometers"); addProperty(P_WIDTH, 20.0)->setToolTip("Width of the rectangular base in nanometers"); addProperty(P_HEIGHT, 14.0)->setToolTip("Height of the ripple in nanometers"); } -std::unique_ptr<IFormFactor> CosineRippleLorentzItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> CosineRippleLorentzItem::createFormFactor() const { return std::make_unique<FormFactorCosineRippleLorentz>(getItemValue(P_LENGTH).toDouble(), getItemValue(P_WIDTH).toDouble(), getItemValue(P_HEIGHT).toDouble()); @@ -442,8 +400,7 @@ const QString SawtoothRippleBoxItem::P_WIDTH("Width"); const QString SawtoothRippleBoxItem::P_HEIGHT("Height"); const QString SawtoothRippleBoxItem::P_ASYMMETRY("AsymmetryLength"); -SawtoothRippleBoxItem::SawtoothRippleBoxItem() : FormFactorItem("SawtoothRippleBox") -{ +SawtoothRippleBoxItem::SawtoothRippleBoxItem() : FormFactorItem("SawtoothRippleBox") { setToolTip("Particle with an asymmetric triangle profile and a rectangular base"); addProperty(P_LENGTH, 36.0)->setToolTip("Length of the rectangular base in nanometers"); addProperty(P_WIDTH, 25.0)->setToolTip("Width of the rectangular base in nanometers"); @@ -452,8 +409,7 @@ SawtoothRippleBoxItem::SawtoothRippleBoxItem() : FormFactorItem("SawtoothRippleB ->setToolTip("Asymmetry length of the triangular profile in nanometers"); } -std::unique_ptr<IFormFactor> SawtoothRippleBoxItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> SawtoothRippleBoxItem::createFormFactor() const { return std::make_unique<FormFactorSawtoothRippleBox>( getItemValue(P_LENGTH).toDouble(), getItemValue(P_WIDTH).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_ASYMMETRY).toDouble()); @@ -466,8 +422,7 @@ const QString SawtoothRippleGaussItem::P_WIDTH("Width"); const QString SawtoothRippleGaussItem::P_HEIGHT("Height"); const QString SawtoothRippleGaussItem::P_ASYMMETRY("AsymmetryLength"); -SawtoothRippleGaussItem::SawtoothRippleGaussItem() : FormFactorItem("SawtoothRippleGauss") -{ +SawtoothRippleGaussItem::SawtoothRippleGaussItem() : FormFactorItem("SawtoothRippleGauss") { setToolTip("Particle with an asymmetric triangle profile and a rectangular base"); addProperty(P_LENGTH, 36.0)->setToolTip("Length of the rectangular base in nanometers"); addProperty(P_WIDTH, 25.0)->setToolTip("Width of the rectangular base in nanometers"); @@ -476,8 +431,7 @@ SawtoothRippleGaussItem::SawtoothRippleGaussItem() : FormFactorItem("SawtoothRip ->setToolTip("Asymmetry length of the triangular profile in nanometers"); } -std::unique_ptr<IFormFactor> SawtoothRippleGaussItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> SawtoothRippleGaussItem::createFormFactor() const { return std::make_unique<FormFactorSawtoothRippleGauss>( getItemValue(P_LENGTH).toDouble(), getItemValue(P_WIDTH).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_ASYMMETRY).toDouble()); @@ -490,8 +444,7 @@ const QString SawtoothRippleLorentzItem::P_WIDTH("Width"); const QString SawtoothRippleLorentzItem::P_HEIGHT("Height"); const QString SawtoothRippleLorentzItem::P_ASYMMETRY("AsymmetryLength"); -SawtoothRippleLorentzItem::SawtoothRippleLorentzItem() : FormFactorItem("SawtoothRippleLorentz") -{ +SawtoothRippleLorentzItem::SawtoothRippleLorentzItem() : FormFactorItem("SawtoothRippleLorentz") { setToolTip("Particle with an asymmetric triangle profile and a rectangular base"); addProperty(P_LENGTH, 36.0)->setToolTip("Length of the rectangular base in nanometers"); addProperty(P_WIDTH, 25.0)->setToolTip("Width of the rectangular base in nanometers"); @@ -500,8 +453,7 @@ SawtoothRippleLorentzItem::SawtoothRippleLorentzItem() : FormFactorItem("Sawtoot ->setToolTip("Asymmetry length of the triangular profile in nanometers"); } -std::unique_ptr<IFormFactor> SawtoothRippleLorentzItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> SawtoothRippleLorentzItem::createFormFactor() const { return std::make_unique<FormFactorSawtoothRippleLorentz>( getItemValue(P_LENGTH).toDouble(), getItemValue(P_WIDTH).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_ASYMMETRY).toDouble()); @@ -513,8 +465,7 @@ const QString TetrahedronItem::P_BASEEDGE("BaseEdge"); const QString TetrahedronItem::P_HEIGHT("Height"); const QString TetrahedronItem::P_ALPHA("Alpha"); -TetrahedronItem::TetrahedronItem() : FormFactorItem("Tetrahedron") -{ +TetrahedronItem::TetrahedronItem() : FormFactorItem("Tetrahedron") { setToolTip("A truncated tethrahedron"); addProperty(P_BASEEDGE, 15.0) ->setToolTip("Length of one edge of the equilateral triangular base in nanometers"); @@ -522,8 +473,7 @@ TetrahedronItem::TetrahedronItem() : FormFactorItem("Tetrahedron") addProperty(P_ALPHA, 60.0)->setToolTip("Dihedral angle in degrees between base and facet"); } -std::unique_ptr<IFormFactor> TetrahedronItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> TetrahedronItem::createFormFactor() const { return std::make_unique<FormFactorTetrahedron>(getItemValue(P_BASEEDGE).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_ALPHA).toDouble() * Units::deg); @@ -534,16 +484,14 @@ std::unique_ptr<IFormFactor> TetrahedronItem::createFormFactor() const const QString TruncatedCubeItem::P_LENGTH("Length"); const QString TruncatedCubeItem::P_REMOVED_LENGTH("RemovedLength"); -TruncatedCubeItem::TruncatedCubeItem() : FormFactorItem("TruncatedCube") -{ +TruncatedCubeItem::TruncatedCubeItem() : FormFactorItem("TruncatedCube") { setToolTip("A cube whose eight vertices have been removed"); addProperty(P_LENGTH, 15.0)->setToolTip("Length of the full cube's edge in nanometers"); addProperty(P_REMOVED_LENGTH, 6.0) ->setToolTip("Removed length from each edge of the cube in nanometers"); } -std::unique_ptr<IFormFactor> TruncatedCubeItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> TruncatedCubeItem::createFormFactor() const { return std::make_unique<FormFactorTruncatedCube>(getItemValue(P_LENGTH).toDouble(), getItemValue(P_REMOVED_LENGTH).toDouble()); } @@ -554,16 +502,14 @@ const QString TruncatedSphereItem::P_RADIUS("Radius"); const QString TruncatedSphereItem::P_HEIGHT("Height"); const QString TruncatedSphereItem::P_REMOVED_TOP("DeltaHeight"); -TruncatedSphereItem::TruncatedSphereItem() : FormFactorItem("TruncatedSphere") -{ +TruncatedSphereItem::TruncatedSphereItem() : FormFactorItem("TruncatedSphere") { setToolTip("Spherical dome"); addProperty(P_RADIUS, 5.0)->setToolTip("Radius of the truncated sphere in nanometers"); addProperty(P_HEIGHT, 7.0)->setToolTip("Height of the truncated sphere in nanometers"); addProperty(P_REMOVED_TOP, 0.0)->setToolTip("Height of the removed top cap in nanometers"); } -std::unique_ptr<IFormFactor> TruncatedSphereItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> TruncatedSphereItem::createFormFactor() const { return std::make_unique<FormFactorTruncatedSphere>(getItemValue(P_RADIUS).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_REMOVED_TOP).toDouble()); @@ -576,8 +522,7 @@ const QString TruncatedSpheroidItem::P_HEIGHT("Height"); const QString TruncatedSpheroidItem::P_HFC("HeightFlattening"); const QString TruncatedSpheroidItem::P_REMOVED_TOP("DeltaHeight"); -TruncatedSpheroidItem::TruncatedSpheroidItem() : FormFactorItem("TruncatedSpheroid") -{ +TruncatedSpheroidItem::TruncatedSpheroidItem() : FormFactorItem("TruncatedSpheroid") { setToolTip("Spheroidal dome"); addProperty(P_RADIUS, 7.5)->setToolTip("Radius of the truncated spheroid in nanometers"); addProperty(P_HEIGHT, 9.0)->setToolTip("Height of the truncated spheroid in nanometers"); @@ -586,8 +531,7 @@ TruncatedSpheroidItem::TruncatedSpheroidItem() : FormFactorItem("TruncatedSphero addProperty(P_REMOVED_TOP, 0.0)->setToolTip("Height of the removed top cap in nanometers"); } -std::unique_ptr<IFormFactor> TruncatedSpheroidItem::createFormFactor() const -{ +std::unique_ptr<IFormFactor> TruncatedSpheroidItem::createFormFactor() const { return std::make_unique<FormFactorTruncatedSpheroid>( getItemValue(P_RADIUS).toDouble(), getItemValue(P_HEIGHT).toDouble(), getItemValue(P_HFC).toDouble(), getItemValue(P_REMOVED_TOP).toDouble()); diff --git a/GUI/coregui/Models/FormFactorItems.h b/GUI/coregui/Models/FormFactorItems.h index 40f7101ad6f7cb590225f2f1ed893704e5e1b2b3..86e7b5535902301ef9064dcdba02008da28e4009 100644 --- a/GUI/coregui/Models/FormFactorItems.h +++ b/GUI/coregui/Models/FormFactorItems.h @@ -19,15 +19,13 @@ class IFormFactor; -class BA_CORE_API_ FormFactorItem : public SessionItem -{ +class BA_CORE_API_ FormFactorItem : public SessionItem { public: explicit FormFactorItem(const QString& model_type) : SessionItem(model_type) {} virtual std::unique_ptr<IFormFactor> createFormFactor() const = 0; }; -class BA_CORE_API_ AnisoPyramidItem : public FormFactorItem -{ +class BA_CORE_API_ AnisoPyramidItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_WIDTH; @@ -37,8 +35,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ BarGaussItem : public FormFactorItem -{ +class BA_CORE_API_ BarGaussItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_WIDTH; @@ -47,8 +44,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ BarLorentzItem : public FormFactorItem -{ +class BA_CORE_API_ BarLorentzItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_WIDTH; @@ -57,8 +53,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ BoxItem : public FormFactorItem -{ +class BA_CORE_API_ BoxItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_WIDTH; @@ -67,8 +62,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ ConeItem : public FormFactorItem -{ +class BA_CORE_API_ ConeItem : public FormFactorItem { public: static const QString P_RADIUS; static const QString P_HEIGHT; @@ -77,8 +71,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ Cone6Item : public FormFactorItem -{ +class BA_CORE_API_ Cone6Item : public FormFactorItem { public: static const QString P_BASEEDGE; static const QString P_HEIGHT; @@ -87,8 +80,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ CuboctahedronItem : public FormFactorItem -{ +class BA_CORE_API_ CuboctahedronItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_HEIGHT; @@ -98,8 +90,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ CylinderItem : public FormFactorItem -{ +class BA_CORE_API_ CylinderItem : public FormFactorItem { public: static const QString P_RADIUS; static const QString P_HEIGHT; @@ -107,24 +98,21 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ DodecahedronItem : public FormFactorItem -{ +class BA_CORE_API_ DodecahedronItem : public FormFactorItem { public: static const QString P_EDGE; DodecahedronItem(); std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ DotItem : public FormFactorItem -{ +class BA_CORE_API_ DotItem : public FormFactorItem { public: static const QString P_RADIUS; DotItem(); std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ EllipsoidalCylinderItem : public FormFactorItem -{ +class BA_CORE_API_ EllipsoidalCylinderItem : public FormFactorItem { public: static const QString P_RADIUS_X; static const QString P_RADIUS_Y; @@ -133,16 +121,14 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ FullSphereItem : public FormFactorItem -{ +class BA_CORE_API_ FullSphereItem : public FormFactorItem { public: static const QString P_RADIUS; FullSphereItem(); std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ FullSpheroidItem : public FormFactorItem -{ +class BA_CORE_API_ FullSpheroidItem : public FormFactorItem { public: static const QString P_RADIUS; static const QString P_HEIGHT; @@ -150,8 +136,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ HemiEllipsoidItem : public FormFactorItem -{ +class BA_CORE_API_ HemiEllipsoidItem : public FormFactorItem { public: static const QString P_RADIUS_X; static const QString P_RADIUS_Y; @@ -160,16 +145,14 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ IcosahedronItem : public FormFactorItem -{ +class BA_CORE_API_ IcosahedronItem : public FormFactorItem { public: static const QString P_EDGE; IcosahedronItem(); std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ Prism3Item : public FormFactorItem -{ +class BA_CORE_API_ Prism3Item : public FormFactorItem { public: static const QString P_BASEEDGE; static const QString P_HEIGHT; @@ -177,8 +160,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ Prism6Item : public FormFactorItem -{ +class BA_CORE_API_ Prism6Item : public FormFactorItem { public: static const QString P_BASEEDGE; static const QString P_HEIGHT; @@ -186,8 +168,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ PyramidItem : public FormFactorItem -{ +class BA_CORE_API_ PyramidItem : public FormFactorItem { public: static const QString P_BASEEDGE; static const QString P_HEIGHT; @@ -196,8 +177,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ CosineRippleBoxItem : public FormFactorItem -{ +class BA_CORE_API_ CosineRippleBoxItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_WIDTH; @@ -206,8 +186,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ CosineRippleGaussItem : public FormFactorItem -{ +class BA_CORE_API_ CosineRippleGaussItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_WIDTH; @@ -216,8 +195,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ CosineRippleLorentzItem : public FormFactorItem -{ +class BA_CORE_API_ CosineRippleLorentzItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_WIDTH; @@ -226,8 +204,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ SawtoothRippleBoxItem : public FormFactorItem -{ +class BA_CORE_API_ SawtoothRippleBoxItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_WIDTH; @@ -237,8 +214,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ SawtoothRippleGaussItem : public FormFactorItem -{ +class BA_CORE_API_ SawtoothRippleGaussItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_WIDTH; @@ -248,8 +224,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ SawtoothRippleLorentzItem : public FormFactorItem -{ +class BA_CORE_API_ SawtoothRippleLorentzItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_WIDTH; @@ -259,8 +234,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ TetrahedronItem : public FormFactorItem -{ +class BA_CORE_API_ TetrahedronItem : public FormFactorItem { public: static const QString P_BASEEDGE; static const QString P_HEIGHT; @@ -269,8 +243,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ TruncatedCubeItem : public FormFactorItem -{ +class BA_CORE_API_ TruncatedCubeItem : public FormFactorItem { public: static const QString P_LENGTH; static const QString P_REMOVED_LENGTH; @@ -278,8 +251,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ TruncatedSphereItem : public FormFactorItem -{ +class BA_CORE_API_ TruncatedSphereItem : public FormFactorItem { public: static const QString P_RADIUS; static const QString P_HEIGHT; @@ -288,8 +260,7 @@ public: std::unique_ptr<IFormFactor> createFormFactor() const; }; -class BA_CORE_API_ TruncatedSpheroidItem : public FormFactorItem -{ +class BA_CORE_API_ TruncatedSpheroidItem : public FormFactorItem { public: static const QString P_RADIUS; static const QString P_HEIGHT; diff --git a/GUI/coregui/Models/GUIDomainSampleVisitor.cpp b/GUI/coregui/Models/GUIDomainSampleVisitor.cpp index 8c3922445994f2f0dcd26beb7e501c3bee716ca2..551d8f067f22ee95ae55b7afc69eb9b81a988887 100644 --- a/GUI/coregui/Models/GUIDomainSampleVisitor.cpp +++ b/GUI/coregui/Models/GUIDomainSampleVisitor.cpp @@ -45,10 +45,8 @@ using SessionItemUtils::SetVectorItem; -namespace -{ -SessionItem* AddFormFactorItem(SessionItem* p_parent, const QString& model_type) -{ +namespace { +SessionItem* AddFormFactorItem(SessionItem* p_parent, const QString& model_type) { auto parent_type = p_parent->modelType(); QString property_name; if (parent_type == "Particle") { @@ -64,17 +62,15 @@ SessionItem* AddFormFactorItem(SessionItem* p_parent, const QString& model_type) } } // namespace -GUIDomainSampleVisitor::GUIDomainSampleVisitor() : m_sampleModel(nullptr), m_materialModel(nullptr) -{ -} +GUIDomainSampleVisitor::GUIDomainSampleVisitor() + : m_sampleModel(nullptr), m_materialModel(nullptr) {} GUIDomainSampleVisitor::~GUIDomainSampleVisitor() = default; SessionItem* GUIDomainSampleVisitor::populateSampleModel(SampleModel* sampleModel, MaterialModel* materialModel, const MultiLayer& sample, - const QString& sample_name) -{ + const QString& sample_name) { m_sampleModel = sampleModel; m_materialModel = materialModel; m_levelToParentItem.clear(); @@ -90,8 +86,7 @@ SessionItem* GUIDomainSampleVisitor::populateSampleModel(SampleModel* sampleMode return result; } -void GUIDomainSampleVisitor::visit(const ParticleLayout* p_sample) -{ +void GUIDomainSampleVisitor::visit(const ParticleLayout* p_sample) { SessionItem* p_parent = m_levelToParentItem[depth() - 1]; SessionItem* p_layout_item(nullptr); if (p_parent) { @@ -106,8 +101,7 @@ void GUIDomainSampleVisitor::visit(const ParticleLayout* p_sample) m_levelToParentItem[depth()] = p_layout_item; } -void GUIDomainSampleVisitor::visit(const Layer* p_sample) -{ +void GUIDomainSampleVisitor::visit(const Layer* p_sample) { SessionItem* p_parent = m_levelToParentItem[depth() - 1]; ASSERT(p_parent); @@ -127,8 +121,7 @@ void GUIDomainSampleVisitor::visit(const Layer* p_sample) m_levelToParentItem[depth()] = p_layer_item; } -void GUIDomainSampleVisitor::visit(const MultiLayer* p_sample) -{ +void GUIDomainSampleVisitor::visit(const MultiLayer* p_sample) { SessionItem* p_multilayer_item = m_sampleModel->insertNewItem("MultiLayer"); p_multilayer_item->setItemName(p_sample->getName().c_str()); p_multilayer_item->setItemValue(MultiLayerItem::P_CROSS_CORR_LENGTH, @@ -138,15 +131,13 @@ void GUIDomainSampleVisitor::visit(const MultiLayer* p_sample) m_itemToSample[p_multilayer_item] = p_sample; } -void GUIDomainSampleVisitor::visit(const Particle* p_sample) -{ +void GUIDomainSampleVisitor::visit(const Particle* p_sample) { auto p_particle_item = InsertIParticle(p_sample, "Particle"); p_particle_item->setItemValue(ParticleItem::P_MATERIAL, createMaterialFromDomain(p_sample->material()).variant()); } -void GUIDomainSampleVisitor::visit(const ParticleDistribution* p_sample) -{ +void GUIDomainSampleVisitor::visit(const ParticleDistribution* p_sample) { SessionItem* p_layout_item = m_levelToParentItem[depth() - 1]; ASSERT(p_layout_item); SessionItem* p_particle_distribution_item = m_sampleModel->insertNewItem( @@ -159,23 +150,19 @@ void GUIDomainSampleVisitor::visit(const ParticleDistribution* p_sample) m_itemToSample[p_particle_distribution_item] = p_sample; } -void GUIDomainSampleVisitor::visit(const ParticleCoreShell* p_sample) -{ +void GUIDomainSampleVisitor::visit(const ParticleCoreShell* p_sample) { InsertIParticle(p_sample, "ParticleCoreShell"); } -void GUIDomainSampleVisitor::visit(const ParticleComposition* p_sample) -{ +void GUIDomainSampleVisitor::visit(const ParticleComposition* p_sample) { InsertIParticle(p_sample, "ParticleComposition"); } -void GUIDomainSampleVisitor::visit(const MesoCrystal* p_sample) -{ +void GUIDomainSampleVisitor::visit(const MesoCrystal* p_sample) { InsertIParticle(p_sample, "MesoCrystal"); } -void GUIDomainSampleVisitor::visit(const Crystal* p_sample) -{ +void GUIDomainSampleVisitor::visit(const Crystal* p_sample) { SessionItem* p_mesocrystal_item = m_levelToParentItem[depth() - 1]; ASSERT(p_mesocrystal_item); if (p_mesocrystal_item->modelType() != "MesoCrystal") { @@ -195,8 +182,7 @@ void GUIDomainSampleVisitor::visit(const Crystal* p_sample) m_levelToParentItem[depth()] = p_mesocrystal_item; } -void GUIDomainSampleVisitor::visit(const FormFactorAnisoPyramid* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorAnisoPyramid* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "AnisoPyramid"); p_ff_item->setItemValue(AnisoPyramidItem::P_LENGTH, p_sample->getLength()); @@ -206,8 +192,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorAnisoPyramid* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorBarGauss* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorBarGauss* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "BarGauss"); p_ff_item->setItemValue(BarGaussItem::P_LENGTH, p_sample->getLength()); @@ -216,8 +201,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorBarGauss* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorBarLorentz* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorBarLorentz* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "BarLorentz"); p_ff_item->setItemValue(BarLorentzItem::P_LENGTH, p_sample->getLength()); @@ -226,8 +210,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorBarLorentz* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorBox* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorBox* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Box"); p_ff_item->setItemValue(BoxItem::P_LENGTH, p_sample->getLength()); @@ -236,8 +219,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorBox* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorCone* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorCone* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Cone"); p_ff_item->setItemValue(ConeItem::P_RADIUS, p_sample->getRadius()); @@ -246,8 +228,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorCone* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorCone6* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorCone6* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Cone6"); p_ff_item->setItemValue(Cone6Item::P_BASEEDGE, p_sample->getBaseEdge()); @@ -256,8 +237,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorCone6* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorCuboctahedron* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorCuboctahedron* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Cuboctahedron"); p_ff_item->setItemValue(CuboctahedronItem::P_LENGTH, p_sample->getLength()); @@ -267,8 +247,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorCuboctahedron* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorCylinder* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorCylinder* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Cylinder"); p_ff_item->setItemValue(CylinderItem::P_RADIUS, p_sample->getRadius()); @@ -276,24 +255,21 @@ void GUIDomainSampleVisitor::visit(const FormFactorCylinder* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorDodecahedron* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorDodecahedron* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Dodecahedron"); p_ff_item->setItemValue(DodecahedronItem::P_EDGE, p_sample->getEdge()); m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorDot* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorDot* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Dot"); p_ff_item->setItemValue(FullSphereItem::P_RADIUS, p_sample->getRadius()); m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorEllipsoidalCylinder* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorEllipsoidalCylinder* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "EllipsoidalCylinder"); p_ff_item->setItemValue(EllipsoidalCylinderItem::P_RADIUS_X, p_sample->getRadiusX()); @@ -302,16 +278,14 @@ void GUIDomainSampleVisitor::visit(const FormFactorEllipsoidalCylinder* p_sample m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorFullSphere* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorFullSphere* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "FullSphere"); p_ff_item->setItemValue(FullSphereItem::P_RADIUS, p_sample->getRadius()); m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorFullSpheroid* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorFullSpheroid* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "FullSpheroid"); p_ff_item->setItemValue(FullSpheroidItem::P_RADIUS, p_sample->getRadius()); @@ -319,16 +293,14 @@ void GUIDomainSampleVisitor::visit(const FormFactorFullSpheroid* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorIcosahedron* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorIcosahedron* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Icosahedron"); p_ff_item->setItemValue(IcosahedronItem::P_EDGE, p_sample->getEdge()); m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorHemiEllipsoid* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorHemiEllipsoid* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "HemiEllipsoid"); p_ff_item->setItemValue(HemiEllipsoidItem::P_RADIUS_X, p_sample->getRadiusX()); @@ -337,8 +309,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorHemiEllipsoid* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorPrism3* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorPrism3* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Prism3"); p_ff_item->setItemValue(Prism3Item::P_BASEEDGE, p_sample->getBaseEdge()); @@ -346,8 +317,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorPrism3* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorPrism6* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorPrism6* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Prism6"); p_ff_item->setItemValue(Prism6Item::P_BASEEDGE, p_sample->getBaseEdge()); @@ -355,8 +325,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorPrism6* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorPyramid* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorPyramid* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Pyramid"); p_ff_item->setItemValue(PyramidItem::P_BASEEDGE, p_sample->getBaseEdge()); @@ -365,8 +334,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorPyramid* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorCosineRippleBox* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorCosineRippleBox* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "CosineRippleBox"); p_ff_item->setItemValue(CosineRippleBoxItem::P_LENGTH, p_sample->getLength()); @@ -375,8 +343,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorCosineRippleBox* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorCosineRippleGauss* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorCosineRippleGauss* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "CosineRippleGauss"); p_ff_item->setItemValue(CosineRippleGaussItem::P_LENGTH, p_sample->getLength()); @@ -385,8 +352,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorCosineRippleGauss* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorCosineRippleLorentz* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorCosineRippleLorentz* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "CosineRippleLorentz"); p_ff_item->setItemValue(CosineRippleLorentzItem::P_LENGTH, p_sample->getLength()); @@ -395,8 +361,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorCosineRippleLorentz* p_sample m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorSawtoothRippleBox* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorSawtoothRippleBox* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "SawtoothRippleBox"); p_ff_item->setItemValue(SawtoothRippleBoxItem::P_LENGTH, p_sample->getLength()); @@ -406,8 +371,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorSawtoothRippleBox* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorSawtoothRippleGauss* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorSawtoothRippleGauss* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "SawtoothRippleGauss"); p_ff_item->setItemValue(SawtoothRippleGaussItem::P_LENGTH, p_sample->getLength()); @@ -417,8 +381,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorSawtoothRippleGauss* p_sample m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorSawtoothRippleLorentz* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorSawtoothRippleLorentz* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "SawtoothRippleLorentz"); p_ff_item->setItemValue(SawtoothRippleLorentzItem::P_LENGTH, p_sample->getLength()); @@ -428,8 +391,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorSawtoothRippleLorentz* p_samp m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorTetrahedron* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorTetrahedron* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "Tetrahedron"); p_ff_item->setItemValue(TetrahedronItem::P_BASEEDGE, p_sample->getBaseEdge()); @@ -438,8 +400,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorTetrahedron* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorTruncatedCube* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorTruncatedCube* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "TruncatedCube"); p_ff_item->setItemValue(TruncatedCubeItem::P_LENGTH, p_sample->getLength()); @@ -447,8 +408,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorTruncatedCube* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorTruncatedSphere* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorTruncatedSphere* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "TruncatedSphere"); p_ff_item->setItemValue(TruncatedSphereItem::P_RADIUS, p_sample->getRadius()); @@ -457,8 +417,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorTruncatedSphere* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const FormFactorTruncatedSpheroid* p_sample) -{ +void GUIDomainSampleVisitor::visit(const FormFactorTruncatedSpheroid* p_sample) { SessionItem* p_particle_item = m_levelToParentItem[depth() - 1]; SessionItem* p_ff_item = AddFormFactorItem(p_particle_item, "TruncatedSpheroid"); p_ff_item->setItemValue(TruncatedSpheroidItem::P_RADIUS, p_sample->getRadius()); @@ -468,8 +427,7 @@ void GUIDomainSampleVisitor::visit(const FormFactorTruncatedSpheroid* p_sample) m_levelToParentItem[depth()] = p_particle_item; } -void GUIDomainSampleVisitor::visit(const InterferenceFunction1DLattice* p_sample) -{ +void GUIDomainSampleVisitor::visit(const InterferenceFunction1DLattice* p_sample) { SessionItem* parent = m_levelToParentItem[depth() - 1]; ASSERT(parent); SessionItem* item = @@ -480,8 +438,7 @@ void GUIDomainSampleVisitor::visit(const InterferenceFunction1DLattice* p_sample m_levelToParentItem[depth()] = item; } -void GUIDomainSampleVisitor::visit(const InterferenceFunction2DLattice* p_sample) -{ +void GUIDomainSampleVisitor::visit(const InterferenceFunction2DLattice* p_sample) { SessionItem* parent = m_levelToParentItem[depth() - 1]; ASSERT(parent); SessionItem* item = @@ -492,8 +449,7 @@ void GUIDomainSampleVisitor::visit(const InterferenceFunction2DLattice* p_sample m_levelToParentItem[depth()] = item; } -void GUIDomainSampleVisitor::visit(const InterferenceFunction2DParaCrystal* p_sample) -{ +void GUIDomainSampleVisitor::visit(const InterferenceFunction2DParaCrystal* p_sample) { SessionItem* parent = m_levelToParentItem[depth() - 1]; ASSERT(parent); SessionItem* item = m_sampleModel->insertNewItem("Interference2DParaCrystal", @@ -504,8 +460,7 @@ void GUIDomainSampleVisitor::visit(const InterferenceFunction2DParaCrystal* p_sa m_levelToParentItem[depth()] = item; } -void GUIDomainSampleVisitor::visit(const InterferenceFunctionFinite2DLattice* p_sample) -{ +void GUIDomainSampleVisitor::visit(const InterferenceFunctionFinite2DLattice* p_sample) { SessionItem* parent = m_levelToParentItem[depth() - 1]; ASSERT(parent); SessionItem* item = m_sampleModel->insertNewItem("InterferenceFinite2DLattice", @@ -516,8 +471,7 @@ void GUIDomainSampleVisitor::visit(const InterferenceFunctionFinite2DLattice* p_ m_levelToParentItem[depth()] = item; } -void GUIDomainSampleVisitor::visit(const InterferenceFunctionHardDisk* p_sample) -{ +void GUIDomainSampleVisitor::visit(const InterferenceFunctionHardDisk* p_sample) { SessionItem* parent = m_levelToParentItem[depth() - 1]; ASSERT(parent); SessionItem* item = @@ -528,8 +482,7 @@ void GUIDomainSampleVisitor::visit(const InterferenceFunctionHardDisk* p_sample) m_levelToParentItem[depth()] = item; } -void GUIDomainSampleVisitor::visit(const InterferenceFunctionRadialParaCrystal* p_sample) -{ +void GUIDomainSampleVisitor::visit(const InterferenceFunctionRadialParaCrystal* p_sample) { SessionItem* parent = m_levelToParentItem[depth() - 1]; ASSERT(parent); SessionItem* item = m_sampleModel->insertNewItem("InterferenceRadialParaCrystal", @@ -540,8 +493,7 @@ void GUIDomainSampleVisitor::visit(const InterferenceFunctionRadialParaCrystal* m_levelToParentItem[depth()] = item; } -void GUIDomainSampleVisitor::visit(const RotationX* p_sample) -{ +void GUIDomainSampleVisitor::visit(const RotationX* p_sample) { SessionItem* parent = m_levelToParentItem[depth() - 1]; ASSERT(parent); @@ -553,8 +505,7 @@ void GUIDomainSampleVisitor::visit(const RotationX* p_sample) m_levelToParentItem[depth()] = transformation_item; } -void GUIDomainSampleVisitor::visit(const RotationY* p_sample) -{ +void GUIDomainSampleVisitor::visit(const RotationY* p_sample) { SessionItem* parent = m_levelToParentItem[depth() - 1]; ASSERT(parent); @@ -566,8 +517,7 @@ void GUIDomainSampleVisitor::visit(const RotationY* p_sample) m_levelToParentItem[depth()] = transformation_item; } -void GUIDomainSampleVisitor::visit(const RotationZ* p_sample) -{ +void GUIDomainSampleVisitor::visit(const RotationZ* p_sample) { SessionItem* parent = m_levelToParentItem[depth() - 1]; ASSERT(parent); @@ -579,8 +529,7 @@ void GUIDomainSampleVisitor::visit(const RotationZ* p_sample) m_levelToParentItem[depth()] = transformation_item; } -void GUIDomainSampleVisitor::visit(const RotationEuler* p_sample) -{ +void GUIDomainSampleVisitor::visit(const RotationEuler* p_sample) { SessionItem* parent = m_levelToParentItem[depth() - 1]; ASSERT(parent); @@ -596,14 +545,12 @@ void GUIDomainSampleVisitor::visit(const RotationEuler* p_sample) } void GUIDomainSampleVisitor::buildPositionInfo(SessionItem* p_particle_item, - const IParticle* p_sample) -{ + const IParticle* p_sample) { kvector_t position = p_sample->position(); SetVectorItem(*p_particle_item, ParticleItem::P_POSITION, position); } -ExternalProperty GUIDomainSampleVisitor::createMaterialFromDomain(const Material* material) -{ +ExternalProperty GUIDomainSampleVisitor::createMaterialFromDomain(const Material* material) { QString materialName = m_topSampleName + QString("_") + QString(material->getName().c_str()); if (auto material = m_materialModel->materialFromName(materialName)) @@ -627,8 +574,7 @@ ExternalProperty GUIDomainSampleVisitor::createMaterialFromDomain(const Material } SessionItem* GUIDomainSampleVisitor::InsertIParticle(const IParticle* p_particle, - QString model_type) -{ + QString model_type) { auto p_parent = m_levelToParentItem[depth() - 1]; ASSERT(p_parent); diff --git a/GUI/coregui/Models/GUIDomainSampleVisitor.h b/GUI/coregui/Models/GUIDomainSampleVisitor.h index e71b4088e58819599be94c95b9e89b62bb886f88..78c058296c5649b570e2af7a133e9e77f59f0167 100644 --- a/GUI/coregui/Models/GUIDomainSampleVisitor.h +++ b/GUI/coregui/Models/GUIDomainSampleVisitor.h @@ -29,8 +29,7 @@ class MultiLayer; //! Visits domain sample tree to build GUI presentation. -class GUIDomainSampleVisitor : public INodeVisitor -{ +class GUIDomainSampleVisitor : public INodeVisitor { public: GUIDomainSampleVisitor(); ~GUIDomainSampleVisitor(); diff --git a/GUI/coregui/Models/GUIExamplesFactory.cpp b/GUI/coregui/Models/GUIExamplesFactory.cpp index 62486a3e724f4f6f458be6b937ff1862abf8ec21..594e26eb04b0321e752670a4c4151b048968a13f 100644 --- a/GUI/coregui/Models/GUIExamplesFactory.cpp +++ b/GUI/coregui/Models/GUIExamplesFactory.cpp @@ -19,8 +19,7 @@ #include <memory> //! Defines correspondance between example name and real name of simulation from SimulationFactory -QMap<QString, QString> init_NameToRegistry() -{ +QMap<QString, QString> init_NameToRegistry() { QMap<QString, QString> result; result["example01"] = "CylindersAndPrismsBuilder"; result["example02"] = "RadialParaCrystalBuilder"; @@ -54,15 +53,13 @@ QMap<QString, QString> init_NameToRegistry() QMap<QString, QString> GUIExamplesFactory::m_name_to_registry = init_NameToRegistry(); -bool GUIExamplesFactory::isValidExampleName(const QString& name) -{ +bool GUIExamplesFactory::isValidExampleName(const QString& name) { return m_name_to_registry.contains(name); } //! Populate sample model with SessionItem* GUIExamplesFactory::createSampleItems(const QString& name, SampleModel* sampleModel, - MaterialModel* materialModel) -{ + MaterialModel* materialModel) { QString exampleName = m_name_to_registry[name]; SampleBuilderFactory factory; diff --git a/GUI/coregui/Models/GUIExamplesFactory.h b/GUI/coregui/Models/GUIExamplesFactory.h index 67a58a273ccd0e13ff55862fb7378e7f52ec5153..1a9dbe64c19faed03edd291385ca3874f30adc9f 100644 --- a/GUI/coregui/Models/GUIExamplesFactory.h +++ b/GUI/coregui/Models/GUIExamplesFactory.h @@ -22,8 +22,7 @@ class SampleModel; class MaterialModel; //! Class that generates GUI model from -class GUIExamplesFactory -{ +class GUIExamplesFactory { public: static bool isValidExampleName(const QString& name); diff --git a/GUI/coregui/Models/GUIObjectBuilder.cpp b/GUI/coregui/Models/GUIObjectBuilder.cpp index 926b3c7c6e083bff9203dcc698efb91f0f757798..0a3f6efa458ea3b7d183da8674e5353e7d520f5b 100644 --- a/GUI/coregui/Models/GUIObjectBuilder.cpp +++ b/GUI/coregui/Models/GUIObjectBuilder.cpp @@ -27,8 +27,7 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include "Sample/Multilayer/MultiLayer.h" -namespace -{ +namespace { GISASInstrumentItem* createGISASInstrumentItem(InstrumentModel* model, const GISASSimulation& simulation, const QString& name); @@ -44,8 +43,7 @@ SpecularInstrumentItem* createSpecularInstrumentItem(InstrumentModel* model, SessionItem* GUIObjectBuilder::populateSampleModelFromSim(SampleModel* sampleModel, MaterialModel* materialModel, - const ISimulation& simulation) -{ + const ISimulation& simulation) { std::unique_ptr<ISimulation> sim(simulation.clone()); sim->prepareSimulation(); SessionItem* item = populateSampleModel(sampleModel, materialModel, *sim->sample()); @@ -55,16 +53,14 @@ SessionItem* GUIObjectBuilder::populateSampleModelFromSim(SampleModel* sampleMod SessionItem* GUIObjectBuilder::populateSampleModel(SampleModel* sampleModel, MaterialModel* materialModel, const MultiLayer& sample, - const QString& sample_name) -{ + const QString& sample_name) { GUIDomainSampleVisitor visitor; return visitor.populateSampleModel(sampleModel, materialModel, sample, sample_name); } SessionItem* GUIObjectBuilder::populateInstrumentModel(InstrumentModel* p_instrument_model, const ISimulation& simulation, - const QString& instrument_name) -{ + const QString& instrument_name) { ASSERT(p_instrument_model); QString name = instrument_name.isEmpty() @@ -84,8 +80,7 @@ SessionItem* GUIObjectBuilder::populateInstrumentModel(InstrumentModel* p_instru } SessionItem* GUIObjectBuilder::populateDocumentModel(DocumentModel* p_document_model, - const ISimulation& simulation) -{ + const ISimulation& simulation) { SimulationOptionsItem* p_options_item = dynamic_cast<SimulationOptionsItem*>(p_document_model->insertNewItem("SimulationOptions")); ASSERT(p_options_item); @@ -103,12 +98,10 @@ SessionItem* GUIObjectBuilder::populateDocumentModel(DocumentModel* p_document_m return p_options_item; } -namespace -{ +namespace { GISASInstrumentItem* createGISASInstrumentItem(InstrumentModel* model, const GISASSimulation& simulation, - const QString& name) -{ + const QString& name) { auto result = dynamic_cast<GISASInstrumentItem*>(model->insertNewItem("GISASInstrument")); result->setItemName(name); @@ -121,8 +114,7 @@ GISASInstrumentItem* createGISASInstrumentItem(InstrumentModel* model, OffSpecInstrumentItem* createOffSpecInstrumentItem(InstrumentModel* model, const OffSpecSimulation& simulation, - const QString& name) -{ + const QString& name) { auto result = dynamic_cast<OffSpecInstrumentItem*>(model->insertNewItem("OffSpecInstrument")); result->setItemName(name); @@ -138,8 +130,7 @@ OffSpecInstrumentItem* createOffSpecInstrumentItem(InstrumentModel* model, SpecularInstrumentItem* createSpecularInstrumentItem(InstrumentModel* model, const SpecularSimulation& simulation, - const QString& name) -{ + const QString& name) { auto result = dynamic_cast<SpecularInstrumentItem*>(model->insertNewItem("SpecularInstrument")); result->setItemName(name); diff --git a/GUI/coregui/Models/GUIObjectBuilder.h b/GUI/coregui/Models/GUIObjectBuilder.h index ff29497b80ad11aef9615bd7fae4ca0729650e09..de7f5368462ae3b037dcdf588de6914d59edd90a 100644 --- a/GUI/coregui/Models/GUIObjectBuilder.h +++ b/GUI/coregui/Models/GUIObjectBuilder.h @@ -30,8 +30,7 @@ class ExternalProperty; //! Contains set of methods to populate GUI models with content from domain. -namespace GUIObjectBuilder -{ +namespace GUIObjectBuilder { SessionItem* populateSampleModelFromSim(SampleModel* sampleModel, MaterialModel* materialModel, const ISimulation& simulation); diff --git a/GUI/coregui/Models/GroupInfo.cpp b/GUI/coregui/Models/GroupInfo.cpp index c605834c7cd965556e38cb106ae9f9555c9a963d..14fb3938e0dc1a9a9fb6c937899336348ab8385b 100644 --- a/GUI/coregui/Models/GroupInfo.cpp +++ b/GUI/coregui/Models/GroupInfo.cpp @@ -16,12 +16,9 @@ #include "GUI/coregui/utils/GUIHelpers.h" GroupInfo::GroupInfo(const QString& groupType, bool is_sorted) - : m_groupType(groupType), is_sorted(is_sorted) -{ -} + : m_groupType(groupType), is_sorted(is_sorted) {} -void GroupInfo::add(const QString& itemType, const QString& itemLabel) -{ +void GroupInfo::add(const QString& itemType, const QString& itemLabel) { if (groupType().isEmpty()) throw GUIHelpers::Error("GroupInfo::add() -> Error. Empty group name"); @@ -37,28 +34,24 @@ void GroupInfo::add(const QString& itemType, const QString& itemLabel) [](TypeAndLabel a, TypeAndLabel b) { return a.m_itemType < b.m_itemType; }); } -QString GroupInfo::defaultType() const -{ +QString GroupInfo::defaultType() const { if (m_defaultItemType == "" && m_info.size() != 0) return m_info[0].m_itemType; return m_defaultItemType; } -void GroupInfo::setDefaultType(const QString& modelType) -{ +void GroupInfo::setDefaultType(const QString& modelType) { if (!containsType(modelType)) throw GUIHelpers::Error("GroupInfo::add() -> Error. No such type '" + modelType + "'"); m_defaultItemType = modelType; } -QString GroupInfo::groupType() const -{ +QString GroupInfo::groupType() const { return m_groupType; } -QStringList GroupInfo::itemTypes() const -{ +QStringList GroupInfo::itemTypes() const { QStringList result; for (auto& pair : m_info) result.append(pair.m_itemType); @@ -66,8 +59,7 @@ QStringList GroupInfo::itemTypes() const return result; } -QStringList GroupInfo::itemLabels() const -{ +QStringList GroupInfo::itemLabels() const { QStringList result; for (auto& pair : m_info) result.append(pair.m_itemLabel); @@ -75,13 +67,11 @@ QStringList GroupInfo::itemLabels() const return result; } -bool GroupInfo::isValid() -{ +bool GroupInfo::isValid() { return !m_groupType.isEmpty(); } -bool GroupInfo::containsType(const QString& itemType) const -{ +bool GroupInfo::containsType(const QString& itemType) const { for (auto& pair : m_info) if (itemType == pair.m_itemType) return true; diff --git a/GUI/coregui/Models/GroupInfo.h b/GUI/coregui/Models/GroupInfo.h index a4d90801f09c1666bb1cdab45834ba3f014edb76..252d7d24ba9c91504139fa7e576ca5cfeb95a376 100644 --- a/GUI/coregui/Models/GroupInfo.h +++ b/GUI/coregui/Models/GroupInfo.h @@ -22,8 +22,7 @@ //! Defines info for GroupProperty, i.e. collection of model types, their labels and //! the name of default item's modelType. -class GroupInfo -{ +class GroupInfo { public: explicit GroupInfo(const QString& groupType = "", bool is_sorted = true); diff --git a/GUI/coregui/Models/GroupInfoCatalog.cpp b/GUI/coregui/Models/GroupInfoCatalog.cpp index d8da8053e28350861eb100dd2bbe6f44e2a7d341..d11aff87720ede37cac01094f3cdf2af12309cc3 100644 --- a/GUI/coregui/Models/GroupInfoCatalog.cpp +++ b/GUI/coregui/Models/GroupInfoCatalog.cpp @@ -15,8 +15,7 @@ #include "GUI/coregui/Models/GroupInfoCatalog.h" #include "GUI/coregui/utils/GUIHelpers.h" -GroupInfoCatalog::GroupInfoCatalog() -{ +GroupInfoCatalog::GroupInfoCatalog() { GroupInfo info("Form Factor"); info.add("AnisoPyramid", "Aniso Pyramid"); info.add("BarGauss", "BarGauss"); @@ -198,8 +197,7 @@ GroupInfoCatalog::GroupInfoCatalog() addInfo(info); } -GroupInfo GroupInfoCatalog::groupInfo(const QString& groupType) const -{ +GroupInfo GroupInfoCatalog::groupInfo(const QString& groupType) const { for (auto& info : m_groups) if (info.groupType() == groupType) return info; @@ -208,8 +206,7 @@ GroupInfo GroupInfoCatalog::groupInfo(const QString& groupType) const + "'"); } -bool GroupInfoCatalog::containsGroup(const QString& groupType) const -{ +bool GroupInfoCatalog::containsGroup(const QString& groupType) const { for (auto& info : m_groups) if (info.groupType() == groupType) return true; @@ -217,8 +214,7 @@ bool GroupInfoCatalog::containsGroup(const QString& groupType) const return false; } -void GroupInfoCatalog::addInfo(const GroupInfo& info) -{ +void GroupInfoCatalog::addInfo(const GroupInfo& info) { if (containsGroup(info.groupType())) throw GUIHelpers::Error("GroupInfoCatalog::addInfo -> Error. Already exists '" + info.groupType() + "'"); diff --git a/GUI/coregui/Models/GroupInfoCatalog.h b/GUI/coregui/Models/GroupInfoCatalog.h index 9eb673aedb2a34c8bb9f2fc8bece51137eab8f5c..38aa14a8703af5e47819680739ad85ed3d622f32 100644 --- a/GUI/coregui/Models/GroupInfoCatalog.h +++ b/GUI/coregui/Models/GroupInfoCatalog.h @@ -19,8 +19,7 @@ //! Catalog to hold info for GroupProperty creation. -class GroupInfoCatalog -{ +class GroupInfoCatalog { public: GroupInfoCatalog(); diff --git a/GUI/coregui/Models/GroupItem.cpp b/GUI/coregui/Models/GroupItem.cpp index 38eaff4d43bda0e2a4f4ddb142ed1118ca6da463..aff196d1cbd4f02e0bfe203d278a1bdab8c24719 100644 --- a/GUI/coregui/Models/GroupItem.cpp +++ b/GUI/coregui/Models/GroupItem.cpp @@ -19,8 +19,7 @@ const QString GroupItem::T_ITEMS = "Item tag"; -GroupItem::GroupItem() : SessionItem("GroupProperty") -{ +GroupItem::GroupItem() : SessionItem("GroupProperty") { registerTag(T_ITEMS); setDefaultTag(T_ITEMS); @@ -29,8 +28,7 @@ GroupItem::GroupItem() : SessionItem("GroupProperty") GroupItem::~GroupItem() = default; -void GroupItem::setGroupInfo(const GroupInfo& groupInfo) -{ +void GroupItem::setGroupInfo(const GroupInfo& groupInfo) { if (m_controller) throw GUIHelpers::Error("GroupItem::setGroup() -> Error. Attempt to set group twice."); @@ -38,36 +36,30 @@ void GroupItem::setGroupInfo(const GroupInfo& groupInfo) updateComboValue(); } -SessionItem* GroupItem::currentItem() const -{ +SessionItem* GroupItem::currentItem() const { return m_controller ? m_controller->currentItem() : nullptr; } -QString GroupItem::currentType() const -{ +QString GroupItem::currentType() const { return m_controller->currentType(); } -SessionItem* GroupItem::setCurrentType(const QString& modelType) -{ +SessionItem* GroupItem::setCurrentType(const QString& modelType) { m_controller->setCurrentType(modelType); updateComboValue(); return currentItem(); } -QStringList GroupItem::translateList(const QStringList& list) const -{ +QStringList GroupItem::translateList(const QStringList& list) const { // we do not add here the name of itself return list; } -SessionItem* GroupItem::getItemOfType(const QString& type) -{ +SessionItem* GroupItem::getItemOfType(const QString& type) { return m_controller->getItemOfType(type); } -void GroupItem::onValueChange() -{ +void GroupItem::onValueChange() { if (!value().canConvert<ComboProperty>()) throw GUIHelpers::Error("GroupItem::onValueChange() -> Error. Wrong property type"); @@ -81,7 +73,6 @@ void GroupItem::onValueChange() } } -void GroupItem::updateComboValue() -{ +void GroupItem::updateComboValue() { setValue(m_controller->createCombo()); } diff --git a/GUI/coregui/Models/GroupItem.h b/GUI/coregui/Models/GroupItem.h index 38568a3023a734e878ca8daf863adfb8125416f1..235e0898be9d159592150140363250c652cf80d5 100644 --- a/GUI/coregui/Models/GroupItem.h +++ b/GUI/coregui/Models/GroupItem.h @@ -22,8 +22,7 @@ class GroupInfo; class GroupItemController; -class BA_CORE_API_ GroupItem : public SessionItem -{ +class BA_CORE_API_ GroupItem : public SessionItem { public: static const QString T_ITEMS; GroupItem(); diff --git a/GUI/coregui/Models/GroupItemController.cpp b/GUI/coregui/Models/GroupItemController.cpp index 1de679d1e1e6dc5a7f05371b3a51ca003e298e30..aae2825d3fb50c73e2a9a7c570e1a90eda1ad7fe 100644 --- a/GUI/coregui/Models/GroupItemController.cpp +++ b/GUI/coregui/Models/GroupItemController.cpp @@ -18,24 +18,20 @@ #include "GUI/coregui/Models/SessionItem.h" GroupItemController::GroupItemController(SessionItem* groupItem, GroupInfo groupInfo) - : m_groupItem(groupItem), m_groupInfo(groupInfo) -{ + : m_groupItem(groupItem), m_groupInfo(groupInfo) { m_current_type = m_groupInfo.defaultType(); m_groupItem->insertItem(-1, createCorrespondingItem()); } -SessionItem* GroupItemController::currentItem() -{ +SessionItem* GroupItemController::currentItem() { return m_groupItem ? m_groupItem->getChildOfType(currentType()) : nullptr; } -QString GroupItemController::currentType() const -{ +QString GroupItemController::currentType() const { return m_current_type; } -void GroupItemController::setCurrentType(const QString& type) -{ +void GroupItemController::setCurrentType(const QString& type) { if (type == currentType()) return; @@ -59,8 +55,7 @@ void GroupItemController::setCurrentType(const QString& type) //! Returns item of give type. If it doesn't exist, it will be created. //! Method do _not_ change current item. -SessionItem* GroupItemController::getItemOfType(const QString& type) -{ +SessionItem* GroupItemController::getItemOfType(const QString& type) { if (m_groupItem) { if (auto item = m_groupItem->getChildOfType(type)) { return item; @@ -77,50 +72,41 @@ SessionItem* GroupItemController::getItemOfType(const QString& type) return nullptr; } -int GroupItemController::currentIndex() const -{ +int GroupItemController::currentIndex() const { return toIndex(m_current_type); } -void GroupItemController::setCurrentIndex(int index) -{ +void GroupItemController::setCurrentIndex(int index) { setCurrentType(toString(index)); } -QVariant GroupItemController::createCombo() const -{ +QVariant GroupItemController::createCombo() const { ComboProperty result; result.setValues(itemLabels()); result.setCurrentIndex(currentIndex()); return result.variant(); } -QStringList GroupItemController::itemTypes() const -{ +QStringList GroupItemController::itemTypes() const { return m_groupInfo.itemTypes(); } -QStringList GroupItemController::itemLabels() const -{ +QStringList GroupItemController::itemLabels() const { return m_groupInfo.itemLabels(); } -SessionItem* GroupItemController::addItem(const QString& item_type) -{ +SessionItem* GroupItemController::addItem(const QString& item_type) { return ItemFactory::CreateItem(item_type); } -SessionItem* GroupItemController::createCorrespondingItem() -{ +SessionItem* GroupItemController::createCorrespondingItem() { return addItem(currentType()); } -int GroupItemController::toIndex(const QString& type) const -{ +int GroupItemController::toIndex(const QString& type) const { return itemTypes().indexOf(type); } -QString GroupItemController::toString(int index) const -{ +QString GroupItemController::toString(int index) const { return itemTypes().at(index); } diff --git a/GUI/coregui/Models/GroupItemController.h b/GUI/coregui/Models/GroupItemController.h index 617590cf24e1dbcf85f2fdba5e245bdf06c736c9..424649f6ac864ff3ef1baa5a236fb31c3bad2ab9 100644 --- a/GUI/coregui/Models/GroupItemController.h +++ b/GUI/coregui/Models/GroupItemController.h @@ -23,8 +23,7 @@ class SessionItem; //! Provides logic for manipulating items belonging to GroupItem parent. -class GroupItemController -{ +class GroupItemController { public: GroupItemController(SessionItem* groupItem, GroupInfo groupInfo); diff --git a/GUI/coregui/Models/InstrumentItems.cpp b/GUI/coregui/Models/InstrumentItems.cpp index 4e61ebebc228ea4b8c18a5eb6d325ac547110293..d4c2843a51a91319b7dde1570d27236c5f46b013 100644 --- a/GUI/coregui/Models/InstrumentItems.cpp +++ b/GUI/coregui/Models/InstrumentItems.cpp @@ -28,8 +28,7 @@ #include "GUI/coregui/Models/SessionModel.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { const QString background_group_label = "Type"; const QStringList instrument_names{"GISASInstrument", "OffSpecInstrument", "SpecularInstrument"}; void addAxisGroupProperty(SessionItem* parent, const QString& tag); @@ -39,8 +38,7 @@ const QString InstrumentItem::P_IDENTIFIER = "Identifier"; const QString InstrumentItem::P_BEAM = "Beam"; const QString InstrumentItem::P_BACKGROUND = "Background"; -QStringList InstrumentItem::translateList(const QStringList& list) const -{ +QStringList InstrumentItem::translateList(const QStringList& list) const { QStringList result; if (list.back().endsWith(P_BACKGROUND) && list.size() == 2) { result << list[0] << list[1]; @@ -54,28 +52,23 @@ QStringList InstrumentItem::translateList(const QStringList& list) const return result; } -BeamItem* InstrumentItem::beamItem() const -{ +BeamItem* InstrumentItem::beamItem() const { return &item<BeamItem>(P_BEAM); } -BackgroundItem* InstrumentItem::backgroundItem() const -{ +BackgroundItem* InstrumentItem::backgroundItem() const { return &groupItem<BackgroundItem>(P_BACKGROUND); } -GroupItem* InstrumentItem::backgroundGroup() -{ +GroupItem* InstrumentItem::backgroundGroup() { return &item<GroupItem>(P_BACKGROUND); } -bool InstrumentItem::alignedWith(const RealDataItem* item) const -{ +bool InstrumentItem::alignedWith(const RealDataItem* item) const { return shape() == item->shape(); } -std::unique_ptr<Instrument> InstrumentItem::createInstrument() const -{ +std::unique_ptr<Instrument> InstrumentItem::createInstrument() const { std::unique_ptr<Instrument> result(new Instrument); auto beam = beamItem()->createBeam(); @@ -84,51 +77,43 @@ std::unique_ptr<Instrument> InstrumentItem::createInstrument() const return result; } -InstrumentItem::InstrumentItem(const QString& modelType) : SessionItem(modelType) -{ +InstrumentItem::InstrumentItem(const QString& modelType) : SessionItem(modelType) { setItemName(modelType); addProperty(P_IDENTIFIER, GUIHelpers::createUuid())->setVisible(false); } -void InstrumentItem::initBeamGroup(const QString& beam_model) -{ +void InstrumentItem::initBeamGroup(const QString& beam_model) { addGroupProperty(P_BEAM, beam_model); } -void InstrumentItem::initBackgroundGroup() -{ +void InstrumentItem::initBackgroundGroup() { auto item = addGroupProperty(P_BACKGROUND, "Background group"); item->setDisplayName(background_group_label); item->setToolTip("Background type"); } -SpecularInstrumentItem::SpecularInstrumentItem() : InstrumentItem("SpecularInstrument") -{ +SpecularInstrumentItem::SpecularInstrumentItem() : InstrumentItem("SpecularInstrument") { initBeamGroup("SpecularBeam"); initBackgroundGroup(); item<SpecularBeamItem>(P_BEAM).updateFileName(ItemFileNameUtils::instrumentDataFileName(*this)); } -SpecularBeamItem* SpecularInstrumentItem::beamItem() const -{ +SpecularBeamItem* SpecularInstrumentItem::beamItem() const { return &item<SpecularBeamItem>(P_BEAM); } SpecularInstrumentItem::~SpecularInstrumentItem() = default; -std::unique_ptr<Instrument> SpecularInstrumentItem::createInstrument() const -{ +std::unique_ptr<Instrument> SpecularInstrumentItem::createInstrument() const { return InstrumentItem::createInstrument(); } -std::vector<int> SpecularInstrumentItem::shape() const -{ +std::vector<int> SpecularInstrumentItem::shape() const { const auto axis_item = beamItem()->currentInclinationAxisItem(); return {axis_item->getItemValue(BasicAxisItem::P_NBINS).toInt()}; } -void SpecularInstrumentItem::updateToRealData(const RealDataItem* item) -{ +void SpecularInstrumentItem::updateToRealData(const RealDataItem* item) { if (shape().size() != item->shape().size()) throw GUIHelpers::Error("Error in SpecularInstrumentItem::updateToRealData: The type " "of instrument is incompatible with passed data shape."); @@ -138,8 +123,7 @@ void SpecularInstrumentItem::updateToRealData(const RealDataItem* item) beamItem()->updateToData(data, units); } -bool SpecularInstrumentItem::alignedWith(const RealDataItem* item) const -{ +bool SpecularInstrumentItem::alignedWith(const RealDataItem* item) const { const QString native_units = item->getItemValue(RealDataItem::P_NATIVE_DATA_UNITS).toString(); if (native_units == "nbins") { return beamItem()->currentInclinationAxisItem()->modelType() == "BasicAxis" @@ -161,8 +145,7 @@ bool SpecularInstrumentItem::alignedWith(const RealDataItem* item) const } } -std::unique_ptr<IUnitConverter> SpecularInstrumentItem::createUnitConverter() const -{ +std::unique_ptr<IUnitConverter> SpecularInstrumentItem::createUnitConverter() const { const auto instrument = createInstrument(); auto axis_item = beamItem()->currentInclinationAxisItem(); if (auto pointwise_axis = dynamic_cast<PointwiseAxisItem*>(axis_item)) { @@ -178,8 +161,7 @@ std::unique_ptr<IUnitConverter> SpecularInstrumentItem::createUnitConverter() co const QString Instrument2DItem::P_DETECTOR = "Detector"; -Instrument2DItem::Instrument2DItem(const QString& modelType) : InstrumentItem(modelType) -{ +Instrument2DItem::Instrument2DItem(const QString& modelType) : InstrumentItem(modelType) { initBeamGroup("GISASBeam"); addGroupProperty(P_DETECTOR, "Detector group"); initBackgroundGroup(); @@ -189,33 +171,27 @@ Instrument2DItem::Instrument2DItem(const QString& modelType) : InstrumentItem(mo Instrument2DItem::~Instrument2DItem() = default; -DetectorItem* Instrument2DItem::detectorItem() const -{ +DetectorItem* Instrument2DItem::detectorItem() const { return &groupItem<DetectorItem>(P_DETECTOR); } -GroupItem* Instrument2DItem::detectorGroup() -{ +GroupItem* Instrument2DItem::detectorGroup() { return &item<GroupItem>(P_DETECTOR); } -void Instrument2DItem::setDetectorGroup(const QString& modelType) -{ +void Instrument2DItem::setDetectorGroup(const QString& modelType) { setGroupProperty(P_DETECTOR, modelType); } -void Instrument2DItem::clearMasks() -{ +void Instrument2DItem::clearMasks() { detectorItem()->clearMasks(); } -void Instrument2DItem::importMasks(const MaskContainerItem* maskContainer) -{ +void Instrument2DItem::importMasks(const MaskContainerItem* maskContainer) { detectorItem()->importMasks(maskContainer); } -std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const -{ +std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const { auto result = InstrumentItem::createInstrument(); auto detector = detectorItem()->createDetector(); @@ -226,14 +202,12 @@ std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const GISASInstrumentItem::GISASInstrumentItem() : Instrument2DItem("GISASInstrument") {} -std::vector<int> GISASInstrumentItem::shape() const -{ +std::vector<int> GISASInstrumentItem::shape() const { auto detector_item = detectorItem(); return {detector_item->xSize(), detector_item->ySize()}; } -void GISASInstrumentItem::updateToRealData(const RealDataItem* item) -{ +void GISASInstrumentItem::updateToRealData(const RealDataItem* item) { if (!item) return; @@ -247,8 +221,7 @@ void GISASInstrumentItem::updateToRealData(const RealDataItem* item) const QString OffSpecInstrumentItem::P_ALPHA_AXIS = "Alpha axis"; -OffSpecInstrumentItem::OffSpecInstrumentItem() : Instrument2DItem("OffSpecInstrument") -{ +OffSpecInstrumentItem::OffSpecInstrumentItem() : Instrument2DItem("OffSpecInstrument") { addAxisGroupProperty(this, P_ALPHA_AXIS); auto inclination_item = getItem(P_ALPHA_AXIS)->getItem(BasicAxisItem::P_MIN_DEG); auto beam_item = beamItem(); @@ -259,15 +232,13 @@ OffSpecInstrumentItem::OffSpecInstrumentItem() : Instrument2DItem("OffSpecInstru }); } -std::vector<int> OffSpecInstrumentItem::shape() const -{ +std::vector<int> OffSpecInstrumentItem::shape() const { const int x_size = getItem(P_ALPHA_AXIS)->getItemValue(BasicAxisItem::P_NBINS).toInt(); auto detector_item = detectorItem(); return {x_size, detector_item->ySize()}; } -void OffSpecInstrumentItem::updateToRealData(const RealDataItem* item) -{ +void OffSpecInstrumentItem::updateToRealData(const RealDataItem* item) { if (!item) return; @@ -280,10 +251,8 @@ void OffSpecInstrumentItem::updateToRealData(const RealDataItem* item) detectorItem()->setYSize(data_shape[1]); } -namespace -{ -void addAxisGroupProperty(SessionItem* parent, const QString& tag) -{ +namespace { +void addAxisGroupProperty(SessionItem* parent, const QString& tag) { auto item = parent->addGroupProperty(tag, "BasicAxis"); item->setToolTip("Incoming alpha range [deg]"); item->getItem(BasicAxisItem::P_TITLE)->setVisible(false); diff --git a/GUI/coregui/Models/InstrumentItems.h b/GUI/coregui/Models/InstrumentItems.h index 11bdbb13fba4a68e2b727a6da2e21645e3989538..2356174e73f0e037fa445c534d89d4e9035c22da 100644 --- a/GUI/coregui/Models/InstrumentItems.h +++ b/GUI/coregui/Models/InstrumentItems.h @@ -26,8 +26,7 @@ class IUnitConverter; class MaskContainerItem; class RealDataItem; -class BA_CORE_API_ InstrumentItem : public SessionItem -{ +class BA_CORE_API_ InstrumentItem : public SessionItem { public: static const QString P_IDENTIFIER; static const QString P_BEAM; @@ -53,8 +52,7 @@ protected: void initBackgroundGroup(); }; -class BA_CORE_API_ SpecularInstrumentItem : public InstrumentItem -{ +class BA_CORE_API_ SpecularInstrumentItem : public InstrumentItem { public: SpecularInstrumentItem(); ~SpecularInstrumentItem() override; @@ -69,8 +67,7 @@ public: std::unique_ptr<IUnitConverter> createUnitConverter() const; }; -class BA_CORE_API_ Instrument2DItem : public InstrumentItem -{ +class BA_CORE_API_ Instrument2DItem : public InstrumentItem { public: static const QString P_DETECTOR; @@ -90,16 +87,14 @@ protected: explicit Instrument2DItem(const QString& modelType); }; -class BA_CORE_API_ GISASInstrumentItem : public Instrument2DItem -{ +class BA_CORE_API_ GISASInstrumentItem : public Instrument2DItem { public: GISASInstrumentItem(); std::vector<int> shape() const override; void updateToRealData(const RealDataItem* item) override; }; -class BA_CORE_API_ OffSpecInstrumentItem : public Instrument2DItem -{ +class BA_CORE_API_ OffSpecInstrumentItem : public Instrument2DItem { public: static const QString P_ALPHA_AXIS; diff --git a/GUI/coregui/Models/InstrumentModel.cpp b/GUI/coregui/Models/InstrumentModel.cpp index ce86eef0c1768bff9db3f22a492750a98176e7df..dca33c78f6858e2c3e9fc45c86557cc9bd3093cd 100644 --- a/GUI/coregui/Models/InstrumentModel.cpp +++ b/GUI/coregui/Models/InstrumentModel.cpp @@ -17,22 +17,19 @@ #include "GUI/coregui/Models/SpecularBeamInclinationItem.h" InstrumentModel::InstrumentModel(QObject* parent) - : SessionModel(SessionXML::InstrumentModelTag, parent) -{ + : SessionModel(SessionXML::InstrumentModelTag, parent) { setObjectName(SessionXML::InstrumentModelTag); } InstrumentModel::~InstrumentModel() = default; -InstrumentModel* InstrumentModel::createCopy(SessionItem* parent) -{ +InstrumentModel* InstrumentModel::createCopy(SessionItem* parent) { InstrumentModel* result = new InstrumentModel(); result->initFrom(this, parent); return result; } -QVector<SessionItem*> InstrumentModel::nonXMLData() const -{ +QVector<SessionItem*> InstrumentModel::nonXMLData() const { QVector<SessionItem*> result; for (auto instrument_item : topItems<SpecularInstrumentItem>()) { @@ -47,7 +44,6 @@ QVector<SessionItem*> InstrumentModel::nonXMLData() const return result; } -InstrumentItem* InstrumentModel::instrumentItem() -{ +InstrumentItem* InstrumentModel::instrumentItem() { return topItem<InstrumentItem>(); } diff --git a/GUI/coregui/Models/InstrumentModel.h b/GUI/coregui/Models/InstrumentModel.h index 0e1ded24acd68dda59897184275d05d2f2ac3959..61aa77a9a4462fcb47070aa283f73b8c834e9fc0 100644 --- a/GUI/coregui/Models/InstrumentModel.h +++ b/GUI/coregui/Models/InstrumentModel.h @@ -19,8 +19,7 @@ class InstrumentItem; -class InstrumentModel : public SessionModel -{ +class InstrumentModel : public SessionModel { Q_OBJECT public: diff --git a/GUI/coregui/Models/IntensityDataItem.cpp b/GUI/coregui/Models/IntensityDataItem.cpp index 7ca858d03b42e7c5da1e85a6b5d65d5888d1fbb6..0c90ce0d32ea4790aa911d56a6a901c03340f2ec 100644 --- a/GUI/coregui/Models/IntensityDataItem.cpp +++ b/GUI/coregui/Models/IntensityDataItem.cpp @@ -21,10 +21,8 @@ #include "GUI/coregui/Views/MaskWidgets/MaskUnitsConverter.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ -ComboProperty gradientCombo() -{ +namespace { +ComboProperty gradientCombo() { ComboProperty result; result << "Grayscale" << "Hot" @@ -56,8 +54,7 @@ const QString IntensityDataItem::P_ZAXIS = "color-axis"; const QString IntensityDataItem::T_MASKS = "Mask tag"; const QString IntensityDataItem::T_PROJECTIONS = "Projection tag"; -IntensityDataItem::IntensityDataItem() : DataItem("IntensityData") -{ +IntensityDataItem::IntensityDataItem() : DataItem("IntensityData") { addProperty(P_TITLE, QString())->setVisible(false); addProperty(P_PROJECTIONS_FLAG, false)->setVisible(false); @@ -82,8 +79,7 @@ IntensityDataItem::IntensityDataItem() : DataItem("IntensityData") registerTag(T_PROJECTIONS, 0, -1, QStringList() << "ProjectionContainer"); } -void IntensityDataItem::setOutputData(OutputData<double>* data) -{ +void IntensityDataItem::setOutputData(OutputData<double>* data) { ASSERT(data && "Assertion failed in IntensityDataItem::setOutputData: nullptr data passed"); if (data->rank() != 2) throw GUIHelpers::Error( @@ -97,127 +93,104 @@ void IntensityDataItem::setOutputData(OutputData<double>* data) emitDataChanged(); } -int IntensityDataItem::getNbinsX() const -{ +int IntensityDataItem::getNbinsX() const { return xAxisItem()->getItemValue(BasicAxisItem::P_NBINS).toInt(); } -int IntensityDataItem::getNbinsY() const -{ +int IntensityDataItem::getNbinsY() const { return yAxisItem()->getItemValue(BasicAxisItem::P_NBINS).toInt(); } -double IntensityDataItem::getLowerX() const -{ +double IntensityDataItem::getLowerX() const { return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_MIN_DEG).toDouble(); } -double IntensityDataItem::getUpperX() const -{ +double IntensityDataItem::getUpperX() const { return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_MAX_DEG).toDouble(); } -double IntensityDataItem::getXmin() const -{ +double IntensityDataItem::getXmin() const { const double defaultXmin(0.0); return m_data ? m_data->axis(0).lowerBound() : defaultXmin; } -double IntensityDataItem::getXmax() const -{ +double IntensityDataItem::getXmax() const { const double defaultXmax(1.0); return m_data ? m_data->axis(0).upperBound() : defaultXmax; } -double IntensityDataItem::getLowerY() const -{ +double IntensityDataItem::getLowerY() const { return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_MIN_DEG).toDouble(); } -double IntensityDataItem::getUpperY() const -{ +double IntensityDataItem::getUpperY() const { return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_MAX_DEG).toDouble(); } -double IntensityDataItem::getYmin() const -{ +double IntensityDataItem::getYmin() const { const double defaultYmin(0.0); return m_data ? m_data->axis(1).lowerBound() : defaultYmin; } -double IntensityDataItem::getYmax() const -{ +double IntensityDataItem::getYmax() const { const double defaultYmax(1.0); return m_data ? m_data->axis(1).upperBound() : defaultYmax; } -double IntensityDataItem::getLowerZ() const -{ +double IntensityDataItem::getLowerZ() const { return getItem(P_ZAXIS)->getItemValue(BasicAxisItem::P_MIN_DEG).toDouble(); } -double IntensityDataItem::getUpperZ() const -{ +double IntensityDataItem::getUpperZ() const { return getItem(P_ZAXIS)->getItemValue(BasicAxisItem::P_MAX_DEG).toDouble(); } -QString IntensityDataItem::getGradient() const -{ +QString IntensityDataItem::getGradient() const { ComboProperty combo_property = getItemValue(P_GRADIENT).value<ComboProperty>(); return combo_property.getValue(); } -bool IntensityDataItem::isLogz() const -{ +bool IntensityDataItem::isLogz() const { return getItem(P_ZAXIS)->getItemValue(AmplitudeAxisItem::P_IS_LOGSCALE).toBool(); } -bool IntensityDataItem::isInterpolated() const -{ +bool IntensityDataItem::isInterpolated() const { return getItemValue(P_IS_INTERPOLATED).toBool(); } -QString IntensityDataItem::getXaxisTitle() const -{ +QString IntensityDataItem::getXaxisTitle() const { return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_TITLE).toString(); } -QString IntensityDataItem::getYaxisTitle() const -{ +QString IntensityDataItem::getYaxisTitle() const { return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_TITLE).toString(); } -bool IntensityDataItem::isZAxisLocked() const -{ +bool IntensityDataItem::isZAxisLocked() const { return getItem(P_ZAXIS)->getItemValue(AmplitudeAxisItem::P_LOCK_MIN_MAX).toBool(); } -void IntensityDataItem::setZAxisLocked(bool state) -{ +void IntensityDataItem::setZAxisLocked(bool state) { return getItem(P_ZAXIS)->setItemValue(AmplitudeAxisItem::P_LOCK_MIN_MAX, state); } -void IntensityDataItem::setXaxisTitle(QString xtitle) -{ +void IntensityDataItem::setXaxisTitle(QString xtitle) { getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_TITLE, xtitle); } -void IntensityDataItem::setYaxisTitle(QString ytitle) -{ +void IntensityDataItem::setYaxisTitle(QString ytitle) { getItem(P_YAXIS)->setItemValue(BasicAxisItem::P_TITLE, ytitle); } //! set zoom range of x,y axes to axes of input data -void IntensityDataItem::setAxesRangeToData() -{ +void IntensityDataItem::setAxesRangeToData() { setLowerX(getXmin()); setUpperX(getXmax()); setLowerY(getYmin()); setUpperY(getYmax()); } -void IntensityDataItem::updateAxesUnits(const InstrumentItem* instrument) -{ +void IntensityDataItem::updateAxesUnits(const InstrumentItem* instrument) { MaskUnitsConverter converter; converter.convertToNbins(this); @@ -226,13 +199,11 @@ void IntensityDataItem::updateAxesUnits(const InstrumentItem* instrument) converter.convertFromNbins(this); } -std::vector<int> IntensityDataItem::shape() const -{ +std::vector<int> IntensityDataItem::shape() const { return {getNbinsX(), getNbinsY()}; } -void IntensityDataItem::reset(ImportDataInfo data) -{ +void IntensityDataItem::reset(ImportDataInfo data) { ASSERT(data.unitsLabel() == "nbins"); ComboProperty combo = ComboProperty() << data.unitsLabel(); setItemValue(IntensityDataItem::P_AXES_UNITS, combo.variant()); @@ -247,28 +218,23 @@ void IntensityDataItem::reset(ImportDataInfo data) converter.convertFromNbins(this); } -void IntensityDataItem::setLowerX(double xmin) -{ +void IntensityDataItem::setLowerX(double xmin) { getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_MIN_DEG, xmin); } -void IntensityDataItem::setUpperX(double xmax) -{ +void IntensityDataItem::setUpperX(double xmax) { getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_MAX_DEG, xmax); } -void IntensityDataItem::setLowerY(double ymin) -{ +void IntensityDataItem::setLowerY(double ymin) { getItem(P_YAXIS)->setItemValue(BasicAxisItem::P_MIN_DEG, ymin); } -void IntensityDataItem::setUpperY(double ymax) -{ +void IntensityDataItem::setUpperY(double ymax) { getItem(P_YAXIS)->setItemValue(BasicAxisItem::P_MAX_DEG, ymax); } -void IntensityDataItem::setLowerAndUpperZ(double zmin, double zmax) -{ +void IntensityDataItem::setLowerAndUpperZ(double zmin, double zmax) { if (getLowerZ() != zmin) getItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MIN_DEG, zmin); @@ -276,30 +242,25 @@ void IntensityDataItem::setLowerAndUpperZ(double zmin, double zmax) getItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MAX_DEG, zmax); } -void IntensityDataItem::setLowerZ(double zmin) -{ +void IntensityDataItem::setLowerZ(double zmin) { getItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MIN_DEG, zmin); } -void IntensityDataItem::setUpperZ(double zmax) -{ +void IntensityDataItem::setUpperZ(double zmax) { getItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MAX_DEG, zmax); } -void IntensityDataItem::setLogz(bool logz) -{ +void IntensityDataItem::setLogz(bool logz) { getItem(P_ZAXIS)->setItemValue(AmplitudeAxisItem::P_IS_LOGSCALE, logz); } -void IntensityDataItem::setInterpolated(bool interp) -{ +void IntensityDataItem::setInterpolated(bool interp) { setItemValue(P_IS_INTERPOLATED, interp); } //! Sets zoom range of X,Y axes, if it was not yet defined. -void IntensityDataItem::updateAxesZoomLevel() -{ +void IntensityDataItem::updateAxesZoomLevel() { // set zoom range of x-axis to min, max values if it was not set already if (getUpperX() < getLowerX()) { setLowerX(getXmin()); @@ -320,8 +281,7 @@ void IntensityDataItem::updateAxesZoomLevel() //! Init axes labels, if it was not done already. -void IntensityDataItem::updateAxesLabels() -{ +void IntensityDataItem::updateAxesLabels() { if (getXaxisTitle().isEmpty()) setXaxisTitle(QString::fromStdString(m_data->axis(0).getName())); @@ -331,23 +291,20 @@ void IntensityDataItem::updateAxesLabels() //! Sets min,max values for z-axis, if axes is not locked, and ranges are not yet set. -void IntensityDataItem::updateDataRange() -{ +void IntensityDataItem::updateDataRange() { if (isZAxisLocked()) return; computeDataRange(); } -void IntensityDataItem::computeDataRange() -{ +void IntensityDataItem::computeDataRange() { QPair<double, double> minmax = dataRange(); setLowerAndUpperZ(minmax.first, minmax.second); } //! Init zmin, zmax to match the intensity values range. -QPair<double, double> IntensityDataItem::dataRange() const -{ +QPair<double, double> IntensityDataItem::dataRange() const { const OutputData<double>* data = getOutputData(); double min(*std::min_element(data->begin(), data->end())); double max(*std::max_element(data->begin(), data->end())); @@ -366,40 +323,33 @@ QPair<double, double> IntensityDataItem::dataRange() const return QPair<double, double>(min, max); } -const BasicAxisItem* IntensityDataItem::xAxisItem() const -{ +const BasicAxisItem* IntensityDataItem::xAxisItem() const { return dynamic_cast<const BasicAxisItem*>(getItem(P_XAXIS)); } -BasicAxisItem* IntensityDataItem::xAxisItem() -{ +BasicAxisItem* IntensityDataItem::xAxisItem() { return const_cast<BasicAxisItem*>(static_cast<const IntensityDataItem*>(this)->xAxisItem()); } -const BasicAxisItem* IntensityDataItem::yAxisItem() const -{ +const BasicAxisItem* IntensityDataItem::yAxisItem() const { return dynamic_cast<const BasicAxisItem*>(getItem(P_YAXIS)); } -BasicAxisItem* IntensityDataItem::yAxisItem() -{ +BasicAxisItem* IntensityDataItem::yAxisItem() { return const_cast<BasicAxisItem*>(static_cast<const IntensityDataItem*>(this)->yAxisItem()); } -const BasicAxisItem* IntensityDataItem::zAxisItem() const -{ +const BasicAxisItem* IntensityDataItem::zAxisItem() const { return dynamic_cast<const BasicAxisItem*>(getItem(P_ZAXIS)); } -BasicAxisItem* IntensityDataItem::zAxisItem() -{ +BasicAxisItem* IntensityDataItem::zAxisItem() { return const_cast<BasicAxisItem*>(static_cast<const IntensityDataItem*>(this)->zAxisItem()); } //! Set axes viewport to original data. -void IntensityDataItem::resetView() -{ +void IntensityDataItem::resetView() { if (!m_data) return; @@ -408,12 +358,10 @@ void IntensityDataItem::resetView() computeDataRange(); } -MaskContainerItem* IntensityDataItem::maskContainerItem() -{ +MaskContainerItem* IntensityDataItem::maskContainerItem() { return dynamic_cast<MaskContainerItem*>(getItem(IntensityDataItem::T_MASKS)); } -ProjectionContainerItem* IntensityDataItem::projectionContainerItem() -{ +ProjectionContainerItem* IntensityDataItem::projectionContainerItem() { return dynamic_cast<ProjectionContainerItem*>(getItem(IntensityDataItem::T_PROJECTIONS)); } diff --git a/GUI/coregui/Models/IntensityDataItem.h b/GUI/coregui/Models/IntensityDataItem.h index 5e2ae239266eebecf871cd3f99eb0737474aef9a..7f69c1004e4fbac27ead571efd9f4e5798dc3802 100644 --- a/GUI/coregui/Models/IntensityDataItem.h +++ b/GUI/coregui/Models/IntensityDataItem.h @@ -21,8 +21,7 @@ class BasicAxisItem; class MaskContainerItem; class ProjectionContainerItem; -class BA_CORE_API_ IntensityDataItem : public DataItem -{ +class BA_CORE_API_ IntensityDataItem : public DataItem { public: static const QString P_PROJECTIONS_FLAG; static const QString P_TITLE; diff --git a/GUI/coregui/Models/InterferenceFunctionItems.cpp b/GUI/coregui/Models/InterferenceFunctionItems.cpp index 7a43697fb1cea4b2a7533396dce40a5f8e071b9b..835644beab5138e2a2398b9ec59af4b346d07b8d 100644 --- a/GUI/coregui/Models/InterferenceFunctionItems.cpp +++ b/GUI/coregui/Models/InterferenceFunctionItems.cpp @@ -21,8 +21,7 @@ #include "GUI/coregui/Models/ModelPath.h" #include "Sample/Aggregate/InterferenceFunctions.h" -namespace -{ +namespace { const QString decay_function_tag = "Decay Function"; } @@ -34,16 +33,14 @@ const QString InterferenceFunctionItem::P_POSITION_VARIANCE = QString::fromStdString("PositionVariance"); InterferenceFunctionItem::InterferenceFunctionItem(const QString& modelType) - : SessionGraphicsItem(modelType) -{ + : SessionGraphicsItem(modelType) { addProperty(P_POSITION_VARIANCE, 0.0) ->setToolTip("Variance of the position in each dimension (nm^2)"); } InterferenceFunctionItem::~InterferenceFunctionItem() = default; -void InterferenceFunctionItem::setPositionVariance(IInterferenceFunction* p_iff) const -{ +void InterferenceFunctionItem::setPositionVariance(IInterferenceFunction* p_iff) const { p_iff->setPositionVariance(getItemValue(P_POSITION_VARIANCE).toDouble()); } @@ -54,8 +51,7 @@ const QString InterferenceFunction1DLatticeItem::P_ROTATION_ANGLE = QString::fro const QString InterferenceFunction1DLatticeItem::P_DECAY_FUNCTION = decay_function_tag; InterferenceFunction1DLatticeItem::InterferenceFunction1DLatticeItem() - : InterferenceFunctionItem("Interference1DLattice") -{ + : InterferenceFunctionItem("Interference1DLattice") { setToolTip("Interference function of a 1D lattice"); addProperty(P_LENGTH, 20.0 * Units::nm)->setToolTip("Lattice length in nanometers"); addProperty(P_ROTATION_ANGLE, 0.0) @@ -66,8 +62,7 @@ InterferenceFunction1DLatticeItem::InterferenceFunction1DLatticeItem() } std::unique_ptr<IInterferenceFunction> -InterferenceFunction1DLatticeItem::createInterferenceFunction() const -{ +InterferenceFunction1DLatticeItem::createInterferenceFunction() const { auto result = std::make_unique<InterferenceFunction1DLattice>( getItemValue(P_LENGTH).toDouble(), Units::deg2rad(getItemValue(P_ROTATION_ANGLE).toDouble())); @@ -85,8 +80,7 @@ const QString InterferenceFunction2DLatticeItem::P_DECAY_FUNCTION = decay_functi const QString InterferenceFunction2DLatticeItem::P_XI_INTEGRATION = "Integration_over_xi"; InterferenceFunction2DLatticeItem::InterferenceFunction2DLatticeItem() - : InterferenceFunctionItem("Interference2DLattice") -{ + : InterferenceFunctionItem("Interference2DLattice") { setToolTip("Interference function of a 2D lattice"); addGroupProperty(P_LATTICE_TYPE, "Lattice group")->setToolTip("Type of lattice"); addGroupProperty(P_DECAY_FUNCTION, "Decay function 2D") @@ -108,8 +102,7 @@ InterferenceFunction2DLatticeItem::InterferenceFunction2DLatticeItem() } std::unique_ptr<IInterferenceFunction> -InterferenceFunction2DLatticeItem::createInterferenceFunction() const -{ +InterferenceFunction2DLatticeItem::createInterferenceFunction() const { auto& latticeItem = groupItem<Lattice2DItem>(P_LATTICE_TYPE); std::unique_ptr<InterferenceFunction2DLattice> result( new InterferenceFunction2DLattice(*latticeItem.createLattice())); @@ -122,8 +115,7 @@ InterferenceFunction2DLatticeItem::createInterferenceFunction() const return std::unique_ptr<IInterferenceFunction>(result.release()); } -void InterferenceFunction2DLatticeItem::update_rotation_availability() -{ +void InterferenceFunction2DLatticeItem::update_rotation_availability() { auto p_lattice_item = getGroupItem(P_LATTICE_TYPE); if (p_lattice_item) { auto angle_item = p_lattice_item->getItem(Lattice2DItem::P_LATTICE_ROTATION_ANGLE); @@ -144,8 +136,7 @@ const QString InterferenceFunction2DParaCrystalItem::P_PDF1 = "PDF #1"; const QString InterferenceFunction2DParaCrystalItem::P_PDF2 = "PDF #2"; InterferenceFunction2DParaCrystalItem::InterferenceFunction2DParaCrystalItem() - : InterferenceFunctionItem("Interference2DParaCrystal") -{ + : InterferenceFunctionItem("Interference2DParaCrystal") { setToolTip("Interference function of a two-dimensional paracrystal"); addGroupProperty(InterferenceFunction2DLatticeItem::P_LATTICE_TYPE, "Lattice group") @@ -188,8 +179,7 @@ InterferenceFunction2DParaCrystalItem::InterferenceFunction2DParaCrystalItem() } std::unique_ptr<IInterferenceFunction> -InterferenceFunction2DParaCrystalItem::createInterferenceFunction() const -{ +InterferenceFunction2DParaCrystalItem::createInterferenceFunction() const { auto& latticeItem = groupItem<Lattice2DItem>(InterferenceFunction2DLatticeItem::P_LATTICE_TYPE); std::unique_ptr<InterferenceFunction2DParaCrystal> result( @@ -211,8 +201,7 @@ InterferenceFunction2DParaCrystalItem::createInterferenceFunction() const //! Sets rotation property of the lattice enabled/disabled depending on integration flag. -void InterferenceFunction2DParaCrystalItem::update_rotation_availability() -{ +void InterferenceFunction2DParaCrystalItem::update_rotation_availability() { auto p_lattice_item = getGroupItem(InterferenceFunction2DLatticeItem::P_LATTICE_TYPE); if (p_lattice_item) { auto angle_item = p_lattice_item->getItem(Lattice2DItem::P_LATTICE_ROTATION_ANGLE); @@ -220,8 +209,7 @@ void InterferenceFunction2DParaCrystalItem::update_rotation_availability() } } -void InterferenceFunction2DParaCrystalItem::update_distribution_displaynames() -{ +void InterferenceFunction2DParaCrystalItem::update_distribution_displaynames() { GroupItem* group1 = dynamic_cast<GroupItem*>(getItem(P_PDF1)); GroupItem* group2 = dynamic_cast<GroupItem*>(getItem(P_PDF2)); @@ -249,8 +237,7 @@ const QString InterferenceFunctionFinite2DLatticeItem::P_DOMAIN_SIZE_1 = "Domain const QString InterferenceFunctionFinite2DLatticeItem::P_DOMAIN_SIZE_2 = "Domain_size_2"; InterferenceFunctionFinite2DLatticeItem::InterferenceFunctionFinite2DLatticeItem() - : InterferenceFunctionItem("InterferenceFinite2DLattice") -{ + : InterferenceFunctionItem("InterferenceFinite2DLattice") { setToolTip("Interference function of a finite 2D lattice"); addGroupProperty(InterferenceFunction2DLatticeItem::P_LATTICE_TYPE, "Lattice group") ->setToolTip("Type of lattice"); @@ -273,8 +260,7 @@ InterferenceFunctionFinite2DLatticeItem::InterferenceFunctionFinite2DLatticeItem } std::unique_ptr<IInterferenceFunction> -InterferenceFunctionFinite2DLatticeItem::createInterferenceFunction() const -{ +InterferenceFunctionFinite2DLatticeItem::createInterferenceFunction() const { auto& latticeItem = groupItem<Lattice2DItem>(InterferenceFunction2DLatticeItem::P_LATTICE_TYPE); auto size_1 = getItemValue(P_DOMAIN_SIZE_1).toUInt(); auto size_2 = getItemValue(P_DOMAIN_SIZE_2).toUInt(); @@ -287,8 +273,7 @@ InterferenceFunctionFinite2DLatticeItem::createInterferenceFunction() const return std::unique_ptr<IInterferenceFunction>(result.release()); } -void InterferenceFunctionFinite2DLatticeItem::update_rotation_availability() -{ +void InterferenceFunctionFinite2DLatticeItem::update_rotation_availability() { auto p_lattice_item = getGroupItem(InterferenceFunction2DLatticeItem::P_LATTICE_TYPE); if (p_lattice_item) { auto angle_item = p_lattice_item->getItem(Lattice2DItem::P_LATTICE_ROTATION_ANGLE); @@ -303,16 +288,14 @@ const QString InterferenceFunctionHardDiskItem::P_DENSITY = QString::fromStdString("TotalParticleDensity"); InterferenceFunctionHardDiskItem::InterferenceFunctionHardDiskItem() - : InterferenceFunctionItem("InterferenceHardDisk") -{ + : InterferenceFunctionItem("InterferenceHardDisk") { setToolTip("Interference function for hard disk Percus-Yevick"); addProperty(P_RADIUS, 5.0 * Units::nm)->setToolTip("Hard disk radius in nanometers"); addProperty(P_DENSITY, 0.002)->setToolTip("Particle density in particles per square nanometer"); } std::unique_ptr<IInterferenceFunction> -InterferenceFunctionHardDiskItem::createInterferenceFunction() const -{ +InterferenceFunctionHardDiskItem::createInterferenceFunction() const { auto result = std::make_unique<InterferenceFunctionHardDisk>( getItemValue(P_RADIUS).toDouble(), getItemValue(P_DENSITY).toDouble()); setPositionVariance(result.get()); @@ -332,8 +315,7 @@ const QString InterferenceFunctionRadialParaCrystalItem::P_KAPPA = const QString InterferenceFunctionRadialParaCrystalItem::P_PDF = "PDF"; InterferenceFunctionRadialParaCrystalItem::InterferenceFunctionRadialParaCrystalItem() - : InterferenceFunctionItem("InterferenceRadialParaCrystal") -{ + : InterferenceFunctionItem("InterferenceRadialParaCrystal") { setToolTip("Interference function of a radial paracrystal"); addProperty(P_PEAK_DISTANCE, 20.0 * Units::nm) ->setToolTip("Average distance to the next neighbor in nanometers"); @@ -350,8 +332,7 @@ InterferenceFunctionRadialParaCrystalItem::InterferenceFunctionRadialParaCrystal } std::unique_ptr<IInterferenceFunction> -InterferenceFunctionRadialParaCrystalItem::createInterferenceFunction() const -{ +InterferenceFunctionRadialParaCrystalItem::createInterferenceFunction() const { auto result = std::make_unique<InterferenceFunctionRadialParaCrystal>( getItemValue(P_PEAK_DISTANCE).toDouble(), getItemValue(P_DAMPING_LENGTH).toDouble()); result->setDomainSize(getItemValue(P_DOMAIN_SIZE).toDouble()); diff --git a/GUI/coregui/Models/InterferenceFunctionItems.h b/GUI/coregui/Models/InterferenceFunctionItems.h index 926401e6fbdeb2487ca926955d1fb9b083bdc846..c8ae259ffa1bc1c770446d40fd6a94bf797e83a1 100644 --- a/GUI/coregui/Models/InterferenceFunctionItems.h +++ b/GUI/coregui/Models/InterferenceFunctionItems.h @@ -18,8 +18,7 @@ #include "GUI/coregui/Models/SessionGraphicsItem.h" class IInterferenceFunction; -class BA_CORE_API_ InterferenceFunctionItem : public SessionGraphicsItem -{ +class BA_CORE_API_ InterferenceFunctionItem : public SessionGraphicsItem { public: static const QString P_POSITION_VARIANCE; explicit InterferenceFunctionItem(const QString& modelType); @@ -30,8 +29,7 @@ protected: void setPositionVariance(IInterferenceFunction* p_iff) const; }; -class BA_CORE_API_ InterferenceFunction1DLatticeItem : public InterferenceFunctionItem -{ +class BA_CORE_API_ InterferenceFunction1DLatticeItem : public InterferenceFunctionItem { public: static const QString P_LENGTH; static const QString P_ROTATION_ANGLE; @@ -40,8 +38,7 @@ public: std::unique_ptr<IInterferenceFunction> createInterferenceFunction() const; }; -class BA_CORE_API_ InterferenceFunction2DLatticeItem : public InterferenceFunctionItem -{ +class BA_CORE_API_ InterferenceFunction2DLatticeItem : public InterferenceFunctionItem { public: static const QString P_LATTICE_TYPE; static const QString P_DECAY_FUNCTION; @@ -53,8 +50,7 @@ private: void update_rotation_availability(); }; -class BA_CORE_API_ InterferenceFunction2DParaCrystalItem : public InterferenceFunctionItem -{ +class BA_CORE_API_ InterferenceFunction2DParaCrystalItem : public InterferenceFunctionItem { public: static const QString P_DAMPING_LENGTH; static const QString P_DOMAIN_SIZE1; @@ -70,8 +66,7 @@ private: void update_distribution_displaynames(); }; -class BA_CORE_API_ InterferenceFunctionFinite2DLatticeItem : public InterferenceFunctionItem -{ +class BA_CORE_API_ InterferenceFunctionFinite2DLatticeItem : public InterferenceFunctionItem { public: static const QString P_XI_INTEGRATION; static const QString P_DOMAIN_SIZE_1; @@ -83,8 +78,7 @@ private: void update_rotation_availability(); }; -class BA_CORE_API_ InterferenceFunctionHardDiskItem : public InterferenceFunctionItem -{ +class BA_CORE_API_ InterferenceFunctionHardDiskItem : public InterferenceFunctionItem { public: static const QString P_RADIUS; static const QString P_DENSITY; @@ -92,8 +86,7 @@ public: std::unique_ptr<IInterferenceFunction> createInterferenceFunction() const; }; -class BA_CORE_API_ InterferenceFunctionRadialParaCrystalItem : public InterferenceFunctionItem -{ +class BA_CORE_API_ InterferenceFunctionRadialParaCrystalItem : public InterferenceFunctionItem { public: static const QString P_PEAK_DISTANCE; static const QString P_DAMPING_LENGTH; diff --git a/GUI/coregui/Models/ItemCatalog.cpp b/GUI/coregui/Models/ItemCatalog.cpp index af0658148cc49497428488e6fae4903ffb5c355f..603146535ef3d0e7d99235ea83bba3033353985c 100644 --- a/GUI/coregui/Models/ItemCatalog.cpp +++ b/GUI/coregui/Models/ItemCatalog.cpp @@ -62,8 +62,7 @@ #include "GUI/coregui/Models/VectorItem.h" #include "GUI/coregui/utils/GUIHelpers.h" -ItemCatalog::ItemCatalog() -{ +ItemCatalog::ItemCatalog() { add("MultiLayer", create_new<MultiLayerItem>); add("Layer", create_new<LayerItem>); add("ParticleLayout", create_new<ParticleLayoutItem>); @@ -240,8 +239,7 @@ ItemCatalog::ItemCatalog() add("DepthProbeInstrument", create_new<DepthProbeInstrumentItem>); } -std::unique_ptr<SessionItem> ItemCatalog::createItemPtr(const QString& modelType) const -{ +std::unique_ptr<SessionItem> ItemCatalog::createItemPtr(const QString& modelType) const { if (!m_data.contains(modelType)) throw GUIHelpers::Error("ItemFactory::createItem() -> Error: Model name does not exist: " + modelType); @@ -249,8 +247,7 @@ std::unique_ptr<SessionItem> ItemCatalog::createItemPtr(const QString& modelType return m_data.createItemPtr(modelType); } -QStringList ItemCatalog::validTopItemTypes() -{ +QStringList ItemCatalog::validTopItemTypes() { return {"MultiLayer", "Layer", "ParticleLayout", @@ -268,7 +265,6 @@ QStringList ItemCatalog::validTopItemTypes() "InterferenceRadialParaCrystal"}; } -void ItemCatalog::add(const QString& modelType, std::function<SessionItem*()> f) -{ +void ItemCatalog::add(const QString& modelType, std::function<SessionItem*()> f) { m_data.registerItem(modelType, f); } diff --git a/GUI/coregui/Models/ItemCatalog.h b/GUI/coregui/Models/ItemCatalog.h index 5f0065b1612fc8bf1d4b5852d84ea2b64313a785..ff8935c9c94b5a2519640ac217cfc9b9604423d4 100644 --- a/GUI/coregui/Models/ItemCatalog.h +++ b/GUI/coregui/Models/ItemCatalog.h @@ -23,8 +23,7 @@ class SessionItem; //! Catalog of SessionItem%s. A single instance is created and used in ItemFactory.cpp. -class ItemCatalog -{ +class ItemCatalog { public: ItemCatalog(); diff --git a/GUI/coregui/Models/ItemFactory.cpp b/GUI/coregui/Models/ItemFactory.cpp index 59377ef8181a510a75a576a8a7f7673e8bc7a09d..00e32bb7d3d096798b445552f2d23b24dd72f223 100644 --- a/GUI/coregui/Models/ItemFactory.cpp +++ b/GUI/coregui/Models/ItemFactory.cpp @@ -16,20 +16,17 @@ #include "GUI/coregui/Models/ItemCatalog.h" #include "GUI/coregui/Models/SessionItem.h" -namespace -{ +namespace { //! Returns the single instance of ItemCatalog. -const ItemCatalog& catalog() -{ +const ItemCatalog& catalog() { static ItemCatalog item_catalog; return item_catalog; } } // namespace -SessionItem* ItemFactory::CreateItem(const QString& model_name, SessionItem* parent) -{ +SessionItem* ItemFactory::CreateItem(const QString& model_name, SessionItem* parent) { SessionItem* result = catalog().createItemPtr(model_name).release(); if (parent) parent->insertItem(-1, result); @@ -37,12 +34,10 @@ SessionItem* ItemFactory::CreateItem(const QString& model_name, SessionItem* par return result; } -SessionItem* ItemFactory::CreateEmptyItem() -{ +SessionItem* ItemFactory::CreateEmptyItem() { return new SessionItem("ROOT_ITEM"); } -QStringList ItemFactory::ValidTopItemTypes() -{ +QStringList ItemFactory::ValidTopItemTypes() { return catalog().validTopItemTypes(); } diff --git a/GUI/coregui/Models/ItemFactory.h b/GUI/coregui/Models/ItemFactory.h index c8d972d9fd861e6fb5f7d252e70cba0a4ef665c1..6decbc92ebb68eacf464d22a074790cab760b346 100644 --- a/GUI/coregui/Models/ItemFactory.h +++ b/GUI/coregui/Models/ItemFactory.h @@ -19,8 +19,7 @@ class SessionItem; -namespace ItemFactory -{ +namespace ItemFactory { //! create SessionItem of specific type and parent SessionItem* CreateItem(const QString& model_name, SessionItem* parent = nullptr); diff --git a/GUI/coregui/Models/ItemFileNameUtils.cpp b/GUI/coregui/Models/ItemFileNameUtils.cpp index de9c1396835a1633e6e8a50b6ee4adfc8ec2a7dd..8326b2e02ad47cd8e7ddcd1af152beac89e0fd9a 100644 --- a/GUI/coregui/Models/ItemFileNameUtils.cpp +++ b/GUI/coregui/Models/ItemFileNameUtils.cpp @@ -18,8 +18,7 @@ #include "GUI/coregui/Models/RealDataItem.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { const QString jobdata_file_prefix = "jobdata"; const QString refdata_file_prefix = "refdata"; const QString realdata_file_prefix = "realdata"; @@ -32,45 +31,38 @@ QString intensityDataFileName(const QString& itemName, const QString& prefix); //! Constructs the name of the file with simulated intensities. -QString ItemFileNameUtils::jobResultsFileName(const JobItem& jobItem) -{ +QString ItemFileNameUtils::jobResultsFileName(const JobItem& jobItem) { return intensityDataFileName(jobItem.itemName(), jobdata_file_prefix); } //! Constructs the name of the file with reference data. -QString ItemFileNameUtils::jobReferenceFileName(const JobItem& jobItem) -{ +QString ItemFileNameUtils::jobReferenceFileName(const JobItem& jobItem) { return intensityDataFileName(jobItem.itemName(), refdata_file_prefix); } -QString ItemFileNameUtils::jobNativeDataFileName(const JobItem& jobItem) -{ +QString ItemFileNameUtils::jobNativeDataFileName(const JobItem& jobItem) { return intensityDataFileName(jobItem.getIdentifier(), nativedata_file_prefix); } //! Constructs the name of the intensity file belonging to real data item. -QString ItemFileNameUtils::realDataFileName(const RealDataItem& realDataItem) -{ +QString ItemFileNameUtils::realDataFileName(const RealDataItem& realDataItem) { return intensityDataFileName(realDataItem.itemName(), realdata_file_prefix); } -QString ItemFileNameUtils::nativeDataFileName(const RealDataItem& realDataItem) -{ +QString ItemFileNameUtils::nativeDataFileName(const RealDataItem& realDataItem) { return intensityDataFileName(realDataItem.itemName(), nativedata_file_prefix); } -QString ItemFileNameUtils::instrumentDataFileName(const InstrumentItem& instrumentItem) -{ +QString ItemFileNameUtils::instrumentDataFileName(const InstrumentItem& instrumentItem) { auto instrument_id = instrumentItem.getItemValue(InstrumentItem::P_IDENTIFIER).toString(); return intensityDataFileName(instrument_id, instrument_file_prefix); } //! Returns list of fileName filters related to nonXML data stored by JobModel and RealDataModel. -QStringList ItemFileNameUtils::nonXMLFileNameFilters() -{ +QStringList ItemFileNameUtils::nonXMLFileNameFilters() { QStringList result = QStringList() << QString(jobdata_file_prefix + "_*.int.gz") << QString(refdata_file_prefix + "_*.int.gz") << QString(realdata_file_prefix + "_*.int.gz") @@ -80,10 +72,8 @@ QStringList ItemFileNameUtils::nonXMLFileNameFilters() return result; } -namespace -{ -QString intensityDataFileName(const QString& itemName, const QString& prefix) -{ +namespace { +QString intensityDataFileName(const QString& itemName, const QString& prefix) { QString bodyName = GUIHelpers::getValidFileName(itemName); return QString("%1_%2_0.int.gz").arg(prefix).arg(bodyName); } diff --git a/GUI/coregui/Models/ItemFileNameUtils.h b/GUI/coregui/Models/ItemFileNameUtils.h index a698f80fd2c78ed3d6810230d4748ffeb56ee359..0440adda359cad042a934c3286051f466987ad69 100644 --- a/GUI/coregui/Models/ItemFileNameUtils.h +++ b/GUI/coregui/Models/ItemFileNameUtils.h @@ -23,8 +23,7 @@ class RealDataItem; //! Contains set of convenience methods for JobItem and its children. -namespace ItemFileNameUtils -{ +namespace ItemFileNameUtils { QString jobResultsFileName(const JobItem& jobItem); diff --git a/GUI/coregui/Models/JobItem.cpp b/GUI/coregui/Models/JobItem.cpp index a7b756fccc777abde093b46f5df822a4486b411a..bc75abbc8b1bd8b89c685a630cdf8923c775a53d 100644 --- a/GUI/coregui/Models/JobItem.cpp +++ b/GUI/coregui/Models/JobItem.cpp @@ -49,8 +49,7 @@ const QString JobItem::T_PARAMETER_TREE = "Parameter tree tag"; const QString JobItem::T_SIMULATION_OPTIONS = "ISimulation options tag"; const QString JobItem::T_FIT_SUITE = "Fit suite tag"; -JobItem::JobItem() : SessionItem("JobItem") -{ +JobItem::JobItem() : SessionItem("JobItem") { setItemName("JobItem"); addProperty(P_IDENTIFIER, QString())->setVisible(false); addProperty(P_SAMPLE_NAME, QString())->setEditable(false); @@ -100,33 +99,27 @@ JobItem::JobItem() : SessionItem("JobItem") }); } -QString JobItem::getIdentifier() const -{ +QString JobItem::getIdentifier() const { return getItemValue(P_IDENTIFIER).toString(); } -void JobItem::setIdentifier(const QString& identifier) -{ +void JobItem::setIdentifier(const QString& identifier) { setItemValue(JobItem::P_IDENTIFIER, identifier); } -IntensityDataItem* JobItem::intensityDataItem() -{ +IntensityDataItem* JobItem::intensityDataItem() { return dynamic_cast<IntensityDataItem*>(getItem(T_OUTPUT)); } -DataItem* JobItem::dataItem() -{ +DataItem* JobItem::dataItem() { return dynamic_cast<DataItem*>(getItem(T_OUTPUT)); } -QString JobItem::getStatus() const -{ +QString JobItem::getStatus() const { return getItemValue(P_STATUS).toString(); } -void JobItem::setStatus(const QString& status) -{ +void JobItem::setStatus(const QString& status) { setItemValue(P_STATUS, status); if (status == "Failed") { if (DataItem* intensityItem = dataItem()) { @@ -137,144 +130,118 @@ void JobItem::setStatus(const QString& status) } } -bool JobItem::isIdle() const -{ +bool JobItem::isIdle() const { return getStatus() == "Idle"; } -bool JobItem::isRunning() const -{ +bool JobItem::isRunning() const { return getStatus() == "Running"; } -bool JobItem::isCompleted() const -{ +bool JobItem::isCompleted() const { return getStatus() == "Completed"; } -bool JobItem::isCanceled() const -{ +bool JobItem::isCanceled() const { return getStatus() == "Canceled"; } -bool JobItem::isFailed() const -{ +bool JobItem::isFailed() const { return getStatus() == "Failed"; } -bool JobItem::isValidForFitting() -{ +bool JobItem::isValidForFitting() { return isTag(T_REALDATA) && getItem(T_REALDATA); } -void JobItem::setBeginTime(const QString& begin_time) -{ +void JobItem::setBeginTime(const QString& begin_time) { setItemValue(P_BEGIN_TIME, begin_time); } -void JobItem::setEndTime(const QString& end_time) -{ +void JobItem::setEndTime(const QString& end_time) { setItemValue(P_END_TIME, end_time); } // Sets duration (msec -> "sec.msec") -void JobItem::setDuration(int duration) -{ +void JobItem::setDuration(int duration) { QString str; if (duration != 0) str = QString("%7.3f").arg(duration / 1000.); setItemValue(P_DURATION, str.simplified()); } -QString JobItem::getComments() const -{ +QString JobItem::getComments() const { return getItemValue(P_COMMENTS).toString(); } -void JobItem::setComments(const QString& comments) -{ +void JobItem::setComments(const QString& comments) { setItemValue(P_COMMENTS, comments); } -int JobItem::getProgress() const -{ +int JobItem::getProgress() const { return getItemValue(P_PROGRESS).toInt(); } -void JobItem::setProgress(int progress) -{ +void JobItem::setProgress(int progress) { setItemValue(P_PROGRESS, progress); } -bool JobItem::runImmediately() const -{ +bool JobItem::runImmediately() const { return simulationOptionsItem()->runImmediately(); } -bool JobItem::runInBackground() const -{ +bool JobItem::runInBackground() const { return simulationOptionsItem()->runInBackground(); } -MultiLayerItem* JobItem::multiLayerItem() -{ +MultiLayerItem* JobItem::multiLayerItem() { return dynamic_cast<MultiLayerItem*>(getItem(T_SAMPLE)); } -InstrumentItem* JobItem::instrumentItem() -{ +InstrumentItem* JobItem::instrumentItem() { return dynamic_cast<InstrumentItem*>(getItem(T_INSTRUMENT)); } -void JobItem::setResults(const ISimulation* simulation) -{ +void JobItem::setResults(const ISimulation* simulation) { JobItemUtils::setResults(dataItem(), simulation); updateIntensityDataFileName(); } -FitSuiteItem* JobItem::fitSuiteItem() -{ +FitSuiteItem* JobItem::fitSuiteItem() { return dynamic_cast<FitSuiteItem*>(getItem(JobItem::T_FIT_SUITE)); } -ParameterContainerItem* JobItem::parameterContainerItem() -{ +ParameterContainerItem* JobItem::parameterContainerItem() { return const_cast<ParameterContainerItem*>( static_cast<const JobItem*>(this)->parameterContainerItem()); } -const ParameterContainerItem* JobItem::parameterContainerItem() const -{ +const ParameterContainerItem* JobItem::parameterContainerItem() const { return dynamic_cast<ParameterContainerItem*>(getItem(JobItem::T_PARAMETER_TREE)); } -FitParameterContainerItem* JobItem::fitParameterContainerItem() -{ +FitParameterContainerItem* JobItem::fitParameterContainerItem() { if (FitSuiteItem* item = fitSuiteItem()) return item->fitParameterContainerItem(); return nullptr; } -RealDataItem* JobItem::realDataItem() -{ +RealDataItem* JobItem::realDataItem() { return dynamic_cast<RealDataItem*>(getItem(JobItem::T_REALDATA)); } -const MaterialItemContainer* JobItem::materialContainerItem() const -{ +const MaterialItemContainer* JobItem::materialContainerItem() const { return static_cast<MaterialItemContainer*>(getItem(JobItem::T_MATERIAL_CONTAINER)); } -Data1DViewItem* JobItem::dataItemView() -{ +Data1DViewItem* JobItem::dataItemView() { return dynamic_cast<Data1DViewItem*>(getItem(JobItem::T_DATAVIEW)); } //! Updates the name of file to store intensity data. -void JobItem::updateIntensityDataFileName() -{ +void JobItem::updateIntensityDataFileName() { if (DataItem* item = dataItem()) item->setItemValue(DataItem::P_FILE_NAME, ItemFileNameUtils::jobResultsFileName(*this)); @@ -289,13 +256,11 @@ void JobItem::updateIntensityDataFileName() } } -SimulationOptionsItem* JobItem::simulationOptionsItem() -{ +SimulationOptionsItem* JobItem::simulationOptionsItem() { return const_cast<SimulationOptionsItem*>( static_cast<const JobItem*>(this)->simulationOptionsItem()); } -const SimulationOptionsItem* JobItem::simulationOptionsItem() const -{ +const SimulationOptionsItem* JobItem::simulationOptionsItem() const { return &item<const SimulationOptionsItem>(T_SIMULATION_OPTIONS); } diff --git a/GUI/coregui/Models/JobItem.h b/GUI/coregui/Models/JobItem.h index 052a05a2da76718f7df80fff48b3f8aef2fa133b..dc23270e9fcab284e82d0821facaa46a56fd8e42 100644 --- a/GUI/coregui/Models/JobItem.h +++ b/GUI/coregui/Models/JobItem.h @@ -30,8 +30,7 @@ class RealDataItem; class ISimulation; class SimulationOptionsItem; -class BA_CORE_API_ JobItem : public SessionItem -{ +class BA_CORE_API_ JobItem : public SessionItem { public: static const QString P_IDENTIFIER; diff --git a/GUI/coregui/Models/JobItemUtils.cpp b/GUI/coregui/Models/JobItemUtils.cpp index c73c99e8c522d9b1bf2486d9c506111ac53aa5db..502fc3d8559946080f466ed7ce5ac537a1843365 100644 --- a/GUI/coregui/Models/JobItemUtils.cpp +++ b/GUI/coregui/Models/JobItemUtils.cpp @@ -24,8 +24,7 @@ #include <QDebug> #include <QFileInfo> -namespace -{ +namespace { const std::map<QString, Axes::Units> units_from_names{{"nbins", Axes::Units::NBINS}, {"Radians", Axes::Units::RADIANS}, {"Degrees", Axes::Units::DEGREES}, @@ -45,8 +44,7 @@ void updateAxesTitle(DataItem* intensityItem, const IUnitConverter& converter, A //! Updates axes of OutputData in IntensityData item to correspond with ::P_AXES_UNITS selection. //! InstrumentItem is used to get domain's detector map for given units. -void JobItemUtils::updateDataAxes(DataItem* intensityItem, const InstrumentItem* instrumentItem) -{ +void JobItemUtils::updateDataAxes(DataItem* intensityItem, const InstrumentItem* instrumentItem) { ASSERT(intensityItem); if (!instrumentItem) { @@ -72,24 +70,21 @@ void JobItemUtils::updateDataAxes(DataItem* intensityItem, const InstrumentItem* //! Correspondance of domain detector axes types to their gui counterpart. -QString JobItemUtils::nameFromAxesUnits(Axes::Units units) -{ +QString JobItemUtils::nameFromAxesUnits(Axes::Units units) { return names_from_units.find(units) != names_from_units.end() ? names_from_units.at(units) : QString(); } //! Correspondance of GUI axes units names to their domain counterpart. -Axes::Units JobItemUtils::axesUnitsFromName(const QString& name) -{ +Axes::Units JobItemUtils::axesUnitsFromName(const QString& name) { return units_from_names.at(name); } //! Sets axes units suitable for given instrument. void JobItemUtils::setIntensityItemAxesUnits(DataItem* intensityItem, - const InstrumentItem* instrumentItem) -{ + const InstrumentItem* instrumentItem) { const auto converter = DomainObjectBuilder::createUnitConverter(instrumentItem); if (!converter) return; @@ -97,15 +92,13 @@ void JobItemUtils::setIntensityItemAxesUnits(DataItem* intensityItem, } void JobItemUtils::setIntensityItemAxesUnits(DataItem* intensityItem, - const IUnitConverter& converter) -{ + const IUnitConverter& converter) { ComboProperty combo = availableUnits(converter); intensityItem->setItemValue(DataItem::P_AXES_UNITS, combo.variant()); } void JobItemUtils::createDefaultDetectorMap(DataItem* intensityItem, - const InstrumentItem* instrumentItem) -{ + const InstrumentItem* instrumentItem) { const auto converter = DomainObjectBuilder::createUnitConverter(instrumentItem); auto output_data = UnitConverterUtils::createOutputData(*converter, converter->defaultUnits()); intensityItem->setOutputData(output_data.release()); @@ -113,8 +106,7 @@ void JobItemUtils::createDefaultDetectorMap(DataItem* intensityItem, updateAxesTitle(intensityItem, *converter, converter->defaultUnits()); } -void JobItemUtils::setResults(DataItem* intensityItem, const ISimulation* simulation) -{ +void JobItemUtils::setResults(DataItem* intensityItem, const ISimulation* simulation) { const auto sim_result = simulation->result(); if (intensityItem->getOutputData() == nullptr) { const auto& converter = sim_result.converter(); @@ -126,8 +118,7 @@ void JobItemUtils::setResults(DataItem* intensityItem, const ISimulation* simula intensityItem->setOutputData(data.release()); } -ComboProperty JobItemUtils::availableUnits(const IUnitConverter& converter) -{ +ComboProperty JobItemUtils::availableUnits(const IUnitConverter& converter) { ComboProperty result; for (auto units : converter.availableUnits()) { auto unit_name = nameFromAxesUnits(units); @@ -139,10 +130,8 @@ ComboProperty JobItemUtils::availableUnits(const IUnitConverter& converter) return result; } -namespace -{ -void updateAxesTitle(DataItem* intensityItem, const IUnitConverter& converter, Axes::Units units) -{ +namespace { +void updateAxesTitle(DataItem* intensityItem, const IUnitConverter& converter, Axes::Units units) { intensityItem->setXaxisTitle(QString::fromStdString(converter.axisName(0, units))); if (converter.dimension() > 1) intensityItem->setYaxisTitle(QString::fromStdString(converter.axisName(1, units))); diff --git a/GUI/coregui/Models/JobItemUtils.h b/GUI/coregui/Models/JobItemUtils.h index 0b4557f9a286f843417e14f65aeeacc601112ec2..fff365a6dc1d06e8e97d6134abb9fa0b921f20cc 100644 --- a/GUI/coregui/Models/JobItemUtils.h +++ b/GUI/coregui/Models/JobItemUtils.h @@ -27,8 +27,7 @@ class ISimulation; //! Contains set of convenience methods to set data to the IntensityDataItem from domain simulation. //! Used to modify OutputData's axes units as requested by IntensityDataItem. -namespace JobItemUtils -{ +namespace JobItemUtils { //! updates axes of OutputData in IntensityData item void updateDataAxes(DataItem* intensityItem, const InstrumentItem* instrumentItem); diff --git a/GUI/coregui/Models/JobModel.cpp b/GUI/coregui/Models/JobModel.cpp index 6d4ff1513340f028ba89447eb9291fef07a6b54c..4528b73f0d801913e8ecd89a58f12ca4788ca750 100644 --- a/GUI/coregui/Models/JobModel.cpp +++ b/GUI/coregui/Models/JobModel.cpp @@ -30,35 +30,30 @@ #include "GUI/coregui/utils/GUIHelpers.h" JobModel::JobModel(QObject* parent) - : SessionModel(SessionXML::JobModelTag, parent), m_queue_data(nullptr) -{ + : SessionModel(SessionXML::JobModelTag, parent), m_queue_data(nullptr) { m_queue_data = new JobQueueData(this); connect(m_queue_data, SIGNAL(focusRequest(JobItem*)), this, SIGNAL(focusRequest(JobItem*))); connect(m_queue_data, SIGNAL(globalProgress(int)), this, SIGNAL(globalProgress(int))); setObjectName(SessionXML::JobModelTag); } -JobModel::~JobModel() -{ +JobModel::~JobModel() { delete m_queue_data; } -const JobItem* JobModel::getJobItemForIndex(const QModelIndex& index) const -{ +const JobItem* JobModel::getJobItemForIndex(const QModelIndex& index) const { const JobItem* result = dynamic_cast<const JobItem*>(itemForIndex(index)); ASSERT(result); return result; } -JobItem* JobModel::getJobItemForIndex(const QModelIndex& index) -{ +JobItem* JobModel::getJobItemForIndex(const QModelIndex& index) { JobItem* result = dynamic_cast<JobItem*>(itemForIndex(index)); ASSERT(result); return result; } -JobItem* JobModel::getJobItemForIdentifier(const QString& identifier) -{ +JobItem* JobModel::getJobItemForIdentifier(const QString& identifier) { QModelIndex parentIndex; for (int i_row = 0; i_row < rowCount(parentIndex); ++i_row) { QModelIndex itemIndex = index(i_row, 0, parentIndex); @@ -72,8 +67,7 @@ JobItem* JobModel::getJobItemForIdentifier(const QString& identifier) //! Main method to add a job JobItem* JobModel::addJob(const MultiLayerItem* multiLayerItem, const InstrumentItem* instrumentItem, const RealDataItem* realDataItem, - const SimulationOptionsItem* optionItem) -{ + const SimulationOptionsItem* optionItem) { ASSERT(multiLayerItem); ASSERT(instrumentItem); ASSERT(optionItem); @@ -103,13 +97,11 @@ JobItem* JobModel::addJob(const MultiLayerItem* multiLayerItem, } //! restore instrument and sample model from backup for given JobItem -void JobModel::restore(JobItem* jobItem) -{ +void JobModel::restore(JobItem* jobItem) { restoreItem(jobItem->getItem(JobItem::T_PARAMETER_TREE)); } -bool JobModel::hasUnfinishedJobs() -{ +bool JobModel::hasUnfinishedJobs() { bool result = m_queue_data->hasUnfinishedJobs(); for (auto jobItem : topItems<JobItem>()) { if (jobItem->getStatus() == "Fitting") @@ -119,16 +111,14 @@ bool JobModel::hasUnfinishedJobs() return result; } -void JobModel::clear() -{ +void JobModel::clear() { for (auto item : topItems()) removeJob(item->index()); SessionModel::clear(); } -QVector<SessionItem*> JobModel::nonXMLData() const -{ +QVector<SessionItem*> JobModel::nonXMLData() const { QVector<SessionItem*> result; for (auto jobItem : topItems<JobItem>()) { @@ -155,8 +145,7 @@ QVector<SessionItem*> JobModel::nonXMLData() const //! Link instruments to real data on project load. -void JobModel::link_instruments() -{ +void JobModel::link_instruments() { for (int i = 0; i < rowCount(QModelIndex()); ++i) { JobItem* jobItem = getJobItemForIndex(index(i, 0, QModelIndex())); if (RealDataItem* refItem = jobItem->realDataItem()) @@ -164,23 +153,19 @@ void JobModel::link_instruments() } } -void JobModel::onCancelAllJobs() -{ +void JobModel::onCancelAllJobs() { m_queue_data->onCancelAllJobs(); } -void JobModel::runJob(const QModelIndex& index) -{ +void JobModel::runJob(const QModelIndex& index) { m_queue_data->runJob(getJobItemForIndex(index)); } -void JobModel::cancelJob(const QModelIndex& index) -{ +void JobModel::cancelJob(const QModelIndex& index) { m_queue_data->cancelJob(getJobItemForIndex(index)->getIdentifier()); } -void JobModel::removeJob(const QModelIndex& index) -{ +void JobModel::removeJob(const QModelIndex& index) { JobItem* jobItem = getJobItemForIndex(index); ASSERT(jobItem); m_queue_data->removeJob(jobItem->getIdentifier()); @@ -190,8 +175,7 @@ void JobModel::removeJob(const QModelIndex& index) } //! generates job name -QString JobModel::generateJobName() -{ +QString JobModel::generateJobName() { int glob_index = 0; QModelIndex parentIndex; for (int i_row = 0; i_row < rowCount(parentIndex); ++i_row) { @@ -211,8 +195,7 @@ QString JobModel::generateJobName() return QString("job") + QString::number(++glob_index); } -void JobModel::restoreItem(SessionItem* item) -{ +void JobModel::restoreItem(SessionItem* item) { if (ParameterItem* parameter = dynamic_cast<ParameterItem*>(item)) parameter->restoreFromBackup(); diff --git a/GUI/coregui/Models/JobModel.h b/GUI/coregui/Models/JobModel.h index 31423093c343b29ce1b394d53693e09efe182c3c..77d0bd0a4cc78b71bcd9cbeb66f55c77a2790f07 100644 --- a/GUI/coregui/Models/JobModel.h +++ b/GUI/coregui/Models/JobModel.h @@ -22,8 +22,7 @@ class InstrumentItem; class RealDataItem; class SimulationOptionsItem; -class JobModel : public SessionModel -{ +class JobModel : public SessionModel { Q_OBJECT public: diff --git a/GUI/coregui/Models/JobModelFunctions.cpp b/GUI/coregui/Models/JobModelFunctions.cpp index ef6cdf1521706192e7bb82b7a082a81499e861bf..079b42f5edaf6815b55757da42009c91d0ad6384 100644 --- a/GUI/coregui/Models/JobModelFunctions.cpp +++ b/GUI/coregui/Models/JobModelFunctions.cpp @@ -37,8 +37,7 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include <map> -namespace -{ +namespace { //! Links RealDataItem to the JobItem's instrument. // (re-)Linking is necessary because of following reason // 1) Copying of RealDataItem from RealDataModel on board of JobItem requires relink to the copied @@ -58,8 +57,7 @@ void createFitContainers(JobItem* jobItem); PointwiseAxisItem* getPointwiseAxisItem(const SpecularInstrumentItem* instrument); } // namespace -void JobModelFunctions::initDataView(JobItem* job_item) -{ +void JobModelFunctions::initDataView(JobItem* job_item) { ASSERT(job_item && job_item->isValidForFitting()); ASSERT(job_item->instrumentItem() && job_item->instrumentItem()->modelType() == "SpecularInstrument"); @@ -84,8 +82,7 @@ void JobModelFunctions::initDataView(JobItem* job_item) JobItemUtils::availableUnits(*converter).variant()); } -void JobModelFunctions::setupJobItemSampleData(JobItem* jobItem, const MultiLayerItem* sampleItem) -{ +void JobModelFunctions::setupJobItemSampleData(JobItem* jobItem, const MultiLayerItem* sampleItem) { auto model = jobItem->model(); MultiLayerItem* multilayer = static_cast<MultiLayerItem*>(model->copyItem(sampleItem, jobItem, JobItem::T_SAMPLE)); @@ -111,8 +108,7 @@ void JobModelFunctions::setupJobItemSampleData(JobItem* jobItem, const MultiLaye } } -void JobModelFunctions::setupJobItemInstrument(JobItem* jobItem, const InstrumentItem* from) -{ +void JobModelFunctions::setupJobItemInstrument(JobItem* jobItem, const InstrumentItem* from) { auto model = jobItem->model(); SessionItem* to = model->copyItem(from, jobItem, JobItem::T_INSTRUMENT); to->setItemName(from->modelType()); @@ -139,8 +135,7 @@ void JobModelFunctions::setupJobItemInstrument(JobItem* jobItem, const Instrumen //! Setup items intended for storing results of the job. -void JobModelFunctions::setupJobItemOutput(JobItem* jobItem) -{ +void JobModelFunctions::setupJobItemOutput(JobItem* jobItem) { auto model = jobItem->model(); auto instrumentType = jobItem->instrumentItem()->modelType(); @@ -159,8 +154,7 @@ void JobModelFunctions::setupJobItemOutput(JobItem* jobItem) //! Setups JobItem for fit. -void JobModelFunctions::setupJobItemForFit(JobItem* jobItem, const RealDataItem* realDataItem) -{ +void JobModelFunctions::setupJobItemForFit(JobItem* jobItem, const RealDataItem* realDataItem) { if (!jobItem->instrumentItem()) throw GUIHelpers::Error("JobModelFunctions::processInstrumentLink() -> Error. " "No instrument."); @@ -178,8 +172,7 @@ void JobModelFunctions::setupJobItemForFit(JobItem* jobItem, const RealDataItem* createFitContainers(jobItem); } -void JobModelFunctions::muteMagnetizationData(JobItem* jobItem) -{ +void JobModelFunctions::muteMagnetizationData(JobItem* jobItem) { auto container = static_cast<MaterialItemContainer*>(jobItem->getItem(JobItem::T_MATERIAL_CONTAINER)); for (auto item : container->getItems(MaterialItemContainer::T_MATERIALS)) @@ -189,8 +182,7 @@ void JobModelFunctions::muteMagnetizationData(JobItem* jobItem) sample->getItem(MultiLayerItem::P_EXTERNAL_FIELD)->setVisible(false); } -void JobModelFunctions::copyRealDataItem(JobItem* jobItem, const RealDataItem* realDataItem) -{ +void JobModelFunctions::copyRealDataItem(JobItem* jobItem, const RealDataItem* realDataItem) { if (!realDataItem) return; @@ -215,17 +207,14 @@ void JobModelFunctions::copyRealDataItem(JobItem* jobItem, const RealDataItem* r DataItem::P_FILE_NAME, ItemFileNameUtils::jobNativeDataFileName(*jobItem)); } -const JobItem* JobModelFunctions::findJobItem(const SessionItem* item) -{ +const JobItem* JobModelFunctions::findJobItem(const SessionItem* item) { while (item && item->modelType() != "JobItem") item = item->parent(); return static_cast<const JobItem*>(item); } -namespace -{ -void processInstrumentLink(JobItem* jobItem) -{ +namespace { +void processInstrumentLink(JobItem* jobItem) { RealDataItem* realData = jobItem->realDataItem(); if (!realData) throw GUIHelpers::Error("JobModelFunctions::processInstrumentLink() -> Error. No data."); @@ -233,14 +222,12 @@ void processInstrumentLink(JobItem* jobItem) realData->linkToInstrument(jobItem->instrumentItem()); } -void copyMasksToInstrument(JobItem* jobItem) -{ +void copyMasksToInstrument(JobItem* jobItem) { auto mask_container = jobItem->realDataItem()->maskContainerItem(); jobItem->instrumentItem()->importMasks(mask_container); } -void cropRealData(JobItem* jobItem) -{ +void cropRealData(JobItem* jobItem) { RealDataItem* realData = jobItem->realDataItem(); // adjusting real data to the size of region of interest @@ -261,8 +248,7 @@ void cropRealData(JobItem* jobItem) intensityItem->updateDataRange(); } -void createFitContainers(JobItem* jobItem) -{ +void createFitContainers(JobItem* jobItem) { SessionModel* model = jobItem->model(); SessionItem* fitSuiteItem = jobItem->getItem(JobItem::T_FIT_SUITE); @@ -294,8 +280,7 @@ void createFitContainers(JobItem* jobItem) FitSuiteItem::T_MINIMIZER); } -PointwiseAxisItem* getPointwiseAxisItem(const SpecularInstrumentItem* instrument) -{ +PointwiseAxisItem* getPointwiseAxisItem(const SpecularInstrumentItem* instrument) { return dynamic_cast<PointwiseAxisItem*>( instrument->beamItem()->inclinationAxisGroup()->getChildOfType("PointwiseAxis")); } diff --git a/GUI/coregui/Models/JobModelFunctions.h b/GUI/coregui/Models/JobModelFunctions.h index b63bd6b60bd549247caed25754b3304f5194d81b..60d2c5b7354afbf021d429343b45dc50de9957a3 100644 --- a/GUI/coregui/Models/JobModelFunctions.h +++ b/GUI/coregui/Models/JobModelFunctions.h @@ -24,8 +24,7 @@ class SessionItem; //! Contains set of functions to extend JobModel functionality. //! Handles setup of JobItem in fitting context. -namespace JobModelFunctions -{ +namespace JobModelFunctions { //! Initializes Data1DViewItem and assigns it to the passed JobItem void initDataView(JobItem* jobItem); diff --git a/GUI/coregui/Models/JobQueueData.cpp b/GUI/coregui/Models/JobQueueData.cpp index 8ace31bdc1aa1e768a7d09e4666a632efd55ccff..abb28205c4b7ee49402834c09e4ef3bdbe7c9c9f 100644 --- a/GUI/coregui/Models/JobQueueData.cpp +++ b/GUI/coregui/Models/JobQueueData.cpp @@ -22,22 +22,17 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include <QThread> -namespace -{ - -} +namespace {} JobQueueData::JobQueueData(JobModel* jobModel) : m_jobModel(jobModel) {} -bool JobQueueData::hasUnfinishedJobs() -{ +bool JobQueueData::hasUnfinishedJobs() { return m_simulations.size(); } //! Submits job and run it in a thread. -void JobQueueData::runJob(JobItem* jobItem) -{ +void JobQueueData::runJob(JobItem* jobItem) { QString identifier = jobItem->getIdentifier(); if (getThread(identifier)) return; @@ -87,24 +82,21 @@ void JobQueueData::runJob(JobItem* jobItem) //! Cancels running job. -void JobQueueData::cancelJob(const QString& identifier) -{ +void JobQueueData::cancelJob(const QString& identifier) { if (getThread(identifier)) getWorker(identifier)->terminate(); } //! Remove job from list completely. -void JobQueueData::removeJob(const QString& identifier) -{ +void JobQueueData::removeJob(const QString& identifier) { cancelJob(identifier); clearSimulation(identifier); } //! Sets JobItem properties when the job is going to start. -void JobQueueData::onStartedJob() -{ +void JobQueueData::onStartedJob() { auto worker = qobject_cast<JobWorker*>(sender()); auto jobItem = m_jobModel->getJobItemForIdentifier(worker->identifier()); @@ -116,8 +108,7 @@ void JobQueueData::onStartedJob() //! Performs necessary actions when job is finished. -void JobQueueData::onFinishedJob() -{ +void JobQueueData::onFinishedJob() { auto worker = qobject_cast<JobWorker*>(sender()); auto jobItem = m_jobModel->getJobItemForIdentifier(worker->identifier()); @@ -136,14 +127,12 @@ void JobQueueData::onFinishedJob() emit globalProgress(100); } -void JobQueueData::onFinishedThread() -{ +void JobQueueData::onFinishedThread() { auto thread = qobject_cast<QThread*>(sender()); assignForDeletion(thread); } -void JobQueueData::onProgressUpdate() -{ +void JobQueueData::onProgressUpdate() { auto worker = qobject_cast<JobWorker*>(sender()); auto jobItem = m_jobModel->getJobItemForIdentifier(worker->identifier()); jobItem->setProgress(worker->progress()); @@ -153,8 +142,7 @@ void JobQueueData::onProgressUpdate() //! Estimates global progress from the progress of multiple running jobs and //! emmits appropriate signal. -void JobQueueData::updateGlobalProgress() -{ +void JobQueueData::updateGlobalProgress() { int global_progress(0); int nRunningJobs(0); QModelIndex parentIndex; @@ -177,16 +165,14 @@ void JobQueueData::updateGlobalProgress() //! Cancels all running jobs. -void JobQueueData::onCancelAllJobs() -{ +void JobQueueData::onCancelAllJobs() { for (const auto& key : m_threads.keys()) cancelJob(key); } //! Removes QThread from the map of known threads, assigns it for deletion. -void JobQueueData::assignForDeletion(QThread* thread) -{ +void JobQueueData::assignForDeletion(QThread* thread) { for (auto it = m_threads.begin(); it != m_threads.end(); ++it) { if (it.value() == thread) { thread->deleteLater(); @@ -200,8 +186,7 @@ void JobQueueData::assignForDeletion(QThread* thread) //! Removes JobRunner from the map of known runners, assigns it for deletion. -void JobQueueData::assignForDeletion(JobWorker* worker) -{ +void JobQueueData::assignForDeletion(JobWorker* worker) { ASSERT(worker); worker->disconnect(); for (auto it = m_workers.begin(); it != m_workers.end(); ++it) { @@ -215,8 +200,7 @@ void JobQueueData::assignForDeletion(JobWorker* worker) throw GUIHelpers::Error("JobQueueData::assignForDeletion() -> Error! Can't find the runner."); } -void JobQueueData::clearSimulation(const QString& identifier) -{ +void JobQueueData::clearSimulation(const QString& identifier) { auto simulation = getSimulation(identifier); m_simulations.remove(identifier); delete simulation; @@ -224,8 +208,7 @@ void JobQueueData::clearSimulation(const QString& identifier) //! Set all data of finished job -void JobQueueData::processFinishedJob(JobWorker* worker, JobItem* jobItem) -{ +void JobQueueData::processFinishedJob(JobWorker* worker, JobItem* jobItem) { jobItem->setEndTime(GUIHelpers::currentDateTime()); jobItem->setDuration(worker->simulationDuration()); @@ -246,24 +229,21 @@ void JobQueueData::processFinishedJob(JobWorker* worker, JobItem* jobItem) //! Returns the thread for given identifier. -QThread* JobQueueData::getThread(const QString& identifier) -{ +QThread* JobQueueData::getThread(const QString& identifier) { auto it = m_threads.find(identifier); return it != m_threads.end() ? it.value() : nullptr; } //! Returns job runner for given identifier. -JobWorker* JobQueueData::getWorker(const QString& identifier) -{ +JobWorker* JobQueueData::getWorker(const QString& identifier) { auto it = m_workers.find(identifier); return it != m_workers.end() ? it.value() : nullptr; } //! Returns the simulation (if exists) for given identifier. -ISimulation* JobQueueData::getSimulation(const QString& identifier) -{ +ISimulation* JobQueueData::getSimulation(const QString& identifier) { auto it = m_simulations.find(identifier); return it != m_simulations.end() ? it.value() : nullptr; } diff --git a/GUI/coregui/Models/JobQueueData.h b/GUI/coregui/Models/JobQueueData.h index 394264972a6e683d6dedb2f7076d6a76b707f3d2..4002d60d59e5574253a8f1dc1956a8319ea03430 100644 --- a/GUI/coregui/Models/JobQueueData.h +++ b/GUI/coregui/Models/JobQueueData.h @@ -25,8 +25,7 @@ class JobWorker; //! The JobQueueData class holds all objects/logic to run simulation in a thread. -class JobQueueData : public QObject -{ +class JobQueueData : public QObject { Q_OBJECT public: JobQueueData(JobModel* jobModel); diff --git a/GUI/coregui/Models/JobWorker.cpp b/GUI/coregui/Models/JobWorker.cpp index 89cdef430fe83b69e130ed96a6e107be2689ba63..0bfcc3551b52d4372927d2b65adafcd39b836b96 100644 --- a/GUI/coregui/Models/JobWorker.cpp +++ b/GUI/coregui/Models/JobWorker.cpp @@ -23,22 +23,17 @@ JobWorker::JobWorker(const QString& identifier, ISimulation* simulation) , m_percentage_done(0) , m_job_status("Idle") , m_terminate_request_flag(false) - , m_simulation_duration(0) -{ -} + , m_simulation_duration(0) {} -QString JobWorker::identifier() const -{ +QString JobWorker::identifier() const { return m_identifier; } -int JobWorker::progress() const -{ +int JobWorker::progress() const { return m_percentage_done; } -void JobWorker::start() -{ +void JobWorker::start() { m_terminate_request_flag = false; m_simulation_duration = 0; emit started(); @@ -78,33 +73,28 @@ void JobWorker::start() emit finished(); } -QString JobWorker::status() const -{ +QString JobWorker::status() const { return m_job_status; } -QString JobWorker::failureMessage() const -{ +QString JobWorker::failureMessage() const { return m_failure_message; } -int JobWorker::simulationDuration() const -{ +int JobWorker::simulationDuration() const { return m_simulation_duration; } //! Sets request for JobRunner to terminate underlying domain simulation. -void JobWorker::terminate() -{ +void JobWorker::terminate() { m_terminate_request_flag = true; m_job_status = "Canceled"; } //! Sets current progress. Returns true if we want to continue the simulation. -bool JobWorker::updateProgress(int percentage_done) -{ +bool JobWorker::updateProgress(int percentage_done) { if (percentage_done > m_percentage_done) { m_percentage_done = percentage_done; emit progressUpdate(); diff --git a/GUI/coregui/Models/JobWorker.h b/GUI/coregui/Models/JobWorker.h index 4b77eced9ec41599486045a3f598538474e303be..31de91bad2a0d67604a5844fb419459d1c9932af 100644 --- a/GUI/coregui/Models/JobWorker.h +++ b/GUI/coregui/Models/JobWorker.h @@ -21,8 +21,7 @@ class ISimulation; //! The JobWorker class provides running the domain simulation in a thread. -class JobWorker : public QObject -{ +class JobWorker : public QObject { Q_OBJECT public: JobWorker(const QString& identifier, ISimulation* simulation); diff --git a/GUI/coregui/Models/Lattice2DItems.cpp b/GUI/coregui/Models/Lattice2DItems.cpp index c05867915e61b1fe7ce9f5f46a6187bb67ebb0b4..548595f9f3ee8e5301355b1ff35617b35a4c9c11 100644 --- a/GUI/coregui/Models/Lattice2DItems.cpp +++ b/GUI/coregui/Models/Lattice2DItems.cpp @@ -16,8 +16,7 @@ #include "Base/Const/Units.h" #include "Sample/Lattice/Lattice2D.h" -namespace -{ +namespace { const QString axis_rotation_tooltip = "Rotation of lattice with respect to x-axis of reference frame \n" "(beam direction) in degrees"; @@ -27,8 +26,7 @@ const QString Lattice2DItem::P_LATTICE_ROTATION_ANGLE = QString::fromStdString(" Lattice2DItem::Lattice2DItem(const QString& modelType) : SessionItem(modelType) {} -double Lattice2DItem::unitCellArea() const -{ +double Lattice2DItem::unitCellArea() const { return createLattice()->unitCellArea(); } @@ -36,8 +34,7 @@ const QString BasicLattice2DItem::P_LATTICE_LENGTH1 = QString::fromStdString("La const QString BasicLattice2DItem::P_LATTICE_LENGTH2 = QString::fromStdString("LatticeLength2"); const QString BasicLattice2DItem::P_LATTICE_ANGLE = QString::fromStdString("Alpha"); -BasicLattice2DItem::BasicLattice2DItem() : Lattice2DItem("BasicLattice2D") -{ +BasicLattice2DItem::BasicLattice2DItem() : Lattice2DItem("BasicLattice2D") { setToolTip("Two dimensional lattice"); addProperty(P_LATTICE_LENGTH1, 20.0) ->setToolTip("Length of first lattice vector in nanometers"); @@ -47,8 +44,7 @@ BasicLattice2DItem::BasicLattice2DItem() : Lattice2DItem("BasicLattice2D") addProperty(Lattice2DItem::P_LATTICE_ROTATION_ANGLE, 0.0)->setToolTip(axis_rotation_tooltip); } -std::unique_ptr<Lattice2D> BasicLattice2DItem::createLattice() const -{ +std::unique_ptr<Lattice2D> BasicLattice2DItem::createLattice() const { return std::make_unique<BasicLattice2D>( getItemValue(P_LATTICE_LENGTH1).toDouble(), getItemValue(P_LATTICE_LENGTH2).toDouble(), Units::deg2rad(getItemValue(P_LATTICE_ANGLE).toDouble()), @@ -59,15 +55,13 @@ std::unique_ptr<Lattice2D> BasicLattice2DItem::createLattice() const const QString SquareLattice2DItem::P_LATTICE_LENGTH = QString::fromStdString("LatticeLength"); -SquareLattice2DItem::SquareLattice2DItem() : Lattice2DItem("SquareLattice2D") -{ +SquareLattice2DItem::SquareLattice2DItem() : Lattice2DItem("SquareLattice2D") { addProperty(P_LATTICE_LENGTH, 20.0) ->setToolTip("Length of first and second lattice vectors in nanometers"); addProperty(Lattice2DItem::P_LATTICE_ROTATION_ANGLE, 0.0)->setToolTip(axis_rotation_tooltip); } -std::unique_ptr<Lattice2D> SquareLattice2DItem::createLattice() const -{ +std::unique_ptr<Lattice2D> SquareLattice2DItem::createLattice() const { return std::make_unique<SquareLattice2D>( getItemValue(P_LATTICE_LENGTH).toDouble(), Units::deg2rad(getItemValue(Lattice2DItem::P_LATTICE_ROTATION_ANGLE).toDouble())); @@ -77,15 +71,13 @@ std::unique_ptr<Lattice2D> SquareLattice2DItem::createLattice() const const QString HexagonalLattice2DItem::P_LATTICE_LENGTH = QString::fromStdString("LatticeLength"); -HexagonalLattice2DItem::HexagonalLattice2DItem() : Lattice2DItem("HexagonalLattice2D") -{ +HexagonalLattice2DItem::HexagonalLattice2DItem() : Lattice2DItem("HexagonalLattice2D") { addProperty(P_LATTICE_LENGTH, 20.0) ->setToolTip("Length of first and second lattice vectors in nanometers"); addProperty(Lattice2DItem::P_LATTICE_ROTATION_ANGLE, 0.0)->setToolTip(axis_rotation_tooltip); } -std::unique_ptr<Lattice2D> HexagonalLattice2DItem::createLattice() const -{ +std::unique_ptr<Lattice2D> HexagonalLattice2DItem::createLattice() const { return std::make_unique<HexagonalLattice2D>( getItemValue(P_LATTICE_LENGTH).toDouble(), Units::deg2rad(getItemValue(Lattice2DItem::P_LATTICE_ROTATION_ANGLE).toDouble())); diff --git a/GUI/coregui/Models/Lattice2DItems.h b/GUI/coregui/Models/Lattice2DItems.h index e2e434df464a77494dcea9092bea2e8bfb2e166a..c0053379703f19ef35ecb8f17a8aac5f26de1747 100644 --- a/GUI/coregui/Models/Lattice2DItems.h +++ b/GUI/coregui/Models/Lattice2DItems.h @@ -18,8 +18,7 @@ #include "GUI/coregui/Models/SessionItem.h" class Lattice2D; -class BA_CORE_API_ Lattice2DItem : public SessionItem -{ +class BA_CORE_API_ Lattice2DItem : public SessionItem { public: static const QString P_LATTICE_ROTATION_ANGLE; explicit Lattice2DItem(const QString& modelType); @@ -27,8 +26,7 @@ public: double unitCellArea() const; }; -class BA_CORE_API_ BasicLattice2DItem : public Lattice2DItem -{ +class BA_CORE_API_ BasicLattice2DItem : public Lattice2DItem { public: static const QString P_LATTICE_LENGTH1; static const QString P_LATTICE_LENGTH2; @@ -37,16 +35,14 @@ public: std::unique_ptr<Lattice2D> createLattice() const; }; -class BA_CORE_API_ SquareLattice2DItem : public Lattice2DItem -{ +class BA_CORE_API_ SquareLattice2DItem : public Lattice2DItem { public: static const QString P_LATTICE_LENGTH; SquareLattice2DItem(); std::unique_ptr<Lattice2D> createLattice() const; }; -class BA_CORE_API_ HexagonalLattice2DItem : public Lattice2DItem -{ +class BA_CORE_API_ HexagonalLattice2DItem : public Lattice2DItem { public: static const QString P_LATTICE_LENGTH; HexagonalLattice2DItem(); diff --git a/GUI/coregui/Models/LayerItem.cpp b/GUI/coregui/Models/LayerItem.cpp index cd41ece84faca9832ea920b78df0ec5a76d32d67..9bd1c6a2421e8e465f50a689714e5b9151e7d2bb 100644 --- a/GUI/coregui/Models/LayerItem.cpp +++ b/GUI/coregui/Models/LayerItem.cpp @@ -15,8 +15,7 @@ #include "GUI/coregui/Models/LayerItem.h" #include "GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h" -namespace -{ +namespace { const QString layer_nslices_tooltip = "Number of horizontal slices.\n" "Used for Average Layer Material calculations \n" "when corresponding ISimulation option set."; @@ -28,8 +27,7 @@ const QString LayerItem::P_MATERIAL = "Material"; const QString LayerItem::P_NSLICES = "Number of slices"; const QString LayerItem::T_LAYOUTS = "Layout tag"; -LayerItem::LayerItem() : SessionGraphicsItem("Layer") -{ +LayerItem::LayerItem() : SessionGraphicsItem("Layer") { setToolTip("A layer with thickness and material"); addProperty(P_THICKNESS, 0.0) ->setLimits(RealLimits::lowerLimited(0.0)) @@ -51,8 +49,7 @@ LayerItem::LayerItem() : SessionGraphicsItem("Layer") mapper()->setOnParentChange([this](SessionItem* new_parent) { updateAppearance(new_parent); }); } -QVector<SessionItem*> LayerItem::materialPropertyItems() -{ +QVector<SessionItem*> LayerItem::materialPropertyItems() { QVector<SessionItem*> result; if (auto property = getItem(LayerItem::P_MATERIAL)) result.push_back(property); @@ -61,8 +58,7 @@ QVector<SessionItem*> LayerItem::materialPropertyItems() return result; } -void LayerItem::updateAppearance(SessionItem* new_parent) -{ +void LayerItem::updateAppearance(SessionItem* new_parent) { if (!new_parent) { if (parent() && parent()->modelType() == "MultiLayer") { // we are about to be removed from MultiLayer diff --git a/GUI/coregui/Models/LayerItem.h b/GUI/coregui/Models/LayerItem.h index e6fe2c88ce63fab947358c711e8b7174270fc336..6d9671abc6691f4b234b8c8f6b45c57c02502fd3 100644 --- a/GUI/coregui/Models/LayerItem.h +++ b/GUI/coregui/Models/LayerItem.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/SessionGraphicsItem.h" -class BA_CORE_API_ LayerItem : public SessionGraphicsItem -{ +class BA_CORE_API_ LayerItem : public SessionGraphicsItem { public: static const QString P_THICKNESS; static const QString P_ROUGHNESS; diff --git a/GUI/coregui/Models/LayerRoughnessItems.cpp b/GUI/coregui/Models/LayerRoughnessItems.cpp index 0590673d249e706476d71accaa4bcd7d3b2f5a9c..342ddd7d352f12ffd05d407bf06520f0644d0986 100644 --- a/GUI/coregui/Models/LayerRoughnessItems.cpp +++ b/GUI/coregui/Models/LayerRoughnessItems.cpp @@ -14,8 +14,7 @@ #include "GUI/coregui/Models/LayerRoughnessItems.h" -namespace -{ +namespace { const QString hurst_tooltip = "Hurst parameter which describes how jagged the interface,\n " "dimensionless [0.0, 1.0], where 0.0 gives more spikes, \n1.0 more smoothness."; @@ -28,8 +27,7 @@ const QString LayerBasicRoughnessItem::P_HURST = QString::fromStdString("Hurst") const QString LayerBasicRoughnessItem::P_LATERAL_CORR_LENGTH = QString::fromStdString("CorrelationLength"); -LayerBasicRoughnessItem::LayerBasicRoughnessItem() : SessionItem("LayerBasicRoughness") -{ +LayerBasicRoughnessItem::LayerBasicRoughnessItem() : SessionItem("LayerBasicRoughness") { setToolTip("A roughness of interface between two layers."); addProperty(P_SIGMA, 1.0)->setToolTip("rms of the roughness in nanometers"); addProperty(P_HURST, 0.3)->setLimits(RealLimits::limited(0.0, 1.0)).setToolTip(hurst_tooltip); diff --git a/GUI/coregui/Models/LayerRoughnessItems.h b/GUI/coregui/Models/LayerRoughnessItems.h index 2a20245d7d496499329f823c74bde95c3cdf0805..228beb5230c83d1d240f30d487ac81240c9de848 100644 --- a/GUI/coregui/Models/LayerRoughnessItems.h +++ b/GUI/coregui/Models/LayerRoughnessItems.h @@ -17,14 +17,12 @@ #include "GUI/coregui/Models/SessionItem.h" -class BA_CORE_API_ LayerZeroRoughnessItem : public SessionItem -{ +class BA_CORE_API_ LayerZeroRoughnessItem : public SessionItem { public: LayerZeroRoughnessItem(); }; -class BA_CORE_API_ LayerBasicRoughnessItem : public SessionItem -{ +class BA_CORE_API_ LayerBasicRoughnessItem : public SessionItem { public: static const QString P_SIGMA; static const QString P_HURST; diff --git a/GUI/coregui/Models/MaskItems.cpp b/GUI/coregui/Models/MaskItems.cpp index d8fb35af355002e0221d53293273b79e9065e727..28fd8d18e217c54926d6983ea96a5915b9fd6a7a 100644 --- a/GUI/coregui/Models/MaskItems.cpp +++ b/GUI/coregui/Models/MaskItems.cpp @@ -20,8 +20,7 @@ #include "Device/Mask/Rectangle.h" #include "GUI/coregui/utils/GUIHelpers.h" -MaskContainerItem::MaskContainerItem() : SessionItem("MaskContainer") -{ +MaskContainerItem::MaskContainerItem() : SessionItem("MaskContainer") { const QString T_MASKS = "Mask Tag"; QStringList allowedMasks = QStringList() << "RectangleMask" << "PolygonMask" @@ -39,14 +38,12 @@ MaskContainerItem::MaskContainerItem() : SessionItem("MaskContainer") const QString MaskItem::P_MASK_VALUE = "Mask value"; const QString MaskItem::P_IS_VISIBLE = "Visibility"; -MaskItem::MaskItem(const QString& name) : SessionItem(name) -{ +MaskItem::MaskItem(const QString& name) : SessionItem(name) { addProperty(P_MASK_VALUE, true); addProperty(P_IS_VISIBLE, true); } -std::unique_ptr<IShape2D> MaskItem::createShape(double scale) const -{ +std::unique_ptr<IShape2D> MaskItem::createShape(double scale) const { Q_UNUSED(scale); throw GUIHelpers::Error("MaskItem::createShape() -> Not implemented."); } @@ -57,8 +54,7 @@ const QString RectangleItem::P_YLOW = "ylow"; const QString RectangleItem::P_XUP = "xup"; const QString RectangleItem::P_YUP = "yup"; -RectangleItem::RectangleItem(const QString& modelType) : MaskItem(modelType) -{ +RectangleItem::RectangleItem(const QString& modelType) : MaskItem(modelType) { setItemName(modelType); addProperty(P_XLOW, 0.0)->setLimits(RealLimits::limitless()); addProperty(P_YLOW, 0.0)->setLimits(RealLimits::limitless()); @@ -66,8 +62,7 @@ RectangleItem::RectangleItem(const QString& modelType) : MaskItem(modelType) addProperty(P_YUP, 0.0)->setLimits(RealLimits::limitless()); } -std::unique_ptr<IShape2D> RectangleItem::createShape(double scale) const -{ +std::unique_ptr<IShape2D> RectangleItem::createShape(double scale) const { double xlow = scale * getItemValue(P_XLOW).toDouble(); double ylow = scale * getItemValue(P_YLOW).toDouble(); double xup = scale * getItemValue(P_XUP).toDouble(); @@ -77,8 +72,7 @@ std::unique_ptr<IShape2D> RectangleItem::createShape(double scale) const /* ------------------------------------------------------------------------- */ -RegionOfInterestItem::RegionOfInterestItem() : RectangleItem("RegionOfInterest") -{ +RegionOfInterestItem::RegionOfInterestItem() : RectangleItem("RegionOfInterest") { setItemValue(P_MASK_VALUE, false); } @@ -87,8 +81,7 @@ RegionOfInterestItem::RegionOfInterestItem() : RectangleItem("RegionOfInterest") const QString PolygonPointItem::P_POSX = "X position"; const QString PolygonPointItem::P_POSY = "Y position"; -PolygonPointItem::PolygonPointItem() : SessionItem("PolygonPoint") -{ +PolygonPointItem::PolygonPointItem() : SessionItem("PolygonPoint") { setItemName("PolygonPoint"); addProperty(P_POSX, 0.0)->setLimits(RealLimits::limitless()); addProperty(P_POSY, 0.0)->setLimits(RealLimits::limitless()); @@ -98,8 +91,7 @@ PolygonPointItem::PolygonPointItem() : SessionItem("PolygonPoint") const QString PolygonItem::P_ISCLOSED = "Is closed"; -PolygonItem::PolygonItem() : MaskItem("PolygonMask") -{ +PolygonItem::PolygonItem() : MaskItem("PolygonMask") { setItemName("PolygonMask"); const QString T_POINTS = "Point tag"; registerTag(T_POINTS, 0, -1, QStringList() << "PolygonPoint"); @@ -107,8 +99,7 @@ PolygonItem::PolygonItem() : MaskItem("PolygonMask") addProperty(P_ISCLOSED, false)->setVisible(false); } -std::unique_ptr<IShape2D> PolygonItem::createShape(double scale) const -{ +std::unique_ptr<IShape2D> PolygonItem::createShape(double scale) const { std::vector<double> x, y; for (auto item : this->getChildrenOfType("PolygonPoint")) { x.push_back(scale * item->getItemValue(PolygonPointItem::P_POSX).toDouble()); @@ -120,14 +111,12 @@ std::unique_ptr<IShape2D> PolygonItem::createShape(double scale) const /* ------------------------------------------------------------------------- */ const QString VerticalLineItem::P_POSX = "X position"; -VerticalLineItem::VerticalLineItem() : MaskItem("VerticalLineMask") -{ +VerticalLineItem::VerticalLineItem() : MaskItem("VerticalLineMask") { setItemName("VerticalLineMask"); addProperty(P_POSX, 0.0)->setLimits(RealLimits::limitless()); } -std::unique_ptr<IShape2D> VerticalLineItem::createShape(double scale) const -{ +std::unique_ptr<IShape2D> VerticalLineItem::createShape(double scale) const { return std::make_unique<VerticalLine>(scale * getItemValue(VerticalLineItem::P_POSX).toDouble()); } @@ -135,14 +124,12 @@ std::unique_ptr<IShape2D> VerticalLineItem::createShape(double scale) const /* ------------------------------------------------------------------------- */ const QString HorizontalLineItem::P_POSY = "Y position"; -HorizontalLineItem::HorizontalLineItem() : MaskItem("HorizontalLineMask") -{ +HorizontalLineItem::HorizontalLineItem() : MaskItem("HorizontalLineMask") { setItemName("HorizontalLineMask"); addProperty(P_POSY, 0.0)->setLimits(RealLimits::limitless()); } -std::unique_ptr<IShape2D> HorizontalLineItem::createShape(double scale) const -{ +std::unique_ptr<IShape2D> HorizontalLineItem::createShape(double scale) const { return std::make_unique<HorizontalLine>(scale * getItemValue(HorizontalLineItem::P_POSY).toDouble()); } @@ -155,8 +142,7 @@ const QString EllipseItem::P_XRADIUS = "X radius"; const QString EllipseItem::P_YRADIUS = "Y radius"; const QString EllipseItem::P_ANGLE = "Angle"; -EllipseItem::EllipseItem() : MaskItem("EllipseMask") -{ +EllipseItem::EllipseItem() : MaskItem("EllipseMask") { setItemName("EllipseMask"); addProperty(P_XCENTER, 0.0)->setLimits(RealLimits::limitless()); addProperty(P_YCENTER, 0.0)->setLimits(RealLimits::limitless()); @@ -165,8 +151,7 @@ EllipseItem::EllipseItem() : MaskItem("EllipseMask") addProperty(P_ANGLE, 0.0)->setLimits(RealLimits::limitless()); } -std::unique_ptr<IShape2D> EllipseItem::createShape(double scale) const -{ +std::unique_ptr<IShape2D> EllipseItem::createShape(double scale) const { double xcenter = scale * getItemValue(EllipseItem::P_XCENTER).toDouble(); double ycenter = scale * getItemValue(EllipseItem::P_YCENTER).toDouble(); double xradius = scale * getItemValue(EllipseItem::P_XRADIUS).toDouble(); @@ -178,14 +163,12 @@ std::unique_ptr<IShape2D> EllipseItem::createShape(double scale) const /* ------------------------------------------------------------------------- */ -MaskAllItem::MaskAllItem() : MaskItem("MaskAllMask") -{ +MaskAllItem::MaskAllItem() : MaskItem("MaskAllMask") { setItemName("MaskAllMask"); getItem(MaskItem::P_MASK_VALUE)->setEnabled(false); } -std::unique_ptr<IShape2D> MaskAllItem::createShape(double scale) const -{ +std::unique_ptr<IShape2D> MaskAllItem::createShape(double scale) const { Q_UNUSED(scale); return std::make_unique<InfinitePlane>(); } diff --git a/GUI/coregui/Models/MaskItems.h b/GUI/coregui/Models/MaskItems.h index d99f21f25e3dc228af0b0673d8498fd328c649d1..3a88825e8fc48e74efb3e61541fca5b09982941a 100644 --- a/GUI/coregui/Models/MaskItems.h +++ b/GUI/coregui/Models/MaskItems.h @@ -21,16 +21,14 @@ class IShape2D; //! Container holding various masks as children -class BA_CORE_API_ MaskContainerItem : public SessionItem -{ +class BA_CORE_API_ MaskContainerItem : public SessionItem { public: MaskContainerItem(); }; //! A base class for all mask items -class BA_CORE_API_ MaskItem : public SessionItem -{ +class BA_CORE_API_ MaskItem : public SessionItem { public: static const QString P_MASK_VALUE; static const QString P_IS_VISIBLE; @@ -38,8 +36,7 @@ public: virtual std::unique_ptr<IShape2D> createShape(double scale = 1.0) const; }; -class BA_CORE_API_ RectangleItem : public MaskItem -{ +class BA_CORE_API_ RectangleItem : public MaskItem { public: static const QString P_XLOW; static const QString P_YLOW; @@ -49,14 +46,12 @@ public: virtual std::unique_ptr<IShape2D> createShape(double scale) const; }; -class BA_CORE_API_ RegionOfInterestItem : public RectangleItem -{ +class BA_CORE_API_ RegionOfInterestItem : public RectangleItem { public: RegionOfInterestItem(); }; -class BA_CORE_API_ PolygonPointItem : public SessionItem -{ +class BA_CORE_API_ PolygonPointItem : public SessionItem { public: static const QString P_POSX; @@ -64,8 +59,7 @@ public: PolygonPointItem(); }; -class BA_CORE_API_ PolygonItem : public MaskItem -{ +class BA_CORE_API_ PolygonItem : public MaskItem { public: static const QString P_ISCLOSED; @@ -73,8 +67,7 @@ public: virtual std::unique_ptr<IShape2D> createShape(double scale) const; }; -class BA_CORE_API_ VerticalLineItem : public MaskItem -{ +class BA_CORE_API_ VerticalLineItem : public MaskItem { public: static const QString P_POSX; @@ -82,8 +75,7 @@ public: virtual std::unique_ptr<IShape2D> createShape(double scale) const; }; -class BA_CORE_API_ HorizontalLineItem : public MaskItem -{ +class BA_CORE_API_ HorizontalLineItem : public MaskItem { public: static const QString P_POSY; @@ -91,8 +83,7 @@ public: virtual std::unique_ptr<IShape2D> createShape(double scale) const; }; -class BA_CORE_API_ EllipseItem : public MaskItem -{ +class BA_CORE_API_ EllipseItem : public MaskItem { public: static const QString P_XCENTER; @@ -104,8 +95,7 @@ public: virtual std::unique_ptr<IShape2D> createShape(double scale) const; }; -class BA_CORE_API_ MaskAllItem : public MaskItem -{ +class BA_CORE_API_ MaskAllItem : public MaskItem { public: MaskAllItem(); virtual std::unique_ptr<IShape2D> createShape(double scale) const; diff --git a/GUI/coregui/Models/MaterialDataItems.cpp b/GUI/coregui/Models/MaterialDataItems.cpp index 28f0d29f3e2bec45b908ca2b3a89cc0d2659e227..d5d1349622042ba824b5a89d2355b174e89cf9f0 100644 --- a/GUI/coregui/Models/MaterialDataItems.cpp +++ b/GUI/coregui/Models/MaterialDataItems.cpp @@ -14,8 +14,7 @@ #include "GUI/coregui/Models/MaterialDataItems.h" -MaterialDataItem::MaterialDataItem(const QString& modelType) : SessionItem(modelType) -{ +MaterialDataItem::MaterialDataItem(const QString& modelType) : SessionItem(modelType) { setEditable(false); // empty label, non-editable } @@ -25,8 +24,7 @@ const QString MaterialRefractiveDataItem::P_DELTA = "Delta"; const QString MaterialRefractiveDataItem::P_BETA = "Beta"; MaterialRefractiveDataItem::MaterialRefractiveDataItem() - : MaterialDataItem("MaterialRefractiveData") -{ + : MaterialDataItem("MaterialRefractiveData") { addProperty(P_DELTA, 0.0) ->setEditorType("ScientificDouble") .setLimits(RealLimits::limitless()) @@ -42,8 +40,7 @@ MaterialRefractiveDataItem::MaterialRefractiveDataItem() const QString MaterialSLDDataItem::P_SLD_REAL = "SLD, real"; const QString MaterialSLDDataItem::P_SLD_IMAG = "SLD, imaginary"; -MaterialSLDDataItem::MaterialSLDDataItem() : MaterialDataItem("MaterialSLDData") -{ +MaterialSLDDataItem::MaterialSLDDataItem() : MaterialDataItem("MaterialSLDData") { addProperty(P_SLD_REAL, 0.0) ->setEditorType("ScientificDouble") .setLimits(RealLimits::limitless()) diff --git a/GUI/coregui/Models/MaterialDataItems.h b/GUI/coregui/Models/MaterialDataItems.h index 87df839bd5a38a4109e40c58b47bbdc67e00746e..bbe9368ec7a172199dbe90c253964746f409efd6 100644 --- a/GUI/coregui/Models/MaterialDataItems.h +++ b/GUI/coregui/Models/MaterialDataItems.h @@ -17,14 +17,12 @@ #include "GUI/coregui/Models/SessionItem.h" -class BA_CORE_API_ MaterialDataItem : public SessionItem -{ +class BA_CORE_API_ MaterialDataItem : public SessionItem { protected: MaterialDataItem(const QString& modelType); }; -class BA_CORE_API_ MaterialRefractiveDataItem : public MaterialDataItem -{ +class BA_CORE_API_ MaterialRefractiveDataItem : public MaterialDataItem { public: static const QString P_DELTA; static const QString P_BETA; @@ -32,8 +30,7 @@ public: MaterialRefractiveDataItem(); }; -class BA_CORE_API_ MaterialSLDDataItem : public MaterialDataItem -{ +class BA_CORE_API_ MaterialSLDDataItem : public MaterialDataItem { public: static const QString P_SLD_REAL; static const QString P_SLD_IMAG; diff --git a/GUI/coregui/Models/MaterialItem.cpp b/GUI/coregui/Models/MaterialItem.cpp index b9718c1103b99c81662008d942d37470de5d35fc..f784e5aac354aab96240e069334c068e537728b6 100644 --- a/GUI/coregui/Models/MaterialItem.cpp +++ b/GUI/coregui/Models/MaterialItem.cpp @@ -20,8 +20,7 @@ using SessionItemUtils::GetVectorItem; -namespace -{ +namespace { const QString magnetization_tooltip = "Magnetization (A/m)"; } @@ -30,8 +29,7 @@ const QString MaterialItem::P_MATERIAL_DATA = "Material data"; const QString MaterialItem::P_MAGNETIZATION = "Magnetization"; const QString MaterialItem::P_IDENTIFIER = "Identifier"; -MaterialItem::MaterialItem() : SessionItem("Material") -{ +MaterialItem::MaterialItem() : SessionItem("Material") { setItemName("Material"); ExternalProperty color = MaterialItemUtils::colorProperty(QColor(Qt::red)); @@ -45,8 +43,7 @@ MaterialItem::MaterialItem() : SessionItem("Material") //! Turns material into refractive index material. -void MaterialItem::setRefractiveData(double delta, double beta) -{ +void MaterialItem::setRefractiveData(double delta, double beta) { auto refractiveData = setGroupProperty(P_MATERIAL_DATA, "MaterialRefractiveData"); refractiveData->setItemValue(MaterialRefractiveDataItem::P_DELTA, delta); refractiveData->setItemValue(MaterialRefractiveDataItem::P_BETA, beta); @@ -54,26 +51,22 @@ void MaterialItem::setRefractiveData(double delta, double beta) //! Turns material into SLD based material. -void MaterialItem::setSLDData(double sld_real, double sld_imag) -{ +void MaterialItem::setSLDData(double sld_real, double sld_imag) { auto sldData = setGroupProperty(P_MATERIAL_DATA, "MaterialSLDData"); sldData->setItemValue(MaterialSLDDataItem::P_SLD_REAL, sld_real); sldData->setItemValue(MaterialSLDDataItem::P_SLD_IMAG, sld_imag); } -QString MaterialItem::identifier() const -{ +QString MaterialItem::identifier() const { return getItemValue(P_IDENTIFIER).toString(); } -QColor MaterialItem::color() const -{ +QColor MaterialItem::color() const { ExternalProperty property = getItemValue(P_COLOR).value<ExternalProperty>(); return property.color(); } -std::unique_ptr<Material> MaterialItem::createMaterial() const -{ +std::unique_ptr<Material> MaterialItem::createMaterial() const { auto dataItem = getGroupItem(P_MATERIAL_DATA); auto magnetization = GetVectorItem(*this, P_MAGNETIZATION); auto name = itemName().toStdString(); diff --git a/GUI/coregui/Models/MaterialItem.h b/GUI/coregui/Models/MaterialItem.h index 39937371db39bf1a243381c15ea46737166ef906..1c87a8d3151e4ff39ddfe239114430086221f9a6 100644 --- a/GUI/coregui/Models/MaterialItem.h +++ b/GUI/coregui/Models/MaterialItem.h @@ -19,8 +19,7 @@ class Material; -class BA_CORE_API_ MaterialItem : public SessionItem -{ +class BA_CORE_API_ MaterialItem : public SessionItem { public: static const QString P_COLOR; static const QString P_MATERIAL_DATA; diff --git a/GUI/coregui/Models/MaterialItemContainer.cpp b/GUI/coregui/Models/MaterialItemContainer.cpp index e1bb85b9272d0bfd74b41a866921376c627e467c..77a6a879ccad70af374bd9475a80fd23bb727d16 100644 --- a/GUI/coregui/Models/MaterialItemContainer.cpp +++ b/GUI/coregui/Models/MaterialItemContainer.cpp @@ -19,14 +19,12 @@ const QString MaterialItemContainer::T_MATERIALS = "MaterialVector"; -MaterialItemContainer::MaterialItemContainer() : SessionItem("MaterialContainer") -{ +MaterialItemContainer::MaterialItemContainer() : SessionItem("MaterialContainer") { setItemName("Materials"); registerTag(T_MATERIALS, 0, -1, QStringList{"Material"}); } -MaterialItem* MaterialItemContainer::insertCopy(MaterialItem* material_item) -{ +MaterialItem* MaterialItemContainer::insertCopy(MaterialItem* material_item) { MaterialItem* item_copy = dynamic_cast<MaterialItem*>(model()->copyItem(material_item, this, T_MATERIALS)); item_copy->setItemValue(MaterialItem::P_IDENTIFIER, GUIHelpers::createUuid()); @@ -34,14 +32,12 @@ MaterialItem* MaterialItemContainer::insertCopy(MaterialItem* material_item) return item_copy; } -MaterialItem* MaterialItemContainer::findMaterialById(QString id) -{ +MaterialItem* MaterialItemContainer::findMaterialById(QString id) { return const_cast<MaterialItem*>( static_cast<const MaterialItemContainer*>(this)->findMaterialById(id)); } -const MaterialItem* MaterialItemContainer::findMaterialById(QString id) const -{ +const MaterialItem* MaterialItemContainer::findMaterialById(QString id) const { auto materials = getItems(T_MATERIALS); for (auto item : materials) { auto material = dynamic_cast<MaterialItem*>(item); diff --git a/GUI/coregui/Models/MaterialItemContainer.h b/GUI/coregui/Models/MaterialItemContainer.h index d1de4db59c7783ab499bb482acff732637fe46e1..04de2b2d4c7b478efefda781407a5e3147cd869f 100644 --- a/GUI/coregui/Models/MaterialItemContainer.h +++ b/GUI/coregui/Models/MaterialItemContainer.h @@ -19,8 +19,7 @@ class MaterialItem; -class MaterialItemContainer : public SessionItem -{ +class MaterialItemContainer : public SessionItem { public: static const QString T_MATERIALS; diff --git a/GUI/coregui/Models/MaterialModel.cpp b/GUI/coregui/Models/MaterialModel.cpp index b254068f718392657fd3995cd421410a8c273b48..ce08a265080b19f30c5320d17bc224ce1355f6e8 100644 --- a/GUI/coregui/Models/MaterialModel.cpp +++ b/GUI/coregui/Models/MaterialModel.cpp @@ -18,47 +18,40 @@ #include "GUI/coregui/mainwindow/AppSvc.h" #include "GUI/coregui/utils/GUIHelpers.h" -MaterialModel::MaterialModel(QObject* parent) : SessionModel(SessionXML::MaterialModelTag, parent) -{ +MaterialModel::MaterialModel(QObject* parent) : SessionModel(SessionXML::MaterialModelTag, parent) { setObjectName(SessionXML::MaterialModelTag); if (AppSvc::materialModel() == nullptr) AppSvc::subscribe(this); } -MaterialModel::~MaterialModel() -{ +MaterialModel::~MaterialModel() { if (AppSvc::materialModel() == this) AppSvc::unsubscribe(this); } -MaterialModel* MaterialModel::createCopy(SessionItem* parent) -{ +MaterialModel* MaterialModel::createCopy(SessionItem* parent) { MaterialModel* result = new MaterialModel(); result->initFrom(this, parent); return result; } -MaterialItem* MaterialModel::addRefractiveMaterial(const QString& name, double delta, double beta) -{ +MaterialItem* MaterialModel::addRefractiveMaterial(const QString& name, double delta, double beta) { auto materialItem = createMaterial(name); materialItem->setRefractiveData(delta, beta); return materialItem; } -MaterialItem* MaterialModel::addSLDMaterial(const QString& name, double sld, double abs_term) -{ +MaterialItem* MaterialModel::addSLDMaterial(const QString& name, double sld, double abs_term) { auto materialItem = createMaterial(name); materialItem->setSLDData(sld, abs_term); return materialItem; } -MaterialItem* MaterialModel::materialFromIndex(const QModelIndex& index) -{ +MaterialItem* MaterialModel::materialFromIndex(const QModelIndex& index) { return dynamic_cast<MaterialItem*>(itemForIndex(index)); } -MaterialItem* MaterialModel::materialFromName(const QString& name) -{ +MaterialItem* MaterialModel::materialFromName(const QString& name) { for (auto materialItem : topItems<MaterialItem>()) if (materialItem->itemName() == name) return materialItem; @@ -66,8 +59,7 @@ MaterialItem* MaterialModel::materialFromName(const QString& name) return nullptr; } -MaterialItem* MaterialModel::materialFromIdentifier(const QString& identifier) -{ +MaterialItem* MaterialModel::materialFromIdentifier(const QString& identifier) { for (auto materialItem : topItems<MaterialItem>()) if (materialItem->identifier() == identifier) return materialItem; @@ -77,8 +69,7 @@ MaterialItem* MaterialModel::materialFromIdentifier(const QString& identifier) //! Returns clone of material with given index. Clone will get unique identifier. -MaterialItem* MaterialModel::cloneMaterial(const QModelIndex& index) -{ +MaterialItem* MaterialModel::cloneMaterial(const QModelIndex& index) { const auto origMaterial = materialFromIndex(index); if (!origMaterial) return nullptr; @@ -91,8 +82,7 @@ MaterialItem* MaterialModel::cloneMaterial(const QModelIndex& index) //! Creates material with name and color. Material data remains uninitialized. -MaterialItem* MaterialModel::createMaterial(const QString& name) -{ +MaterialItem* MaterialModel::createMaterial(const QString& name) { auto result = dynamic_cast<MaterialItem*>(insertNewItem("Material")); result->setItemName(name); diff --git a/GUI/coregui/Models/MaterialModel.h b/GUI/coregui/Models/MaterialModel.h index c4963c588f2b6489a3e1cdccef671fc75a9b833f..01bb92caeca64309c58a67c36d1999ff14826b88 100644 --- a/GUI/coregui/Models/MaterialModel.h +++ b/GUI/coregui/Models/MaterialModel.h @@ -20,8 +20,7 @@ class MaterialItem; class ExternalProperty; -class MaterialModel : public SessionModel -{ +class MaterialModel : public SessionModel { Q_OBJECT public: diff --git a/GUI/coregui/Models/MaterialPropertyController.cpp b/GUI/coregui/Models/MaterialPropertyController.cpp index 0a324817696a412a3f722bb2ad825a32a408ee66..5f65f30ee274743cc6245c579a4a1aa1c163c85a 100644 --- a/GUI/coregui/Models/MaterialPropertyController.cpp +++ b/GUI/coregui/Models/MaterialPropertyController.cpp @@ -21,12 +21,9 @@ #include <QVector> MaterialPropertyController::MaterialPropertyController(QObject* parent) - : QObject(parent), m_materialModel(nullptr), m_sampleModel(nullptr) -{ -} + : QObject(parent), m_materialModel(nullptr), m_sampleModel(nullptr) {} -void MaterialPropertyController::setModels(MaterialModel* materialModel, SampleModel* sampleModel) -{ +void MaterialPropertyController::setModels(MaterialModel* materialModel, SampleModel* sampleModel) { m_materialModel = materialModel; m_sampleModel = sampleModel; @@ -43,8 +40,7 @@ void MaterialPropertyController::setModels(MaterialModel* materialModel, SampleM //! Special case when original MaterialModel was fully rebuild from MaterialEditor. //! Full update of MaterialProperties. -void MaterialPropertyController::onMaterialModelLoad() -{ +void MaterialPropertyController::onMaterialModelLoad() { for (auto sampleItem : relatedSampleItems()) { QString tag = MaterialItemUtils::materialTag(*sampleItem); ASSERT(!tag.isEmpty()); @@ -64,8 +60,7 @@ void MaterialPropertyController::onMaterialModelLoad() //! On MaterialItem change: updates corresponding MaterialProperty in sample items. void MaterialPropertyController::onMaterialDataChanged(const QModelIndex& topLeft, - const QModelIndex&, const QVector<int>&) -{ + const QModelIndex&, const QVector<int>&) { auto changedItem = m_materialModel->itemForIndex(topLeft); if (auto materialItem = dynamic_cast<const MaterialItem*>(ModelPath::ancestor(changedItem, "Material"))) { @@ -86,8 +81,7 @@ void MaterialPropertyController::onMaterialDataChanged(const QModelIndex& topLef //! On MaterialItem removal: updates corresponding MaterialProperty in sample items. void MaterialPropertyController::onMaterialRowsAboutToBeRemoved(const QModelIndex& parent, - int first, int last) -{ + int first, int last) { // looking for top level items (MaterialItems) if (parent.isValid()) return; @@ -115,8 +109,7 @@ void MaterialPropertyController::onMaterialRowsAboutToBeRemoved(const QModelInde //! Returns vector of SessionItems having MaterialProperty on board. -QVector<SessionItem*> MaterialPropertyController::relatedSampleItems() -{ +QVector<SessionItem*> MaterialPropertyController::relatedSampleItems() { static QStringList materialRelated = MaterialItemUtils::materialRelatedModelTypes(); QVector<SessionItem*> result; diff --git a/GUI/coregui/Models/MaterialPropertyController.h b/GUI/coregui/Models/MaterialPropertyController.h index 965f49c676be6db74c5b5f2e02c2c84e95acd3ba..4ee5a63432a688e83065d4292ab3c29adf4a26bd 100644 --- a/GUI/coregui/Models/MaterialPropertyController.h +++ b/GUI/coregui/Models/MaterialPropertyController.h @@ -24,8 +24,7 @@ class SessionItem; //! Listens MaterialModel for changes in MaterialItems and then //! updates MaterialProperties in all related items in SampleModel. -class MaterialPropertyController : public QObject -{ +class MaterialPropertyController : public QObject { Q_OBJECT public: MaterialPropertyController(QObject* parent = nullptr); diff --git a/GUI/coregui/Models/MesoCrystalItem.cpp b/GUI/coregui/Models/MesoCrystalItem.cpp index d1c4684fb175d5b96698bdad6e47efb8ca1a0696..1153bb6c5f261b22b64e4997dc24b8e55f00eec4 100644 --- a/GUI/coregui/Models/MesoCrystalItem.cpp +++ b/GUI/coregui/Models/MesoCrystalItem.cpp @@ -31,8 +31,7 @@ using SessionItemUtils::GetVectorItem; -namespace -{ +namespace { const QString abundance_tooltip = "Proportion of this type of mesocrystal normalized to the \n" "total number of particles in the layout"; @@ -49,8 +48,7 @@ const QString density_tooltip = "Number of mesocrystals per square nanometer (particle surface density).\n " "Should be defined for disordered and 1d-ordered particle collections."; -bool IsIParticleName(QString name) -{ +bool IsIParticleName(QString name) { return (name.startsWith("Particle") || name.startsWith("ParticleComposition") || name.startsWith("ParticleCoreShell") || name.startsWith("MesoCrystal")); } @@ -65,8 +63,7 @@ const QString MesoCrystalItem::P_VECTOR_C = "Third lattice vector"; // TODO make derived from ParticleItem -MesoCrystalItem::MesoCrystalItem() : SessionGraphicsItem("MesoCrystal") -{ +MesoCrystalItem::MesoCrystalItem() : SessionGraphicsItem("MesoCrystal") { setToolTip("A 3D crystal structure of nanoparticles"); addGroupProperty(P_OUTER_SHAPE, "Form Factor"); @@ -108,8 +105,7 @@ MesoCrystalItem::MesoCrystalItem() : SessionGraphicsItem("MesoCrystal") }); } -std::unique_ptr<MesoCrystal> MesoCrystalItem::createMesoCrystal() const -{ +std::unique_ptr<MesoCrystal> MesoCrystalItem::createMesoCrystal() const { const Lattice3D& lattice = getLattice(); if (!(lattice.unitCellVolume() > 0.0)) throw GUIHelpers::Error("MesoCrystalItem::createMesoCrystal(): " @@ -131,8 +127,7 @@ std::unique_ptr<MesoCrystal> MesoCrystalItem::createMesoCrystal() const return result; } -QStringList MesoCrystalItem::translateList(const QStringList& list) const -{ +QStringList MesoCrystalItem::translateList(const QStringList& list) const { QStringList result = list; // Add CrystalType to path name of basis particle if (IsIParticleName(list.back())) @@ -141,16 +136,14 @@ QStringList MesoCrystalItem::translateList(const QStringList& list) const return result; } -Lattice3D MesoCrystalItem::getLattice() const -{ +Lattice3D MesoCrystalItem::getLattice() const { const kvector_t a1 = GetVectorItem(*this, P_VECTOR_A); const kvector_t a2 = GetVectorItem(*this, P_VECTOR_B); const kvector_t a3 = GetVectorItem(*this, P_VECTOR_C); return Lattice3D(a1, a2, a3); } -std::unique_ptr<IParticle> MesoCrystalItem::getBasis() const -{ +std::unique_ptr<IParticle> MesoCrystalItem::getBasis() const { QVector<SessionItem*> childlist = children(); for (int i = 0; i < childlist.size(); ++i) { if (childlist[i]->modelType() == "Particle") { @@ -170,8 +163,7 @@ std::unique_ptr<IParticle> MesoCrystalItem::getBasis() const return {}; } -std::unique_ptr<IFormFactor> MesoCrystalItem::getOuterShape() const -{ +std::unique_ptr<IFormFactor> MesoCrystalItem::getOuterShape() const { auto& ff_item = groupItem<FormFactorItem>(MesoCrystalItem::P_OUTER_SHAPE); return ff_item.createFormFactor(); } diff --git a/GUI/coregui/Models/MesoCrystalItem.h b/GUI/coregui/Models/MesoCrystalItem.h index f5cde529772e1f7c65ba46464c7827fccb99fb16..168b8b5ca93c082f99322e7824b41c0172115153 100644 --- a/GUI/coregui/Models/MesoCrystalItem.h +++ b/GUI/coregui/Models/MesoCrystalItem.h @@ -22,8 +22,7 @@ class IFormFactor; class IParticle; class MesoCrystal; -class BA_CORE_API_ MesoCrystalItem : public SessionGraphicsItem -{ +class BA_CORE_API_ MesoCrystalItem : public SessionGraphicsItem { public: static const QString P_OUTER_SHAPE; static const QString T_BASIS_PARTICLE; diff --git a/GUI/coregui/Models/MinimizerItem.cpp b/GUI/coregui/Models/MinimizerItem.cpp index 39e9dc787231f79ed2f72d82bfee5b20a4f70687..fff352c553be9f96367301d8820b8cd7473794b1 100644 --- a/GUI/coregui/Models/MinimizerItem.cpp +++ b/GUI/coregui/Models/MinimizerItem.cpp @@ -31,8 +31,7 @@ const QString MinimizerContainerItem::P_MINIMIZERS = "Minimizer"; const QString MinimizerContainerItem::P_METRIC = "Objective metric"; const QString MinimizerContainerItem::P_NORM = "Norm function"; -MinimizerContainerItem::MinimizerContainerItem() : MinimizerItem("MinimizerContainer") -{ +MinimizerContainerItem::MinimizerContainerItem() : MinimizerItem("MinimizerContainer") { addGroupProperty(P_MINIMIZERS, "Minimizer library group")->setToolTip("Minimizer library"); ComboProperty metric_combo; @@ -52,13 +51,11 @@ MinimizerContainerItem::MinimizerContainerItem() : MinimizerItem("MinimizerConta "experimental data."); } -std::unique_ptr<IMinimizer> MinimizerContainerItem::createMinimizer() const -{ +std::unique_ptr<IMinimizer> MinimizerContainerItem::createMinimizer() const { return groupItem<MinimizerItem>(P_MINIMIZERS).createMinimizer(); } -std::unique_ptr<ObjectiveMetric> MinimizerContainerItem::createMetric() const -{ +std::unique_ptr<ObjectiveMetric> MinimizerContainerItem::createMetric() const { QString metric = getItemValue(P_METRIC).value<ComboProperty>().getValue(); QString norm = getItemValue(P_NORM).value<ComboProperty>().getValue(); return ObjectiveMetricUtils::createMetric(metric.toStdString(), norm.toStdString()); @@ -73,8 +70,7 @@ const QString MinuitMinimizerItem::P_TOLERANCE = QString::fromStdString("Toleran const QString MinuitMinimizerItem::P_PRECISION = QString::fromStdString("Precision"); const QString MinuitMinimizerItem::P_MAXFUNCTIONCALLS = QString::fromStdString("MaxFunctionCalls"); -MinuitMinimizerItem::MinuitMinimizerItem() : MinimizerItem("Minuit2") -{ +MinuitMinimizerItem::MinuitMinimizerItem() : MinimizerItem("Minuit2") { addProperty(P_ALGORITHMS, MinimizerItemCatalog::algorithmCombo(modelType()).variant()); addProperty(P_STRATEGY, 1) @@ -93,8 +89,7 @@ MinuitMinimizerItem::MinuitMinimizerItem() : MinimizerItem("Minuit2") addProperty(P_MAXFUNCTIONCALLS, 0)->setToolTip("Maximum number of function calls"); } -std::unique_ptr<IMinimizer> MinuitMinimizerItem::createMinimizer() const -{ +std::unique_ptr<IMinimizer> MinuitMinimizerItem::createMinimizer() const { QString algorithmName = getItemValue(P_ALGORITHMS).value<ComboProperty>().getValue(); Minuit2Minimizer* domainMinimizer = new Minuit2Minimizer(algorithmName.toStdString()); @@ -112,14 +107,12 @@ std::unique_ptr<IMinimizer> MinuitMinimizerItem::createMinimizer() const const QString GSLMultiMinimizerItem::P_ALGORITHMS = "Algorithms"; const QString GSLMultiMinimizerItem::P_MAXITERATIONS = QString::fromStdString("MaxIterations"); -GSLMultiMinimizerItem::GSLMultiMinimizerItem() : MinimizerItem("GSLMultiMin") -{ +GSLMultiMinimizerItem::GSLMultiMinimizerItem() : MinimizerItem("GSLMultiMin") { addProperty(P_ALGORITHMS, MinimizerItemCatalog::algorithmCombo(modelType()).variant()); addProperty(P_MAXITERATIONS, 0)->setToolTip("Maximum number of iterations"); } -std::unique_ptr<IMinimizer> GSLMultiMinimizerItem::createMinimizer() const -{ +std::unique_ptr<IMinimizer> GSLMultiMinimizerItem::createMinimizer() const { QString algorithmName = getItemValue(P_ALGORITHMS).value<ComboProperty>().getValue(); GSLMultiMinimizer* domainMinimizer = new GSLMultiMinimizer(algorithmName.toStdString()); @@ -134,16 +127,14 @@ const QString GeneticMinimizerItem::P_MAXITERATIONS = QString::fromStdString("Ma const QString GeneticMinimizerItem::P_POPULATIONSIZE = QString::fromStdString("PopSize"); const QString GeneticMinimizerItem::P_RANDOMSEED = QString::fromStdString("RandomSeed"); -GeneticMinimizerItem::GeneticMinimizerItem() : MinimizerItem("Genetic") -{ +GeneticMinimizerItem::GeneticMinimizerItem() : MinimizerItem("Genetic") { addProperty(P_TOLERANCE, 0.01)->setToolTip("Tolerance on the function value at the minimum"); addProperty(P_MAXITERATIONS, 3)->setToolTip("Maximum number of iterations"); addProperty(P_POPULATIONSIZE, 300)->setToolTip("Population size"); addProperty(P_RANDOMSEED, 0)->setToolTip("Random seed"); } -std::unique_ptr<IMinimizer> GeneticMinimizerItem::createMinimizer() const -{ +std::unique_ptr<IMinimizer> GeneticMinimizerItem::createMinimizer() const { GeneticMinimizer* domainMinimizer = new GeneticMinimizer(); domainMinimizer->setTolerance(getItemValue(P_TOLERANCE).toDouble()); domainMinimizer->setMaxIterations(getItemValue(P_MAXITERATIONS).toInt()); @@ -162,8 +153,7 @@ const QString SimAnMinimizerItem::P_BOLTZMANN_TINIT = QString::fromStdString("t_ const QString SimAnMinimizerItem::P_BOLTZMANN_MU = QString::fromStdString("mu"); const QString SimAnMinimizerItem::P_BOLTZMANN_TMIN = QString::fromStdString("t_min"); -SimAnMinimizerItem::SimAnMinimizerItem() : MinimizerItem("GSLSimAn") -{ +SimAnMinimizerItem::SimAnMinimizerItem() : MinimizerItem("GSLSimAn") { addProperty(P_MAXITERATIONS, 100)->setToolTip("Number of points to try for each step"); addProperty(P_ITERATIONSTEMP, 10)->setToolTip("Number of iterations at each temperature"); addProperty(P_STEPSIZE, 1.0)->setToolTip("Max step size used in random walk"); @@ -173,8 +163,7 @@ SimAnMinimizerItem::SimAnMinimizerItem() : MinimizerItem("GSLSimAn") addProperty(P_BOLTZMANN_TMIN, 0.1)->setToolTip("Boltzmann minimal temperature"); } -std::unique_ptr<IMinimizer> SimAnMinimizerItem::createMinimizer() const -{ +std::unique_ptr<IMinimizer> SimAnMinimizerItem::createMinimizer() const { SimAnMinimizer* domainMinimizer = new SimAnMinimizer(); domainMinimizer->setMaxIterations(getItemValue(P_MAXITERATIONS).toInt()); domainMinimizer->setIterationsAtEachTemp(getItemValue(P_ITERATIONSTEMP).toInt()); @@ -191,14 +180,12 @@ std::unique_ptr<IMinimizer> SimAnMinimizerItem::createMinimizer() const const QString GSLLMAMinimizerItem::P_TOLERANCE = QString::fromStdString("Tolerance"); const QString GSLLMAMinimizerItem::P_MAXITERATIONS = QString::fromStdString("MaxIterations"); -GSLLMAMinimizerItem::GSLLMAMinimizerItem() : MinimizerItem("GSLLMA") -{ +GSLLMAMinimizerItem::GSLLMAMinimizerItem() : MinimizerItem("GSLLMA") { addProperty(P_TOLERANCE, 0.01)->setToolTip("Tolerance on the function value at the minimum"); addProperty(P_MAXITERATIONS, 0)->setToolTip("Maximum number of iterations"); } -std::unique_ptr<IMinimizer> GSLLMAMinimizerItem::createMinimizer() const -{ +std::unique_ptr<IMinimizer> GSLLMAMinimizerItem::createMinimizer() const { GSLLevenbergMarquardtMinimizer* domainMinimizer = new GSLLevenbergMarquardtMinimizer(); domainMinimizer->setTolerance(getItemValue(P_TOLERANCE).toDouble()); domainMinimizer->setMaxIterations(getItemValue(P_MAXITERATIONS).toInt()); @@ -209,7 +196,6 @@ std::unique_ptr<IMinimizer> GSLLMAMinimizerItem::createMinimizer() const TestMinimizerItem::TestMinimizerItem() : MinimizerItem("Test") {} -std::unique_ptr<IMinimizer> TestMinimizerItem::createMinimizer() const -{ +std::unique_ptr<IMinimizer> TestMinimizerItem::createMinimizer() const { return std::unique_ptr<IMinimizer>(new TestMinimizer()); } diff --git a/GUI/coregui/Models/MinimizerItem.h b/GUI/coregui/Models/MinimizerItem.h index 7b63fa02d1f99605c770de5bce0375c213c45e1a..66cf88db6bd263a905b3a32468dd5211a7a89eb6 100644 --- a/GUI/coregui/Models/MinimizerItem.h +++ b/GUI/coregui/Models/MinimizerItem.h @@ -22,8 +22,7 @@ class ObjectiveMetric; //! The MinimizerItem class is the base item to hold minimizer settings. -class BA_CORE_API_ MinimizerItem : public SessionItem -{ +class BA_CORE_API_ MinimizerItem : public SessionItem { public: explicit MinimizerItem(const QString& model_type); virtual std::unique_ptr<IMinimizer> createMinimizer() const = 0; @@ -31,8 +30,7 @@ public: //! The MinimizerContainerItem class holds collection of minimizers. -class BA_CORE_API_ MinimizerContainerItem : public MinimizerItem -{ +class BA_CORE_API_ MinimizerContainerItem : public MinimizerItem { public: static const QString P_MINIMIZERS; static const QString P_METRIC; @@ -46,8 +44,7 @@ public: //! The MinuitMinimizerItem class represents settings for ROOT Minuit2 minimizer. -class BA_CORE_API_ MinuitMinimizerItem : public MinimizerItem -{ +class BA_CORE_API_ MinuitMinimizerItem : public MinimizerItem { public: static const QString P_ALGORITHMS; static const QString P_STRATEGY; @@ -62,8 +59,7 @@ public: //! The GSLMinimizerItem class represents settings for GSL MultiMin minimizer family. -class BA_CORE_API_ GSLMultiMinimizerItem : public MinimizerItem -{ +class BA_CORE_API_ GSLMultiMinimizerItem : public MinimizerItem { public: static const QString P_ALGORITHMS; static const QString P_MAXITERATIONS; @@ -74,8 +70,7 @@ public: //! The GeneticMinimizerItem class represents settings for TMVA/Genetic minimizer. -class BA_CORE_API_ GeneticMinimizerItem : public MinimizerItem -{ +class BA_CORE_API_ GeneticMinimizerItem : public MinimizerItem { public: static const QString P_TOLERANCE; static const QString P_MAXITERATIONS; @@ -88,8 +83,7 @@ public: //! The SimAnMinimizerItem class represents settings for GSL's simulated annealing minimizer. -class BA_CORE_API_ SimAnMinimizerItem : public MinimizerItem -{ +class BA_CORE_API_ SimAnMinimizerItem : public MinimizerItem { public: static const QString P_MAXITERATIONS; static const QString P_ITERATIONSTEMP; @@ -106,8 +100,7 @@ public: //! The GSLLMAMinimizerItem class represents settings for GSL's version of Levenberg-Marquardt. -class BA_CORE_API_ GSLLMAMinimizerItem : public MinimizerItem -{ +class BA_CORE_API_ GSLLMAMinimizerItem : public MinimizerItem { public: static const QString P_TOLERANCE; static const QString P_MAXITERATIONS; @@ -118,8 +111,7 @@ public: //! The TestMinimizerItem class represents domain's TestMinimizer to test whole chain -class BA_CORE_API_ TestMinimizerItem : public MinimizerItem -{ +class BA_CORE_API_ TestMinimizerItem : public MinimizerItem { public: TestMinimizerItem(); std::unique_ptr<IMinimizer> createMinimizer() const; diff --git a/GUI/coregui/Models/MinimizerItemCatalog.cpp b/GUI/coregui/Models/MinimizerItemCatalog.cpp index 15f1ba1e655702467da469d13cae1a7e3a2d4c1d..5fd01ddf3fd6b3c885f9ce9036928792fb1fff8a 100644 --- a/GUI/coregui/Models/MinimizerItemCatalog.cpp +++ b/GUI/coregui/Models/MinimizerItemCatalog.cpp @@ -18,8 +18,7 @@ //! Returns ComboProperty representing list of algorithms defined for given minimizerType. -ComboProperty MinimizerItemCatalog::algorithmCombo(const QString& minimizerType) -{ +ComboProperty MinimizerItemCatalog::algorithmCombo(const QString& minimizerType) { ComboProperty result = ComboProperty() << algorithmNames(minimizerType); result.setToolTips(algorithmDescriptions(minimizerType)); return result; @@ -27,8 +26,7 @@ ComboProperty MinimizerItemCatalog::algorithmCombo(const QString& minimizerType) //! Returns list of algorithm names defined for given minimizer. -QStringList MinimizerItemCatalog::algorithmNames(const QString& minimizerType) -{ +QStringList MinimizerItemCatalog::algorithmNames(const QString& minimizerType) { std::vector<std::string> algos = MinimizerFactory::catalog().algorithmNames(minimizerType.toStdString()); return GUIHelpers::fromStdStrings(algos); @@ -36,8 +34,7 @@ QStringList MinimizerItemCatalog::algorithmNames(const QString& minimizerType) //! Returns list of algoritm descriptions defined for given minimizer. -QStringList MinimizerItemCatalog::algorithmDescriptions(const QString& minimizerType) -{ +QStringList MinimizerItemCatalog::algorithmDescriptions(const QString& minimizerType) { std::vector<std::string> descr = MinimizerFactory::catalog().algorithmDescriptions(minimizerType.toStdString()); return GUIHelpers::fromStdStrings(descr); diff --git a/GUI/coregui/Models/MinimizerItemCatalog.h b/GUI/coregui/Models/MinimizerItemCatalog.h index 321c3cd15b130d0b573df93d2c36d66570e2f6d0..5e8999ebddf7ad5c6cedab8ab7e66582401e746c 100644 --- a/GUI/coregui/Models/MinimizerItemCatalog.h +++ b/GUI/coregui/Models/MinimizerItemCatalog.h @@ -22,8 +22,7 @@ class MinimizerItem; //! The MinimizerItemCatalog class is a static class to provide MinimizerItem //! with the list of available minimizers/algorithms. -class MinimizerItemCatalog -{ +class MinimizerItemCatalog { public: static ComboProperty algorithmCombo(const QString& minimizerType); diff --git a/GUI/coregui/Models/ModelMapper.cpp b/GUI/coregui/Models/ModelMapper.cpp index 58ade7f75333016f6adf5bb5829ab99b6366ea3c..bf062554ac66039eed7ad8c22c316d460bba3605 100644 --- a/GUI/coregui/Models/ModelMapper.cpp +++ b/GUI/coregui/Models/ModelMapper.cpp @@ -15,40 +15,33 @@ #include "GUI/coregui/Models/SessionModel.h" ModelMapper::ModelMapper(QObject* parent) - : QObject(parent), m_active(true), m_model(nullptr), m_item(nullptr) -{ -} + : QObject(parent), m_active(true), m_model(nullptr), m_item(nullptr) {} -void ModelMapper::setItem(SessionItem* item) -{ +void ModelMapper::setItem(SessionItem* item) { if (item) { m_item = item; setModel(item->model()); } } -void ModelMapper::setOnValueChange(std::function<void(void)> f, const void* caller) -{ +void ModelMapper::setOnValueChange(std::function<void(void)> f, const void* caller) { m_onValueChange.push_back(call_t(f, caller)); } -void ModelMapper::setOnPropertyChange(std::function<void(QString)> f, const void* caller) -{ +void ModelMapper::setOnPropertyChange(std::function<void(QString)> f, const void* caller) { auto ff = [=](SessionItem* /*item*/, const QString& property) { f(property); }; m_onPropertyChange.push_back(call_item_str_t(ff, caller)); } void ModelMapper::setOnPropertyChange(std::function<void(SessionItem*, QString)> f, - const void* caller) -{ + const void* caller) { m_onPropertyChange.push_back(call_item_str_t(f, caller)); } //! Calls back on child property change, report childItem and property name. void ModelMapper::setOnChildPropertyChange(std::function<void(SessionItem*, QString)> f, - const void* caller) -{ + const void* caller) { m_onChildPropertyChange.push_back(call_item_str_t(f, caller)); } @@ -57,21 +50,18 @@ void ModelMapper::setOnChildPropertyChange(std::function<void(SessionItem*, QStr //! will still report old parent. //! If newParent!=0, it is just the same as parent(). -void ModelMapper::setOnParentChange(std::function<void(SessionItem*)> f, const void* caller) -{ +void ModelMapper::setOnParentChange(std::function<void(SessionItem*)> f, const void* caller) { m_onParentChange.push_back(call_item_t(f, caller)); } //! Calls back when number of children has changed, reports newChild. //! newChild == nullptr denotes the case when number of children has decreased. -void ModelMapper::setOnChildrenChange(std::function<void(SessionItem*)> f, const void* caller) -{ +void ModelMapper::setOnChildrenChange(std::function<void(SessionItem*)> f, const void* caller) { m_onChildrenChange.push_back(call_item_t(f, caller)); } -void ModelMapper::setOnSiblingsChange(std::function<void()> f, const void* caller) -{ +void ModelMapper::setOnSiblingsChange(std::function<void()> f, const void* caller) { m_onSiblingsChange.push_back(call_t(f, caller)); } @@ -79,24 +69,20 @@ void ModelMapper::setOnSiblingsChange(std::function<void()> f, const void* calle //! reports childItem. //! childItem == nullptr denotes the case when child was removed. -void ModelMapper::setOnAnyChildChange(std::function<void(SessionItem*)> f, const void* caller) -{ +void ModelMapper::setOnAnyChildChange(std::function<void(SessionItem*)> f, const void* caller) { m_onAnyChildChange.push_back(call_item_t(f, caller)); } -void ModelMapper::setOnItemDestroy(std::function<void(SessionItem*)> f, const void* caller) -{ +void ModelMapper::setOnItemDestroy(std::function<void(SessionItem*)> f, const void* caller) { m_onItemDestroy.push_back(call_item_t(f, caller)); } -void ModelMapper::setOnAboutToRemoveChild(std::function<void(SessionItem*)> f, const void* caller) -{ +void ModelMapper::setOnAboutToRemoveChild(std::function<void(SessionItem*)> f, const void* caller) { m_onAboutToRemoveChild.push_back(call_item_t(f, caller)); } //! Cancells all subscribtion of given caller -void ModelMapper::unsubscribe(const void* caller) -{ +void ModelMapper::unsubscribe(const void* caller) { clean_container(m_onValueChange, caller); clean_container(m_onPropertyChange, caller); clean_container(m_onChildPropertyChange, caller); @@ -108,8 +94,7 @@ void ModelMapper::unsubscribe(const void* caller) clean_container(m_onAboutToRemoveChild, caller); } -void ModelMapper::setModel(SessionModel* model) -{ +void ModelMapper::setModel(SessionModel* model) { if (m_model) { disconnect(m_model, &SessionModel::dataChanged, this, &ModelMapper::onDataChanged); disconnect(m_model, &SessionModel::rowsInserted, this, &ModelMapper::onRowsInserted); @@ -127,8 +112,7 @@ void ModelMapper::setModel(SessionModel* model) } } -int ModelMapper::nestlingDepth(SessionItem* item, int level) -{ +int ModelMapper::nestlingDepth(SessionItem* item, int level) { if (item == nullptr || item == m_model->rootItem()) return -1; if (item == m_item) @@ -137,72 +121,62 @@ int ModelMapper::nestlingDepth(SessionItem* item, int level) return nestlingDepth(item->parent(), level + 1); } -void ModelMapper::callOnValueChange() -{ +void ModelMapper::callOnValueChange() { if (m_active && m_onValueChange.size() > 0) for (auto f : m_onValueChange) f.first(); } -void ModelMapper::callOnPropertyChange(const QString& name) -{ +void ModelMapper::callOnPropertyChange(const QString& name) { if (m_active) for (auto f : m_onPropertyChange) f.first(m_item, name); } -void ModelMapper::callOnChildPropertyChange(SessionItem* item, const QString& name) -{ +void ModelMapper::callOnChildPropertyChange(SessionItem* item, const QString& name) { if (m_active) for (auto f : m_onChildPropertyChange) f.first(item, name); } -void ModelMapper::callOnParentChange(SessionItem* new_parent) -{ +void ModelMapper::callOnParentChange(SessionItem* new_parent) { if (m_active) for (auto f : m_onParentChange) f.first(new_parent); } -void ModelMapper::callOnChildrenChange(SessionItem* item) -{ +void ModelMapper::callOnChildrenChange(SessionItem* item) { if (m_active) for (auto f : m_onChildrenChange) f.first(item); } -void ModelMapper::callOnSiblingsChange() -{ +void ModelMapper::callOnSiblingsChange() { if (m_active) for (auto f : m_onSiblingsChange) f.first(); } -void ModelMapper::callOnAnyChildChange(SessionItem* item) -{ +void ModelMapper::callOnAnyChildChange(SessionItem* item) { if (m_active) for (auto f : m_onAnyChildChange) f.first(item); } -void ModelMapper::callOnAboutToRemoveChild(SessionItem* item) -{ +void ModelMapper::callOnAboutToRemoveChild(SessionItem* item) { if (m_active) for (auto f : m_onAboutToRemoveChild) f.first(item); } //! Notifies subscribers if an item owning given mapper is about to be destroyed -void ModelMapper::callOnItemDestroy() -{ +void ModelMapper::callOnItemDestroy() { if (m_active) for (auto f : m_onItemDestroy) f.first(m_item); } -void ModelMapper::clearMapper() -{ +void ModelMapper::clearMapper() { m_item = nullptr; setModel(nullptr); m_onValueChange.clear(); @@ -217,8 +191,7 @@ void ModelMapper::clearMapper() } void ModelMapper::onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, - const QVector<int>& /*roles*/) -{ + const QVector<int>& /*roles*/) { if (topLeft.parent() != bottomRight.parent()) return; // range must be from the same parent @@ -250,8 +223,7 @@ void ModelMapper::onDataChanged(const QModelIndex& topLeft, const QModelIndex& b callOnAnyChildChange(item); } -void ModelMapper::onRowsInserted(const QModelIndex& parent, int first, int /*last*/) -{ +void ModelMapper::onRowsInserted(const QModelIndex& parent, int first, int /*last*/) { SessionItem* newChild = m_model->itemForIndex(m_model->index(first, 0, parent)); int nestling = nestlingDepth(newChild); @@ -272,8 +244,7 @@ void ModelMapper::onRowsInserted(const QModelIndex& parent, int first, int /*las } } -void ModelMapper::onBeginRemoveRows(const QModelIndex& parent, int first, int /*last*/) -{ +void ModelMapper::onBeginRemoveRows(const QModelIndex& parent, int first, int /*last*/) { SessionItem* oldChild = m_model->itemForIndex(m_model->index(first, 0, parent)); int nestling = nestlingDepth(m_model->itemForIndex(parent)); @@ -289,8 +260,7 @@ void ModelMapper::onBeginRemoveRows(const QModelIndex& parent, int first, int /* m_aboutToDelete = m_model->index(first, 0, parent); } -void ModelMapper::onRowRemoved(const QModelIndex& parent, int first, int /*last*/) -{ +void ModelMapper::onRowRemoved(const QModelIndex& parent, int first, int /*last*/) { int nestling = nestlingDepth(m_model->itemForIndex(parent)); if (nestling >= 0 || m_model->itemForIndex(parent) == m_item->parent()) { diff --git a/GUI/coregui/Models/ModelMapper.h b/GUI/coregui/Models/ModelMapper.h index e0f72092fb219c4a70c4a5dc60cb00b435263055..841881893793b32b45f139be799f766f002e2c2a 100644 --- a/GUI/coregui/Models/ModelMapper.h +++ b/GUI/coregui/Models/ModelMapper.h @@ -21,8 +21,7 @@ class SessionModel; class SessionItem; -class ModelMapper : public QObject -{ +class ModelMapper : public QObject { Q_OBJECT public: @@ -105,8 +104,7 @@ private: QModelIndex m_aboutToDelete; }; -template <class U> inline void ModelMapper::clean_container(U& v, const void* caller) -{ +template <class U> inline void ModelMapper::clean_container(U& v, const void* caller) { v.erase(std::remove_if( v.begin(), v.end(), [caller](typename U::value_type const& x) -> bool { return (x.second == caller); }), diff --git a/GUI/coregui/Models/ModelPath.cpp b/GUI/coregui/Models/ModelPath.cpp index dd9082555df0bc30415e79da2acdf7b807038083..be6a3ddf4290627f55396f7a3f332bd705859d64 100644 --- a/GUI/coregui/Models/ModelPath.cpp +++ b/GUI/coregui/Models/ModelPath.cpp @@ -16,8 +16,7 @@ #include "GUI/coregui/Models/JobItem.h" #include "GUI/coregui/Models/SessionModel.h" -QString ModelPath::getPathFromIndex(const QModelIndex& index) -{ +QString ModelPath::getPathFromIndex(const QModelIndex& index) { if (index.isValid()) { QStringList namePath; QModelIndex cur = index; @@ -33,8 +32,7 @@ QString ModelPath::getPathFromIndex(const QModelIndex& index) // TODO cover with unit tests and simplify -QModelIndex ModelPath::getIndexFromPath(const SessionModel* model, const QString& path) -{ +QModelIndex ModelPath::getIndexFromPath(const SessionModel* model, const QString& path) { if (model) { QStringList parts = path.split("/"); SessionItem* t = model->rootItem(); @@ -57,8 +55,7 @@ QModelIndex ModelPath::getIndexFromPath(const SessionModel* model, const QString //! returns an item from relative path wrt to given parent -SessionItem* ModelPath::getItemFromPath(const QString& relPath, const SessionItem* parent) -{ +SessionItem* ModelPath::getItemFromPath(const QString& relPath, const SessionItem* parent) { ASSERT(parent); QString fullPath = getPathFromIndex(parent->index()) + "/" + relPath; return parent->model()->itemForIndex(ModelPath::getIndexFromPath(parent->model(), fullPath)); @@ -66,8 +63,7 @@ SessionItem* ModelPath::getItemFromPath(const QString& relPath, const SessionIte //! Iterates through all the model and returns true if item is found. This is to -bool ModelPath::isValidItem(SessionModel* model, SessionItem* item, const QModelIndex& parent) -{ +bool ModelPath::isValidItem(SessionModel* model, SessionItem* item, const QModelIndex& parent) { for (int i_row = 0; i_row < model->rowCount(parent); ++i_row) { QModelIndex index = model->index(i_row, 0, parent); SessionItem* curr = model->itemForIndex(index); @@ -84,8 +80,7 @@ bool ModelPath::isValidItem(SessionModel* model, SessionItem* item, const QModel //! Returns ancestor of given modelType for given item. //! For example, returns corresponding jobItem owning ParameterItem via ParameterContainer. -const SessionItem* ModelPath::ancestor(const SessionItem* item, const QString& requiredModelType) -{ +const SessionItem* ModelPath::ancestor(const SessionItem* item, const QString& requiredModelType) { const SessionItem* cur = item; while (cur && cur->modelType() != requiredModelType) cur = cur->parent(); @@ -95,8 +90,7 @@ const SessionItem* ModelPath::ancestor(const SessionItem* item, const QString& r //! Returns translation of item path to domain name -QString ModelPath::itemPathTranslation(const SessionItem& item, const SessionItem* topItem) -{ +QString ModelPath::itemPathTranslation(const SessionItem& item, const SessionItem* topItem) { QStringList pathList; const SessionItem* current(&item); while (current && current != topItem) { diff --git a/GUI/coregui/Models/ModelPath.h b/GUI/coregui/Models/ModelPath.h index 5e531cb489996def06560bceeddeb2a06fc9621a..39e8514921bb2e20e3b397a7e102b4d98cfcea10 100644 --- a/GUI/coregui/Models/ModelPath.h +++ b/GUI/coregui/Models/ModelPath.h @@ -23,8 +23,7 @@ class SessionItem; class QModelIndex; class SessionModel; -namespace ModelPath -{ +namespace ModelPath { QString getPathFromIndex(const QModelIndex& index); QModelIndex getIndexFromPath(const SessionModel* model, const QString& path); diff --git a/GUI/coregui/Models/ModelUtils.cpp b/GUI/coregui/Models/ModelUtils.cpp index 8dcbb85493c31aec25826772de5444e3d51174b1..cc3acea137ca0d315064895ac38cda808a076221 100644 --- a/GUI/coregui/Models/ModelUtils.cpp +++ b/GUI/coregui/Models/ModelUtils.cpp @@ -17,8 +17,7 @@ #include <QAbstractItemModel> #include <QModelIndex> -QStringList ModelUtils::topItemNames(SessionModel* model, const QString& modelType) -{ +QStringList ModelUtils::topItemNames(SessionModel* model, const QString& modelType) { QStringList result; for (auto item : model->topItems()) @@ -31,8 +30,7 @@ QStringList ModelUtils::topItemNames(SessionModel* model, const QString& modelTy } void ModelUtils::iterate(const QModelIndex& index, const QAbstractItemModel* model, - const std::function<void(const QModelIndex&)>& fun) -{ + const std::function<void(const QModelIndex&)>& fun) { if (index.isValid()) fun(index); @@ -45,8 +43,7 @@ void ModelUtils::iterate(const QModelIndex& index, const QAbstractItemModel* mod } void ModelUtils::iterate_if(const QModelIndex& index, const QAbstractItemModel* model, - const std::function<bool(const QModelIndex&)>& fun) -{ + const std::function<bool(const QModelIndex&)>& fun) { bool proceed_with_children(true); if (index.isValid()) proceed_with_children = fun(index); diff --git a/GUI/coregui/Models/ModelUtils.h b/GUI/coregui/Models/ModelUtils.h index 4cfddf72a2bc44572ae1872f8d8e2ce717da9359..0a8f80f26dbf85962cf8ceca6743930da6b145c5 100644 --- a/GUI/coregui/Models/ModelUtils.h +++ b/GUI/coregui/Models/ModelUtils.h @@ -22,8 +22,7 @@ class QModelIndex; class QAbstractItemModel; class SessionModel; -namespace ModelUtils -{ +namespace ModelUtils { //! Returns list of top iten manes. QStringList topItemNames(SessionModel* model, const QString& modelType = ""); diff --git a/GUI/coregui/Models/MultiLayerItem.cpp b/GUI/coregui/Models/MultiLayerItem.cpp index ed201142735d31a3aa62a6c2db0df69c4418d4af..fe12aba0ec32cdafa5bbd1ed5097be59b06bcb80 100644 --- a/GUI/coregui/Models/MultiLayerItem.cpp +++ b/GUI/coregui/Models/MultiLayerItem.cpp @@ -16,8 +16,7 @@ #include "GUI/coregui/Models/LayerItem.h" #include "GUI/coregui/Models/ParameterTranslators.h" -namespace -{ +namespace { const QString external_field_tooltip = "External field (A/m)"; } @@ -26,8 +25,7 @@ const QString MultiLayerItem::P_CROSS_CORR_LENGTH = const QString MultiLayerItem::P_EXTERNAL_FIELD = "ExternalField"; const QString MultiLayerItem::T_LAYERS = "Layer tag"; -MultiLayerItem::MultiLayerItem() : SessionGraphicsItem("MultiLayer") -{ +MultiLayerItem::MultiLayerItem() : SessionGraphicsItem("MultiLayer") { setToolTip("A multilayer to hold stack of layers"); setItemName("MultiLayer"); @@ -46,16 +44,14 @@ MultiLayerItem::MultiLayerItem() : SessionGraphicsItem("MultiLayer") mapper()->setOnChildrenChange([this](SessionItem*) { updateLayers(); }); } -QVector<SessionItem*> MultiLayerItem::materialPropertyItems() -{ +QVector<SessionItem*> MultiLayerItem::materialPropertyItems() { QVector<SessionItem*> result; for (auto layer_item : getItems(T_LAYERS)) result.append(static_cast<LayerItem*>(layer_item)->materialPropertyItems()); return result; } -void MultiLayerItem::updateLayers() -{ +void MultiLayerItem::updateLayers() { QVector<SessionItem*> list = getChildrenOfType("Layer"); for (auto it = list.begin(); it != list.end(); ++it) { if (it == list.begin()) diff --git a/GUI/coregui/Models/MultiLayerItem.h b/GUI/coregui/Models/MultiLayerItem.h index 7aa7584a5ffd7c9d51087542878c939720d3b2d3..8b59119b401001493cfb01910c534e288dda7106 100644 --- a/GUI/coregui/Models/MultiLayerItem.h +++ b/GUI/coregui/Models/MultiLayerItem.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/SessionGraphicsItem.h" -class BA_CORE_API_ MultiLayerItem : public SessionGraphicsItem -{ +class BA_CORE_API_ MultiLayerItem : public SessionGraphicsItem { public: static const QString P_CROSS_CORR_LENGTH; static const QString P_EXTERNAL_FIELD; diff --git a/GUI/coregui/Models/ParameterTranslators.cpp b/GUI/coregui/Models/ParameterTranslators.cpp index 14bbd9b01a5532679a65717fcf216e1d5be616a5..ce028b7716d65cc99a108cfb2a60a8a3912b33e5 100644 --- a/GUI/coregui/Models/ParameterTranslators.cpp +++ b/GUI/coregui/Models/ParameterTranslators.cpp @@ -18,8 +18,7 @@ #include "GUI/coregui/Models/VectorItem.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { const QStringList expectedRoughnessPars = QStringList() << QString::fromStdString("Sigma") << QString::fromStdString("Hurst") << QString::fromStdString("CorrelationLength"); @@ -28,17 +27,13 @@ const QStringList expectedRoughnessPars = IPathTranslator::~IPathTranslator() = default; ModelTypeTranslator::ModelTypeTranslator(QString gui_model_type, QString domain_name) - : m_gui_model_type{std::move(gui_model_type)}, m_domain_name{std::move(domain_name)} -{ -} + : m_gui_model_type{std::move(gui_model_type)}, m_domain_name{std::move(domain_name)} {} -ModelTypeTranslator* ModelTypeTranslator::clone() const -{ +ModelTypeTranslator* ModelTypeTranslator::clone() const { return new ModelTypeTranslator(m_gui_model_type, m_domain_name); } -QStringList ModelTypeTranslator::translate(const QStringList& list) const -{ +QStringList ModelTypeTranslator::translate(const QStringList& list) const { if (list.back() != m_gui_model_type) return list; @@ -49,17 +44,13 @@ QStringList ModelTypeTranslator::translate(const QStringList& list) const } AddElementTranslator::AddElementTranslator(QString gui_name, QString additional_name) - : m_gui_name{std::move(gui_name)}, m_additional_name{std::move(additional_name)} -{ -} + : m_gui_name{std::move(gui_name)}, m_additional_name{std::move(additional_name)} {} -AddElementTranslator* AddElementTranslator::clone() const -{ +AddElementTranslator* AddElementTranslator::clone() const { return new AddElementTranslator(m_gui_name, m_additional_name); } -QStringList AddElementTranslator::translate(const QStringList& list) const -{ +QStringList AddElementTranslator::translate(const QStringList& list) const { if (list.back() != m_gui_name) return list; @@ -68,8 +59,7 @@ QStringList AddElementTranslator::translate(const QStringList& list) const return result; } -QStringList RotationTranslator::translate(const QStringList& list) const -{ +QStringList RotationTranslator::translate(const QStringList& list) const { if (list.back() != "Rotation") return list; @@ -79,8 +69,7 @@ QStringList RotationTranslator::translate(const QStringList& list) const return result; } -QStringList DistributionNoneTranslator::translate(const QStringList& list) const -{ +QStringList DistributionNoneTranslator::translate(const QStringList& list) const { if (list.back() != "DistributionNone") return list; @@ -92,13 +81,11 @@ QStringList DistributionNoneTranslator::translate(const QStringList& list) const RoughnessTranslator::RoughnessTranslator(const SessionItem* p_parent) : m_parent(p_parent) {} -RoughnessTranslator* RoughnessTranslator::clone() const -{ +RoughnessTranslator* RoughnessTranslator::clone() const { return new RoughnessTranslator(m_parent); } -QStringList RoughnessTranslator::translate(const QStringList& list) const -{ +QStringList RoughnessTranslator::translate(const QStringList& list) const { if (list.empty()) return {}; @@ -117,8 +104,7 @@ QStringList RoughnessTranslator::translate(const QStringList& list) const //! Extract layer index from the string "Layer11" -int RoughnessTranslator::getLayerIndex(QString layerName) const -{ +int RoughnessTranslator::getLayerIndex(QString layerName) const { layerName.remove("Layer"); bool ok(true); int layerIndex = layerName.toInt(&ok); @@ -127,8 +113,7 @@ int RoughnessTranslator::getLayerIndex(QString layerName) const return layerIndex; } -int RoughnessTranslator::numberOfLayers() const -{ +int RoughnessTranslator::numberOfLayers() const { QVector<SessionItem*> list = m_parent->getChildrenOfType("Layer"); return list.size(); } @@ -137,17 +122,13 @@ VectorParameterTranslator::VectorParameterTranslator(QString gui_name, std::stri QStringList additional_names) : m_gui_name{std::move(gui_name)} , m_base_name{std::move(base_name)} - , m_additional_names{std::move(additional_names)} -{ -} + , m_additional_names{std::move(additional_names)} {} -VectorParameterTranslator* VectorParameterTranslator::clone() const -{ +VectorParameterTranslator* VectorParameterTranslator::clone() const { return new VectorParameterTranslator(m_gui_name, m_base_name, m_additional_names); } -QStringList VectorParameterTranslator::translate(const QStringList& list) const -{ +QStringList VectorParameterTranslator::translate(const QStringList& list) const { if (list.empty()) return {}; diff --git a/GUI/coregui/Models/ParameterTranslators.h b/GUI/coregui/Models/ParameterTranslators.h index b63c66bb903f9b3f52088ac3310bc6ed1e8263ed..8605152c6a5cec69cece3ad0b820c94e536796d4 100644 --- a/GUI/coregui/Models/ParameterTranslators.h +++ b/GUI/coregui/Models/ParameterTranslators.h @@ -19,8 +19,7 @@ class SessionItem; -class IPathTranslator -{ +class IPathTranslator { public: virtual ~IPathTranslator(); @@ -29,8 +28,7 @@ public: virtual QStringList translate(const QStringList& list) const = 0; }; -class ModelTypeTranslator : public IPathTranslator -{ +class ModelTypeTranslator : public IPathTranslator { public: ModelTypeTranslator(QString gui_model_type, QString domain_name); ~ModelTypeTranslator() override {} @@ -44,8 +42,7 @@ private: QString m_domain_name; }; -class AddElementTranslator : public IPathTranslator -{ +class AddElementTranslator : public IPathTranslator { public: AddElementTranslator(QString gui_name, QString additional_name); ~AddElementTranslator() override {} @@ -59,8 +56,7 @@ private: QString m_additional_name; }; -class RotationTranslator : public IPathTranslator -{ +class RotationTranslator : public IPathTranslator { public: ~RotationTranslator() override {} @@ -69,8 +65,7 @@ public: QStringList translate(const QStringList& list) const override; }; -class DistributionNoneTranslator : public IPathTranslator -{ +class DistributionNoneTranslator : public IPathTranslator { public: ~DistributionNoneTranslator() override {} @@ -79,8 +74,7 @@ public: QStringList translate(const QStringList& list) const override; }; -class RoughnessTranslator : public IPathTranslator -{ +class RoughnessTranslator : public IPathTranslator { public: RoughnessTranslator(const SessionItem* p_parent); ~RoughnessTranslator() override {} @@ -95,8 +89,7 @@ private: const SessionItem* m_parent; }; -class VectorParameterTranslator : public IPathTranslator -{ +class VectorParameterTranslator : public IPathTranslator { public: VectorParameterTranslator(QString gui_name, std::string base_name, QStringList additional_names = {}); diff --git a/GUI/coregui/Models/ParameterTreeItems.cpp b/GUI/coregui/Models/ParameterTreeItems.cpp index e00a3202c21da592685d25543de01bad099093e7..dea8c52f72dc0d17f51c6088888449186e1282ec 100644 --- a/GUI/coregui/Models/ParameterTreeItems.cpp +++ b/GUI/coregui/Models/ParameterTreeItems.cpp @@ -19,8 +19,7 @@ // ---------------------------------------------------------------------------- -ParameterLabelItem::ParameterLabelItem() : SessionItem("Parameter Label") -{ +ParameterLabelItem::ParameterLabelItem() : SessionItem("Parameter Label") { const QString T_CHILDREN = "children tag"; registerTag(T_CHILDREN, 0, -1, QStringList() << "Parameter Label" @@ -31,8 +30,7 @@ ParameterLabelItem::ParameterLabelItem() : SessionItem("Parameter Label") const QString ParameterItem::P_LINK = "Link"; const QString ParameterItem::P_BACKUP = "Backup"; const QString ParameterItem::P_DOMAIN = "Domain"; -ParameterItem::ParameterItem() : SessionItem("Parameter") -{ +ParameterItem::ParameterItem() : SessionItem("Parameter") { // Link to original PropertyItem in one of components of MultiLayerItem or InstrumentItem addProperty(P_LINK, ""); // The back up value of PropertyItem to be able to reset parameter tuning tree to initial state @@ -45,8 +43,7 @@ ParameterItem::ParameterItem() : SessionItem("Parameter") //! Sets current value to the original PropertyItem of MultiLayerItem/InstrumentItem. -void ParameterItem::propagateValueToLink(double newValue) -{ +void ParameterItem::propagateValueToLink(double newValue) { setValue(newValue); if (SessionItem* item = linkedItem()) @@ -55,8 +52,7 @@ void ParameterItem::propagateValueToLink(double newValue) //! Returns corresponding linked item in MultiLayerItem/IsntrumentItem -SessionItem* ParameterItem::linkedItem() -{ +SessionItem* ParameterItem::linkedItem() { const SessionItem* jobItem = ModelPath::ancestor(this, "JobItem"); ASSERT(jobItem); QString link = jobItem->itemName() + "/" + getItemValue(P_LINK).toString(); @@ -65,16 +61,14 @@ SessionItem* ParameterItem::linkedItem() //! Restore the value from backup and propagate it to the linked item. -void ParameterItem::restoreFromBackup() -{ +void ParameterItem::restoreFromBackup() { double newValue = getItemValue(P_BACKUP).toDouble(); propagateValueToLink(newValue); } // ---------------------------------------------------------------------------- -ParameterContainerItem::ParameterContainerItem() : SessionItem("Parameter Container") -{ +ParameterContainerItem::ParameterContainerItem() : SessionItem("Parameter Container") { const QString T_CHILDREN = "children tag"; registerTag(T_CHILDREN, 0, -1, QStringList() << "Parameter Label"); setDefaultTag(T_CHILDREN); diff --git a/GUI/coregui/Models/ParameterTreeItems.h b/GUI/coregui/Models/ParameterTreeItems.h index 976519fbf4866f91cc3163e94be19a11d14d5b20..21559505cbc4dab6b8f600061d35362e62fef939 100644 --- a/GUI/coregui/Models/ParameterTreeItems.h +++ b/GUI/coregui/Models/ParameterTreeItems.h @@ -23,16 +23,14 @@ //! The ParameterLabelItem class represents a label (string without value, like 'Layer', //! 'MultiLayer') in a parameter tuning tree. -class BA_CORE_API_ ParameterLabelItem : public SessionItem -{ +class BA_CORE_API_ ParameterLabelItem : public SessionItem { public: ParameterLabelItem(); }; //! The ParameterItem class represent a tuning value in a parameter tuning tree. -class BA_CORE_API_ ParameterItem : public SessionItem -{ +class BA_CORE_API_ ParameterItem : public SessionItem { public: static const QString P_LINK; static const QString P_BACKUP; @@ -48,8 +46,7 @@ public: //! The ParameterContainerItem is a top item to hold all ParameterItem, represents an entry //! point to parameter tuning tree. Part of JobItem. -class BA_CORE_API_ ParameterContainerItem : public SessionItem -{ +class BA_CORE_API_ ParameterContainerItem : public SessionItem { public: ParameterContainerItem(); }; diff --git a/GUI/coregui/Models/ParameterTreeUtils.cpp b/GUI/coregui/Models/ParameterTreeUtils.cpp index 8bd981d9df933a011ecb7a9425ebb565d3222d40..da9de7a469ac0333a8d05823abc26f3189262fe1 100644 --- a/GUI/coregui/Models/ParameterTreeUtils.cpp +++ b/GUI/coregui/Models/ParameterTreeUtils.cpp @@ -23,11 +23,9 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include <QStack> -namespace -{ +namespace { -QString removeLeadingSlash(const QString& name) -{ +QString removeLeadingSlash(const QString& name) { return name.indexOf('/') == 0 ? name.mid(1) : name; } @@ -35,8 +33,7 @@ QString removeLeadingSlash(const QString& name) //! For every ParameterItem in a container creates a link to the domain. -void populateDomainLinks(SessionItem* container) -{ +void populateDomainLinks(SessionItem* container) { if (container->modelType() != "Parameter Container") throw GUIHelpers::Error("ParameterTreeUtils::populateParameterContainer() -> Error. " "Not a ParameterContainerType."); @@ -54,8 +51,7 @@ void handleItem(SessionItem* tree, const SessionItem* source); } // namespace -void ParameterTreeUtils::createParameterTree(JobItem* jobItem) -{ +void ParameterTreeUtils::createParameterTree(JobItem* jobItem) { SessionItem* container = jobItem->model()->insertNewItem( "Parameter Container", jobItem->index(), -1, JobItem::T_PARAMETER_TREE); @@ -77,8 +73,7 @@ void ParameterTreeUtils::createParameterTree(JobItem* jobItem) //! in a source item. void ParameterTreeUtils::populateParameterContainer(SessionItem* container, - const SessionItem* source) -{ + const SessionItem* source) { if (container->modelType() != "Parameter Container") throw GUIHelpers::Error("ParameterTreeUtils::populateParameterContainer() -> Error. " "Not a ParameterContainerType."); @@ -92,8 +87,7 @@ void ParameterTreeUtils::populateParameterContainer(SessionItem* container, //! Visit all ParameterItem in container and execute user function. void ParameterTreeUtils::visitParameterContainer(SessionItem* container, - std::function<void(ParameterItem*)> fun) -{ + std::function<void(ParameterItem*)> fun) { SessionItem* current(container); QStack<SessionItem*> stack; stack.push(current); @@ -112,8 +106,7 @@ void ParameterTreeUtils::visitParameterContainer(SessionItem* container, //! Creates list with parameter names of source item. -QStringList ParameterTreeUtils::parameterTreeNames(const SessionItem* source) -{ +QStringList ParameterTreeUtils::parameterTreeNames(const SessionItem* source) { QStringList result; for (auto pair : parameterDictionary(source)) @@ -124,8 +117,7 @@ QStringList ParameterTreeUtils::parameterTreeNames(const SessionItem* source) //! Creates domain translated list of parameter names for source item. -QStringList ParameterTreeUtils::translatedParameterTreeNames(const SessionItem* source) -{ +QStringList ParameterTreeUtils::translatedParameterTreeNames(const SessionItem* source) { QStringList result; for (auto pair : parameterDictionary(source)) @@ -137,8 +129,8 @@ QStringList ParameterTreeUtils::translatedParameterTreeNames(const SessionItem* //! Correspondance of parameter name to translated name for all properties found in source //! in its children. -QVector<QPair<QString, QString>> ParameterTreeUtils::parameterDictionary(const SessionItem* source) -{ +QVector<QPair<QString, QString>> +ParameterTreeUtils::parameterDictionary(const SessionItem* source) { ASSERT(source); QVector<QPair<QString, QString>> result; @@ -169,8 +161,7 @@ QVector<QPair<QString, QString>> ParameterTreeUtils::parameterDictionary(const S //! one of its children. QString ParameterTreeUtils::domainNameToParameterName(const QString& domainName, - const SessionItem* source) -{ + const SessionItem* source) { QString domain = removeLeadingSlash(domainName); for (auto pair : parameterDictionary(source)) { // parName, domainName if (pair.second == domain) @@ -184,8 +175,7 @@ QString ParameterTreeUtils::domainNameToParameterName(const QString& domainName, //! one of its children. QString ParameterTreeUtils::parameterNameToDomainName(const QString& parName, - const SessionItem* source) -{ + const SessionItem* source) { for (auto pair : parameterDictionary(source)) // parName, domainName if (pair.first == parName) return "/" + pair.second; @@ -196,8 +186,7 @@ QString ParameterTreeUtils::parameterNameToDomainName(const QString& parName, //! Converts parameter item name to the corresponding item in the tree below the source. SessionItem* ParameterTreeUtils::parameterNameToLinkedItem(const QString& parName, - const SessionItem* source) -{ + const SessionItem* source) { SampleModel model; SessionItem* container = model.insertNewItem("Parameter Container"); populateParameterContainer(container, source); @@ -217,11 +206,9 @@ SessionItem* ParameterTreeUtils::parameterNameToLinkedItem(const QString& parNam return result; } -namespace -{ +namespace { -void handleItem(SessionItem* tree, const SessionItem* source) -{ +void handleItem(SessionItem* tree, const SessionItem* source) { if (tree->modelType() == "Parameter Label") { tree->setDisplayName(source->itemName()); diff --git a/GUI/coregui/Models/ParameterTreeUtils.h b/GUI/coregui/Models/ParameterTreeUtils.h index 8111633d977fcd56c2603745c7e7ac71ff699db2..14088931133167465060e1dd5692f107cfdf8c88 100644 --- a/GUI/coregui/Models/ParameterTreeUtils.h +++ b/GUI/coregui/Models/ParameterTreeUtils.h @@ -27,8 +27,7 @@ class ParameterItem; //! with ParameterItems. The ParameterItem appears in RealTimeView and provides real //! time tuning of MultiLayerItem and InstrumentItem. -namespace ParameterTreeUtils -{ +namespace ParameterTreeUtils { void createParameterTree(JobItem* jobItem); diff --git a/GUI/coregui/Models/ParameterTuningModel.cpp b/GUI/coregui/Models/ParameterTuningModel.cpp index 8542de93ee52ff30be12f15a71dbb5b852bd0c63..097ead8b3d675802d04fc713cfa4ecf08762f72a 100644 --- a/GUI/coregui/Models/ParameterTuningModel.cpp +++ b/GUI/coregui/Models/ParameterTuningModel.cpp @@ -20,8 +20,7 @@ ParameterTuningModel::ParameterTuningModel(QObject* parent) : FilterPropertyProxy(2, parent) {} -Qt::ItemFlags ParameterTuningModel::flags(const QModelIndex& proxyIndex) const -{ +Qt::ItemFlags ParameterTuningModel::flags(const QModelIndex& proxyIndex) const { Qt::ItemFlags result = Qt::ItemIsSelectable | Qt::ItemIsEnabled; QModelIndex sourceIndex = toSourceIndex(proxyIndex); @@ -36,8 +35,7 @@ Qt::ItemFlags ParameterTuningModel::flags(const QModelIndex& proxyIndex) const return result; } -QMimeData* ParameterTuningModel::mimeData(const QModelIndexList& proxyIndexes) const -{ +QMimeData* ParameterTuningModel::mimeData(const QModelIndexList& proxyIndexes) const { QMimeData* mimeData = new QMimeData(); for (auto proxyIndex : proxyIndexes) { @@ -52,8 +50,7 @@ QMimeData* ParameterTuningModel::mimeData(const QModelIndexList& proxyIndexes) c //! Returns ParameterItem from given proxy index -ParameterItem* ParameterTuningModel::getParameterItem(const QModelIndex& proxyIndex) const -{ +ParameterItem* ParameterTuningModel::getParameterItem(const QModelIndex& proxyIndex) const { SessionModel* sessionModel = dynamic_cast<SessionModel*>(sourceModel()); ASSERT(sessionModel); diff --git a/GUI/coregui/Models/ParameterTuningModel.h b/GUI/coregui/Models/ParameterTuningModel.h index f543bd06326c70dc91a80de57fb4e8b9bab42ca2..7e8acbf9407c500dc3bf84d3568bef301933dd4c 100644 --- a/GUI/coregui/Models/ParameterTuningModel.h +++ b/GUI/coregui/Models/ParameterTuningModel.h @@ -25,8 +25,7 @@ class ParameterItem; //! to the FitParametersWidget. //! -class ParameterTuningModel : public FilterPropertyProxy -{ +class ParameterTuningModel : public FilterPropertyProxy { Q_OBJECT public: @@ -40,13 +39,11 @@ public: ParameterItem* getParameterItem(const QModelIndex& proxyIndex) const; }; -inline Qt::DropActions ParameterTuningModel::supportedDragActions() const -{ +inline Qt::DropActions ParameterTuningModel::supportedDragActions() const { return Qt::CopyAction; } -inline Qt::DropActions ParameterTuningModel::supportedDropActions() const -{ +inline Qt::DropActions ParameterTuningModel::supportedDropActions() const { return Qt::IgnoreAction; } diff --git a/GUI/coregui/Models/ParticleCompositionItem.cpp b/GUI/coregui/Models/ParticleCompositionItem.cpp index 531d37a08c559ef57a6ea30adf64a0a4879e4d9d..ab5ec0ec1f2d94d93f3afa1b92ea2964f9db8bcd 100644 --- a/GUI/coregui/Models/ParticleCompositionItem.cpp +++ b/GUI/coregui/Models/ParticleCompositionItem.cpp @@ -23,8 +23,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/Particle/ParticleCoreShell.h" -namespace -{ +namespace { const QString abundance_tooltip = "Proportion of this type of particles normalized to the \n" "total number of particles in the layout"; @@ -36,8 +35,7 @@ const QString ParticleCompositionItem::T_PARTICLES = "Particle Tag"; // TODO make ParticleCoreShellItem and ParticleItem to derive from common base. -ParticleCompositionItem::ParticleCompositionItem() : SessionGraphicsItem("ParticleComposition") -{ +ParticleCompositionItem::ParticleCompositionItem() : SessionGraphicsItem("ParticleComposition") { setToolTip("Composition of particles with fixed positions"); addProperty(ParticleItem::P_ABUNDANCE, 1.0) @@ -68,8 +66,7 @@ ParticleCompositionItem::ParticleCompositionItem() : SessionGraphicsItem("Partic }); } -std::unique_ptr<ParticleComposition> ParticleCompositionItem::createParticleComposition() const -{ +std::unique_ptr<ParticleComposition> ParticleCompositionItem::createParticleComposition() const { double abundance = getItemValue(ParticleItem::P_ABUNDANCE).toDouble(); auto P_composition = std::make_unique<ParticleComposition>(); P_composition->setAbundance(abundance); diff --git a/GUI/coregui/Models/ParticleCompositionItem.h b/GUI/coregui/Models/ParticleCompositionItem.h index 9862c1396e9eaebb5e816b9a26990e6d24aa2732..d561decbea1e87af51d21b22881941c805c33f2b 100644 --- a/GUI/coregui/Models/ParticleCompositionItem.h +++ b/GUI/coregui/Models/ParticleCompositionItem.h @@ -18,8 +18,7 @@ #include "GUI/coregui/Models/SessionGraphicsItem.h" #include "Sample/Particle/ParticleComposition.h" -class BA_CORE_API_ ParticleCompositionItem : public SessionGraphicsItem -{ +class BA_CORE_API_ ParticleCompositionItem : public SessionGraphicsItem { public: static const QString T_PARTICLES; ParticleCompositionItem(); diff --git a/GUI/coregui/Models/ParticleCoreShellItem.cpp b/GUI/coregui/Models/ParticleCoreShellItem.cpp index 78fa2242656bbc8c5b18ef9b2ed36d4f6ac254fa..055b6864ea668a2aa3ca26ea87036636f7dfd0c6 100644 --- a/GUI/coregui/Models/ParticleCoreShellItem.cpp +++ b/GUI/coregui/Models/ParticleCoreShellItem.cpp @@ -21,8 +21,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/Particle/ParticleCoreShell.h" -namespace -{ +namespace { const QString abundance_tooltip = "Proportion of this type of particles normalized to the \n" "total number of particles in the layout"; @@ -36,8 +35,7 @@ const QString ParticleCoreShellItem::T_SHELL = "Shell tag"; // TODO make ParticleCoreShellItem and ParticleItem to derive from common base. -ParticleCoreShellItem::ParticleCoreShellItem() : SessionGraphicsItem("ParticleCoreShell") -{ +ParticleCoreShellItem::ParticleCoreShellItem() : SessionGraphicsItem("ParticleCoreShell") { setToolTip("A particle with a core/shell geometry"); addProperty(ParticleItem::P_ABUNDANCE, 1.0) @@ -64,8 +62,7 @@ ParticleCoreShellItem::ParticleCoreShellItem() : SessionGraphicsItem("ParticleCo }); } -std::unique_ptr<ParticleCoreShell> ParticleCoreShellItem::createParticleCoreShell() const -{ +std::unique_ptr<ParticleCoreShell> ParticleCoreShellItem::createParticleCoreShell() const { double abundance = getItemValue(ParticleItem::P_ABUNDANCE).toDouble(); std::unique_ptr<Particle> P_core{}; std::unique_ptr<Particle> P_shell{}; @@ -84,8 +81,7 @@ std::unique_ptr<ParticleCoreShell> ParticleCoreShellItem::createParticleCoreShel return P_coreshell; } -QVector<SessionItem*> ParticleCoreShellItem::materialPropertyItems() -{ +QVector<SessionItem*> ParticleCoreShellItem::materialPropertyItems() { QVector<SessionItem*> result; if (auto core = static_cast<ParticleItem*>(getItem(T_CORE))) result.append(core->materialPropertyItems()); diff --git a/GUI/coregui/Models/ParticleCoreShellItem.h b/GUI/coregui/Models/ParticleCoreShellItem.h index 35559930a665aba55cf67b9d7e89d9aa22c20492..300715c687502289e8a40dbb31a3d4c7af77b7e3 100644 --- a/GUI/coregui/Models/ParticleCoreShellItem.h +++ b/GUI/coregui/Models/ParticleCoreShellItem.h @@ -19,8 +19,7 @@ class ParticleCoreShell; -class BA_CORE_API_ ParticleCoreShellItem : public SessionGraphicsItem -{ +class BA_CORE_API_ ParticleCoreShellItem : public SessionGraphicsItem { public: static const QString T_CORE; static const QString T_SHELL; diff --git a/GUI/coregui/Models/ParticleDistributionItem.cpp b/GUI/coregui/Models/ParticleDistributionItem.cpp index ff1bcf7915444b870ba09f5948fbf70fe9a80980..2a1c0b9db339ced77137f571e054117dfa344c4f 100644 --- a/GUI/coregui/Models/ParticleDistributionItem.cpp +++ b/GUI/coregui/Models/ParticleDistributionItem.cpp @@ -24,8 +24,7 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include "Param/Varia/ParameterUtils.h" -namespace -{ +namespace { const QString abundance_tooltip = "Proportion of this type of particles normalized to the \n" "total number of particles in the layout"; } @@ -36,8 +35,7 @@ const QString ParticleDistributionItem::P_DISTRIBUTION = "Distribution"; const QString ParticleDistributionItem::NO_SELECTION = "None"; const QString ParticleDistributionItem::T_PARTICLES = "Particle Tag"; -ParticleDistributionItem::ParticleDistributionItem() : SessionGraphicsItem("ParticleDistribution") -{ +ParticleDistributionItem::ParticleDistributionItem() : SessionGraphicsItem("ParticleDistribution") { setToolTip("Collection of particles obtained via parametric distribution " "of particle prototype"); @@ -78,8 +76,7 @@ ParticleDistributionItem::ParticleDistributionItem() : SessionGraphicsItem("Part }); } -std::unique_ptr<ParticleDistribution> ParticleDistributionItem::createParticleDistribution() const -{ +std::unique_ptr<ParticleDistribution> ParticleDistributionItem::createParticleDistribution() const { if (children().empty()) return nullptr; std::unique_ptr<IParticle> P_particle = TransformToDomain::createIParticle(*getItem()); @@ -115,14 +112,12 @@ std::unique_ptr<ParticleDistribution> ParticleDistributionItem::createParticleDi return result; } -void ParticleDistributionItem::setDomainCacheNames(const QString& name, const QStringList& linked) -{ +void ParticleDistributionItem::setDomainCacheNames(const QString& name, const QStringList& linked) { m_domain_cache_name = name; m_linked_names = linked; } -void ParticleDistributionItem::updateMainParameterList() -{ +void ParticleDistributionItem::updateMainParameterList() { if (!isTag(P_DISTRIBUTED_PARAMETER)) return; @@ -145,8 +140,7 @@ void ParticleDistributionItem::updateMainParameterList() setItemValue(P_DISTRIBUTED_PARAMETER, newProp.variant()); } -void ParticleDistributionItem::updateLinkedParameterList() -{ +void ParticleDistributionItem::updateLinkedParameterList() { if (!isTag(P_LINKED_PARAMETER) || !isTag(P_DISTRIBUTED_PARAMETER)) return; @@ -178,8 +172,7 @@ void ParticleDistributionItem::updateLinkedParameterList() setItemValue(P_LINKED_PARAMETER, newProp.variant()); } -QStringList ParticleDistributionItem::childParameterNames() const -{ +QStringList ParticleDistributionItem::childParameterNames() const { if (auto child = childParticle()) { auto result = ParameterTreeUtils::parameterTreeNames(child); result.removeAll(ParticleItem::P_ABUNDANCE); @@ -189,15 +182,13 @@ QStringList ParticleDistributionItem::childParameterNames() const return {}; } -QString ParticleDistributionItem::translateParameterNameToGUI(const QString& domainName) -{ +QString ParticleDistributionItem::translateParameterNameToGUI(const QString& domainName) { if (auto child = childParticle()) return ParameterTreeUtils::domainNameToParameterName(domainName, child); return {}; } -const SessionItem* ParticleDistributionItem::childParticle() const -{ +const SessionItem* ParticleDistributionItem::childParticle() const { if (getItems(T_PARTICLES).empty()) return nullptr; @@ -205,14 +196,12 @@ const SessionItem* ParticleDistributionItem::childParticle() const return getItems(T_PARTICLES).front(); } -std::string ParticleDistributionItem::domainMainParameter() const -{ +std::string ParticleDistributionItem::domainMainParameter() const { auto par_name = getItemValue(P_DISTRIBUTED_PARAMETER).value<ComboProperty>().getValue(); return ParameterTreeUtils::parameterNameToDomainName(par_name, childParticle()).toStdString(); } -std::vector<std::string> ParticleDistributionItem::domainLinkedParameters() const -{ +std::vector<std::string> ParticleDistributionItem::domainLinkedParameters() const { std::vector<std::string> result; auto linked_names = getItemValue(P_LINKED_PARAMETER).value<ComboProperty>().selectedValues(); for (auto name : linked_names) { diff --git a/GUI/coregui/Models/ParticleDistributionItem.h b/GUI/coregui/Models/ParticleDistributionItem.h index 8245e1e1e9c920e0058cbdfb14c8b52799515405..f0c167257d2fcaa77ada784bef09316b19cd6e13 100644 --- a/GUI/coregui/Models/ParticleDistributionItem.h +++ b/GUI/coregui/Models/ParticleDistributionItem.h @@ -20,8 +20,7 @@ #include <string> #include <vector> -class BA_CORE_API_ ParticleDistributionItem : public SessionGraphicsItem -{ +class BA_CORE_API_ ParticleDistributionItem : public SessionGraphicsItem { public: static const QString P_DISTRIBUTED_PARAMETER; static const QString P_LINKED_PARAMETER; diff --git a/GUI/coregui/Models/ParticleItem.cpp b/GUI/coregui/Models/ParticleItem.cpp index 49011f7a5f04922f44cccc073747cc010d9f4f57..c814148595bbd614017ba72bf5e05a8d7b0769fc 100644 --- a/GUI/coregui/Models/ParticleItem.cpp +++ b/GUI/coregui/Models/ParticleItem.cpp @@ -26,8 +26,7 @@ using SessionItemUtils::SetVectorItem; -namespace -{ +namespace { const QString abundance_tooltip = "Proportion of this type of particles normalized to the \n" "total number of particles in the layout"; @@ -42,8 +41,7 @@ const QString ParticleItem::P_MATERIAL = "Material"; const QString ParticleItem::P_POSITION = "Position Offset"; const QString ParticleItem::T_TRANSFORMATION = "Transformation Tag"; -ParticleItem::ParticleItem() : SessionGraphicsItem("Particle") -{ +ParticleItem::ParticleItem() : SessionGraphicsItem("Particle") { addGroupProperty(P_FORM_FACTOR, "Form Factor"); addProperty(P_MATERIAL, MaterialItemUtils::defaultMaterialProperty().variant()) ->setToolTip("Material of particle") @@ -65,8 +63,7 @@ ParticleItem::ParticleItem() : SessionGraphicsItem("Particle") [this](SessionItem* newParent) { updatePropertiesAppearance(newParent); }); } -std::unique_ptr<Particle> ParticleItem::createParticle() const -{ +std::unique_ptr<Particle> ParticleItem::createParticle() const { auto& ffItem = groupItem<FormFactorItem>(ParticleItem::P_FORM_FACTOR); auto material = TransformToDomain::createDomainMaterial(*this); double abundance = getItemValue(ParticleItem::P_ABUNDANCE).toDouble(); @@ -79,8 +76,7 @@ std::unique_ptr<Particle> ParticleItem::createParticle() const return particle; } -QVector<SessionItem*> ParticleItem::materialPropertyItems() -{ +QVector<SessionItem*> ParticleItem::materialPropertyItems() { auto item = getItem(P_MATERIAL); if (!item) return {}; @@ -89,8 +85,7 @@ QVector<SessionItem*> ParticleItem::materialPropertyItems() //! Updates enabled/disabled for particle position and particle abundance depending on context. -void ParticleItem::updatePropertiesAppearance(SessionItem* newParent) -{ +void ParticleItem::updatePropertiesAppearance(SessionItem* newParent) { if (SessionItemUtils::HasOwnAbundance(newParent)) { setItemValue(ParticleItem::P_ABUNDANCE, 1.0); getItem(ParticleItem::P_ABUNDANCE)->setEnabled(false); @@ -108,8 +103,7 @@ void ParticleItem::updatePropertiesAppearance(SessionItem* newParent) //! Returns true if this particle is a shell particle. -bool ParticleItem::isShellParticle() const -{ +bool ParticleItem::isShellParticle() const { if (!parent()) return false; @@ -119,8 +113,7 @@ bool ParticleItem::isShellParticle() const //! Returns true if this particle is directly connected to a ParticleLayout -bool ParticleItem::parentIsParticleLayout() const -{ +bool ParticleItem::parentIsParticleLayout() const { if (!parent()) return false; diff --git a/GUI/coregui/Models/ParticleItem.h b/GUI/coregui/Models/ParticleItem.h index f9e35184100f683bc728d2ae5b88acf34064efa5..70328f3034fbf7de0728b964c1b568a86754f23a 100644 --- a/GUI/coregui/Models/ParticleItem.h +++ b/GUI/coregui/Models/ParticleItem.h @@ -19,8 +19,7 @@ class Particle; -class BA_CORE_API_ ParticleItem : public SessionGraphicsItem -{ +class BA_CORE_API_ ParticleItem : public SessionGraphicsItem { public: static const QString P_FORM_FACTOR; static const QString P_ABUNDANCE; diff --git a/GUI/coregui/Models/ParticleLayoutItem.cpp b/GUI/coregui/Models/ParticleLayoutItem.cpp index 877ee38397950fa305dc8880c7c2f3a4a9c3d6e8..90f85f2e03993a80d0874d9259eea19c156262d8 100644 --- a/GUI/coregui/Models/ParticleLayoutItem.cpp +++ b/GUI/coregui/Models/ParticleLayoutItem.cpp @@ -18,12 +18,10 @@ #include "GUI/coregui/Models/Lattice2DItems.h" #include <QDebug> -namespace -{ +namespace { //! Returns true if name is related to 2D interference functions. -bool isInterference2D(const QString& name) -{ +bool isInterference2D(const QString& name) { if (name == "Interference2DLattice" || name == "Interference2DParaCrystal" || name == "InterferenceFinite2DLattice" || name == "InterferenceHardDisk") return true; @@ -31,8 +29,7 @@ bool isInterference2D(const QString& name) } //! Returns true if name is related to 2D interference functions. -bool isLattice2D(SessionItem* item) -{ +bool isLattice2D(SessionItem* item) { return dynamic_cast<Lattice2DItem*>(item); } @@ -49,8 +46,7 @@ const QString ParticleLayoutItem::P_WEIGHT = QString::fromStdString("Weight"); const QString ParticleLayoutItem::T_PARTICLES = "Particle Tag"; const QString ParticleLayoutItem::T_INTERFERENCE = "Interference Tag"; -ParticleLayoutItem::ParticleLayoutItem() : SessionGraphicsItem("ParticleLayout") -{ +ParticleLayoutItem::ParticleLayoutItem() : SessionGraphicsItem("ParticleLayout") { setToolTip("A layout of particles"); addProperty(P_TOTAL_DENSITY, 0.01)->setToolTip(density_tooltip); @@ -87,8 +83,7 @@ ParticleLayoutItem::ParticleLayoutItem() : SessionGraphicsItem("ParticleLayout") //! Two dimensional interference calculates density automatically, so property should //! be disabled. -void ParticleLayoutItem::updateDensityAppearance() -{ +void ParticleLayoutItem::updateDensityAppearance() { getItem(P_TOTAL_DENSITY)->setEnabled(true); if (auto interferenceItem = getItem(T_INTERFERENCE)) if (isInterference2D(interferenceItem->modelType())) @@ -97,8 +92,7 @@ void ParticleLayoutItem::updateDensityAppearance() //! Updates the value of TotalSurfaceDensity on lattice type change. -void ParticleLayoutItem::updateDensityValue() -{ +void ParticleLayoutItem::updateDensityValue() { if (auto interferenceItem = getItem(T_INTERFERENCE)) { if (interferenceItem->isTag(InterferenceFunction2DLatticeItem::P_LATTICE_TYPE)) { auto& latticeItem = interferenceItem->groupItem<Lattice2DItem>( diff --git a/GUI/coregui/Models/ParticleLayoutItem.h b/GUI/coregui/Models/ParticleLayoutItem.h index e46899efe6ce539e0065ea16911e9318bf792ff0..c75f85484860377ce4dfc6c0d369f17caca5d491 100644 --- a/GUI/coregui/Models/ParticleLayoutItem.h +++ b/GUI/coregui/Models/ParticleLayoutItem.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/SessionGraphicsItem.h" -class BA_CORE_API_ ParticleLayoutItem : public SessionGraphicsItem -{ +class BA_CORE_API_ ParticleLayoutItem : public SessionGraphicsItem { public: static const QString P_TOTAL_DENSITY; static const QString P_WEIGHT; diff --git a/GUI/coregui/Models/PointwiseAxisItem.cpp b/GUI/coregui/Models/PointwiseAxisItem.cpp index f94c32c141928666b743efba537bdd3c6cbce7b8..3f48b910dad6353425cf93fe73255a6b866c8902 100644 --- a/GUI/coregui/Models/PointwiseAxisItem.cpp +++ b/GUI/coregui/Models/PointwiseAxisItem.cpp @@ -19,16 +19,14 @@ #include "Device/Unit/IUnitConverter.h" #include "GUI/coregui/Models/InstrumentItems.h" -namespace -{ +namespace { std::unique_ptr<OutputData<double>> makeOutputData(const IAxis& axis); } const QString PointwiseAxisItem::P_NATIVE_AXIS_UNITS = "NativeAxisUnits"; const QString PointwiseAxisItem::P_FILE_NAME = "FileName"; -PointwiseAxisItem::PointwiseAxisItem() : BasicAxisItem("PointwiseAxis"), m_instrument(nullptr) -{ +PointwiseAxisItem::PointwiseAxisItem() : BasicAxisItem("PointwiseAxis"), m_instrument(nullptr) { getItem(P_MIN_DEG)->setEnabled(false); getItem(P_NBINS)->setEnabled(false); getItem(P_MAX_DEG)->setEnabled(false); @@ -44,26 +42,22 @@ PointwiseAxisItem::PointwiseAxisItem() : BasicAxisItem("PointwiseAxis"), m_instr PointwiseAxisItem::~PointwiseAxisItem() = default; -void PointwiseAxisItem::init(const IAxis& axis, const QString& units_label) -{ +void PointwiseAxisItem::init(const IAxis& axis, const QString& units_label) { setLastModified(QDateTime::currentDateTime()); m_axis = std::unique_ptr<IAxis>(axis.clone()); setItemValue(P_NATIVE_AXIS_UNITS, units_label); findInstrument(); } -const IAxis* PointwiseAxisItem::axis() const -{ +const IAxis* PointwiseAxisItem::axis() const { return m_axis.get(); } -const QString PointwiseAxisItem::getUnitsLabel() const -{ +const QString PointwiseAxisItem::getUnitsLabel() const { return getItemValue(P_NATIVE_AXIS_UNITS).toString(); } -std::unique_ptr<IAxis> PointwiseAxisItem::createAxis(double scale) const -{ +std::unique_ptr<IAxis> PointwiseAxisItem::createAxis(double scale) const { if (!checkValidity()) return nullptr; @@ -77,8 +71,7 @@ std::unique_ptr<IAxis> PointwiseAxisItem::createAxis(double scale) const return std::make_unique<PointwiseAxis>(converted_axis->getName(), std::move(centers)); } -bool PointwiseAxisItem::load(const QString& projectDir) -{ +bool PointwiseAxisItem::load(const QString& projectDir) { QString filename = SaveLoadInterface::fileName(projectDir); auto data = IntensityDataIOFactory::readOutputData(filename.toStdString()); if (!data) @@ -90,8 +83,7 @@ bool PointwiseAxisItem::load(const QString& projectDir) return true; } -bool PointwiseAxisItem::save(const QString& projectDir) -{ +bool PointwiseAxisItem::save(const QString& projectDir) { if (!containsNonXMLData()) return false; @@ -100,41 +92,34 @@ bool PointwiseAxisItem::save(const QString& projectDir) return true; } -bool PointwiseAxisItem::containsNonXMLData() const -{ +bool PointwiseAxisItem::containsNonXMLData() const { return static_cast<bool>(m_axis); } -QDateTime PointwiseAxisItem::lastModified() const -{ +QDateTime PointwiseAxisItem::lastModified() const { return m_last_modified; } -QString PointwiseAxisItem::fileName() const -{ +QString PointwiseAxisItem::fileName() const { return getItemValue(PointwiseAxisItem::P_FILE_NAME).toString(); } -void PointwiseAxisItem::setLastModified(const QDateTime& dtime) -{ +void PointwiseAxisItem::setLastModified(const QDateTime& dtime) { m_last_modified = dtime; } -bool PointwiseAxisItem::checkValidity() const -{ +bool PointwiseAxisItem::checkValidity() const { return m_axis && m_instrument && getUnitsLabel() != "nbins"; } -void PointwiseAxisItem::findInstrument() -{ +void PointwiseAxisItem::findInstrument() { SessionItem* parent_item = parent(); while (parent_item && parent_item->modelType() != "SpecularInstrument") parent_item = parent_item->parent(); m_instrument = static_cast<SpecularInstrumentItem*>(parent_item); } -void PointwiseAxisItem::updateIndicators() -{ +void PointwiseAxisItem::updateIndicators() { if (!checkValidity()) return; @@ -146,10 +131,8 @@ void PointwiseAxisItem::updateIndicators() emitDataChanged(); } -namespace -{ -std::unique_ptr<OutputData<double>> makeOutputData(const IAxis& axis) -{ +namespace { +std::unique_ptr<OutputData<double>> makeOutputData(const IAxis& axis) { std::unique_ptr<OutputData<double>> result(new OutputData<double>); result->addAxis(axis); return result; diff --git a/GUI/coregui/Models/PointwiseAxisItem.h b/GUI/coregui/Models/PointwiseAxisItem.h index 7e818a562510568d66e47c5e60986c0dbe36073f..07197af6f36cb9d5e690181e493b44f29fa96289 100644 --- a/GUI/coregui/Models/PointwiseAxisItem.h +++ b/GUI/coregui/Models/PointwiseAxisItem.h @@ -22,8 +22,7 @@ class PointwiseAxis; class SpecularInstrumentItem; //! Item for non-uniform axis with specified coordinates. -class BA_CORE_API_ PointwiseAxisItem : public BasicAxisItem, public SaveLoadInterface -{ +class BA_CORE_API_ PointwiseAxisItem : public BasicAxisItem, public SaveLoadInterface { static const QString P_NATIVE_AXIS_UNITS; public: diff --git a/GUI/coregui/Models/ProjectionItems.cpp b/GUI/coregui/Models/ProjectionItems.cpp index c76885a2eea0cc89860286112ac212dc6d5e48c4..da1da329f1337450ba3b7995519a989b066380b8 100644 --- a/GUI/coregui/Models/ProjectionItems.cpp +++ b/GUI/coregui/Models/ProjectionItems.cpp @@ -14,8 +14,7 @@ #include "GUI/coregui/Models/ProjectionItems.h" -ProjectionContainerItem::ProjectionContainerItem() : SessionItem("ProjectionContainer") -{ +ProjectionContainerItem::ProjectionContainerItem() : SessionItem("ProjectionContainer") { const QString T_CHILDREN = "children tag"; registerTag(T_CHILDREN, 0, -1, QStringList() << "HorizontalLineMask" diff --git a/GUI/coregui/Models/ProjectionItems.h b/GUI/coregui/Models/ProjectionItems.h index 8cc94fe708ecf1a851a15ce4b5d7b13ec0f38e18..a1a78c96b1b0f4ec668d5fa36ba58a2c64358407 100644 --- a/GUI/coregui/Models/ProjectionItems.h +++ b/GUI/coregui/Models/ProjectionItems.h @@ -19,8 +19,7 @@ //! A container to hold ProjectionItems, intended to store projections of color map on X, Y axes. -class ProjectionContainerItem : public SessionItem -{ +class ProjectionContainerItem : public SessionItem { public: ProjectionContainerItem(); }; diff --git a/GUI/coregui/Models/PropertyItem.h b/GUI/coregui/Models/PropertyItem.h index bf644c35999b2116a3e0b654ded1fdb3bd35f95b..77843d7f592bcf93d4525fdcadce7588f4e9e83c 100644 --- a/GUI/coregui/Models/PropertyItem.h +++ b/GUI/coregui/Models/PropertyItem.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/SessionItem.h" -class PropertyItem : public SessionItem -{ +class PropertyItem : public SessionItem { public: PropertyItem(); diff --git a/GUI/coregui/Models/ProxyModelStrategy.cpp b/GUI/coregui/Models/ProxyModelStrategy.cpp index 46e362fc618195f8c774dad06fca4674a7180e51..2f53bee2d2c033d1e7ecc0017b2569f036343665 100644 --- a/GUI/coregui/Models/ProxyModelStrategy.cpp +++ b/GUI/coregui/Models/ProxyModelStrategy.cpp @@ -18,8 +18,7 @@ ProxyModelStrategy::ProxyModelStrategy() : m_source(nullptr), m_proxy(nullptr) {} -void ProxyModelStrategy::buildModelMap(SessionModel* source, ComponentProxyModel* proxy) -{ +void ProxyModelStrategy::buildModelMap(SessionModel* source, ComponentProxyModel* proxy) { m_sourceToProxy.clear(); m_proxySourceParent.clear(); m_source = source; @@ -34,41 +33,35 @@ void ProxyModelStrategy::buildModelMap(SessionModel* source, ComponentProxyModel processSourceIndex(m_sourceRootIndex.sibling(m_sourceRootIndex.row(), 1)); } -void ProxyModelStrategy::onDataChanged(SessionModel* source, ComponentProxyModel* proxy) -{ +void ProxyModelStrategy::onDataChanged(SessionModel* source, ComponentProxyModel* proxy) { Q_UNUSED(source); Q_UNUSED(proxy); // we do not expect here change of model layout } -const ProxyModelStrategy::map_t& ProxyModelStrategy::sourceToProxy() -{ +const ProxyModelStrategy::map_t& ProxyModelStrategy::sourceToProxy() { return m_sourceToProxy; } -const ProxyModelStrategy::map_t& ProxyModelStrategy::proxySourceParent() -{ +const ProxyModelStrategy::map_t& ProxyModelStrategy::proxySourceParent() { return m_proxySourceParent; } -void ProxyModelStrategy::setRootIndex(const QModelIndex& sourceRootIndex) -{ +void ProxyModelStrategy::setRootIndex(const QModelIndex& sourceRootIndex) { m_sourceRootIndex = QPersistentModelIndex(sourceRootIndex); } //! Method to ask proxy to create an index using friendship of ProxyModelStrategy //! and ComponentProxyModel. -QModelIndex ProxyModelStrategy::createProxyIndex(int nrow, int ncol, void* adata) -{ +QModelIndex ProxyModelStrategy::createProxyIndex(int nrow, int ncol, void* adata) { ASSERT(m_proxy); return m_proxy->createIndex(nrow, ncol, adata); } //! Builds one-to-one mapping for source and proxy. -bool IndentityProxyStrategy::processSourceIndex(const QModelIndex& index) -{ +bool IndentityProxyStrategy::processSourceIndex(const QModelIndex& index) { QPersistentModelIndex proxyIndex = createProxyIndex(index.row(), index.column(), index.internalPointer()); m_sourceToProxy.insert(QPersistentModelIndex(index), proxyIndex); diff --git a/GUI/coregui/Models/ProxyModelStrategy.h b/GUI/coregui/Models/ProxyModelStrategy.h index 15cca3db32228ed0283b6a1914596b91bbbdbfbb..e9775ecf50f3895e6230493bc164a222cf17f702 100644 --- a/GUI/coregui/Models/ProxyModelStrategy.h +++ b/GUI/coregui/Models/ProxyModelStrategy.h @@ -23,8 +23,7 @@ class SessionItem; //! Base class for proxy strategies in ComponentProxyModel. -class ProxyModelStrategy -{ +class ProxyModelStrategy { public: using map_t = QMap<QPersistentModelIndex, QPersistentModelIndex>; @@ -55,8 +54,7 @@ protected: //! Strategy for ComponentProxyModel which makes it identical to source model. -class IndentityProxyStrategy : public ProxyModelStrategy -{ +class IndentityProxyStrategy : public ProxyModelStrategy { protected: bool processSourceIndex(const QModelIndex& index); }; diff --git a/GUI/coregui/Models/RealDataItem.cpp b/GUI/coregui/Models/RealDataItem.cpp index 3c360286f4f01511e85b2f92a8fca1756bf67077..65041518756918af10311a0db057643039597c63 100644 --- a/GUI/coregui/Models/RealDataItem.cpp +++ b/GUI/coregui/Models/RealDataItem.cpp @@ -28,8 +28,7 @@ const QString RealDataItem::T_INTENSITY_DATA = "Intensity data"; const QString RealDataItem::T_NATIVE_DATA = "Native user data axis"; const QString RealDataItem::P_NATIVE_DATA_UNITS = "Native user data units"; -RealDataItem::RealDataItem() : SessionItem("RealData"), m_linkedInstrument(nullptr) -{ +RealDataItem::RealDataItem() : SessionItem("RealData"), m_linkedInstrument(nullptr) { setItemName("undefined"); // Registering this tag even without actual data item to avoid troubles in copying RealDataItem @@ -67,41 +66,34 @@ RealDataItem::RealDataItem() : SessionItem("RealData"), m_linkedInstrument(nullp }); } -IntensityDataItem* RealDataItem::intensityDataItem() -{ +IntensityDataItem* RealDataItem::intensityDataItem() { return const_cast<IntensityDataItem*>( static_cast<const RealDataItem*>(this)->intensityDataItem()); } -const IntensityDataItem* RealDataItem::intensityDataItem() const -{ +const IntensityDataItem* RealDataItem::intensityDataItem() const { return dynamic_cast<const IntensityDataItem*>(dataItem()); } -DataItem* RealDataItem::dataItem() -{ +DataItem* RealDataItem::dataItem() { return const_cast<DataItem*>(static_cast<const RealDataItem*>(this)->dataItem()); } -const DataItem* RealDataItem::dataItem() const -{ +const DataItem* RealDataItem::dataItem() const { return dynamic_cast<const DataItem*>(getItem(T_INTENSITY_DATA)); } -DataItem* RealDataItem::nativeData() -{ +DataItem* RealDataItem::nativeData() { return const_cast<DataItem*>(static_cast<const RealDataItem*>(this)->nativeData()); } -const DataItem* RealDataItem::nativeData() const -{ +const DataItem* RealDataItem::nativeData() const { return dynamic_cast<const DataItem*>(getItem(T_NATIVE_DATA)); } //! Sets OutputData to underlying item. Creates it, if not exists. -void RealDataItem::setOutputData(OutputData<double>* data) -{ +void RealDataItem::setOutputData(OutputData<double>* data) { ASSERT(data && "Assertion failed in RealDataItem::setOutputData: passed data is nullptr"); ASSERT(data->rank() < 3 && data->rank() > 0); @@ -120,8 +112,7 @@ void RealDataItem::setOutputData(OutputData<double>* data) dataItem()->setOutputData(data); } -void RealDataItem::initDataItem(size_t data_rank, const QString& tag) -{ +void RealDataItem::initDataItem(size_t data_rank, const QString& tag) { ASSERT(data_rank <= 2 && data_rank > 0); const QString& target_model_type = data_rank == 2 ? "IntensityData" : "SpecularData"; auto data_item = getItem(tag); @@ -132,8 +123,7 @@ void RealDataItem::initDataItem(size_t data_rank, const QString& tag) this->model()->insertNewItem(target_model_type, this->index(), 0, tag); } -void RealDataItem::setImportData(ImportDataInfo data) -{ +void RealDataItem::setImportData(ImportDataInfo data) { if (!data) return; @@ -149,20 +139,17 @@ void RealDataItem::setImportData(ImportDataInfo data) item<DataItem>(T_NATIVE_DATA).setOutputData(output_data.release()); } -bool RealDataItem::holdsDimensionalData() const -{ +bool RealDataItem::holdsDimensionalData() const { return getItemValue(P_NATIVE_DATA_UNITS).toString() != "nbins"; } -void RealDataItem::linkToInstrument(const InstrumentItem* instrument, bool make_update) -{ +void RealDataItem::linkToInstrument(const InstrumentItem* instrument, bool make_update) { m_linkedInstrument = instrument; if (make_update) updateToInstrument(); } -std::vector<int> RealDataItem::shape() const -{ +std::vector<int> RealDataItem::shape() const { auto data_item = dataItem(); if (!data_item) { ASSERT(data_item); @@ -171,13 +158,11 @@ std::vector<int> RealDataItem::shape() const return data_item->shape(); } -QString RealDataItem::underlyingDataModel() -{ +QString RealDataItem::underlyingDataModel() { return dataItem()->modelType(); } -MaskContainerItem* RealDataItem::maskContainerItem() -{ +MaskContainerItem* RealDataItem::maskContainerItem() { if (auto intensity_data = intensityDataItem()) return intensity_data->maskContainerItem(); return nullptr; @@ -185,16 +170,14 @@ MaskContainerItem* RealDataItem::maskContainerItem() //! Updates the name of file to store intensity data. -void RealDataItem::updateNonXMLDataFileNames() -{ +void RealDataItem::updateNonXMLDataFileNames() { if (DataItem* item = dataItem()) item->setItemValue(DataItem::P_FILE_NAME, ItemFileNameUtils::realDataFileName(*this)); if (DataItem* item = nativeData()) item->setItemValue(DataItem::P_FILE_NAME, ItemFileNameUtils::nativeDataFileName(*this)); } -void RealDataItem::updateToInstrument() -{ +void RealDataItem::updateToInstrument() { DataItem* data_item = dataItem(); if (!data_item) return; diff --git a/GUI/coregui/Models/RealDataItem.h b/GUI/coregui/Models/RealDataItem.h index 353cb96c73e11b7b65c69f50613e7cb3992e4062..8baef18842fc99178d68e1379368356d1f2c0576 100644 --- a/GUI/coregui/Models/RealDataItem.h +++ b/GUI/coregui/Models/RealDataItem.h @@ -26,8 +26,7 @@ class ImportDataInfo; //! The RealDataItem class represents intensity data imported from file and intended for fitting. -class BA_CORE_API_ RealDataItem : public SessionItem -{ +class BA_CORE_API_ RealDataItem : public SessionItem { public: static const QString T_INTENSITY_DATA; static const QString P_INSTRUMENT_ID; diff --git a/GUI/coregui/Models/RealDataModel.cpp b/GUI/coregui/Models/RealDataModel.cpp index 448fb402b85bbbd6625797eda4cb37b5ef68f1e4..8cb84fe80615a240d1889c9c437f739c68962837 100644 --- a/GUI/coregui/Models/RealDataModel.cpp +++ b/GUI/coregui/Models/RealDataModel.cpp @@ -16,8 +16,7 @@ #include "GUI/coregui/Models/DataItem.h" #include "GUI/coregui/Models/RealDataItem.h" -RealDataModel::RealDataModel(QObject* parent) : SessionModel(SessionXML::RealDataModelTag, parent) -{ +RealDataModel::RealDataModel(QObject* parent) : SessionModel(SessionXML::RealDataModelTag, parent) { setObjectName(SessionXML::RealDataModelTag); } @@ -28,8 +27,7 @@ RealDataModel::RealDataModel(QObject* parent) : SessionModel(SessionXML::RealDat // return result_flags; //} -QVector<SessionItem*> RealDataModel::nonXMLData() const -{ +QVector<SessionItem*> RealDataModel::nonXMLData() const { QVector<SessionItem*> result; for (auto realData : topItems<RealDataItem>()) { diff --git a/GUI/coregui/Models/RealDataModel.h b/GUI/coregui/Models/RealDataModel.h index db6c0e4cb2f59220aa3b2aae00d1a5c67553e8a9..e04db8f98f63fbb483764f9225c5ec0c58644afe 100644 --- a/GUI/coregui/Models/RealDataModel.h +++ b/GUI/coregui/Models/RealDataModel.h @@ -19,8 +19,7 @@ //! The RealDataModel class is a model to store all imported RealDataItem's. -class RealDataModel : public SessionModel -{ +class RealDataModel : public SessionModel { Q_OBJECT public: diff --git a/GUI/coregui/Models/RealLimitsItems.cpp b/GUI/coregui/Models/RealLimitsItems.cpp index 567c14aedd7380df115ce6b04a67967f208d5dea..57501ba05c57a3391a3c02ebb6f7c3f5928ffd5f 100644 --- a/GUI/coregui/Models/RealLimitsItems.cpp +++ b/GUI/coregui/Models/RealLimitsItems.cpp @@ -14,8 +14,7 @@ #include "GUI/coregui/Models/RealLimitsItems.h" -namespace -{ +namespace { const QString tooltip_min_value = "Minimum allowed value, value included."; const QString tooltip_max_value = "Maximum allowed value, value excluded."; } // namespace @@ -29,8 +28,7 @@ RealLimitsItem::RealLimitsItem(const QString& name) : SessionItem(name) {} LimitlessItem::LimitlessItem() : RealLimitsItem("RealLimitsLimitless") {} -RealLimits LimitlessItem::createRealLimits(double /*scale_factor*/) const -{ +RealLimits LimitlessItem::createRealLimits(double /*scale_factor*/) const { return RealLimits(); } @@ -38,8 +36,7 @@ RealLimits LimitlessItem::createRealLimits(double /*scale_factor*/) const PositiveItem::PositiveItem() : RealLimitsItem("RealLimitsPositive") {} -RealLimits PositiveItem::createRealLimits(double /*scale_factor*/) const -{ +RealLimits PositiveItem::createRealLimits(double /*scale_factor*/) const { return RealLimits::positive(); } @@ -47,45 +44,38 @@ RealLimits PositiveItem::createRealLimits(double /*scale_factor*/) const NonnegativeItem::NonnegativeItem() : RealLimitsItem("RealLimitsNonnegative") {} -RealLimits NonnegativeItem::createRealLimits(double /*scale_factor*/) const -{ +RealLimits NonnegativeItem::createRealLimits(double /*scale_factor*/) const { return RealLimits::nonnegative(); } // --------------------------------------------------------------------------------------------- // -LowerLimitedItem::LowerLimitedItem() : RealLimitsItem("RealLimitsLowerLimited") -{ +LowerLimitedItem::LowerLimitedItem() : RealLimitsItem("RealLimitsLowerLimited") { addProperty(P_XMIN, 0.0)->setToolTip(tooltip_min_value).setLimits(RealLimits::limitless()); } -RealLimits LowerLimitedItem::createRealLimits(double scale_factor) const -{ +RealLimits LowerLimitedItem::createRealLimits(double scale_factor) const { return RealLimits::lowerLimited(scale_factor * getItemValue(P_XMIN).toDouble()); } // --------------------------------------------------------------------------------------------- // -UpperLimitedItem::UpperLimitedItem() : RealLimitsItem("RealLimitsUpperLimited") -{ +UpperLimitedItem::UpperLimitedItem() : RealLimitsItem("RealLimitsUpperLimited") { addProperty(P_XMAX, 1.0)->setToolTip(tooltip_max_value).setLimits(RealLimits::limitless()); } -RealLimits UpperLimitedItem::createRealLimits(double scale_factor) const -{ +RealLimits UpperLimitedItem::createRealLimits(double scale_factor) const { return RealLimits::upperLimited(scale_factor * getItemValue(P_XMAX).toDouble()); } // --------------------------------------------------------------------------------------------- // -LimitedItem::LimitedItem() : RealLimitsItem("RealLimitsLimited") -{ +LimitedItem::LimitedItem() : RealLimitsItem("RealLimitsLimited") { addProperty(P_XMIN, 0.0)->setToolTip(tooltip_min_value).setLimits(RealLimits::limitless()); addProperty(P_XMAX, 1.0)->setToolTip(tooltip_max_value).setLimits(RealLimits::limitless()); } -RealLimits LimitedItem::createRealLimits(double scale_factor) const -{ +RealLimits LimitedItem::createRealLimits(double scale_factor) const { return RealLimits::limited(scale_factor * getItemValue(P_XMIN).toDouble(), scale_factor * getItemValue(P_XMAX).toDouble()); } diff --git a/GUI/coregui/Models/RealLimitsItems.h b/GUI/coregui/Models/RealLimitsItems.h index b97ae4d4738c194d0a234430f0348eaa485b8d77..e4e4a99b68037994aa5c6b92690a43a05b6ff374 100644 --- a/GUI/coregui/Models/RealLimitsItems.h +++ b/GUI/coregui/Models/RealLimitsItems.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/SessionItem.h" -class BA_CORE_API_ RealLimitsItem : public SessionItem -{ +class BA_CORE_API_ RealLimitsItem : public SessionItem { public: static const QString P_XMIN; static const QString P_XMAX; @@ -27,43 +26,37 @@ public: virtual RealLimits createRealLimits(double scale_factor = 1.0) const = 0; }; -class BA_CORE_API_ LimitlessItem : public RealLimitsItem -{ +class BA_CORE_API_ LimitlessItem : public RealLimitsItem { public: LimitlessItem(); RealLimits createRealLimits(double scale_factor = 1.0) const; }; -class BA_CORE_API_ PositiveItem : public RealLimitsItem -{ +class BA_CORE_API_ PositiveItem : public RealLimitsItem { public: PositiveItem(); RealLimits createRealLimits(double scale_factor = 1.0) const; }; -class BA_CORE_API_ NonnegativeItem : public RealLimitsItem -{ +class BA_CORE_API_ NonnegativeItem : public RealLimitsItem { public: NonnegativeItem(); RealLimits createRealLimits(double scale_factor = 1.0) const; }; -class BA_CORE_API_ LowerLimitedItem : public RealLimitsItem -{ +class BA_CORE_API_ LowerLimitedItem : public RealLimitsItem { public: LowerLimitedItem(); RealLimits createRealLimits(double scale_factor = 1.0) const; }; -class BA_CORE_API_ UpperLimitedItem : public RealLimitsItem -{ +class BA_CORE_API_ UpperLimitedItem : public RealLimitsItem { public: UpperLimitedItem(); RealLimits createRealLimits(double scale_factor = 1.0) const; }; -class BA_CORE_API_ LimitedItem : public RealLimitsItem -{ +class BA_CORE_API_ LimitedItem : public RealLimitsItem { public: LimitedItem(); RealLimits createRealLimits(double scale_factor = 1.0) const; diff --git a/GUI/coregui/Models/RectangularDetectorItem.cpp b/GUI/coregui/Models/RectangularDetectorItem.cpp index 8bac5821288e92a38a903d9873bd15558d5732ef..df2bb90aae2a8ac659825fe2f5962729a332b253 100644 --- a/GUI/coregui/Models/RectangularDetectorItem.cpp +++ b/GUI/coregui/Models/RectangularDetectorItem.cpp @@ -20,8 +20,7 @@ #include "GUI/coregui/Models/VectorItem.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { const double default_detector_width = 20.0; const double default_detector_height = 20.0; const double default_detector_distance = 1000.0; @@ -49,8 +48,7 @@ const QString tooltip_samplex_v0 = "v-coordinate of point where sample x-axis crosses the detector, \n" "in local detector coordinates [mm]"; -ComboProperty alignmentCombo() -{ +ComboProperty alignmentCombo() { ComboProperty result; result << "Generic" << "Perpendicular to direct beam" @@ -74,8 +72,7 @@ const QString RectangularDetectorItem::P_DBEAM_V0 = "v0 (dbeam)"; const QString RectangularDetectorItem::P_DISTANCE = "Distance"; RectangularDetectorItem::RectangularDetectorItem() - : DetectorItem("RectangularDetector"), m_is_constructed(false) -{ + : DetectorItem("RectangularDetector"), m_is_constructed(false) { // axes parameters SessionItem* item = addGroupProperty(P_X_AXIS, "BasicAxis"); item->getItem(BasicAxisItem::P_TITLE)->setVisible(false); @@ -125,8 +122,7 @@ RectangularDetectorItem::RectangularDetectorItem() }); } -void RectangularDetectorItem::setDetectorAlignment(const QString& alignment) -{ +void RectangularDetectorItem::setDetectorAlignment(const QString& alignment) { ComboProperty combo_property = getItemValue(RectangularDetectorItem::P_ALIGNMENT).value<ComboProperty>(); @@ -138,28 +134,23 @@ void RectangularDetectorItem::setDetectorAlignment(const QString& alignment) setItemValue(RectangularDetectorItem::P_ALIGNMENT, combo_property.variant()); } -int RectangularDetectorItem::xSize() const -{ +int RectangularDetectorItem::xSize() const { return getItem(RectangularDetectorItem::P_X_AXIS)->getItemValue(BasicAxisItem::P_NBINS).toInt(); } -int RectangularDetectorItem::ySize() const -{ +int RectangularDetectorItem::ySize() const { return getItem(RectangularDetectorItem::P_Y_AXIS)->getItemValue(BasicAxisItem::P_NBINS).toInt(); } -void RectangularDetectorItem::setXSize(int nx) -{ +void RectangularDetectorItem::setXSize(int nx) { getItem(RectangularDetectorItem::P_X_AXIS)->setItemValue(BasicAxisItem::P_NBINS, nx); } -void RectangularDetectorItem::setYSize(int ny) -{ +void RectangularDetectorItem::setYSize(int ny) { getItem(RectangularDetectorItem::P_Y_AXIS)->setItemValue(BasicAxisItem::P_NBINS, ny); } -std::unique_ptr<IDetector2D> RectangularDetectorItem::createDomainDetector() const -{ +std::unique_ptr<IDetector2D> RectangularDetectorItem::createDomainDetector() const { // basic axes parameters auto& x_axis = item<BasicAxisItem>(RectangularDetectorItem::P_X_AXIS); size_t n_x = x_axis.getItemValue(BasicAxisItem::P_NBINS).toUInt(); @@ -196,8 +187,7 @@ std::unique_ptr<IDetector2D> RectangularDetectorItem::createDomainDetector() con } //! updates property tooltips and visibility flags, depending from type of alignment selected -void RectangularDetectorItem::update_properties_appearance() -{ +void RectangularDetectorItem::update_properties_appearance() { // hiding all alignment properties ComboProperty alignment = getItemValue(P_ALIGNMENT).value<ComboProperty>(); QStringList prop_list; @@ -236,12 +226,10 @@ void RectangularDetectorItem::update_properties_appearance() } } -kvector_t RectangularDetectorItem::normalVector() const -{ +kvector_t RectangularDetectorItem::normalVector() const { return item<VectorItem>(RectangularDetectorItem::P_NORMAL).getVector(); } -kvector_t RectangularDetectorItem::directionVector() const -{ +kvector_t RectangularDetectorItem::directionVector() const { return item<VectorItem>(RectangularDetectorItem::P_DIRECTION).getVector(); } diff --git a/GUI/coregui/Models/RectangularDetectorItem.h b/GUI/coregui/Models/RectangularDetectorItem.h index e52e47d2ad1c47f74577c41045f23a1db3c080a6..2acae52173bcf3221112a3e6606c11920832a3ad 100644 --- a/GUI/coregui/Models/RectangularDetectorItem.h +++ b/GUI/coregui/Models/RectangularDetectorItem.h @@ -18,8 +18,7 @@ #include "Base/Vector/Vectors3D.h" #include "GUI/coregui/Models/DetectorItems.h" -class BA_CORE_API_ RectangularDetectorItem : public DetectorItem -{ +class BA_CORE_API_ RectangularDetectorItem : public DetectorItem { public: static const QString P_X_AXIS; static const QString P_Y_AXIS; diff --git a/GUI/coregui/Models/ResolutionFunctionItems.cpp b/GUI/coregui/Models/ResolutionFunctionItems.cpp index 44f29a4fbd1b60d62feeef749eae6ff765436c5c..4e24119d84f9c5fc2f599cae0f607bcbc4a0a1ae 100644 --- a/GUI/coregui/Models/ResolutionFunctionItems.cpp +++ b/GUI/coregui/Models/ResolutionFunctionItems.cpp @@ -20,13 +20,10 @@ ResolutionFunctionItem::ResolutionFunctionItem(const QString& name) : SessionIte /* --------------------------------------------------------------------------------------------- */ ResolutionFunctionNoneItem::ResolutionFunctionNoneItem() - : ResolutionFunctionItem("ResolutionFunctionNone") -{ -} + : ResolutionFunctionItem("ResolutionFunctionNone") {} std::unique_ptr<IResolutionFunction2D> -ResolutionFunctionNoneItem::createResolutionFunction(double) const -{ +ResolutionFunctionNoneItem::createResolutionFunction(double) const { return std::unique_ptr<IResolutionFunction2D>(); } @@ -36,8 +33,7 @@ const QString ResolutionFunction2DGaussianItem::P_SIGMA_X = QString::fromStdStri const QString ResolutionFunction2DGaussianItem::P_SIGMA_Y = QString::fromStdString("SigmaY"); ResolutionFunction2DGaussianItem::ResolutionFunction2DGaussianItem() - : ResolutionFunctionItem("ResolutionFunction2DGaussian") -{ + : ResolutionFunctionItem("ResolutionFunction2DGaussian") { addProperty(P_SIGMA_X, 0.02) ->setLimits(RealLimits::lowerLimited(0.0)) .setDecimals(3) @@ -49,8 +45,7 @@ ResolutionFunction2DGaussianItem::ResolutionFunction2DGaussianItem() } std::unique_ptr<IResolutionFunction2D> -ResolutionFunction2DGaussianItem::createResolutionFunction(double scale) const -{ +ResolutionFunction2DGaussianItem::createResolutionFunction(double scale) const { return std::make_unique<ResolutionFunction2DGaussian>( scale * getItemValue(P_SIGMA_X).toDouble(), scale * getItemValue(P_SIGMA_Y).toDouble()); } diff --git a/GUI/coregui/Models/ResolutionFunctionItems.h b/GUI/coregui/Models/ResolutionFunctionItems.h index e01d98e7e32126cc2d32a743f8b3b0242096a8aa..ce40318c86e9a75d58cd8bded67106cf90623cbc 100644 --- a/GUI/coregui/Models/ResolutionFunctionItems.h +++ b/GUI/coregui/Models/ResolutionFunctionItems.h @@ -20,8 +20,7 @@ class IResolutionFunction2D; -class BA_CORE_API_ ResolutionFunctionItem : public SessionItem -{ +class BA_CORE_API_ ResolutionFunctionItem : public SessionItem { public: explicit ResolutionFunctionItem(const QString& name); @@ -31,16 +30,14 @@ public: createResolutionFunction(double scale = 1.0) const = 0; }; -class BA_CORE_API_ ResolutionFunctionNoneItem : public ResolutionFunctionItem -{ +class BA_CORE_API_ ResolutionFunctionNoneItem : public ResolutionFunctionItem { public: ResolutionFunctionNoneItem(); std::unique_ptr<IResolutionFunction2D> createResolutionFunction(double scale = 1.0) const; }; -class BA_CORE_API_ ResolutionFunction2DGaussianItem : public ResolutionFunctionItem -{ +class BA_CORE_API_ ResolutionFunction2DGaussianItem : public ResolutionFunctionItem { public: static const QString P_SIGMA_X; diff --git a/GUI/coregui/Models/RotationItems.cpp b/GUI/coregui/Models/RotationItems.cpp index e7541fcc8cb66b02058684c0bd8e965e68ffb942..9966daa8f03ea3eee01aa6d02ed84a8787bea4fb 100644 --- a/GUI/coregui/Models/RotationItems.cpp +++ b/GUI/coregui/Models/RotationItems.cpp @@ -20,14 +20,12 @@ const QString XRotationItem::P_ANGLE = "Angle"; -XRotationItem::XRotationItem() : RotationItem("XRotation") -{ +XRotationItem::XRotationItem() : RotationItem("XRotation") { setToolTip("Particle rotation around x-axis"); addProperty(P_ANGLE, 0.0)->setToolTip("Rotation angle around x-axis in degrees"); } -std::unique_ptr<IRotation> XRotationItem::createRotation() const -{ +std::unique_ptr<IRotation> XRotationItem::createRotation() const { double alpha = Units::deg2rad(getItemValue(P_ANGLE).toDouble()); return std::make_unique<RotationX>(alpha); } @@ -36,14 +34,12 @@ std::unique_ptr<IRotation> XRotationItem::createRotation() const const QString YRotationItem::P_ANGLE = "Angle"; -YRotationItem::YRotationItem() : RotationItem("YRotation") -{ +YRotationItem::YRotationItem() : RotationItem("YRotation") { setToolTip("Particle rotation around y-axis"); addProperty(P_ANGLE, 0.0)->setToolTip("Rotation angle around y-axis in degrees"); } -std::unique_ptr<IRotation> YRotationItem::createRotation() const -{ +std::unique_ptr<IRotation> YRotationItem::createRotation() const { double alpha = Units::deg2rad(getItemValue(P_ANGLE).toDouble()); return std::make_unique<RotationY>(alpha); } @@ -52,14 +48,12 @@ std::unique_ptr<IRotation> YRotationItem::createRotation() const const QString ZRotationItem::P_ANGLE = "Angle"; -ZRotationItem::ZRotationItem() : RotationItem("ZRotation") -{ +ZRotationItem::ZRotationItem() : RotationItem("ZRotation") { setToolTip("Particle rotation around z-axis"); addProperty(P_ANGLE, 0.0)->setToolTip("Rotation angle around z-axis in degrees"); } -std::unique_ptr<IRotation> ZRotationItem::createRotation() const -{ +std::unique_ptr<IRotation> ZRotationItem::createRotation() const { double alpha = Units::deg2rad(getItemValue(P_ANGLE).toDouble()); return std::make_unique<RotationZ>(alpha); } @@ -70,8 +64,7 @@ const QString EulerRotationItem::P_ALPHA = "Alpha"; const QString EulerRotationItem::P_BETA = "Beta"; const QString EulerRotationItem::P_GAMMA = "Gamma"; -EulerRotationItem::EulerRotationItem() : RotationItem("EulerRotation") -{ +EulerRotationItem::EulerRotationItem() : RotationItem("EulerRotation") { setToolTip("Sequence of three rotations following Euler angles \n" "notation z-x'-z'"); addProperty(P_ALPHA, 0.0)->setToolTip("First Euler anle in z-x'-z' sequence in degrees"); @@ -79,8 +72,7 @@ EulerRotationItem::EulerRotationItem() : RotationItem("EulerRotation") addProperty(P_GAMMA, 0.0)->setToolTip("Third Euler anle in z-x'-z' sequence in degrees"); } -std::unique_ptr<IRotation> EulerRotationItem::createRotation() const -{ +std::unique_ptr<IRotation> EulerRotationItem::createRotation() const { double alpha = Units::deg2rad(getItemValue(P_ALPHA).toDouble()); double beta = Units::deg2rad(getItemValue(P_BETA).toDouble()); double gamma = Units::deg2rad(getItemValue(P_GAMMA).toDouble()); diff --git a/GUI/coregui/Models/RotationItems.h b/GUI/coregui/Models/RotationItems.h index 98ad3d5276fdd2ca41848a75fa21ed3c1bfe6483..8a23757767c1f1149361e612b85148da7caa13a0 100644 --- a/GUI/coregui/Models/RotationItems.h +++ b/GUI/coregui/Models/RotationItems.h @@ -19,39 +19,34 @@ class IRotation; -class BA_CORE_API_ RotationItem : public SessionItem -{ +class BA_CORE_API_ RotationItem : public SessionItem { public: explicit RotationItem(const QString& name) : SessionItem(name) {} virtual std::unique_ptr<IRotation> createRotation() const = 0; }; -class BA_CORE_API_ XRotationItem : public RotationItem -{ +class BA_CORE_API_ XRotationItem : public RotationItem { public: static const QString P_ANGLE; XRotationItem(); std::unique_ptr<IRotation> createRotation() const; }; -class BA_CORE_API_ YRotationItem : public RotationItem -{ +class BA_CORE_API_ YRotationItem : public RotationItem { public: static const QString P_ANGLE; YRotationItem(); std::unique_ptr<IRotation> createRotation() const; }; -class BA_CORE_API_ ZRotationItem : public RotationItem -{ +class BA_CORE_API_ ZRotationItem : public RotationItem { public: static const QString P_ANGLE; ZRotationItem(); std::unique_ptr<IRotation> createRotation() const; }; -class BA_CORE_API_ EulerRotationItem : public RotationItem -{ +class BA_CORE_API_ EulerRotationItem : public RotationItem { public: static const QString P_ALPHA; static const QString P_BETA; diff --git a/GUI/coregui/Models/SampleModel.cpp b/GUI/coregui/Models/SampleModel.cpp index 49d3897795ee7770b84118c73b6b01cc712d5de4..35e715380ed219674311805fede0a0f654923ce2 100644 --- a/GUI/coregui/Models/SampleModel.cpp +++ b/GUI/coregui/Models/SampleModel.cpp @@ -15,19 +15,16 @@ #include "GUI/coregui/Models/SampleModel.h" #include "GUI/coregui/Models/MultiLayerItem.h" -SampleModel::SampleModel(QObject* parent) : SessionModel(SessionXML::SampleModelTag, parent) -{ +SampleModel::SampleModel(QObject* parent) : SessionModel(SessionXML::SampleModelTag, parent) { setObjectName(SessionXML::SampleModelTag); } -SampleModel* SampleModel::createCopy(SessionItem* parent) -{ +SampleModel* SampleModel::createCopy(SessionItem* parent) { SampleModel* result = new SampleModel(); result->initFrom(this, parent); return result; } -MultiLayerItem* SampleModel::multiLayerItem() -{ +MultiLayerItem* SampleModel::multiLayerItem() { return topItem<MultiLayerItem>(); } diff --git a/GUI/coregui/Models/SampleModel.h b/GUI/coregui/Models/SampleModel.h index 71137c1292f7b11c09bedcd2c48c08b6cbc32d65..2750df3bbe9d03dbc0900f41007db1b1e97b9a38 100644 --- a/GUI/coregui/Models/SampleModel.h +++ b/GUI/coregui/Models/SampleModel.h @@ -21,8 +21,7 @@ class MultiLayerItem; //! Main model to hold sample items. -class SampleModel : public SessionModel -{ +class SampleModel : public SessionModel { Q_OBJECT public: diff --git a/GUI/coregui/Models/SampleValidator.cpp b/GUI/coregui/Models/SampleValidator.cpp index c3d429633e71deced56cfa8a88e482dc46909555..ad3edb38c01f7e82debcf04d445ae0071c2e21f3 100644 --- a/GUI/coregui/Models/SampleValidator.cpp +++ b/GUI/coregui/Models/SampleValidator.cpp @@ -22,22 +22,19 @@ SampleValidator::SampleValidator() : m_valid_sample(true) {} -void SampleValidator::initValidator() -{ +void SampleValidator::initValidator() { m_validation_message.clear(); m_valid_sample = true; } -void SampleValidator::iterateItems(const SessionItem* parentItem) -{ +void SampleValidator::iterateItems(const SessionItem* parentItem) { for (const SessionItem* child : parentItem->children()) { validateItem(child); iterateItems(child); } } -void SampleValidator::validateItem(const SessionItem* item) -{ +void SampleValidator::validateItem(const SessionItem* item) { if (!item) return; @@ -60,8 +57,7 @@ void SampleValidator::validateItem(const SessionItem* item) } } -QString SampleValidator::validateMultiLayerItem(const SessionItem* item) -{ +QString SampleValidator::validateMultiLayerItem(const SessionItem* item) { QString result; QVector<SessionItem*> layers = item->getItems(MultiLayerItem::T_LAYERS); @@ -76,8 +72,7 @@ QString SampleValidator::validateMultiLayerItem(const SessionItem* item) return result; } -QString SampleValidator::validateParticleLayoutItem(const SessionItem* item) -{ +QString SampleValidator::validateParticleLayoutItem(const SessionItem* item) { QString result; QVector<SessionItem*> particles = item->getItems(ParticleLayoutItem::T_PARTICLES); @@ -87,8 +82,7 @@ QString SampleValidator::validateParticleLayoutItem(const SessionItem* item) return result; } -QString SampleValidator::validateParticleCoreShellItem(const SessionItem* item) -{ +QString SampleValidator::validateParticleCoreShellItem(const SessionItem* item) { QString result; const SessionItem* core = item->getItem(ParticleCoreShellItem::T_CORE); @@ -100,8 +94,7 @@ QString SampleValidator::validateParticleCoreShellItem(const SessionItem* item) return result; } -QString SampleValidator::validateParticleCompositionItem(const SessionItem* item) -{ +QString SampleValidator::validateParticleCompositionItem(const SessionItem* item) { QString result; if (item->getItems(ParticleCompositionItem::T_PARTICLES).isEmpty()) result = "ParticleComposition doesn't have any particles."; @@ -109,8 +102,7 @@ QString SampleValidator::validateParticleCompositionItem(const SessionItem* item return result; } -QString SampleValidator::validateParticleDistributionItem(const SessionItem* item) -{ +QString SampleValidator::validateParticleDistributionItem(const SessionItem* item) { QString result; if (item->getItems(ParticleDistributionItem::T_PARTICLES).isEmpty()) result = "ParticleDistribution doesn't have any particle."; @@ -118,8 +110,7 @@ QString SampleValidator::validateParticleDistributionItem(const SessionItem* ite return result; } -bool SampleValidator::isValidMultiLayer(const MultiLayerItem* multilayer) -{ +bool SampleValidator::isValidMultiLayer(const MultiLayerItem* multilayer) { initValidator(); validateItem(multilayer); diff --git a/GUI/coregui/Models/SampleValidator.h b/GUI/coregui/Models/SampleValidator.h index 07f0da19cb63724dcf517787e3877f215354dd28..db732aba6190a66cbbf9476a9d5b85ac8b32edc8 100644 --- a/GUI/coregui/Models/SampleValidator.h +++ b/GUI/coregui/Models/SampleValidator.h @@ -21,8 +21,7 @@ class SessionItem; class MultiLayerItem; //! Validates SampleModel for MultiLayerItem suitable for simulation -class SampleValidator -{ +class SampleValidator { public: SampleValidator(); diff --git a/GUI/coregui/Models/SessionDecorationModel.cpp b/GUI/coregui/Models/SessionDecorationModel.cpp index f2e650f9d2efa4278a9d4444ae56b33e29dc4308..4efd79e2a1c9f66bf9ccbf0a99ee45f2f4bf1f71 100644 --- a/GUI/coregui/Models/SessionDecorationModel.cpp +++ b/GUI/coregui/Models/SessionDecorationModel.cpp @@ -19,8 +19,7 @@ #include <QIcon> #include <QPixmap> -namespace -{ +namespace { struct IconCatalog { QIcon gisasIcon; @@ -28,8 +27,7 @@ struct IconCatalog { QIcon specularIcon; QIcon depthIcon; - IconCatalog() - { + IconCatalog() { gisasIcon.addPixmap(QPixmap(":/images/gisas_instrument.svg"), QIcon::Selected); gisasIcon.addPixmap(QPixmap(":/images/gisas_instrument_shaded.svg"), QIcon::Normal); offspecIcon.addPixmap(QPixmap(":/images/offspec_instrument.svg"), QIcon::Selected); @@ -41,14 +39,12 @@ struct IconCatalog { } }; -IconCatalog& iconCatalog() -{ +IconCatalog& iconCatalog() { static IconCatalog result; return result; } -QIcon materialIcon(const QColor& color) -{ +QIcon materialIcon(const QColor& color) { QIcon result; QPixmap pixmap(10, 10); pixmap.fill(color); @@ -56,8 +52,7 @@ QIcon materialIcon(const QColor& color) return result; } -QVariant itemIcon(const SessionItem* item) -{ +QVariant itemIcon(const SessionItem* item) { QVariant result; auto modelType = item->modelType(); @@ -86,19 +81,16 @@ QVariant itemIcon(const SessionItem* item) } // namespace SessionDecorationModel::SessionDecorationModel(QObject* parent, SessionModel* model) - : QIdentityProxyModel(parent), m_model(nullptr) -{ + : QIdentityProxyModel(parent), m_model(nullptr) { setSessionModel(model); } -void SessionDecorationModel::setSessionModel(SessionModel* model) -{ +void SessionDecorationModel::setSessionModel(SessionModel* model) { QIdentityProxyModel::setSourceModel(model); m_model = model; } -QVariant SessionDecorationModel::data(const QModelIndex& index, int role) const -{ +QVariant SessionDecorationModel::data(const QModelIndex& index, int role) const { if (role == Qt::DecorationRole) { QVariant result = createIcon(index); if (result.isValid()) @@ -114,8 +106,7 @@ QVariant SessionDecorationModel::data(const QModelIndex& index, int role) const return QIdentityProxyModel::data(index, role); } -QVariant SessionDecorationModel::createIcon(const QModelIndex& index) const -{ +QVariant SessionDecorationModel::createIcon(const QModelIndex& index) const { if (SessionItem* item = m_model->itemForIndex(index)) return itemIcon(item); @@ -124,8 +115,7 @@ QVariant SessionDecorationModel::createIcon(const QModelIndex& index) const //! Returns text color. Disabled SessionItem's will appear in gray. -QVariant SessionDecorationModel::textColor(const QModelIndex& index) const -{ +QVariant SessionDecorationModel::textColor(const QModelIndex& index) const { QVariant result; if (SessionItem* item = m_model->itemForIndex(index)) { diff --git a/GUI/coregui/Models/SessionDecorationModel.h b/GUI/coregui/Models/SessionDecorationModel.h index 206abfe3c7421111240f9f8106bf6445877f2d2c..e9edb0c6a961e62d61e80487dadddf6fd8dda2d6 100644 --- a/GUI/coregui/Models/SessionDecorationModel.h +++ b/GUI/coregui/Models/SessionDecorationModel.h @@ -24,8 +24,7 @@ class SessionItem; //! It is implemented as identity proxy model, so it has one-to-one data structure as in //! source SessionModel. -class SessionDecorationModel : public QIdentityProxyModel -{ +class SessionDecorationModel : public QIdentityProxyModel { Q_OBJECT public: explicit SessionDecorationModel(QObject* parent, SessionModel* model = nullptr); diff --git a/GUI/coregui/Models/SessionFlags.h b/GUI/coregui/Models/SessionFlags.h index 0c131dd433e1a54c6d3dd7558b5628a17668af18..514193678dc89d0bfdd3dfdd9115328b18ef6904 100644 --- a/GUI/coregui/Models/SessionFlags.h +++ b/GUI/coregui/Models/SessionFlags.h @@ -19,8 +19,7 @@ //! Collection of flags for SessionModel and SessionItem. -class SessionFlags -{ +class SessionFlags { public: // SessionModel columns enum EColumn { ITEM_NAME, ITEM_VALUE, MAX_COLUMNS }; diff --git a/GUI/coregui/Models/SessionGraphicsItem.cpp b/GUI/coregui/Models/SessionGraphicsItem.cpp index e62f7dce56d7ae83118cab5c1182d5e1756e1233..903136cea2d32cea3ee494f230f8b3975132d83e 100644 --- a/GUI/coregui/Models/SessionGraphicsItem.cpp +++ b/GUI/coregui/Models/SessionGraphicsItem.cpp @@ -17,8 +17,7 @@ const QString SessionGraphicsItem::P_XPOS = "xpos"; const QString SessionGraphicsItem::P_YPOS = "ypos"; -SessionGraphicsItem::SessionGraphicsItem(const QString& model_type) : SessionItem(model_type) -{ +SessionGraphicsItem::SessionGraphicsItem(const QString& model_type) : SessionItem(model_type) { addProperty(P_XPOS, qreal(0.0))->setVisible(false); addProperty(P_YPOS, qreal(0.0))->setVisible(false); } diff --git a/GUI/coregui/Models/SessionGraphicsItem.h b/GUI/coregui/Models/SessionGraphicsItem.h index 2316dc2a13f6a3656984f5ded807e35a07fca90c..d314bd607bd341a063645bae9dbb51178a689695 100644 --- a/GUI/coregui/Models/SessionGraphicsItem.h +++ b/GUI/coregui/Models/SessionGraphicsItem.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/SessionItem.h" -class BA_CORE_API_ SessionGraphicsItem : public SessionItem -{ +class BA_CORE_API_ SessionGraphicsItem : public SessionItem { public: static const QString P_XPOS; diff --git a/GUI/coregui/Models/SessionItem.cpp b/GUI/coregui/Models/SessionItem.cpp index 3a5083ac73441acb30eb9be866938d52745fa654..5b51cdf6b72698a83bbe991c5b9362eb3ca93adf 100644 --- a/GUI/coregui/Models/SessionItem.cpp +++ b/GUI/coregui/Models/SessionItem.cpp @@ -28,8 +28,7 @@ SessionItem::SessionItem(const QString& modelType) : m_parent(nullptr) , m_model(nullptr) , m_properties(new SessionItemData) - , m_tags(new SessionItemTags) -{ + , m_tags(new SessionItemTags) { ASSERT(!modelType.isEmpty()); setRoleProperty(SessionFlags::ModelTypeRole, modelType); @@ -40,8 +39,7 @@ SessionItem::SessionItem(const QString& modelType) //! Destructor deletes all its children and request parent to delete this item. -SessionItem::~SessionItem() -{ +SessionItem::~SessionItem() { if (m_mapper) m_mapper->callOnItemDestroy(); @@ -62,64 +60,55 @@ SessionItem::~SessionItem() //! Returns model of this item. -SessionModel* SessionItem::model() const -{ +SessionModel* SessionItem::model() const { return m_model; } //! Returns parent of this item. -SessionItem* SessionItem::parent() const -{ +SessionItem* SessionItem::parent() const { return m_parent; } //! Returns model index of this item. -QModelIndex SessionItem::index() const -{ +QModelIndex SessionItem::index() const { return model() ? model()->indexOfItem(const_cast<SessionItem*>(this)) : QModelIndex(); } //! Indicates whether this SessionItem has any child items -bool SessionItem::hasChildren() const -{ +bool SessionItem::hasChildren() const { return numberOfChildren() > 0; } //! Returns total number of children. -int SessionItem::numberOfChildren() const -{ +int SessionItem::numberOfChildren() const { return m_children.size(); } //! Returns vector of all children. -QVector<SessionItem*> SessionItem::children() const -{ +QVector<SessionItem*> SessionItem::children() const { return m_children; } //! Returns the child at the given row. -SessionItem* SessionItem::childAt(int row) const -{ +SessionItem* SessionItem::childAt(int row) const { return m_children.value(row, nullptr); } //! Returns row index of given child. -int SessionItem::rowOfChild(SessionItem* child) const -{ +int SessionItem::rowOfChild(SessionItem* child) const { return m_children.indexOf(child); } //! Returns the first child of the given type. -SessionItem* SessionItem::getChildOfType(const QString& type) const -{ +SessionItem* SessionItem::getChildOfType(const QString& type) const { for (auto child : m_children) if (child->modelType() == type) return child; @@ -129,8 +118,7 @@ SessionItem* SessionItem::getChildOfType(const QString& type) const //! Returns a vector of all children of the given type. -QVector<SessionItem*> SessionItem::getChildrenOfType(const QString& model_type) const -{ +QVector<SessionItem*> SessionItem::getChildrenOfType(const QString& model_type) const { QVector<SessionItem*> result; for (auto child : m_children) if (child->modelType() == model_type) @@ -141,8 +129,7 @@ QVector<SessionItem*> SessionItem::getChildrenOfType(const QString& model_type) //! Removes row from item and returns the item. -SessionItem* SessionItem::takeRow(int row) -{ +SessionItem* SessionItem::takeRow(int row) { SessionItem* item = childAt(row); QString tag = tagFromItem(item); auto items = getItems(tag); @@ -152,49 +139,42 @@ SessionItem* SessionItem::takeRow(int row) //! Add new tag to this item with given name, min, max and types. //! max = -1 -> unlimited, modelTypes empty -> all types allowed -bool SessionItem::registerTag(const QString& name, int min, int max, QStringList modelTypes) -{ +bool SessionItem::registerTag(const QString& name, int min, int max, QStringList modelTypes) { return m_tags->registerTag(name, min, max, modelTypes); } //! Returns true if tag is available. -bool SessionItem::isTag(const QString& name) const -{ +bool SessionItem::isTag(const QString& name) const { return m_tags->isValid(name); } -SessionItemTags* SessionItem::sessionItemTags() -{ +SessionItemTags* SessionItem::sessionItemTags() { return m_tags.get(); } //! Returns the tag name of given item when existing. -QString SessionItem::tagFromItem(const SessionItem* item) const -{ +QString SessionItem::tagFromItem(const SessionItem* item) const { int index = m_children.indexOf(const_cast<SessionItem*>(item)); return m_tags->tagFromIndex(index); } //! Returns true if model type can be added to default tag. -bool SessionItem::acceptsAsDefaultItem(const QString& item_name) const -{ +bool SessionItem::acceptsAsDefaultItem(const QString& item_name) const { return m_tags->isValid(defaultTag(), item_name); } //! Returns vector of acceptable default tag types. -QVector<QString> SessionItem::acceptableDefaultItemTypes() const -{ +QVector<QString> SessionItem::acceptableDefaultItemTypes() const { return m_tags->modelTypesForTag(defaultTag()).toVector(); } //! Returns item in given row of given tag. -SessionItem* SessionItem::getItem(const QString& tag, int row) const -{ +SessionItem* SessionItem::getItem(const QString& tag, int row) const { const QString tagName = tag.isEmpty() ? defaultTag() : tag; if (!m_tags->isValid(tagName)) @@ -214,8 +194,7 @@ SessionItem* SessionItem::getItem(const QString& tag, int row) const //! Returns vector of all items of given tag. -QVector<SessionItem*> SessionItem::getItems(const QString& tag) const -{ +QVector<SessionItem*> SessionItem::getItems(const QString& tag) const { const QString tagName = tag.isEmpty() ? defaultTag() : tag; if (!m_tags->isValid(tagName)) return QVector<SessionItem*>(); @@ -226,8 +205,7 @@ QVector<SessionItem*> SessionItem::getItems(const QString& tag) const } //! Insert item into given tag into given row. -bool SessionItem::insertItem(int row, SessionItem* item, const QString& tag) -{ +bool SessionItem::insertItem(int row, SessionItem* item, const QString& tag) { ASSERT(item); ASSERT(!item->parent()); @@ -253,8 +231,7 @@ bool SessionItem::insertItem(int row, SessionItem* item, const QString& tag) //! Remove item from given row from given tag. -SessionItem* SessionItem::takeItem(int row, const QString& tag) -{ +SessionItem* SessionItem::takeItem(int row, const QString& tag) { const QString tagName = tag.isEmpty() ? defaultTag() : tag; ASSERT(m_tags->isValid(tagName)); ASSERT(!m_tags->isSingleItemTag(tagName)); @@ -275,8 +252,7 @@ SessionItem* SessionItem::takeItem(int row, const QString& tag) //! Add new property item and register new tag. -SessionItem* SessionItem::addProperty(const QString& name, const QVariant& variant) -{ +SessionItem* SessionItem::addProperty(const QString& name, const QVariant& variant) { ASSERT(!isTag(name)); SessionItem* property = ItemFactory::CreateItem("Property"); @@ -291,24 +267,21 @@ SessionItem* SessionItem::addProperty(const QString& name, const QVariant& varia //! Directly access value of item under given tag. -QVariant SessionItem::getItemValue(const QString& tag) const -{ +QVariant SessionItem::getItemValue(const QString& tag) const { ASSERT(isTag(tag)); return getItem(tag)->value(); } //! Directly set value of item under given tag. -void SessionItem::setItemValue(const QString& tag, const QVariant& variant) -{ +void SessionItem::setItemValue(const QString& tag, const QVariant& variant) { ASSERT(isTag(tag)); getItem(tag)->setValue(variant); } //! Creates new group item and register new tag, returns GroupItem. -SessionItem* SessionItem::addGroupProperty(const QString& groupTag, const QString& groupType) -{ +SessionItem* SessionItem::addGroupProperty(const QString& groupTag, const QString& groupType) { SessionItem* result(0); if (SessionItemUtils::IsValidGroup(groupType)) { @@ -333,29 +306,26 @@ SessionItem* SessionItem::addGroupProperty(const QString& groupTag, const QStrin //! Set the current type of group item. -SessionItem* SessionItem::setGroupProperty(const QString& groupTag, const QString& modelType) const -{ +SessionItem* SessionItem::setGroupProperty(const QString& groupTag, + const QString& modelType) const { return item<GroupItem>(groupTag).setCurrentType(modelType); } //! Access subitem of group item. -SessionItem* SessionItem::getGroupItem(const QString& groupName) const -{ +SessionItem* SessionItem::getGroupItem(const QString& groupName) const { return item<GroupItem>(groupName).currentItem(); } //! Returns corresponding variant under given role, invalid variant when role is not present. -QVariant SessionItem::roleProperty(int role) const -{ +QVariant SessionItem::roleProperty(int role) const { return m_properties->data(role); } //! Set variant to role, create role if not present yet. -bool SessionItem::setRoleProperty(int role, const QVariant& value) -{ +bool SessionItem::setRoleProperty(int role, const QVariant& value) { bool result = m_properties->setData(role, value); if (result) emitDataChanged(role); @@ -364,15 +334,13 @@ bool SessionItem::setRoleProperty(int role, const QVariant& value) //! Returns vector of all present roles. -QVector<int> SessionItem::getRoles() const -{ +QVector<int> SessionItem::getRoles() const { return m_properties->roles(); } //! Notify model about data changes. -void SessionItem::emitDataChanged(int role) -{ +void SessionItem::emitDataChanged(int role) { if (m_model) { QModelIndex index = m_model->indexOfItem(this); m_model->dataChanged(index, index.sibling(index.row(), 1), QVector<int>() << role); @@ -381,44 +349,38 @@ void SessionItem::emitDataChanged(int role) //! Get model type. -QString SessionItem::modelType() const -{ +QString SessionItem::modelType() const { return roleProperty(SessionFlags::ModelTypeRole).toString(); } //! Get value. -QVariant SessionItem::value() const -{ +QVariant SessionItem::value() const { return roleProperty(Qt::DisplayRole); } //! Set value, ensure that variant types match. -bool SessionItem::setValue(QVariant value) -{ +bool SessionItem::setValue(QVariant value) { ASSERT(SessionItemUtils::CompatibleVariantTypes(this->value(), value)); return setRoleProperty(Qt::DisplayRole, value); } //! Get default tag -QString SessionItem::defaultTag() const -{ +QString SessionItem::defaultTag() const { return roleProperty(SessionFlags::DefaultTagRole).toString(); } //! Set default tag -void SessionItem::setDefaultTag(const QString& tag) -{ +void SessionItem::setDefaultTag(const QString& tag) { setRoleProperty(SessionFlags::DefaultTagRole, tag); } //! Get display name of item, append index if ambigue. -QString SessionItem::displayName() const -{ +QString SessionItem::displayName() const { QString result = roleProperty(SessionFlags::DisplayNameRole).toString(); if (modelType() == "Property" || modelType() == "GroupProperty" || modelType() == "Parameter" @@ -440,20 +402,17 @@ QString SessionItem::displayName() const //! Set display name -void SessionItem::setDisplayName(const QString& display_name) -{ +void SessionItem::setDisplayName(const QString& display_name) { setRoleProperty(SessionFlags::DisplayNameRole, display_name); } //! Get item name, return display name if no name is set. -QString SessionItem::itemName() const -{ +QString SessionItem::itemName() const { return isTag(P_NAME) ? getItemValue(P_NAME).toString() : displayName(); } //! Set item name, add property if necessary. -void SessionItem::setItemName(const QString& name) -{ +void SessionItem::setItemName(const QString& name) { if (isTag(P_NAME)) setItemValue(P_NAME, name); else @@ -462,85 +421,70 @@ void SessionItem::setItemName(const QString& name) //! Flags accessors. -void SessionItem::setVisible(bool enabled) -{ +void SessionItem::setVisible(bool enabled) { changeFlags(enabled, SessionFlags::VISIBLE); } -void SessionItem::setEnabled(bool enabled) -{ +void SessionItem::setEnabled(bool enabled) { changeFlags(enabled, SessionFlags::ENABLED); } -void SessionItem::setEditable(bool enabled) -{ +void SessionItem::setEditable(bool enabled) { changeFlags(enabled, SessionFlags::EDITABLE); } -bool SessionItem::isVisible() const -{ +bool SessionItem::isVisible() const { return flags() & SessionFlags::VISIBLE; } -bool SessionItem::isEnabled() const -{ +bool SessionItem::isEnabled() const { return flags() & SessionFlags::ENABLED; } -bool SessionItem::isEditable() const -{ +bool SessionItem::isEditable() const { return flags() & SessionFlags::EDITABLE; } -RealLimits SessionItem::limits() const -{ +RealLimits SessionItem::limits() const { return roleProperty(SessionFlags::LimitsRole).value<RealLimits>(); } -SessionItem& SessionItem::setLimits(const RealLimits& value) -{ +SessionItem& SessionItem::setLimits(const RealLimits& value) { setRoleProperty(SessionFlags::LimitsRole, QVariant::fromValue<RealLimits>(value)); return *this; } -int SessionItem::decimals() const -{ +int SessionItem::decimals() const { return roleProperty(SessionFlags::DecimalRole).toInt(); } -SessionItem& SessionItem::setDecimals(int n) -{ +SessionItem& SessionItem::setDecimals(int n) { setRoleProperty(SessionFlags::DecimalRole, n); return *this; } -QString SessionItem::toolTip() const -{ +QString SessionItem::toolTip() const { return roleProperty(Qt::ToolTipRole).toString(); } -SessionItem& SessionItem::setToolTip(const QString& tooltip) -{ +SessionItem& SessionItem::setToolTip(const QString& tooltip) { setRoleProperty(Qt::ToolTipRole, tooltip); return *this; } -QString SessionItem::editorType() const -{ +QString SessionItem::editorType() const { const auto variant = roleProperty(SessionFlags::CustomEditorRole); return variant.isValid() ? variant.toString() : "Default"; } -SessionItem& SessionItem::setEditorType(const QString& editorType) -{ +SessionItem& SessionItem::setEditorType(const QString& editorType) { setRoleProperty(SessionFlags::CustomEditorRole, editorType); return *this; } //! Returns the current model mapper of this item. Creates new one if necessary. -ModelMapper* SessionItem::mapper() -{ +ModelMapper* SessionItem::mapper() { if (!m_mapper) { m_mapper = std::unique_ptr<ModelMapper>(new ModelMapper); m_mapper->setItem(this); @@ -548,8 +492,7 @@ ModelMapper* SessionItem::mapper() return m_mapper.get(); } -QStringList SessionItem::translateList(const QStringList& list) const -{ +QStringList SessionItem::translateList(const QStringList& list) const { QStringList result = list; for (const IPathTranslator* translator : m_translators) result = translator->translate(result); @@ -558,26 +501,22 @@ QStringList SessionItem::translateList(const QStringList& list) const return result; } -void SessionItem::addTranslator(const IPathTranslator& translator) -{ +void SessionItem::addTranslator(const IPathTranslator& translator) { m_translators.push_back(translator.clone()); } -void SessionItem::childDeleted(SessionItem* child) -{ +void SessionItem::childDeleted(SessionItem* child) { int index = rowOfChild(child); ASSERT(index != -1); m_children.replace(index, nullptr); } -void SessionItem::setParentAndModel(SessionItem* parent, SessionModel* model) -{ +void SessionItem::setParentAndModel(SessionItem* parent, SessionModel* model) { setModel(model); m_parent = parent; } -void SessionItem::setModel(SessionModel* model) -{ +void SessionItem::setModel(SessionModel* model) { m_model = model; if (m_mapper) @@ -587,8 +526,7 @@ void SessionItem::setModel(SessionModel* model) child->setModel(model); } -int SessionItem::flags() const -{ +int SessionItem::flags() const { QVariant flags = roleProperty(SessionFlags::FlagRole); if (!flags.isValid()) @@ -598,8 +536,7 @@ int SessionItem::flags() const } //! internal -void SessionItem::changeFlags(bool enabled, int flag) -{ +void SessionItem::changeFlags(bool enabled, int flag) { int flags = this->flags(); if (enabled) flags |= flag; @@ -610,8 +547,7 @@ void SessionItem::changeFlags(bool enabled, int flag) } //! internal -int SessionItem::getCopyNumberOfChild(const SessionItem* item) const -{ +int SessionItem::getCopyNumberOfChild(const SessionItem* item) const { if (!item) return -1; int result = -1; diff --git a/GUI/coregui/Models/SessionItem.h b/GUI/coregui/Models/SessionItem.h index 13bdd32d0b8ec5be736efcc74407f32259458001..817311304ba8d50899a69adcdb2e9b94c6559e1b 100644 --- a/GUI/coregui/Models/SessionItem.h +++ b/GUI/coregui/Models/SessionItem.h @@ -28,8 +28,7 @@ class SessionItemData; class SessionItemTags; class IPathTranslator; -class BA_CORE_API_ SessionItem -{ +class BA_CORE_API_ SessionItem { friend class SessionModel; public: @@ -139,15 +138,13 @@ private: QVector<IPathTranslator*> m_translators; }; -template <typename T> T& SessionItem::item(const QString& tag) const -{ +template <typename T> T& SessionItem::item(const QString& tag) const { T* t = dynamic_cast<T*>(getItem(tag)); ASSERT(t); return *t; } -template <typename T> T& SessionItem::groupItem(const QString& groupName) const -{ +template <typename T> T& SessionItem::groupItem(const QString& groupName) const { T* t = dynamic_cast<T*>(getGroupItem(groupName)); ASSERT(t); return *t; diff --git a/GUI/coregui/Models/SessionItemData.cpp b/GUI/coregui/Models/SessionItemData.cpp index ce705ae1401d0115ba1a1f0d1689077498a9b39d..c02292dbc895ca662e9c4ab497f555de97b2e83a 100644 --- a/GUI/coregui/Models/SessionItemData.cpp +++ b/GUI/coregui/Models/SessionItemData.cpp @@ -17,21 +17,18 @@ SessionItemData::ItemData::ItemData(int r, const QVariant& v) : role(r), data(v) {} -bool SessionItemData::ItemData::operator==(const SessionItemData::ItemData& other) const -{ +bool SessionItemData::ItemData::operator==(const SessionItemData::ItemData& other) const { return role == other.role && SessionItemUtils::IsTheSame(data, other.data); } -QVector<int> SessionItemData::roles() const -{ +QVector<int> SessionItemData::roles() const { QVector<int> result; for (const auto& value : m_values) result.push_back(value.role); return result; } -QVariant SessionItemData::data(int role) const -{ +QVariant SessionItemData::data(int role) const { role = (role == Qt::EditRole) ? Qt::DisplayRole : role; for (const auto& value : m_values) { if (value.role == role) @@ -42,8 +39,7 @@ QVariant SessionItemData::data(int role) const //! Sets the data for given role. Returns true if data was changed. -bool SessionItemData::setData(int role, const QVariant& value) -{ +bool SessionItemData::setData(int role, const QVariant& value) { role = (role == Qt::EditRole) ? Qt::DisplayRole : role; for (auto it = m_values.begin(); it != m_values.end(); ++it) { if (it->role == role) { diff --git a/GUI/coregui/Models/SessionItemData.h b/GUI/coregui/Models/SessionItemData.h index 4d107d870bc8acde8cd9def8846cdd85331119af..0a9b83a0a7663c28877925649bd6f91b376ada42 100644 --- a/GUI/coregui/Models/SessionItemData.h +++ b/GUI/coregui/Models/SessionItemData.h @@ -20,8 +20,7 @@ //! Handles all data roles for SessionItem. -class SessionItemData -{ +class SessionItemData { public: QVector<int> roles() const; @@ -30,8 +29,7 @@ public: bool setData(int role, const QVariant& value); private: - class ItemData - { + class ItemData { public: ItemData(int r = -1, const QVariant& v = {}); int role; diff --git a/GUI/coregui/Models/SessionItemTags.cpp b/GUI/coregui/Models/SessionItemTags.cpp index 51d57a85d0abd55e0d5f9a2bf58dc943c9b8b176..d15d3dae743b4fe07c7a857ab32abe590fc4254a 100644 --- a/GUI/coregui/Models/SessionItemTags.cpp +++ b/GUI/coregui/Models/SessionItemTags.cpp @@ -19,8 +19,7 @@ //! false if parameters are invalid or such tag was already registered. bool SessionItemTags::registerTag(const QString& name, int min, int max, - const QStringList& modelTypes) -{ + const QStringList& modelTypes) { if (min < 0 || (min > max && max >= 0)) return false; if (name.isEmpty() || isValid(name)) @@ -33,8 +32,7 @@ bool SessionItemTags::registerTag(const QString& name, int min, int max, //! If modelType is not empty, than an additional check is performed if tag is //! intended for the given modelType. -bool SessionItemTags::isValid(const QString& tagName, const QString& modelType) const -{ +bool SessionItemTags::isValid(const QString& tagName, const QString& modelType) const { for (const auto& tag : m_tags) { if (tag.name == tagName) { if (modelType.isEmpty()) @@ -47,15 +45,13 @@ bool SessionItemTags::isValid(const QString& tagName, const QString& modelType) //! Returns list of modelTypes the given tagName is intended for. -QStringList SessionItemTags::modelTypesForTag(const QString& tagName) const -{ +QStringList SessionItemTags::modelTypesForTag(const QString& tagName) const { return isValid(tagName) ? tagInfo(tagName).modelTypes : QStringList(); } //! Returns start index of given tagName corresponding to the index of SessionItem's m_children. -int SessionItemTags::tagStartIndex(const QString& tagName) const -{ +int SessionItemTags::tagStartIndex(const QString& tagName) const { int index(0); for (const auto& tag : m_tags) { if (tag.name == tagName) @@ -67,8 +63,7 @@ int SessionItemTags::tagStartIndex(const QString& tagName) const //! Returns index in SessionItem's m_children corresponding to given row in tagName. -int SessionItemTags::indexFromTagRow(const QString& tagName, int row) const -{ +int SessionItemTags::indexFromTagRow(const QString& tagName, int row) const { if (row < 0 || row >= tagInfo(tagName).childCount) throw GUIHelpers::Error("SessionItemTags::tagIndexFromRow() -> Error. Wrong row"); return tagStartIndex(tagName) + row; @@ -77,8 +72,7 @@ int SessionItemTags::indexFromTagRow(const QString& tagName, int row) const //! Returns index in SessionItem's m_children to insert new item. //! If number of items for given tagName exceeds maximum allowed, returns -1; -int SessionItemTags::insertIndexFromTagRow(const QString& tagName, int row) -{ +int SessionItemTags::insertIndexFromTagRow(const QString& tagName, int row) { if (maximumReached(tagName)) return -1; auto& tag = tagInfo(tagName); @@ -89,8 +83,7 @@ int SessionItemTags::insertIndexFromTagRow(const QString& tagName, int row) return tagStartIndex(tagName) + row; } -QString SessionItemTags::tagFromIndex(int index) const -{ +QString SessionItemTags::tagFromIndex(int index) const { if (index < 0) return ""; for (const auto& tag : m_tags) { @@ -101,26 +94,22 @@ QString SessionItemTags::tagFromIndex(int index) const return ""; } -int SessionItemTags::childCount(const QString& tagName) -{ +int SessionItemTags::childCount(const QString& tagName) { return tagInfo(tagName).childCount; } -int SessionItemTags::childMax(const QString& tagName) -{ +int SessionItemTags::childMax(const QString& tagName) { return tagInfo(tagName).max; } -void SessionItemTags::addChild(const QString& tagName) -{ +void SessionItemTags::addChild(const QString& tagName) { if (maximumReached(tagName)) throw GUIHelpers::Error("SessionItemTags::addChild() -> Error. Can't exceed maximum" "allowed number of children."); tagInfo(tagName).childCount++; } -void SessionItemTags::removeChild(const QString& tagName) -{ +void SessionItemTags::removeChild(const QString& tagName) { auto& tag = tagInfo(tagName); if (tag.childCount == 0) throw GUIHelpers::Error("SessionItemTags::removeChild() -> Error. Attempt to remove " @@ -128,29 +117,25 @@ void SessionItemTags::removeChild(const QString& tagName) tag.childCount--; } -bool SessionItemTags::isSingleItemTag(const QString& tagName) -{ +bool SessionItemTags::isSingleItemTag(const QString& tagName) { if (!isValid(tagName)) return false; const auto& tag = tagInfo(tagName); return tag.min == 1 && tag.max == 1 && tag.childCount == 1; } -SessionItemTags::TagInfo& SessionItemTags::tagInfo(const QString& tagName) -{ +SessionItemTags::TagInfo& SessionItemTags::tagInfo(const QString& tagName) { return const_cast<TagInfo&>(static_cast<const SessionItemTags*>(this)->tagInfo(tagName)); } -const SessionItemTags::TagInfo& SessionItemTags::tagInfo(const QString& tagName) const -{ +const SessionItemTags::TagInfo& SessionItemTags::tagInfo(const QString& tagName) const { for (const auto& tag : m_tags) if (tag.name == tagName) return tag; throw GUIHelpers::Error("SessionItemTags::tagInfo() -> Error. No such tag '" + tagName + "'."); } -bool SessionItemTags::maximumReached(const QString& tagName) const -{ +bool SessionItemTags::maximumReached(const QString& tagName) const { const auto& tag = tagInfo(tagName); if (tag.max != -1 && tag.max == tag.childCount) return true; diff --git a/GUI/coregui/Models/SessionItemTags.h b/GUI/coregui/Models/SessionItemTags.h index a4750b29701dc5539bbe52b89d5f6dc2d92ab848..6d4af31d74bba8fa6f30a1f419fc3d49c5e8f2af 100644 --- a/GUI/coregui/Models/SessionItemTags.h +++ b/GUI/coregui/Models/SessionItemTags.h @@ -21,8 +21,7 @@ //! Holds all tag info for SessionItem. -class SessionItemTags -{ +class SessionItemTags { public: bool registerTag(const QString& name, int min, int max, const QStringList& modelTypes); diff --git a/GUI/coregui/Models/SessionItemUtils.cpp b/GUI/coregui/Models/SessionItemUtils.cpp index 76037c4fa583191a2b078fcc68c20b9365a412f9..ba4a31c07eb7f5ad9544e2bb386e29808388533d 100644 --- a/GUI/coregui/Models/SessionItemUtils.cpp +++ b/GUI/coregui/Models/SessionItemUtils.cpp @@ -23,16 +23,13 @@ #include <QIcon> #include <QPixmap> -namespace -{ -const GroupInfoCatalog& groupInfoCatalog() -{ +namespace { +const GroupInfoCatalog& groupInfoCatalog() { static GroupInfoCatalog s_catalog = {}; return s_catalog; } -QStringList parents_with_abundance() -{ +QStringList parents_with_abundance() { return QStringList() << "ParticleCoreShell" << "ParticleComposition" << "ParticleDistribution" @@ -41,15 +38,13 @@ QStringList parents_with_abundance() } // namespace -int SessionItemUtils::ParentRow(const SessionItem& item) -{ +int SessionItemUtils::ParentRow(const SessionItem& item) { if (item.parent()) return item.parent()->rowOfChild(const_cast<SessionItem*>(&item)); return -1; } -kvector_t SessionItemUtils::GetVectorItem(const SessionItem& item, const QString& name) -{ +kvector_t SessionItemUtils::GetVectorItem(const SessionItem& item, const QString& name) { SessionItem* vectorItem = item.getItem(name); ASSERT(vectorItem); double x = vectorItem->getItemValue(VectorItem::P_X).toDouble(); @@ -58,16 +53,15 @@ kvector_t SessionItemUtils::GetVectorItem(const SessionItem& item, const QString return {x, y, z}; } -void SessionItemUtils::SetVectorItem(const SessionItem& item, const QString& name, kvector_t value) -{ +void SessionItemUtils::SetVectorItem(const SessionItem& item, const QString& name, + kvector_t value) { auto p_vector_item = item.getItem(name); p_vector_item->setItemValue(VectorItem::P_X, value.x()); p_vector_item->setItemValue(VectorItem::P_Y, value.y()); p_vector_item->setItemValue(VectorItem::P_Z, value.z()); } -int SessionItemUtils::ParentVisibleRow(const SessionItem& item) -{ +int SessionItemUtils::ParentVisibleRow(const SessionItem& item) { int result(-1); if (!item.parent() || !item.isVisible()) @@ -84,13 +78,11 @@ int SessionItemUtils::ParentVisibleRow(const SessionItem& item) return result; } -QVariant SessionItemUtils::ForegroundRole(const SessionItem& item) -{ +QVariant SessionItemUtils::ForegroundRole(const SessionItem& item) { return item.isEnabled() ? QVariant() : QColor(Qt::gray); } -QVariant SessionItemUtils::ToolTipRole(const SessionItem& item, int ncol) -{ +QVariant SessionItemUtils::ToolTipRole(const SessionItem& item, int ncol) { QString result = item.toolTip(); if (result.isEmpty()) { result = item.displayName(); @@ -101,41 +93,35 @@ QVariant SessionItemUtils::ToolTipRole(const SessionItem& item, int ncol) return QVariant(result); } -QVariant SessionItemUtils::DecorationRole(const SessionItem& item) -{ +QVariant SessionItemUtils::DecorationRole(const SessionItem& item) { if (item.value().canConvert<ExternalProperty>()) return QIcon(item.value().value<ExternalProperty>().pixmap()); return QVariant(); } -QVariant SessionItemUtils::CheckStateRole(const SessionItem& item) -{ +QVariant SessionItemUtils::CheckStateRole(const SessionItem& item) { if (item.value().type() == QVariant::Bool) return item.value().toBool() ? Qt::Checked : Qt::Unchecked; return QVariant(); } -bool SessionItemUtils::IsValidGroup(const QString& group_type) -{ +bool SessionItemUtils::IsValidGroup(const QString& group_type) { return groupInfoCatalog().containsGroup(group_type); } -GroupInfo SessionItemUtils::GetGroupInfo(const QString& group_type) -{ +GroupInfo SessionItemUtils::GetGroupInfo(const QString& group_type) { return groupInfoCatalog().groupInfo(group_type); } -int SessionItemUtils::VariantType(const QVariant& variant) -{ +int SessionItemUtils::VariantType(const QVariant& variant) { int result = static_cast<int>(variant.type()); if (result == QVariant::UserType) result = variant.userType(); return result; } -bool SessionItemUtils::CompatibleVariantTypes(const QVariant& oldValue, const QVariant& newValue) -{ +bool SessionItemUtils::CompatibleVariantTypes(const QVariant& oldValue, const QVariant& newValue) { // if olfValue is undefined than it is compatible with any value, otherwise newValue // should have same variant type as oldValue @@ -148,8 +134,7 @@ bool SessionItemUtils::CompatibleVariantTypes(const QVariant& oldValue, const QV // For custom variants (based on ExternalProperty, ComboProperty) will always return false, i.e. // we will rely here on our custom editors. // This is done to not to register custom comparators in main.cpp. -bool SessionItemUtils::IsTheSame(const QVariant& var1, const QVariant& var2) -{ +bool SessionItemUtils::IsTheSame(const QVariant& var1, const QVariant& var2) { // variants of different type are always reported as not the same if (VariantType(var1) != VariantType(var2)) return false; @@ -162,8 +147,7 @@ bool SessionItemUtils::IsTheSame(const QVariant& var1, const QVariant& var2) return var1 == var2; } -bool SessionItemUtils::IsPositionRelated(const SessionItem& item) -{ +bool SessionItemUtils::IsPositionRelated(const SessionItem& item) { if (item.modelType() == "Property" && (item.displayName() == SessionGraphicsItem::P_XPOS || item.displayName() == SessionGraphicsItem::P_YPOS)) @@ -172,8 +156,7 @@ bool SessionItemUtils::IsPositionRelated(const SessionItem& item) return false; } -bool SessionItemUtils::HasOwnAbundance(const SessionItem* item) -{ +bool SessionItemUtils::HasOwnAbundance(const SessionItem* item) { static QStringList special_parent = parents_with_abundance(); return item ? special_parent.contains(item->modelType()) : false; } diff --git a/GUI/coregui/Models/SessionItemUtils.h b/GUI/coregui/Models/SessionItemUtils.h index aaf481d3f3921c9e07c7d90b967f052fba4930c7..9942bd9cfa2bb414576348614d5e1d4a914f0929 100644 --- a/GUI/coregui/Models/SessionItemUtils.h +++ b/GUI/coregui/Models/SessionItemUtils.h @@ -22,8 +22,7 @@ class SessionItem; class GroupInfo; -namespace SessionItemUtils -{ +namespace SessionItemUtils { //! Returns the index of the given item within its parent. Returns -1 when no parent is set. int ParentRow(const SessionItem& item); diff --git a/GUI/coregui/Models/SessionModel.cpp b/GUI/coregui/Models/SessionModel.cpp index 7a074caf0d310ab4af98f9f40e305ef8ad378003..d17b3c2f5f10d83baf9c0020bf8f05af08600341 100644 --- a/GUI/coregui/Models/SessionModel.cpp +++ b/GUI/coregui/Models/SessionModel.cpp @@ -23,34 +23,29 @@ using SessionItemUtils::ParentRow; -namespace -{ +namespace { const int MaxCompression = 9; } SessionModel::SessionModel(QString model_tag, QObject* parent) - : QAbstractItemModel(parent), m_root_item(0), m_name("DefaultName"), m_model_tag(model_tag) -{ + : QAbstractItemModel(parent), m_root_item(0), m_name("DefaultName"), m_model_tag(model_tag) { createRootItem(); } -void SessionModel::createRootItem() -{ +void SessionModel::createRootItem() { m_root_item = ItemFactory::CreateEmptyItem(); m_root_item->setModel(this); m_root_item->registerTag("rootTag"); m_root_item->setDefaultTag("rootTag"); } -SessionModel::~SessionModel() -{ +SessionModel::~SessionModel() { delete m_root_item; } // TODO make it relying on SessionItem::flags -Qt::ItemFlags SessionModel::flags(const QModelIndex& index) const -{ +Qt::ItemFlags SessionModel::flags(const QModelIndex& index) const { Qt::ItemFlags result_flags = QAbstractItemModel::flags(index); if (index.isValid()) { result_flags |= Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled; @@ -68,8 +63,7 @@ Qt::ItemFlags SessionModel::flags(const QModelIndex& index) const return result_flags; } -QVariant SessionModel::data(const QModelIndex& index, int role) const -{ +QVariant SessionModel::data(const QModelIndex& index, int role) const { if (!m_root_item || !index.isValid() || index.column() < 0 || index.column() >= columnCount(QModelIndex())) { return QVariant(); @@ -96,8 +90,7 @@ QVariant SessionModel::data(const QModelIndex& index, int role) const return QVariant(); } -QVariant SessionModel::headerData(int section, Qt::Orientation orientation, int role) const -{ +QVariant SessionModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { switch (section) { case SessionFlags::ITEM_NAME: @@ -109,23 +102,20 @@ QVariant SessionModel::headerData(int section, Qt::Orientation orientation, int return QVariant(); } -int SessionModel::rowCount(const QModelIndex& parent) const -{ +int SessionModel::rowCount(const QModelIndex& parent) const { if (parent.isValid() && parent.column() != 0) return 0; SessionItem* parent_item = itemForIndex(parent); return parent_item ? parent_item->numberOfChildren() : 0; } -int SessionModel::columnCount(const QModelIndex& parent) const -{ +int SessionModel::columnCount(const QModelIndex& parent) const { if (parent.isValid() && parent.column() != 0) return 0; return SessionFlags::MAX_COLUMNS; } -QModelIndex SessionModel::index(int row, int column, const QModelIndex& parent) const -{ +QModelIndex SessionModel::index(int row, int column, const QModelIndex& parent) const { if (!m_root_item || row < 0 || column < 0 || column >= columnCount(QModelIndex()) || (parent.isValid() && parent.column() != 0)) return QModelIndex(); @@ -137,8 +127,7 @@ QModelIndex SessionModel::index(int row, int column, const QModelIndex& parent) return QModelIndex(); } -QModelIndex SessionModel::parent(const QModelIndex& child) const -{ +QModelIndex SessionModel::parent(const QModelIndex& child) const { if (!child.isValid()) return QModelIndex(); @@ -153,8 +142,7 @@ QModelIndex SessionModel::parent(const QModelIndex& child) const return QModelIndex(); } -bool SessionModel::setData(const QModelIndex& index, const QVariant& value, int role) -{ +bool SessionModel::setData(const QModelIndex& index, const QVariant& value, int role) { if (!index.isValid()) return false; @@ -166,8 +154,7 @@ bool SessionModel::setData(const QModelIndex& index, const QVariant& value, int return false; } -bool SessionModel::removeRows(int row, int count, const QModelIndex& parent) -{ +bool SessionModel::removeRows(int row, int count, const QModelIndex& parent) { if (!m_root_item) return false; SessionItem* item = parent.isValid() ? itemForIndex(parent) : m_root_item; @@ -176,13 +163,11 @@ bool SessionModel::removeRows(int row, int count, const QModelIndex& parent) return true; } -QStringList SessionModel::mimeTypes() const -{ +QStringList SessionModel::mimeTypes() const { return QStringList() << SessionXML::ItemMimeType; } -QMimeData* SessionModel::mimeData(const QModelIndexList& indices) const -{ +QMimeData* SessionModel::mimeData(const QModelIndexList& indices) const { if (indices.count() != 2) return 0; @@ -198,8 +183,7 @@ QMimeData* SessionModel::mimeData(const QModelIndexList& indices) const } bool SessionModel::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, - int column, const QModelIndex& parent) const -{ + int column, const QModelIndex& parent) const { Q_UNUSED(row); if (action == Qt::IgnoreAction) @@ -226,8 +210,7 @@ bool SessionModel::canDropMimeData(const QMimeData* data, Qt::DropAction action, } bool SessionModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, - const QModelIndex& parent) -{ + const QModelIndex& parent) { if (action == Qt::IgnoreAction) return true; if (action != Qt::MoveAction || column > 0 || !data @@ -249,8 +232,7 @@ bool SessionModel::dropMimeData(const QMimeData* data, Qt::DropAction action, in return false; } -QModelIndex SessionModel::indexOfItem(SessionItem* item) const -{ +QModelIndex SessionModel::indexOfItem(SessionItem* item) const { if (!item || item == m_root_item || !item->parent()) return QModelIndex(); SessionItem* parent_item = item->parent(); @@ -259,8 +241,7 @@ QModelIndex SessionModel::indexOfItem(SessionItem* item) const } SessionItem* SessionModel::insertNewItem(QString model_type, const QModelIndex& parent, int row, - QString tag) -{ + QString tag) { SessionItem* parent_item = itemForIndex(parent); if (!parent_item) parent_item = m_root_item; @@ -285,8 +266,7 @@ SessionItem* SessionModel::insertNewItem(QString model_type, const QModelIndex& return new_item; } -QVector<QString> SessionModel::acceptableDefaultItemTypes(const QModelIndex& parent) const -{ +QVector<QString> SessionModel::acceptableDefaultItemTypes(const QModelIndex& parent) const { QVector<QString> result; if (SessionItem* parent_item = itemForIndex(parent)) result = parent_item->acceptableDefaultItemTypes(); @@ -294,16 +274,14 @@ QVector<QString> SessionModel::acceptableDefaultItemTypes(const QModelIndex& par return result; } -void SessionModel::clear() -{ +void SessionModel::clear() { beginResetModel(); delete m_root_item; createRootItem(); endResetModel(); } -void SessionModel::load(const QString& filename) -{ +void SessionModel::load(const QString& filename) { beginResetModel(); QFile file(filename); if (!file.open(QIODevice::ReadOnly)) @@ -317,8 +295,7 @@ void SessionModel::load(const QString& filename) endResetModel(); } -void SessionModel::save(const QString& filename) -{ +void SessionModel::save(const QString& filename) { QFile file(filename); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) throw GUIHelpers::Error(file.errorString()); @@ -333,8 +310,7 @@ void SessionModel::save(const QString& filename) writer.writeEndDocument(); } -SessionItem* SessionModel::itemForIndex(const QModelIndex& index) const -{ +SessionItem* SessionModel::itemForIndex(const QModelIndex& index) const { if (index.isValid()) if (SessionItem* item = static_cast<SessionItem*>(index.internalPointer())) return item; @@ -342,8 +318,7 @@ SessionItem* SessionModel::itemForIndex(const QModelIndex& index) const return m_root_item; } -void SessionModel::readFrom(QXmlStreamReader* reader, MessageService* messageService) -{ +void SessionModel::readFrom(QXmlStreamReader* reader, MessageService* messageService) { ASSERT(reader); if (reader->name() != m_model_tag) @@ -360,8 +335,7 @@ void SessionModel::readFrom(QXmlStreamReader* reader, MessageService* messageSer endResetModel(); } -void SessionModel::writeTo(QXmlStreamWriter* writer, SessionItem* parent) -{ +void SessionModel::writeTo(QXmlStreamWriter* writer, SessionItem* parent) { if (!parent) parent = m_root_item; SessionXML::writeTo(writer, parent); @@ -371,8 +345,7 @@ void SessionModel::writeTo(QXmlStreamWriter* writer, SessionItem* parent) //! use root_item as a new parent. SessionItem* SessionModel::moveItem(SessionItem* item, SessionItem* new_parent, int row, - const QString& tag) -{ + const QString& tag) { if (!new_parent) new_parent = m_root_item; @@ -406,8 +379,7 @@ SessionItem* SessionModel::moveItem(SessionItem* item, SessionItem* new_parent, //! another model and it will remains intact. Returns pointer to the new child. SessionItem* SessionModel::copyItem(const SessionItem* item_to_copy, SessionItem* new_parent, - const QString& tag) -{ + const QString& tag) { if (!new_parent) new_parent = m_root_item; @@ -423,14 +395,12 @@ SessionItem* SessionModel::copyItem(const SessionItem* item_to_copy, SessionItem return new_parent->getItems(tagName).back(); } -SessionModel* SessionModel::createCopy(SessionItem* parent) -{ +SessionModel* SessionModel::createCopy(SessionItem* parent) { Q_UNUSED(parent); throw GUIHelpers::Error("SessionModel::createCopy() -> Error. Not implemented."); } -void SessionModel::initFrom(SessionModel* model, SessionItem*) -{ +void SessionModel::initFrom(SessionModel* model, SessionItem*) { QByteArray byte_array; QXmlStreamWriter writer(&byte_array); writer.setAutoFormatting(true); @@ -447,12 +417,10 @@ void SessionModel::initFrom(SessionModel* model, SessionItem*) modelLoaded(); } -SessionItem* SessionModel::rootItem() const -{ +SessionItem* SessionModel::rootItem() const { return m_root_item; } -QVector<SessionItem*> SessionModel::nonXMLData() const -{ +QVector<SessionItem*> SessionModel::nonXMLData() const { return QVector<SessionItem*>(); } diff --git a/GUI/coregui/Models/SessionModel.h b/GUI/coregui/Models/SessionModel.h index 038a9900fec50a6bac4b90a1d72f8dfd8796d7d4..583404dd06eb98624c8951009e07f901361b9a70 100644 --- a/GUI/coregui/Models/SessionModel.h +++ b/GUI/coregui/Models/SessionModel.h @@ -20,8 +20,7 @@ #include "GUI/coregui/Models/SessionXML.h" #include <QStringList> -class SessionModel : public QAbstractItemModel -{ +class SessionModel : public QAbstractItemModel { Q_OBJECT friend class SessionItem; @@ -104,14 +103,12 @@ private: QString m_model_tag; //!< model tag (SampleModel, InstrumentModel) }; -template <typename T> T* SessionModel::topItem() const -{ +template <typename T> T* SessionModel::topItem() const { auto items = topItems<T>(); return items.isEmpty() ? nullptr : items.front(); } -template <typename T> QVector<T*> SessionModel::topItems() const -{ +template <typename T> QVector<T*> SessionModel::topItems() const { QVector<T*> result; QModelIndex parentIndex; @@ -124,33 +121,27 @@ template <typename T> QVector<T*> SessionModel::topItems() const return result; } -inline bool SessionModel::setHeaderData(int, Qt::Orientation, const QVariant&, int) -{ +inline bool SessionModel::setHeaderData(int, Qt::Orientation, const QVariant&, int) { return false; } -inline Qt::DropActions SessionModel::supportedDragActions() const -{ +inline Qt::DropActions SessionModel::supportedDragActions() const { return Qt::MoveAction; } -inline Qt::DropActions SessionModel::supportedDropActions() const -{ +inline Qt::DropActions SessionModel::supportedDropActions() const { return Qt::MoveAction; } -inline QString SessionModel::getModelTag() const -{ +inline QString SessionModel::getModelTag() const { return m_model_tag; } -inline QString SessionModel::getModelName() const -{ +inline QString SessionModel::getModelName() const { return m_name; } -inline void SessionModel::setDraggedItemType(const QString& type) -{ +inline void SessionModel::setDraggedItemType(const QString& type) { m_dragged_item_type = type; } diff --git a/GUI/coregui/Models/SessionModelDelegate.cpp b/GUI/coregui/Models/SessionModelDelegate.cpp index 709b2601b3ffae3e2731b3ab7b08553c13cce039..ffc510b6cdda9d70b859520091c7c57acd13ed7f 100644 --- a/GUI/coregui/Models/SessionModelDelegate.cpp +++ b/GUI/coregui/Models/SessionModelDelegate.cpp @@ -19,16 +19,14 @@ #include "GUI/coregui/utils/CustomEventFilters.h" #include <QApplication> -namespace -{ +namespace { QWidget* createEditorFromIndex(const QModelIndex& index, QWidget* parent); } // unnamed namespace SessionModelDelegate::SessionModelDelegate(QObject* parent) : QStyledItemDelegate(parent) {} void SessionModelDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ + const QModelIndex& index) const { if (PropertyEditorFactory::hasStringRepresentation(index)) { QString text = PropertyEditorFactory::toString(index); paintCustomLabel(painter, option, index, text); @@ -37,8 +35,7 @@ void SessionModelDelegate::paint(QPainter* painter, const QStyleOptionViewItem& } QWidget* SessionModelDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ + const QModelIndex& index) const { auto result = createEditorFromIndex(index, parent); if (auto customEditor = dynamic_cast<CustomEditor*>(result)) { @@ -56,8 +53,7 @@ QWidget* SessionModelDelegate::createEditor(QWidget* parent, const QStyleOptionV //! Propagates changed data from the editor to the model. void SessionModelDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, - const QModelIndex& index) const -{ + const QModelIndex& index) const { if (!index.isValid()) return; @@ -69,8 +65,7 @@ void SessionModelDelegate::setModelData(QWidget* editor, QAbstractItemModel* mod //! Propagates the data change from the model to the editor (if it is still opened). -void SessionModelDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const -{ +void SessionModelDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { if (!index.isValid()) return; @@ -83,8 +78,7 @@ void SessionModelDelegate::setEditorData(QWidget* editor, const QModelIndex& ind //! Increases height of the row by 20% wrt the default. QSize SessionModelDelegate::sizeHint(const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ + const QModelIndex& index) const { QSize result = QStyledItemDelegate::sizeHint(option, index); result.setHeight(static_cast<int>(result.height() * 1.2)); return result; @@ -95,16 +89,14 @@ QSize SessionModelDelegate::sizeHint(const QStyleOptionViewItem& option, //! up and running. void SessionModelDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ + const QModelIndex& index) const { QStyledItemDelegate::updateEditorGeometry(editor, option, index); editor->setGeometry(option.rect); } //! Notifies everyone that the editor has completed editing the data. -void SessionModelDelegate::onCustomEditorDataChanged(const QVariant&) -{ +void SessionModelDelegate::onCustomEditorDataChanged(const QVariant&) { CustomEditor* editor = qobject_cast<CustomEditor*>(sender()); ASSERT(editor); emit commitData(editor); @@ -113,8 +105,7 @@ void SessionModelDelegate::onCustomEditorDataChanged(const QVariant&) //! Paints custom text in a a place corresponding given index. void SessionModelDelegate::paintCustomLabel(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index, const QString& text) const -{ + const QModelIndex& index, const QString& text) const { QStyleOptionViewItem opt = option; initStyleOption(&opt, index); // calling original method to take into accounts colors etc opt.text = displayText(text, option.locale); // by overriding text with ours @@ -123,10 +114,8 @@ void SessionModelDelegate::paintCustomLabel(QPainter* painter, const QStyleOptio style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget); } -namespace -{ -QWidget* createEditorFromIndex(const QModelIndex& index, QWidget* parent) -{ +namespace { +QWidget* createEditorFromIndex(const QModelIndex& index, QWidget* parent) { if (index.internalPointer()) { auto item = static_cast<SessionItem*>(index.internalPointer()); return PropertyEditorFactory::CreateEditor(*item, parent); diff --git a/GUI/coregui/Models/SessionModelDelegate.h b/GUI/coregui/Models/SessionModelDelegate.h index 00630a76cee54f24926797291f6f36a8865ec7ed..51ffb496b3babfa58c45431a71f2656bd29ee89c 100644 --- a/GUI/coregui/Models/SessionModelDelegate.h +++ b/GUI/coregui/Models/SessionModelDelegate.h @@ -21,8 +21,7 @@ //! standard QTreeView. Extents base QItemDelegate with possibility to show/edit //! our custom QVariant's. -class SessionModelDelegate : public QStyledItemDelegate -{ +class SessionModelDelegate : public QStyledItemDelegate { Q_OBJECT public: SessionModelDelegate(QObject* parent); diff --git a/GUI/coregui/Models/SessionXML.cpp b/GUI/coregui/Models/SessionXML.cpp index d95c92c1eb7d1b53ed8ec3356363eb4c34ffd1d4..57efcce93e7847195fd7575ff989b961a7869c5f 100644 --- a/GUI/coregui/Models/SessionXML.cpp +++ b/GUI/coregui/Models/SessionXML.cpp @@ -23,8 +23,7 @@ #include "GUI/coregui/utils/MessageService.h" #include <QtCore/QXmlStreamWriter> -namespace -{ +namespace { const QString bool_type_name = "bool"; const QString double_type_name = "double"; const QString int_type_name = "int"; @@ -36,8 +35,7 @@ void report_error(MessageService* messageService, SessionItem* item, const QStri SessionItem* createItem(SessionItem* item, const QString& modelType, const QString& tag); } // namespace -void SessionXML::writeTo(QXmlStreamWriter* writer, SessionItem* parent) -{ +void SessionXML::writeTo(QXmlStreamWriter* writer, SessionItem* parent) { writer->writeStartElement(parent->model()->getModelTag()); writer->writeAttribute(SessionXML::ModelNameAttribute, parent->model()->getModelName()); @@ -46,8 +44,7 @@ void SessionXML::writeTo(QXmlStreamWriter* writer, SessionItem* parent) writer->writeEndElement(); // m_model_tag } -void SessionXML::writeItemAndChildItems(QXmlStreamWriter* writer, const SessionItem* item) -{ +void SessionXML::writeItemAndChildItems(QXmlStreamWriter* writer, const SessionItem* item) { if (item->parent()) { writer->writeStartElement(SessionXML::ItemTag); writer->writeAttribute(SessionXML::ModelTypeAttribute, item->modelType()); @@ -68,8 +65,7 @@ void SessionXML::writeItemAndChildItems(QXmlStreamWriter* writer, const SessionI writer->writeEndElement(); // ItemTag } -void SessionXML::writeVariant(QXmlStreamWriter* writer, QVariant variant, int role) -{ +void SessionXML::writeVariant(QXmlStreamWriter* writer, QVariant variant, int role) { if (variant.isValid()) { writer->writeStartElement(SessionXML::ParameterTag); QString type_name = variant.typeName(); @@ -112,8 +108,7 @@ void SessionXML::writeVariant(QXmlStreamWriter* writer, QVariant variant, int ro } void SessionXML::readItems(QXmlStreamReader* reader, SessionItem* parent, QString topTag, - MessageService* messageService) -{ + MessageService* messageService) { ASSERT(parent); const QString start_type = parent->model()->getModelTag(); while (!reader->atEnd()) { @@ -157,8 +152,7 @@ void SessionXML::readItems(QXmlStreamReader* reader, SessionItem* parent, QStrin } QString SessionXML::readProperty(QXmlStreamReader* reader, SessionItem* item, - MessageService* messageService) -{ + MessageService* messageService) { const QString parameter_name = reader->attributes().value(SessionXML::ParameterNameAttribute).toString(); const QString parameter_type = @@ -228,10 +222,8 @@ QString SessionXML::readProperty(QXmlStreamReader* reader, SessionItem* item, return parameter_name; } -namespace -{ -void report_error(MessageService* messageService, SessionItem* item, const QString& message) -{ +namespace { +void report_error(MessageService* messageService, SessionItem* item, const QString& message) { if (messageService) { messageService->send_warning(item->model(), message); } else { @@ -239,8 +231,7 @@ void report_error(MessageService* messageService, SessionItem* item, const QStri } } -SessionItem* createItem(SessionItem* item, const QString& modelType, const QString& tag) -{ +SessionItem* createItem(SessionItem* item, const QString& modelType, const QString& tag) { SessionItem* result(nullptr); if (item->modelType() == "GroupProperty") { diff --git a/GUI/coregui/Models/SessionXML.h b/GUI/coregui/Models/SessionXML.h index 305b27af09770e99bc54fef0efe36b6278626c76..d9908c278d54265e113494b13307b8285c478de8 100644 --- a/GUI/coregui/Models/SessionXML.h +++ b/GUI/coregui/Models/SessionXML.h @@ -22,8 +22,7 @@ class QXmlStreamReader; class SessionItem; class MessageService; -namespace SessionXML -{ +namespace SessionXML { const QString ItemMimeType = "application/org.bornagainproject.xml.item.z"; const QString LinkMimeType = "application/org.bornagainproject.fittinglink"; diff --git a/GUI/coregui/Models/SimulationOptionsItem.cpp b/GUI/coregui/Models/SimulationOptionsItem.cpp index 423b57068bfbdc86d79cb1b563225510d2a209e9..240dddcebbfcfb3f9eb6ba7300ea8e3544f2dbde 100644 --- a/GUI/coregui/Models/SimulationOptionsItem.cpp +++ b/GUI/coregui/Models/SimulationOptionsItem.cpp @@ -16,11 +16,9 @@ #include "GUI/coregui/Models/ComboProperty.h" #include <thread> -namespace -{ +namespace { -QStringList getRunPolicyTooltips() -{ +QStringList getRunPolicyTooltips() { QStringList result; result.append("Start simulation immediately, switch to Jobs view automatically when completed"); result.append("Start simulation immediately, do not switch to Jobs view when completed"); @@ -47,8 +45,7 @@ const QString SimulationOptionsItem::P_FRESNEL_MATERIAL_METHOD = "Material for Fresnel calculations"; const QString SimulationOptionsItem::P_INCLUDE_SPECULAR_PEAK = "Include specular peak"; -SimulationOptionsItem::SimulationOptionsItem() : SessionItem("SimulationOptions") -{ +SimulationOptionsItem::SimulationOptionsItem() : SessionItem("SimulationOptions") { ComboProperty policy; policy << getRunPolicyNames(); @@ -96,87 +93,73 @@ SimulationOptionsItem::SimulationOptionsItem() : SessionItem("SimulationOptions" }); } -int SimulationOptionsItem::getNumberOfThreads() const -{ +int SimulationOptionsItem::getNumberOfThreads() const { ComboProperty combo = getItemValue(P_NTHREADS).value<ComboProperty>(); return m_text_to_nthreads[combo.getValue()]; } -bool SimulationOptionsItem::runImmediately() const -{ +bool SimulationOptionsItem::runImmediately() const { return runPolicy() == "Immediately"; } -bool SimulationOptionsItem::runInBackground() const -{ +bool SimulationOptionsItem::runInBackground() const { return runPolicy() == "In background"; } -void SimulationOptionsItem::setRunPolicy(const QString& policy) -{ +void SimulationOptionsItem::setRunPolicy(const QString& policy) { ComboProperty combo = getItemValue(P_RUN_POLICY).value<ComboProperty>(); combo.setValue(policy); setItemValue(P_RUN_POLICY, combo.variant()); } -void SimulationOptionsItem::setComputationMethod(const QString& name) -{ +void SimulationOptionsItem::setComputationMethod(const QString& name) { ComboProperty combo = getItemValue(P_COMPUTATION_METHOD).value<ComboProperty>(); combo.setValue(name); setItemValue(P_COMPUTATION_METHOD, combo.variant()); } -QString SimulationOptionsItem::getComputationMethod() const -{ +QString SimulationOptionsItem::getComputationMethod() const { ComboProperty combo = getItemValue(P_COMPUTATION_METHOD).value<ComboProperty>(); return combo.getValue(); } -int SimulationOptionsItem::getNumberOfMonteCarloPoints() const -{ +int SimulationOptionsItem::getNumberOfMonteCarloPoints() const { return getItemValue(P_MC_POINTS).toInt(); } -void SimulationOptionsItem::setNumberOfMonteCarloPoints(int npoints) -{ +void SimulationOptionsItem::setNumberOfMonteCarloPoints(int npoints) { setItemValue(P_MC_POINTS, npoints); } -void SimulationOptionsItem::setFresnelMaterialMethod(const QString& name) -{ +void SimulationOptionsItem::setFresnelMaterialMethod(const QString& name) { ComboProperty combo = getItemValue(P_FRESNEL_MATERIAL_METHOD).value<ComboProperty>(); combo.setValue(name); setItemValue(P_FRESNEL_MATERIAL_METHOD, combo.variant()); } -QString SimulationOptionsItem::getFresnelMaterialMethod() const -{ +QString SimulationOptionsItem::getFresnelMaterialMethod() const { ComboProperty combo = getItemValue(P_FRESNEL_MATERIAL_METHOD).value<ComboProperty>(); return combo.getValue(); } -void SimulationOptionsItem::setIncludeSpecularPeak(const QString& name) -{ +void SimulationOptionsItem::setIncludeSpecularPeak(const QString& name) { ComboProperty combo = getItemValue(P_INCLUDE_SPECULAR_PEAK).value<ComboProperty>(); combo.setValue(name); setItemValue(P_INCLUDE_SPECULAR_PEAK, combo.variant()); } -QString SimulationOptionsItem::getIncludeSpecularPeak() const -{ +QString SimulationOptionsItem::getIncludeSpecularPeak() const { ComboProperty combo = getItemValue(P_INCLUDE_SPECULAR_PEAK).value<ComboProperty>(); return combo.getValue(); } -QString SimulationOptionsItem::runPolicy() const -{ +QString SimulationOptionsItem::runPolicy() const { ComboProperty combo = getItemValue(P_RUN_POLICY).value<ComboProperty>(); return combo.getValue(); } //! returns list with number of threads to select -QStringList SimulationOptionsItem::getCPUUsageOptions() -{ +QStringList SimulationOptionsItem::getCPUUsageOptions() { m_text_to_nthreads.clear(); QStringList result; int nthreads = static_cast<int>(std::thread::hardware_concurrency()); @@ -195,16 +178,14 @@ QStringList SimulationOptionsItem::getCPUUsageOptions() return result; } -QStringList SimulationOptionsItem::getRunPolicyNames() -{ +QStringList SimulationOptionsItem::getRunPolicyNames() { QStringList result; result << "Immediately" << "In background"; return result; } -void SimulationOptionsItem::updateComboItem(QString name, QStringList option_names) -{ +void SimulationOptionsItem::updateComboItem(QString name, QStringList option_names) { ComboProperty combo = getItemValue(name).value<ComboProperty>(); if (combo.getValues().size() != option_names.size()) { auto p_item = getItem(name); diff --git a/GUI/coregui/Models/SimulationOptionsItem.h b/GUI/coregui/Models/SimulationOptionsItem.h index 1ce1b25f3babbb28beb6ac37ef5f2d267f46eb9f..3ff692765d00032b8936e72024c758cacee70344 100644 --- a/GUI/coregui/Models/SimulationOptionsItem.h +++ b/GUI/coregui/Models/SimulationOptionsItem.h @@ -22,8 +22,7 @@ //! integration flag). Used in SimulationView to define job settings. When job is started, //! item is copied to the job as a child. -class BA_CORE_API_ SimulationOptionsItem : public SessionItem -{ +class BA_CORE_API_ SimulationOptionsItem : public SessionItem { public: static const QString P_RUN_POLICY; static const QString P_NTHREADS; diff --git a/GUI/coregui/Models/SpecularBeamInclinationItem.cpp b/GUI/coregui/Models/SpecularBeamInclinationItem.cpp index a46158b16c27c5a047118b9186fa7d2aa41ac84f..b005658f4fb5c3c752a4067fe25ad1b7e782a397 100644 --- a/GUI/coregui/Models/SpecularBeamInclinationItem.cpp +++ b/GUI/coregui/Models/SpecularBeamInclinationItem.cpp @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/GroupItem.h" #include "GUI/coregui/Models/PointwiseAxisItem.h" -namespace -{ +namespace { void setupDistributionMean(SessionItem* distribution); void setAxisPresentationDefaults(SessionItem* axis_item, const QString& type); } // namespace @@ -26,8 +25,7 @@ void setAxisPresentationDefaults(SessionItem* axis_item, const QString& type); const QString SpecularBeamInclinationItem::P_ALPHA_AXIS = "Alpha axis"; SpecularBeamInclinationItem::SpecularBeamInclinationItem() - : BeamDistributionItem("SpecularBeamInclinationAxis", m_show_mean) -{ + : BeamDistributionItem("SpecularBeamInclinationAxis", m_show_mean) { register_distribution_group("Symmetric distribution group"); setupAxisGroup(); setupDistributionMean(getGroupItem(P_DISTRIBUTION)); @@ -37,20 +35,17 @@ SpecularBeamInclinationItem::SpecularBeamInclinationItem() SpecularBeamInclinationItem::~SpecularBeamInclinationItem() = default; -double SpecularBeamInclinationItem::scaleFactor() const -{ +double SpecularBeamInclinationItem::scaleFactor() const { return Units::deg; } -void SpecularBeamInclinationItem::updateFileName(const QString& filename) -{ +void SpecularBeamInclinationItem::updateFileName(const QString& filename) { auto& group_item = item<GroupItem>(P_ALPHA_AXIS); auto axis_item = group_item.getChildOfType("PointwiseAxis"); axis_item->setItemValue(PointwiseAxisItem::P_FILE_NAME, filename); } -void SpecularBeamInclinationItem::setupAxisGroup() -{ +void SpecularBeamInclinationItem::setupAxisGroup() { auto group_item = dynamic_cast<GroupItem*>(this->addGroupProperty(P_ALPHA_AXIS, "Axes group")); // Both underlying axis items are created, since it @@ -75,10 +70,8 @@ void SpecularBeamInclinationItem::setupAxisGroup() this); } -namespace -{ -void setupDistributionMean(SessionItem* distribution) -{ +namespace { +void setupDistributionMean(SessionItem* distribution) { ASSERT(distribution); SessionItem* valueItem = distribution->getItem(DistributionNoneItem::P_MEAN); @@ -89,8 +82,7 @@ void setupDistributionMean(SessionItem* distribution) valueItem->setValue(0.0); } -void setAxisPresentationDefaults(SessionItem* axis_item, const QString& type) -{ +void setAxisPresentationDefaults(SessionItem* axis_item, const QString& type) { axis_item->getItem(BasicAxisItem::P_TITLE)->setVisible(false); axis_item->setItemValue(BasicAxisItem::P_TITLE, "alpha_i"); axis_item->getItem(BasicAxisItem::P_NBINS)->setToolTip("Number of points in scan"); diff --git a/GUI/coregui/Models/SpecularBeamInclinationItem.h b/GUI/coregui/Models/SpecularBeamInclinationItem.h index fa0d93ff73080976d3c06fdb122aa1d9335fa0bb..3f862052e303f5299f3ca117c9c6fbb4ddb8eeb9 100644 --- a/GUI/coregui/Models/SpecularBeamInclinationItem.h +++ b/GUI/coregui/Models/SpecularBeamInclinationItem.h @@ -22,8 +22,7 @@ //! Considering distribution, differs from BeamInclinationAngleItem //! by any distribution mean value being always zero. -class BA_CORE_API_ SpecularBeamInclinationItem : public BeamDistributionItem -{ +class BA_CORE_API_ SpecularBeamInclinationItem : public BeamDistributionItem { public: static const QString P_ALPHA_AXIS; diff --git a/GUI/coregui/Models/SpecularDataItem.cpp b/GUI/coregui/Models/SpecularDataItem.cpp index 5e6192dd97935d26a64a7b8f7f444f9095b4bb38..f27100b9f7e633dddc956885faae414fd469bca9 100644 --- a/GUI/coregui/Models/SpecularDataItem.cpp +++ b/GUI/coregui/Models/SpecularDataItem.cpp @@ -22,8 +22,7 @@ const QString SpecularDataItem::P_TITLE = "Title"; const QString SpecularDataItem::P_XAXIS = "x-axis"; const QString SpecularDataItem::P_YAXIS = "y-axis"; -SpecularDataItem::SpecularDataItem() : DataItem("SpecularData") -{ +SpecularDataItem::SpecularDataItem() : DataItem("SpecularData") { addProperty(P_TITLE, QString())->setVisible(false); SessionItem* item = addGroupProperty(P_XAXIS, "BasicAxis"); @@ -41,8 +40,7 @@ SpecularDataItem::SpecularDataItem() : DataItem("SpecularData") setYaxisTitle(SpecularDataAxesNames::y_axis_default_name); } -void SpecularDataItem::setOutputData(OutputData<double>* data) -{ +void SpecularDataItem::setOutputData(OutputData<double>* data) { ASSERT(data && "Assertion failed in SpecularDataItem::setOutputData: nullptr data passed"); if (data->rank() != 1) throw GUIHelpers::Error( @@ -54,99 +52,81 @@ void SpecularDataItem::setOutputData(OutputData<double>* data) emitDataChanged(); } -int SpecularDataItem::getNbins() const -{ +int SpecularDataItem::getNbins() const { return xAxisItem()->getItemValue(BasicAxisItem::P_NBINS).toInt(); } -double SpecularDataItem::getLowerX() const -{ +double SpecularDataItem::getLowerX() const { return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_MIN_DEG).toDouble(); } -double SpecularDataItem::getUpperX() const -{ +double SpecularDataItem::getUpperX() const { return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_MAX_DEG).toDouble(); } -double SpecularDataItem::getXmin() const -{ +double SpecularDataItem::getXmin() const { const double defaultXmin(0.0); return m_data ? m_data->axis(0).lowerBound() : defaultXmin; } -double SpecularDataItem::getXmax() const -{ +double SpecularDataItem::getXmax() const { const double defaultXmax(1.0); return m_data ? m_data->axis(0).upperBound() : defaultXmax; } -double SpecularDataItem::getLowerY() const -{ +double SpecularDataItem::getLowerY() const { return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_MIN_DEG).toDouble(); } -double SpecularDataItem::getUpperY() const -{ +double SpecularDataItem::getUpperY() const { return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_MAX_DEG).toDouble(); } -double SpecularDataItem::getYmin() const -{ +double SpecularDataItem::getYmin() const { return dataRange().first; } -double SpecularDataItem::getYmax() const -{ +double SpecularDataItem::getYmax() const { return dataRange().second; } -bool SpecularDataItem::isLog() const -{ +bool SpecularDataItem::isLog() const { return getItem(P_YAXIS)->getItemValue(AmplitudeAxisItem::P_IS_LOGSCALE).toBool(); } -QString SpecularDataItem::getXaxisTitle() const -{ +QString SpecularDataItem::getXaxisTitle() const { return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_TITLE).toString(); } -QString SpecularDataItem::getYaxisTitle() const -{ +QString SpecularDataItem::getYaxisTitle() const { return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_TITLE).toString(); } -void SpecularDataItem::setXaxisTitle(QString xtitle) -{ +void SpecularDataItem::setXaxisTitle(QString xtitle) { getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_TITLE, xtitle); } -void SpecularDataItem::setYaxisTitle(QString ytitle) -{ +void SpecularDataItem::setYaxisTitle(QString ytitle) { getItem(P_YAXIS)->setItemValue(AmplitudeAxisItem::P_TITLE, ytitle); } //! set zoom range of x,y axes to axes of input data -void SpecularDataItem::setAxesRangeToData() -{ +void SpecularDataItem::setAxesRangeToData() { setLowerX(getXmin()); setUpperX(getXmax()); setLowerY(getYmin()); setUpperY(getYmax()); } -void SpecularDataItem::updateAxesUnits(const InstrumentItem* instrument) -{ +void SpecularDataItem::updateAxesUnits(const InstrumentItem* instrument) { JobItemUtils::updateDataAxes(this, instrument); } -std::vector<int> SpecularDataItem::shape() const -{ +std::vector<int> SpecularDataItem::shape() const { return {getNbins()}; } -void SpecularDataItem::reset(ImportDataInfo data) -{ +void SpecularDataItem::reset(ImportDataInfo data) { ComboProperty combo = ComboProperty() << data.unitsLabel(); setItemValue(SpecularDataItem::P_AXES_UNITS, combo.variant()); getItem(SpecularDataItem::P_AXES_UNITS)->setVisible(true); @@ -157,35 +137,29 @@ void SpecularDataItem::reset(ImportDataInfo data) setAxesRangeToData(); } -void SpecularDataItem::setLowerX(double xmin) -{ +void SpecularDataItem::setLowerX(double xmin) { getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_MIN_DEG, xmin); } -void SpecularDataItem::setUpperX(double xmax) -{ +void SpecularDataItem::setUpperX(double xmax) { getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_MAX_DEG, xmax); } -void SpecularDataItem::setLowerY(double ymin) -{ +void SpecularDataItem::setLowerY(double ymin) { getItem(P_YAXIS)->setItemValue(AmplitudeAxisItem::P_MIN_DEG, ymin); } -void SpecularDataItem::setUpperY(double ymax) -{ +void SpecularDataItem::setUpperY(double ymax) { getItem(P_YAXIS)->setItemValue(AmplitudeAxisItem::P_MAX_DEG, ymax); } -void SpecularDataItem::setLog(bool log_flag) -{ +void SpecularDataItem::setLog(bool log_flag) { getItem(P_YAXIS)->setItemValue(AmplitudeAxisItem::P_IS_LOGSCALE, log_flag); } //! Sets zoom range of X,Y axes, if it was not yet defined. -void SpecularDataItem::updateAxesZoomLevel() -{ +void SpecularDataItem::updateAxesZoomLevel() { // set zoom range of x-axis to min, max values if it was not set already if (getUpperX() < getLowerX()) { setLowerX(getXmin()); @@ -203,8 +177,7 @@ void SpecularDataItem::updateAxesZoomLevel() } //! Init ymin, ymax to match the intensity values range. -QPair<double, double> SpecularDataItem::dataRange() const -{ +QPair<double, double> SpecularDataItem::dataRange() const { const double default_min = 0.0; const double default_max = 1.0; const OutputData<double>* data = getOutputData(); @@ -221,18 +194,15 @@ QPair<double, double> SpecularDataItem::dataRange() const return QPair<double, double>(min, max); } -const BasicAxisItem* SpecularDataItem::xAxisItem() const -{ +const BasicAxisItem* SpecularDataItem::xAxisItem() const { return dynamic_cast<const BasicAxisItem*>(getItem(P_XAXIS)); } -BasicAxisItem* SpecularDataItem::xAxisItem() -{ +BasicAxisItem* SpecularDataItem::xAxisItem() { return const_cast<BasicAxisItem*>(static_cast<const SpecularDataItem*>(this)->xAxisItem()); } -const AmplitudeAxisItem* SpecularDataItem::yAxisItem() const -{ +const AmplitudeAxisItem* SpecularDataItem::yAxisItem() const { auto result = dynamic_cast<const AmplitudeAxisItem*>(getItem(P_YAXIS)); ASSERT(result); return result; @@ -240,7 +210,6 @@ const AmplitudeAxisItem* SpecularDataItem::yAxisItem() const //! Set axes viewport to original data. -void SpecularDataItem::resetView() -{ +void SpecularDataItem::resetView() { setAxesRangeToData(); } diff --git a/GUI/coregui/Models/SpecularDataItem.h b/GUI/coregui/Models/SpecularDataItem.h index d0ea8e79941bdd7f3fc921da6d18dcd93c4d8313..200a4e7fe946e2a980b88e8c1be111d25209bbc1 100644 --- a/GUI/coregui/Models/SpecularDataItem.h +++ b/GUI/coregui/Models/SpecularDataItem.h @@ -20,14 +20,12 @@ class AmplitudeAxisItem; class BasicAxisItem; -namespace SpecularDataAxesNames -{ +namespace SpecularDataAxesNames { const QString x_axis_default_name = "X [nbins]"; const QString y_axis_default_name = "Signal [a.u.]"; } // namespace SpecularDataAxesNames -class BA_CORE_API_ SpecularDataItem : public DataItem -{ +class BA_CORE_API_ SpecularDataItem : public DataItem { public: static const QString P_TITLE; static const QString P_XAXIS; diff --git a/GUI/coregui/Models/SphericalDetectorItem.cpp b/GUI/coregui/Models/SphericalDetectorItem.cpp index a0e94e4dcd70f58bb2b6439e2153733098a7795d..016bdf68e19a61f17d814c80a24d91e7837d0415 100644 --- a/GUI/coregui/Models/SphericalDetectorItem.cpp +++ b/GUI/coregui/Models/SphericalDetectorItem.cpp @@ -20,8 +20,7 @@ const QString SphericalDetectorItem::P_PHI_AXIS = "Phi axis"; const QString SphericalDetectorItem::P_ALPHA_AXIS = "Alpha axis"; -SphericalDetectorItem::SphericalDetectorItem() : DetectorItem("SphericalDetector") -{ +SphericalDetectorItem::SphericalDetectorItem() : DetectorItem("SphericalDetector") { SessionItem* item = addGroupProperty(P_PHI_AXIS, "BasicAxis"); item->getItem(BasicAxisItem::P_TITLE)->setVisible(false); item->setItemValue(BasicAxisItem::P_MIN_DEG, -1.0); @@ -43,8 +42,7 @@ SphericalDetectorItem::SphericalDetectorItem() : DetectorItem("SphericalDetector register_resolution_function(); } -std::unique_ptr<IDetector2D> SphericalDetectorItem::createDomainDetector() const -{ +std::unique_ptr<IDetector2D> SphericalDetectorItem::createDomainDetector() const { std::unique_ptr<SphericalDetector> result(new SphericalDetector()); auto x_axis = dynamic_cast<BasicAxisItem*>(getItem(SphericalDetectorItem::P_PHI_AXIS)); @@ -64,29 +62,24 @@ std::unique_ptr<IDetector2D> SphericalDetectorItem::createDomainDetector() const return std::unique_ptr<IDetector2D>(result.release()); } -int SphericalDetectorItem::xSize() const -{ +int SphericalDetectorItem::xSize() const { return getItem(SphericalDetectorItem::P_PHI_AXIS)->getItemValue(BasicAxisItem::P_NBINS).toInt(); } -int SphericalDetectorItem::ySize() const -{ +int SphericalDetectorItem::ySize() const { return getItem(SphericalDetectorItem::P_ALPHA_AXIS) ->getItemValue(BasicAxisItem::P_NBINS) .toInt(); } -void SphericalDetectorItem::setXSize(int nx) -{ +void SphericalDetectorItem::setXSize(int nx) { getItem(SphericalDetectorItem::P_PHI_AXIS)->setItemValue(BasicAxisItem::P_NBINS, nx); } -void SphericalDetectorItem::setYSize(int ny) -{ +void SphericalDetectorItem::setYSize(int ny) { getItem(SphericalDetectorItem::P_ALPHA_AXIS)->setItemValue(BasicAxisItem::P_NBINS, ny); } -double SphericalDetectorItem::axesToDomainUnitsFactor() const -{ +double SphericalDetectorItem::axesToDomainUnitsFactor() const { return Units::deg; } diff --git a/GUI/coregui/Models/SphericalDetectorItem.h b/GUI/coregui/Models/SphericalDetectorItem.h index 19abceabc93b89be698e2f27fada30f39694672a..b03e085cf8e934d3c8213d695110a315800352b8 100644 --- a/GUI/coregui/Models/SphericalDetectorItem.h +++ b/GUI/coregui/Models/SphericalDetectorItem.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/DetectorItems.h" -class BA_CORE_API_ SphericalDetectorItem : public DetectorItem -{ +class BA_CORE_API_ SphericalDetectorItem : public DetectorItem { public: static const QString P_PHI_AXIS; static const QString P_ALPHA_AXIS; diff --git a/GUI/coregui/Models/TransformFromDomain.cpp b/GUI/coregui/Models/TransformFromDomain.cpp index 8b28ad1645455da670ffded80ed5787634795913..9a0d98540c8100ed5391a26bafa11347cf481d71 100644 --- a/GUI/coregui/Models/TransformFromDomain.cpp +++ b/GUI/coregui/Models/TransformFromDomain.cpp @@ -66,8 +66,7 @@ using namespace INodeUtils; using SessionItemUtils::SetVectorItem; -namespace -{ +namespace { void SetPDF1D(SessionItem* item, const IFTDistribution1D* pdf, QString group_name); void setPDF2D(SessionItem* item, const IFTDistribution2D* pdf, QString group_name); void SetDecayFunction1D(SessionItem* item, const IFTDecayFunction1D* pdf, QString group_name); @@ -88,8 +87,7 @@ void addRangedDistributionToItem(SessionItem* item, const RangedDistribution& ra } // namespace void TransformFromDomain::set1DLatticeItem(SessionItem* item, - const InterferenceFunction1DLattice& sample) -{ + const InterferenceFunction1DLattice& sample) { item->setItemValue(InterferenceFunction1DLatticeItem::P_LENGTH, sample.getLength()); item->setItemValue(InterferenceFunction1DLatticeItem::P_ROTATION_ANGLE, Units::rad2deg(sample.getXi())); @@ -101,8 +99,7 @@ void TransformFromDomain::set1DLatticeItem(SessionItem* item, } void TransformFromDomain::set2DLatticeItem(SessionItem* item, - const InterferenceFunction2DLattice& sample) -{ + const InterferenceFunction2DLattice& sample) { set2DLatticeParameters(item, sample.lattice()); item->setItemValue(InterferenceFunction2DLatticeItem::P_XI_INTEGRATION, @@ -115,8 +112,7 @@ void TransformFromDomain::set2DLatticeItem(SessionItem* item, } void TransformFromDomain::set2DParaCrystalItem(SessionItem* item, - const InterferenceFunction2DParaCrystal& sample) -{ + const InterferenceFunction2DParaCrystal& sample) { set2DLatticeParameters(item, sample.lattice()); item->setItemValue(InterferenceFunction2DParaCrystalItem::P_DAMPING_LENGTH, @@ -137,9 +133,8 @@ void TransformFromDomain::set2DParaCrystalItem(SessionItem* item, setPositionVariance(item, sample); } -void TransformFromDomain::setFinite2DLatticeItem(SessionItem* item, - const InterferenceFunctionFinite2DLattice& sample) -{ +void TransformFromDomain::setFinite2DLatticeItem( + SessionItem* item, const InterferenceFunctionFinite2DLattice& sample) { set2DLatticeParameters(item, sample.lattice()); item->setItemValue(InterferenceFunctionFinite2DLatticeItem::P_DOMAIN_SIZE_1, @@ -154,16 +149,14 @@ void TransformFromDomain::setFinite2DLatticeItem(SessionItem* item, } void TransformFromDomain::setHardDiskItem(SessionItem* item, - const InterferenceFunctionHardDisk& sample) -{ + const InterferenceFunctionHardDisk& sample) { item->setItemValue(InterferenceFunctionHardDiskItem::P_RADIUS, sample.radius()); item->setItemValue(InterferenceFunctionHardDiskItem::P_DENSITY, sample.density()); setPositionVariance(item, sample); } void TransformFromDomain::setRadialParaCrystalItem( - SessionItem* item, const InterferenceFunctionRadialParaCrystal& sample) -{ + SessionItem* item, const InterferenceFunctionRadialParaCrystal& sample) { item->setItemValue(InterferenceFunctionRadialParaCrystalItem::P_PEAK_DISTANCE, sample.peakDistance()); item->setItemValue(InterferenceFunctionRadialParaCrystalItem::P_DAMPING_LENGTH, @@ -179,8 +172,7 @@ void TransformFromDomain::setRadialParaCrystalItem( } void TransformFromDomain::setLayerItem(SessionItem* layerItem, const Layer* layer, - const LayerInterface* top_interface) -{ + const LayerInterface* top_interface) { layerItem->setItemValue(LayerItem::P_THICKNESS, layer->thickness()); layerItem->setGroupProperty(LayerItem::P_ROUGHNESS, "LayerZeroRoughness"); layerItem->setItemValue(LayerItem::P_NSLICES, (int)layer->numberOfSlices()); @@ -195,8 +187,7 @@ void TransformFromDomain::setLayerItem(SessionItem* layerItem, const Layer* laye } } -void TransformFromDomain::setRoughnessItem(SessionItem* item, const LayerRoughness& sample) -{ +void TransformFromDomain::setRoughnessItem(SessionItem* item, const LayerRoughness& sample) { item->setItemValue(LayerBasicRoughnessItem::P_SIGMA, sample.getSigma()); item->setItemValue(LayerBasicRoughnessItem::P_HURST, sample.getHurstParameter()); item->setItemValue(LayerBasicRoughnessItem::P_LATERAL_CORR_LENGTH, @@ -205,8 +196,7 @@ void TransformFromDomain::setRoughnessItem(SessionItem* item, const LayerRoughne //! Initialization of ParticleDistributionItem void TransformFromDomain::setParticleDistributionItem(SessionItem* item, - const ParticleDistribution& sample) -{ + const ParticleDistribution& sample) { ParticleDistributionItem* distItem = dynamic_cast<ParticleDistributionItem*>(item); ASSERT(distItem); @@ -227,8 +217,7 @@ void TransformFromDomain::setParticleDistributionItem(SessionItem* item, } //! Returns true if given roughness is non-zero roughness -bool TransformFromDomain::isValidRoughness(const LayerRoughness* roughness) -{ +bool TransformFromDomain::isValidRoughness(const LayerRoughness* roughness) { if (!roughness) return false; if (roughness->getSigma() == 0 && roughness->getHurstParameter() == 0.0 @@ -237,8 +226,7 @@ bool TransformFromDomain::isValidRoughness(const LayerRoughness* roughness) return true; } -void TransformFromDomain::setGISASBeamItem(BeamItem* beam_item, const GISASSimulation& simulation) -{ +void TransformFromDomain::setGISASBeamItem(BeamItem* beam_item, const GISASSimulation& simulation) { ASSERT(beam_item); Beam beam = simulation.instrument().beam(); @@ -264,8 +252,7 @@ void TransformFromDomain::setGISASBeamItem(BeamItem* beam_item, const GISASSimul } void TransformFromDomain::setOffSpecBeamItem(BeamItem* beam_item, - const OffSpecSimulation& simulation) -{ + const OffSpecSimulation& simulation) { Beam beam = simulation.instrument().beam(); beam_item->setIntensity(beam.getIntensity()); @@ -276,8 +263,7 @@ void TransformFromDomain::setOffSpecBeamItem(BeamItem* beam_item, } void TransformFromDomain::setSpecularBeamItem(SpecularBeamItem* beam_item, - const SpecularSimulation& simulation) -{ + const SpecularSimulation& simulation) { const Beam& beam = simulation.instrument().beam(); beam_item->setIntensity(beam.getIntensity()); @@ -311,8 +297,7 @@ void TransformFromDomain::setSpecularBeamItem(SpecularBeamItem* beam_item, } void TransformFromDomain::setDetector(Instrument2DItem* instrument_item, - const ISimulation2D& simulation) -{ + const ISimulation2D& simulation) { const IDetector* p_detector = simulation.instrument().getDetector(); setDetectorGeometry(instrument_item, *p_detector); @@ -324,8 +309,7 @@ void TransformFromDomain::setDetector(Instrument2DItem* instrument_item, } void TransformFromDomain::setDetectorGeometry(Instrument2DItem* instrument_item, - const IDetector& detector) -{ + const IDetector& detector) { if (auto det = dynamic_cast<const SphericalDetector*>(&detector)) { instrument_item->setDetectorGroup("SphericalDetector"); auto item = dynamic_cast<SphericalDetectorItem*>(instrument_item->detectorItem()); @@ -341,8 +325,7 @@ void TransformFromDomain::setDetectorGeometry(Instrument2DItem* instrument_item, } void TransformFromDomain::setDetectorResolution(DetectorItem* detector_item, - const IDetector& detector) -{ + const IDetector& detector) { const IDetectorResolution* p_resfunc = detector.detectorResolution(); if (!p_resfunc) @@ -371,8 +354,7 @@ void TransformFromDomain::setDetectorResolution(DetectorItem* detector_item, } void TransformFromDomain::setDetectorProperties(DetectorItem* detector_item, - const IDetector& detector) -{ + const IDetector& detector) { double total_transmission = detector.detectionProperties().analyzerTotalTransmission(); if (total_transmission <= 0.0) return; @@ -385,8 +367,7 @@ void TransformFromDomain::setDetectorProperties(DetectorItem* detector_item, } void TransformFromDomain::setSphericalDetector(SphericalDetectorItem* detector_item, - const SphericalDetector& detector) -{ + const SphericalDetector& detector) { // Axes const IAxis& phi_axis = detector.axis(0); const IAxis& alpha_axis = detector.axis(1); @@ -407,8 +388,7 @@ void TransformFromDomain::setSphericalDetector(SphericalDetectorItem* detector_i } void TransformFromDomain::setRectangularDetector(RectangularDetectorItem* detector_item, - const RectangularDetector& detector) -{ + const RectangularDetector& detector) { // Axes BasicAxisItem* xAxisItem = dynamic_cast<BasicAxisItem*>(detector_item->getItem(RectangularDetectorItem::P_X_AXIS)); @@ -472,8 +452,7 @@ void TransformFromDomain::setRectangularDetector(RectangularDetectorItem* detect } void TransformFromDomain::setDetectorMasks(DetectorItem* detector_item, - const ISimulation& simulation) -{ + const ISimulation& simulation) { const IDetector* detector = simulation.instrument().getDetector(); if ((detector->detectorMask() && detector->detectorMask()->numberOfMasks()) || detector->regionOfInterest()) { @@ -488,8 +467,7 @@ void TransformFromDomain::setDetectorMasks(DetectorItem* detector_item, } void TransformFromDomain::setMaskContainer(MaskContainerItem* container_item, - const IDetector& detector, double scale) -{ + const IDetector& detector, double scale) { auto detectorMask = detector.detectorMask(); for (size_t i_mask = 0; i_mask < detectorMask->numberOfMasks(); ++i_mask) { bool mask_value(false); @@ -574,8 +552,7 @@ void TransformFromDomain::setMaskContainer(MaskContainerItem* container_item, } void TransformFromDomain::setItemFromSample(BeamDistributionItem* beam_distribution_item, - const ParameterDistribution& parameter_distribution) -{ + const ParameterDistribution& parameter_distribution) { ASSERT(beam_distribution_item); if (parameter_distribution.getMinValue() < parameter_distribution.getMaxValue()) { @@ -591,8 +568,7 @@ void TransformFromDomain::setItemFromSample(BeamDistributionItem* beam_distribut } void TransformFromDomain::setBackground(InstrumentItem* instrument_item, - const ISimulation& simulation) -{ + const ISimulation& simulation) { auto p_bg = simulation.background(); if (auto p_constant_bg = dynamic_cast<const ConstantBackground*>(p_bg)) { auto constant_bg_item = @@ -605,8 +581,7 @@ void TransformFromDomain::setBackground(InstrumentItem* instrument_item, } void TransformFromDomain::setFootprintFactor(const IFootprintFactor* footprint, - SpecularBeamItem* beam_item) -{ + SpecularBeamItem* beam_item) { if (!footprint) return; if (const auto gaussian_fp = dynamic_cast<const FootprintGauss*>(footprint)) { @@ -622,8 +597,7 @@ void TransformFromDomain::setFootprintFactor(const IFootprintFactor* footprint, } } -void TransformFromDomain::setAxisItem(SessionItem* item, const IAxis& axis, double factor) -{ +void TransformFromDomain::setAxisItem(SessionItem* item, const IAxis& axis, double factor) { if (item->modelType() != "BasicAxis") throw GUIHelpers::Error("TransformFromDomain::setAxisItem() -> Error. Unexpected item."); @@ -636,10 +610,8 @@ void TransformFromDomain::setAxisItem(SessionItem* item, const IAxis& axis, doub item->setItemValue(BasicAxisItem::P_TITLE, QString::fromStdString(axis.getName())); } -namespace -{ -void SetPDF1D(SessionItem* item, const IFTDistribution1D* ipdf, QString group_name) -{ +namespace { +void SetPDF1D(SessionItem* item, const IFTDistribution1D* ipdf, QString group_name) { if (const FTDistribution1DCauchy* pdf = dynamic_cast<const FTDistribution1DCauchy*>(ipdf)) { SessionItem* pdfItem = item->setGroupProperty(group_name, "FTDistribution1DCauchy"); pdfItem->setItemValue(FTDistribution1DCauchyItem::P_OMEGA, pdf->omega()); @@ -668,8 +640,7 @@ void SetPDF1D(SessionItem* item, const IFTDistribution1D* ipdf, QString group_na } } -void setPDF2D(SessionItem* item, const IFTDistribution2D* pdf, QString group_name) -{ +void setPDF2D(SessionItem* item, const IFTDistribution2D* pdf, QString group_name) { if (const FTDistribution2DCauchy* pdf_cauchy = dynamic_cast<const FTDistribution2DCauchy*>(pdf)) { SessionItem* pdfItem = item->setGroupProperty(group_name, "FTDistribution2DCauchy"); @@ -709,8 +680,7 @@ void setPDF2D(SessionItem* item, const IFTDistribution2D* pdf, QString group_nam } } -void SetDecayFunction1D(SessionItem* item, const IFTDecayFunction1D* ipdf, QString group_name) -{ +void SetDecayFunction1D(SessionItem* item, const IFTDecayFunction1D* ipdf, QString group_name) { if (const FTDecayFunction1DCauchy* pdf = dynamic_cast<const FTDecayFunction1DCauchy*>(ipdf)) { SessionItem* pdfItem = item->setGroupProperty(group_name, "FTDecayFunction1DCauchy"); pdfItem->setItemValue(FTDecayFunction1DItem::P_DECAY_LENGTH, pdf->decayLength()); @@ -732,8 +702,7 @@ void SetDecayFunction1D(SessionItem* item, const IFTDecayFunction1D* ipdf, QStri } } -void SetDecayFunction2D(SessionItem* item, const IFTDecayFunction2D* pdf, QString group_name) -{ +void SetDecayFunction2D(SessionItem* item, const IFTDecayFunction2D* pdf, QString group_name) { if (const FTDecayFunction2DCauchy* pdf_cauchy = dynamic_cast<const FTDecayFunction2DCauchy*>(pdf)) { SessionItem* pdfItem = item->setGroupProperty(group_name, "FTDecayFunction2DCauchy"); @@ -758,8 +727,7 @@ void SetDecayFunction2D(SessionItem* item, const IFTDecayFunction2D* pdf, QStrin } } -void set2DLatticeParameters(SessionItem* item, const Lattice2D& lattice) -{ +void set2DLatticeParameters(SessionItem* item, const Lattice2D& lattice) { SessionItem* latticeItem(nullptr); if (lattice.getName() == "SquareLattice2D") { latticeItem = item->setGroupProperty(InterferenceFunction2DLatticeItem::P_LATTICE_TYPE, @@ -783,15 +751,13 @@ void set2DLatticeParameters(SessionItem* item, const Lattice2D& lattice) Units::rad2deg(lattice.rotationAngle())); } -void setPositionVariance(SessionItem* item, const IInterferenceFunction& iff) -{ +void setPositionVariance(SessionItem* item, const IInterferenceFunction& iff) { double pos_var = iff.positionVariance(); item->setItemValue(InterferenceFunctionItem::P_POSITION_VARIANCE, pos_var); } void setDistribution(SessionItem* part_distr_item, ParameterDistribution par_distr, - QString group_name, double factor) -{ + QString group_name, double factor) { const IDistribution1D* p_distribution = par_distr.getDistribution(); SessionItem* item = 0; @@ -846,8 +812,8 @@ void setDistribution(SessionItem* part_distr_item, ParameterDistribution par_dis } void addDistributionToBeamItem(const std::string& parameter_name, const QString& item_name, - const ParameterDistribution& distribution, const BeamItem* beam_item) -{ + const ParameterDistribution& distribution, + const BeamItem* beam_item) { ParameterPattern pattern; pattern.beginsWith("*").add("Beam").add(parameter_name); if (distribution.getMainParameterName() != pattern.toStdString()) @@ -858,8 +824,7 @@ void addDistributionToBeamItem(const std::string& parameter_name, const QString& } void addRangedDistributionToItem(SessionItem* item, const RangedDistribution& ranged, double mean, - double std_dev) -{ + double std_dev) { auto distr_item = dynamic_cast<BeamDistributionItem*>(item); if (!distr_item) return; diff --git a/GUI/coregui/Models/TransformFromDomain.h b/GUI/coregui/Models/TransformFromDomain.h index ac14d21f2b122234a9d9aadf27f268a8c9477ced..f7013f297fd0d7fd512d3b9f0aed5b6d9c8a05af 100644 --- a/GUI/coregui/Models/TransformFromDomain.h +++ b/GUI/coregui/Models/TransformFromDomain.h @@ -50,8 +50,7 @@ class ISimulation2D; class OffSpecSimulation; class IAxis; -namespace TransformFromDomain -{ +namespace TransformFromDomain { void set1DLatticeItem(SessionItem* item, const InterferenceFunction1DLattice& sample); void set2DLatticeItem(SessionItem* item, const InterferenceFunction2DLattice& sample); diff --git a/GUI/coregui/Models/TransformToDomain.cpp b/GUI/coregui/Models/TransformToDomain.cpp index 48e974705786d709cee353893592a898734361d4..1c844256a3200c0be3da4c243bc5b0ea7e94c492 100644 --- a/GUI/coregui/Models/TransformToDomain.cpp +++ b/GUI/coregui/Models/TransformToDomain.cpp @@ -55,8 +55,7 @@ using SessionItemUtils::GetVectorItem; -namespace -{ +namespace { template <class T> void setParameterDistributionToSimulation(const std::string& parameter_name, const SessionItem* item, ISimulation& simulation); @@ -64,8 +63,7 @@ void setParameterDistributionToSimulation(const std::string& parameter_name, std::unique_ptr<ScanResolution> createScanResolution(const SessionItem* item); } // namespace -std::unique_ptr<Material> TransformToDomain::createDomainMaterial(const SessionItem& item) -{ +std::unique_ptr<Material> TransformToDomain::createDomainMaterial(const SessionItem& item) { auto parent_job = JobModelFunctions::findJobItem(&item); const MaterialItemContainer* container = parent_job ? parent_job->materialContainerItem() : nullptr; @@ -75,8 +73,7 @@ std::unique_ptr<Material> TransformToDomain::createDomainMaterial(const SessionI : MaterialItemUtils::createDomainMaterial(property); } -std::unique_ptr<MultiLayer> TransformToDomain::createMultiLayer(const SessionItem& item) -{ +std::unique_ptr<MultiLayer> TransformToDomain::createMultiLayer(const SessionItem& item) { auto P_multilayer = std::make_unique<MultiLayer>(); auto cross_corr_length = item.getItemValue(MultiLayerItem::P_CROSS_CORR_LENGTH).toDouble(); if (cross_corr_length > 0) @@ -86,8 +83,7 @@ std::unique_ptr<MultiLayer> TransformToDomain::createMultiLayer(const SessionIte return P_multilayer; } -std::unique_ptr<Layer> TransformToDomain::createLayer(const SessionItem& item) -{ +std::unique_ptr<Layer> TransformToDomain::createLayer(const SessionItem& item) { auto P_layer = std::make_unique<Layer>(*createDomainMaterial(item), item.getItemValue(LayerItem::P_THICKNESS).toDouble()); P_layer->setNumberOfSlices(item.getItemValue(LayerItem::P_NSLICES).toUInt()); @@ -95,8 +91,7 @@ std::unique_ptr<Layer> TransformToDomain::createLayer(const SessionItem& item) } std::unique_ptr<LayerRoughness> -TransformToDomain::createLayerRoughness(const SessionItem& roughnessItem) -{ +TransformToDomain::createLayerRoughness(const SessionItem& roughnessItem) { if (roughnessItem.modelType() == "LayerZeroRoughness") { return nullptr; } else if (roughnessItem.modelType() == "LayerBasicRoughness") { @@ -109,8 +104,7 @@ TransformToDomain::createLayerRoughness(const SessionItem& roughnessItem) } } -std::unique_ptr<ParticleLayout> TransformToDomain::createParticleLayout(const SessionItem& item) -{ +std::unique_ptr<ParticleLayout> TransformToDomain::createParticleLayout(const SessionItem& item) { auto P_layout = std::make_unique<ParticleLayout>(); auto total_density = item.getItemValue(ParticleLayoutItem::P_TOTAL_DENSITY).value<double>(); auto layout_weight = item.getItemValue(ParticleLayoutItem::P_WEIGHT).value<double>(); @@ -119,8 +113,7 @@ std::unique_ptr<ParticleLayout> TransformToDomain::createParticleLayout(const Se return P_layout; } -std::unique_ptr<IParticle> TransformToDomain::createIParticle(const SessionItem& item) -{ +std::unique_ptr<IParticle> TransformToDomain::createIParticle(const SessionItem& item) { std::unique_ptr<IParticle> P_particle; if (item.modelType() == "Particle") { auto& particle_item = static_cast<const ParticleItem&>(item); @@ -139,8 +132,7 @@ std::unique_ptr<IParticle> TransformToDomain::createIParticle(const SessionItem& } std::unique_ptr<ParticleDistribution> -TransformToDomain::createParticleDistribution(const SessionItem& item) -{ +TransformToDomain::createParticleDistribution(const SessionItem& item) { auto& particle_distribution = static_cast<const ParticleDistributionItem&>(item); auto P_part_distr = particle_distribution.createParticleDistribution(); return P_part_distr; @@ -148,8 +140,7 @@ TransformToDomain::createParticleDistribution(const SessionItem& item) //! adds DistributionParameters to the ISimulation void TransformToDomain::addDistributionParametersToSimulation(const SessionItem& beam_item, - GISASSimulation& simulation) -{ + GISASSimulation& simulation) { if (beam_item.modelType() != "GISASBeam") { ASSERT(beam_item.modelType() == "GISASBeam"); return; @@ -164,8 +155,7 @@ void TransformToDomain::addDistributionParametersToSimulation(const SessionItem& } void TransformToDomain::addBeamDivergencesToScan(const SessionItem& beam_item, - AngularSpecScan& scan) -{ + AngularSpecScan& scan) { if (beam_item.modelType() != "SpecularBeam") { ASSERT(beam_item.modelType() == "SpecularBeam"); return; @@ -181,8 +171,7 @@ void TransformToDomain::addBeamDivergencesToScan(const SessionItem& beam_item, void TransformToDomain::setBeamDistribution(const std::string& parameter_name, const BeamDistributionItem& item, - ISimulation& simulation) -{ + ISimulation& simulation) { ParameterPattern parameter_pattern; parameter_pattern.beginsWith("*").add("Beam").add(parameter_name); @@ -191,8 +180,7 @@ void TransformToDomain::setBeamDistribution(const std::string& parameter_name, simulation.addParameterDistribution(*P_par_distr); } -void TransformToDomain::setSimulationOptions(ISimulation* simulation, const SessionItem& item) -{ +void TransformToDomain::setSimulationOptions(ISimulation* simulation, const SessionItem& item) { ASSERT(item.modelType() == "SimulationOptions"); if (auto optionItem = dynamic_cast<const SimulationOptionsItem*>(&item)) { @@ -208,20 +196,17 @@ void TransformToDomain::setSimulationOptions(ISimulation* simulation, const Sess } } -void TransformToDomain::setTransformationInfo(IParticle* result, const SessionItem& item) -{ +void TransformToDomain::setTransformationInfo(IParticle* result, const SessionItem& item) { setPositionInfo(result, item); setRotationInfo(result, item); } -void TransformToDomain::setPositionInfo(IParticle* result, const SessionItem& item) -{ +void TransformToDomain::setPositionInfo(IParticle* result, const SessionItem& item) { kvector_t pos = GetVectorItem(item, ParticleItem::P_POSITION); result->setPosition(pos.x(), pos.y(), pos.z()); } -void TransformToDomain::setRotationInfo(IParticle* result, const SessionItem& item) -{ +void TransformToDomain::setRotationInfo(IParticle* result, const SessionItem& item) { QVector<SessionItem*> children = item.children(); for (int i = 0; i < children.size(); ++i) { if (children[i]->modelType() == "Rotation") { @@ -234,12 +219,10 @@ void TransformToDomain::setRotationInfo(IParticle* result, const SessionItem& it } } -namespace -{ +namespace { template <class T> void setParameterDistributionToSimulation(const std::string& parameter_name, - const SessionItem* item, ISimulation& simulation) -{ + const SessionItem* item, ISimulation& simulation) { const auto parameter_item = dynamic_cast<const T*>(item); if (!parameter_item) { ASSERT(parameter_item); @@ -255,8 +238,7 @@ void setParameterDistributionToSimulation(const std::string& parameter_name, simulation.addParameterDistribution(*P_par_distr); } -std::unique_ptr<ScanResolution> createScanResolution(const SessionItem* item) -{ +std::unique_ptr<ScanResolution> createScanResolution(const SessionItem* item) { auto beam_item = dynamic_cast<const BeamDistributionItem*>(item); if (!beam_item) return nullptr; diff --git a/GUI/coregui/Models/TransformToDomain.h b/GUI/coregui/Models/TransformToDomain.h index f0f411f60a27737e4c34b56100374b3cb24d40f8..df79064d818d3f1a1095695eb28b58dcc2a3906a 100644 --- a/GUI/coregui/Models/TransformToDomain.h +++ b/GUI/coregui/Models/TransformToDomain.h @@ -34,8 +34,7 @@ class MaterialItemContainer; class SessionItem; class ISimulation; -namespace TransformToDomain -{ +namespace TransformToDomain { std::unique_ptr<Material> createDomainMaterial(const SessionItem& item); std::unique_ptr<IParticle> createIParticle(const SessionItem& item); std::unique_ptr<Layer> createLayer(const SessionItem& item); diff --git a/GUI/coregui/Models/TransformationItem.cpp b/GUI/coregui/Models/TransformationItem.cpp index 710afa9cf42d0cb76c2b364c629cc7b7241e6b0b..f99280b65e5d05010af608300f79c7f681214110 100644 --- a/GUI/coregui/Models/TransformationItem.cpp +++ b/GUI/coregui/Models/TransformationItem.cpp @@ -16,8 +16,7 @@ const QString TransformationItem::P_ROT = "Rotation type"; -TransformationItem::TransformationItem() : SessionGraphicsItem("Rotation") -{ +TransformationItem::TransformationItem() : SessionGraphicsItem("Rotation") { setToolTip("Rotation applied to particles"); addGroupProperty(P_ROT, "Rotation group"); } diff --git a/GUI/coregui/Models/TransformationItem.h b/GUI/coregui/Models/TransformationItem.h index d40790488584e116f7cea9fb19f8dabb237a3856..c7ca1fead23d15f8a674a8ecb9050bf81c8f99f9 100644 --- a/GUI/coregui/Models/TransformationItem.h +++ b/GUI/coregui/Models/TransformationItem.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Models/SessionGraphicsItem.h" -class BA_CORE_API_ TransformationItem : public SessionGraphicsItem -{ +class BA_CORE_API_ TransformationItem : public SessionGraphicsItem { public: static const QString P_ROT; TransformationItem(); diff --git a/GUI/coregui/Models/VectorItem.cpp b/GUI/coregui/Models/VectorItem.cpp index 39d7d2d203cb85056535e08eb0e1e0373e0c153b..b33bfd8a5cac520cae09d72b4b832765ac61edc5 100644 --- a/GUI/coregui/Models/VectorItem.cpp +++ b/GUI/coregui/Models/VectorItem.cpp @@ -18,8 +18,7 @@ const QString VectorItem::P_X = "X"; const QString VectorItem::P_Y = "Y"; const QString VectorItem::P_Z = "Z"; -VectorItem::VectorItem() : SessionItem("Vector") -{ +VectorItem::VectorItem() : SessionItem("Vector") { addProperty(P_X, 0.0)->setLimits(RealLimits::limitless()).setToolTip("x-coordinate"); addProperty(P_Y, 0.0)->setLimits(RealLimits::limitless()).setToolTip("y-coordinate"); addProperty(P_Z, 0.0)->setLimits(RealLimits::limitless()).setToolTip("z-coordinate"); @@ -30,14 +29,12 @@ VectorItem::VectorItem() : SessionItem("Vector") setEditable(false); } -kvector_t VectorItem::getVector() const -{ +kvector_t VectorItem::getVector() const { return kvector_t(getItemValue(P_X).toDouble(), getItemValue(P_Y).toDouble(), getItemValue(P_Z).toDouble()); } -void VectorItem::updateLabel() -{ +void VectorItem::updateLabel() { QString label = QString("(%1, %2, %3)") .arg(getItemValue(P_X).toDouble()) .arg(getItemValue(P_Y).toDouble()) diff --git a/GUI/coregui/Models/VectorItem.h b/GUI/coregui/Models/VectorItem.h index 191fefa2c2da37e17f9717381214aa5f465c0c82..0224c4491735232b1e5df5f92dee02f89239394a 100644 --- a/GUI/coregui/Models/VectorItem.h +++ b/GUI/coregui/Models/VectorItem.h @@ -18,8 +18,7 @@ #include "Base/Vector/Vectors3D.h" #include "GUI/coregui/Models/SessionItem.h" -class BA_CORE_API_ VectorItem : public SessionItem -{ +class BA_CORE_API_ VectorItem : public SessionItem { public: static const QString P_X; diff --git a/GUI/coregui/Views/AccordionWidget/AccordionWidget.cpp b/GUI/coregui/Views/AccordionWidget/AccordionWidget.cpp index 8ac8fe6f5f68f4c8cba22cbadce570c464839569..8de82c01971a0869108f0b639efa3a92f972f8cb 100644 --- a/GUI/coregui/Views/AccordionWidget/AccordionWidget.cpp +++ b/GUI/coregui/Views/AccordionWidget/AccordionWidget.cpp @@ -32,8 +32,7 @@ #include <QDebug> #include <stdexcept> -AccordionWidget::AccordionWidget(QWidget* parent) : QWidget(parent) -{ +AccordionWidget::AccordionWidget(QWidget* parent) : QWidget(parent) { // make sure our resource file gets initialized Q_INIT_RESOURCE(accordionwidgeticons); @@ -55,43 +54,35 @@ AccordionWidget::AccordionWidget(QWidget* parent) : QWidget(parent) &AccordionWidget::numberOfPanesChanged); } -int AccordionWidget::numberOfContentPanes() -{ +int AccordionWidget::numberOfContentPanes() { return static_cast<int>(contentPanes.size()); } -int AccordionWidget::addContentPane(QString header) -{ +int AccordionWidget::addContentPane(QString header) { return this->internalAddContentPane(std::move(header)); } -int AccordionWidget::addContentPane(QString header, QFrame* contentFrame) -{ +int AccordionWidget::addContentPane(QString header, QFrame* contentFrame) { return this->internalAddContentPane(std::move(header), contentFrame); } -int AccordionWidget::addContentPane(ContentPane* cpane) -{ +int AccordionWidget::addContentPane(ContentPane* cpane) { return this->internalAddContentPane("", nullptr, cpane); } -bool AccordionWidget::insertContentPane(uint index, QString header) -{ +bool AccordionWidget::insertContentPane(uint index, QString header) { return this->internalInsertContentPane(index, header); } -bool AccordionWidget::insertContentPane(uint index, QString header, QFrame* contentFrame) -{ +bool AccordionWidget::insertContentPane(uint index, QString header, QFrame* contentFrame) { return this->internalInsertContentPane(index, header, contentFrame); } -bool AccordionWidget::insertContentPane(uint index, ContentPane* cpane) -{ +bool AccordionWidget::insertContentPane(uint index, ContentPane* cpane) { return this->internalInsertContentPane(index, "", nullptr, cpane); } -bool AccordionWidget::swapContentPane(uint index, ContentPane* cpane) -{ +bool AccordionWidget::swapContentPane(uint index, ContentPane* cpane) { if (this->checkIndexError(index, false, "Can not swap content pane at index " + QString::number(index) + ". Index out of range.")) { @@ -117,28 +108,23 @@ bool AccordionWidget::swapContentPane(uint index, ContentPane* cpane) return true; } -bool AccordionWidget::removeContentPane(bool deleteObject, uint index) -{ +bool AccordionWidget::removeContentPane(bool deleteObject, uint index) { return this->internalRemoveContentPane(deleteObject, index); } -bool AccordionWidget::removeContentPane(bool deleteObject, QString header) -{ +bool AccordionWidget::removeContentPane(bool deleteObject, QString header) { return this->internalRemoveContentPane(deleteObject, -1, header); } -bool AccordionWidget::removeContentPane(bool deleteObject, QFrame* contentframe) -{ +bool AccordionWidget::removeContentPane(bool deleteObject, QFrame* contentframe) { return this->internalRemoveContentPane(deleteObject, -1, "", contentframe); } -bool AccordionWidget::removeContentPane(bool deleteObject, ContentPane* contentPane) -{ +bool AccordionWidget::removeContentPane(bool deleteObject, ContentPane* contentPane) { return this->internalRemoveContentPane(deleteObject, -1, "", nullptr, contentPane); } -bool AccordionWidget::moveContentPane(uint currentIndex, uint newIndex) -{ +bool AccordionWidget::moveContentPane(uint currentIndex, uint newIndex) { if (this->checkIndexError(currentIndex, false, "Can not move from " + QString::number(currentIndex) + ". Index out of range.") @@ -163,8 +149,7 @@ bool AccordionWidget::moveContentPane(uint currentIndex, uint newIndex) return true; } -ContentPane* AccordionWidget::getContentPane(uint index) -{ +ContentPane* AccordionWidget::getContentPane(uint index) { try { return this->contentPanes.at(index); } catch (const std::out_of_range& ex) { @@ -174,23 +159,19 @@ ContentPane* AccordionWidget::getContentPane(uint index) } } -int AccordionWidget::getContentPaneIndex(QString header) -{ +int AccordionWidget::getContentPaneIndex(QString header) { return this->findContentPaneIndex(header); } -int AccordionWidget::getContentPaneIndex(QFrame* contentFrame) -{ +int AccordionWidget::getContentPaneIndex(QFrame* contentFrame) { return this->findContentPaneIndex("", contentFrame); } -int AccordionWidget::getContentPaneIndex(ContentPane* contentPane) -{ +int AccordionWidget::getContentPaneIndex(ContentPane* contentPane) { return this->findContentPaneIndex("", nullptr, contentPane); } -void AccordionWidget::getActiveContentPaneIndex(std::vector<int>& indexVector) -{ +void AccordionWidget::getActiveContentPaneIndex(std::vector<int>& indexVector) { // first of all make sure it is empty indexVector.clear(); std::for_each(this->contentPanes.begin(), this->contentPanes.end(), @@ -201,33 +182,27 @@ void AccordionWidget::getActiveContentPaneIndex(std::vector<int>& indexVector) }); } -void AccordionWidget::setMultiActive(bool status) -{ +void AccordionWidget::setMultiActive(bool status) { this->multiActive = status; } -bool AccordionWidget::getMultiActive() -{ +bool AccordionWidget::getMultiActive() { return this->multiActive; } -void AccordionWidget::setCollapsible(bool status) -{ +void AccordionWidget::setCollapsible(bool status) { this->collapsible = status; } -bool AccordionWidget::getCollapsible() -{ +bool AccordionWidget::getCollapsible() { return this->collapsible; } -QString AccordionWidget::getError() -{ +QString AccordionWidget::getError() { return this->errorString; } -int AccordionWidget::internalAddContentPane(QString header, QFrame* cframe, ContentPane* cpane) -{ +int AccordionWidget::internalAddContentPane(QString header, QFrame* cframe, ContentPane* cpane) { if (this->findContentPaneIndex(header, cframe, cpane) != -1) { this->errorString = "Can not add content pane as it already exists"; return -1; @@ -253,8 +228,7 @@ int AccordionWidget::internalAddContentPane(QString header, QFrame* cframe, Cont } bool AccordionWidget::internalInsertContentPane(uint index, QString header, QFrame* contentFrame, - ContentPane* cpane) -{ + ContentPane* cpane) { if (this->checkIndexError(index, true, "Can not insert Content Pane at index " + QString::number(index) + ". Index out of range")) { @@ -287,8 +261,7 @@ bool AccordionWidget::internalInsertContentPane(uint index, QString header, QFra } bool AccordionWidget::internalRemoveContentPane(bool deleteOject, int index, QString name, - QFrame* contentFrame, ContentPane* cpane) -{ + QFrame* contentFrame, ContentPane* cpane) { if (index != -1 && this->checkIndexError(index, false, "Can not remove content pane at index " + QString::number(index) @@ -320,8 +293,7 @@ bool AccordionWidget::internalRemoveContentPane(bool deleteOject, int index, QSt return true; } -int AccordionWidget::findContentPaneIndex(QString name, QFrame* cframe, ContentPane* cpane) -{ +int AccordionWidget::findContentPaneIndex(QString name, QFrame* cframe, ContentPane* cpane) { // simple method that finds the index of a content by Header, content frame // or content pane. int index = -1; @@ -353,8 +325,8 @@ int AccordionWidget::findContentPaneIndex(QString name, QFrame* cframe, ContentP return index; } -bool AccordionWidget::checkIndexError(uint index, bool sizeIndexAllowed, const QString& errMessage) -{ +bool AccordionWidget::checkIndexError(uint index, bool sizeIndexAllowed, + const QString& errMessage) { // sizeIndexAllowed is only used by inserting. If there is one pane you will // be able to insert a new one before and after. // FIXME: Actually there seem to be some bugs hidden here. User may now for @@ -378,8 +350,7 @@ bool AccordionWidget::checkIndexError(uint index, bool sizeIndexAllowed, const Q return false; } -void AccordionWidget::handleClickedSignal(ContentPane* cpane) -{ +void AccordionWidget::handleClickedSignal(ContentPane* cpane) { // if the clicked content pane is open we simply close it and return if (cpane->getActive()) { // if collapsible and multiActive are false we are not allowed to close @@ -414,8 +385,7 @@ void AccordionWidget::handleClickedSignal(ContentPane* cpane) } } -void AccordionWidget::numberOfPanesChanged(int number) -{ +void AccordionWidget::numberOfPanesChanged(int number) { // automatically open contentpane if we have only one and collapsible is // false if (number == 1 && this->collapsible == false) { @@ -423,8 +393,7 @@ void AccordionWidget::numberOfPanesChanged(int number) } } -void AccordionWidget::paintEvent(ATTR_UNUSED QPaintEvent* event) -{ +void AccordionWidget::paintEvent(ATTR_UNUSED QPaintEvent* event) { QStyleOption o; o.initFrom(this); QPainter p(this); diff --git a/GUI/coregui/Views/AccordionWidget/AccordionWidget.h b/GUI/coregui/Views/AccordionWidget/AccordionWidget.h index a7ca1185225567138fc1c45fe0dfa670247e691c..2c53ca09d589ed197a62c831f5dc51ceebefd512 100644 --- a/GUI/coregui/Views/AccordionWidget/AccordionWidget.h +++ b/GUI/coregui/Views/AccordionWidget/AccordionWidget.h @@ -74,8 +74,7 @@ class ContentPane; * Currently Headers have to be unique * */ -class AccordionWidget : public QWidget -{ +class AccordionWidget : public QWidget { Q_OBJECT public: /** diff --git a/GUI/coregui/Views/AccordionWidget/ClickableFrame.cpp b/GUI/coregui/Views/AccordionWidget/ClickableFrame.cpp index 7128b59eda75a74bd49f714a9be3617ce1760f08..e9d31a1acccfa099c7489a4fcbec21566ac7e0c6 100644 --- a/GUI/coregui/Views/AccordionWidget/ClickableFrame.cpp +++ b/GUI/coregui/Views/AccordionWidget/ClickableFrame.cpp @@ -34,8 +34,7 @@ #include <QStyleOption> ClickableFrame::ClickableFrame(QString header, QWidget* parent, Qt::WindowFlags f) - : QFrame(parent, f), header(header) -{ + : QFrame(parent, f), header(header) { this->setAttribute(Qt::WA_Hover, true); this->clickable = true; this->setCursor(Qt::PointingHandCursor); @@ -46,8 +45,7 @@ ClickableFrame::ClickableFrame(QString header, QWidget* parent, Qt::WindowFlags this->initFrame(); } -void ClickableFrame::setClickable(bool status) -{ +void ClickableFrame::setClickable(bool status) { this->clickable = status; if (status) { this->setCursor(Qt::PointingHandCursor); @@ -56,50 +54,41 @@ void ClickableFrame::setClickable(bool status) } } -bool ClickableFrame::getClickable() -{ +bool ClickableFrame::getClickable() { return this->clickable; } -void ClickableFrame::setHeader(QString header) -{ +void ClickableFrame::setHeader(QString header) { this->header = header; this->nameLabel->setText(this->header); } -QString ClickableFrame::getHeader() -{ +QString ClickableFrame::getHeader() { return this->header; } -void ClickableFrame::setNormalStylesheet(QString stylesheet) -{ +void ClickableFrame::setNormalStylesheet(QString stylesheet) { this->normalStylesheet = stylesheet; this->setStyleSheet(this->normalStylesheet); } -QString ClickableFrame::getNormalStylesheet() -{ +QString ClickableFrame::getNormalStylesheet() { return this->normalStylesheet; } -void ClickableFrame::setHoverStylesheet(QString stylesheet) -{ +void ClickableFrame::setHoverStylesheet(QString stylesheet) { this->hoverStylesheet = stylesheet; } -QString ClickableFrame::getHoverStylesheet() -{ +QString ClickableFrame::getHoverStylesheet() { return this->hoverStylesheet; } -void ClickableFrame::setCaretPixmap(QString pixmapPath) -{ +void ClickableFrame::setCaretPixmap(QString pixmapPath) { this->caretLabel->setPixmap(QPixmap(pixmapPath)); } -void ClickableFrame::initFrame() -{ +void ClickableFrame::initFrame() { this->setSizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Fixed); this->setLayout(new QHBoxLayout()); @@ -116,8 +105,7 @@ void ClickableFrame::initFrame() this->setStyleSheet(this->normalStylesheet); } -void ClickableFrame::mousePressEvent(QMouseEvent* event) -{ +void ClickableFrame::mousePressEvent(QMouseEvent* event) { if (this->clickable) { emit this->singleClick(event->pos()); event->accept(); @@ -126,15 +114,13 @@ void ClickableFrame::mousePressEvent(QMouseEvent* event) } } -void ClickableFrame::enterEvent(ATTR_UNUSED QEvent* event) -{ +void ClickableFrame::enterEvent(ATTR_UNUSED QEvent* event) { if (this->clickable) { this->setStyleSheet(this->hoverStylesheet); } } -void ClickableFrame::leaveEvent(ATTR_UNUSED QEvent* event) -{ +void ClickableFrame::leaveEvent(ATTR_UNUSED QEvent* event) { if (this->clickable) { this->setStyleSheet(this->normalStylesheet); } diff --git a/GUI/coregui/Views/AccordionWidget/ClickableFrame.h b/GUI/coregui/Views/AccordionWidget/ClickableFrame.h index ecb267bad18162aff3514c492019d498d59cb038..2a6c019dd9b3378abf9c225d3ed786aae5c7d683 100644 --- a/GUI/coregui/Views/AccordionWidget/ClickableFrame.h +++ b/GUI/coregui/Views/AccordionWidget/ClickableFrame.h @@ -48,8 +48,7 @@ // TODO: No need to use a namespace for our constants as we are using them only // in this class -namespace ClickableFrame_constants -{ +namespace ClickableFrame_constants { const char* const CARRET_ICON_CLOSED = ":/qAccordionIcons/caret-right.png"; /**< Qt qrc "path" for the closed icon */ const char* const CARRET_ICON_OPENED = @@ -62,8 +61,7 @@ const char* const CARRET_ICON_OPENED = * This class represents a clickable QFrame. It is used by a ContentPane. The class * is used internally. */ -class ClickableFrame : public QFrame -{ +class ClickableFrame : public QFrame { Q_OBJECT public: diff --git a/GUI/coregui/Views/AccordionWidget/ContentPane.cpp b/GUI/coregui/Views/AccordionWidget/ContentPane.cpp index 4f2cfe6dd5973ed140e570538a209ae1d0ee615e..8bed8a62b5e9355940766117d4591d58eb7c1a4b 100644 --- a/GUI/coregui/Views/AccordionWidget/ContentPane.cpp +++ b/GUI/coregui/Views/AccordionWidget/ContentPane.cpp @@ -32,31 +32,26 @@ namespace clickcon = ClickableFrame_constants; -ContentPane::ContentPane(QString header, QWidget* parent) : QWidget(parent) -{ +ContentPane::ContentPane(QString header, QWidget* parent) : QWidget(parent) { this->content = nullptr; this->initDefaults(std::move(header)); } ContentPane::ContentPane(QString header, QFrame* content, QWidget* parent) - : QWidget(parent), content(content) -{ + : QWidget(parent), content(content) { this->initDefaults(std::move(header)); } -bool ContentPane::getActive() -{ +bool ContentPane::getActive() { return this->active; } -QFrame* ContentPane::getContentFrame() -{ +QFrame* ContentPane::getContentFrame() { return this->content; } -void ContentPane::setContentFrame(QFrame* content) -{ +void ContentPane::setContentFrame(QFrame* content) { this->container->layout()->removeWidget(this->content); if (this->content != nullptr) delete (this->content); @@ -64,13 +59,11 @@ void ContentPane::setContentFrame(QFrame* content) dynamic_cast<QVBoxLayout*>(this->container->layout())->insertWidget(0, this->content); } -int ContentPane::getMaximumHeight() -{ +int ContentPane::getMaximumHeight() { return this->container->maximumHeight(); } -void ContentPane::setMaximumHeight(int maxHeight) -{ +void ContentPane::setMaximumHeight(int maxHeight) { this->containerAnimationMaxHeight = maxHeight; if (this->getActive()) @@ -79,68 +72,55 @@ void ContentPane::setMaximumHeight(int maxHeight) this->closeAnimation->setStartValue(this->containerAnimationMaxHeight); } -void ContentPane::setHeader(QString header) -{ +void ContentPane::setHeader(QString header) { this->header->setHeader(std::move(header)); } -QString ContentPane::getHeader() -{ +QString ContentPane::getHeader() { return this->header->getHeader(); } -void ContentPane::setHeaderTooltip(QString tooltip) -{ +void ContentPane::setHeaderTooltip(QString tooltip) { this->header->setToolTip(tooltip); } -QString ContentPane::getHeaderTooltip() -{ +QString ContentPane::getHeaderTooltip() { return this->header->toolTip(); } -void ContentPane::setHeaderStylesheet(QString stylesheet) -{ +void ContentPane::setHeaderStylesheet(QString stylesheet) { this->header->setNormalStylesheet(std::move(stylesheet)); } -QString ContentPane::getHeaderStylesheet() -{ +QString ContentPane::getHeaderStylesheet() { return this->header->getNormalStylesheet(); } -void ContentPane::setHeaderHoverStylesheet(QString stylesheet) -{ +void ContentPane::setHeaderHoverStylesheet(QString stylesheet) { this->header->setHoverStylesheet(std::move(stylesheet)); } -QString ContentPane::getHeaderHoverStylesheet() -{ +QString ContentPane::getHeaderHoverStylesheet() { return this->header->getHoverStylesheet(); } -void ContentPane::setHeaderFrameStyle(int style) -{ +void ContentPane::setHeaderFrameStyle(int style) { this->header->setFrameStyle(style); } -int ContentPane::getHeaderFrameStyle() -{ +int ContentPane::getHeaderFrameStyle() { return this->header->frameStyle(); } -void ContentPane::setContainerFrameStyle(int style) -{ +void ContentPane::setContainerFrameStyle(int style) { this->container->setFrameStyle(style); } -int ContentPane::getContainerFrameStyle() -{ +int ContentPane::getContainerFrameStyle() { return this->container->frameStyle(); } -void ContentPane::openContentPane() -{ +void ContentPane::openContentPane() { if (this->getActive()) return; this->openAnimation->start(); @@ -148,8 +128,7 @@ void ContentPane::openContentPane() this->active = true; } -void ContentPane::closeContentPane() -{ +void ContentPane::closeContentPane() { if (!this->getActive()) return; this->closeAnimation->start(); @@ -157,8 +136,7 @@ void ContentPane::closeContentPane() this->active = false; } -void ContentPane::initDefaults(QString header) -{ +void ContentPane::initDefaults(QString header) { this->active = false; this->headerFrameStyle = QFrame::Shape::StyledPanel | QFrame::Shadow::Raised; @@ -177,8 +155,7 @@ void ContentPane::initDefaults(QString header) this->initAnimations(); } -void ContentPane::initHeaderFrame(QString header) -{ +void ContentPane::initHeaderFrame(QString header) { this->header = new ClickableFrame(std::move(header)); this->header->setFrameStyle(this->headerFrameStyle); this->layout()->addWidget(this->header); @@ -186,8 +163,7 @@ void ContentPane::initHeaderFrame(QString header) QObject::connect(this->header, &ClickableFrame::singleClick, this, &ContentPane::headerClicked); } -void ContentPane::initContainerContentFrame() -{ +void ContentPane::initContainerContentFrame() { this->container = new QFrame(); this->container->setLayout(new QVBoxLayout()); this->container->setFrameStyle(this->contentPaneFrameStyle); @@ -204,8 +180,7 @@ void ContentPane::initContainerContentFrame() this->container->layout()->setContentsMargins(QMargins()); } -void ContentPane::initAnimations() -{ +void ContentPane::initAnimations() { this->openAnimation = std::unique_ptr<QPropertyAnimation>(new QPropertyAnimation()); this->closeAnimation = std::unique_ptr<QPropertyAnimation>(new QPropertyAnimation()); // TODO: Currently these animations only animate maximumHeight. This leads to @@ -227,13 +202,11 @@ void ContentPane::initAnimations() this->closeAnimation->setEasingCurve(QEasingCurve(QEasingCurve::Type::Linear)); } -void ContentPane::headerClicked() -{ +void ContentPane::headerClicked() { emit this->clicked(); } -void ContentPane::paintEvent(ATTR_UNUSED QPaintEvent* event) -{ +void ContentPane::paintEvent(ATTR_UNUSED QPaintEvent* event) { QStyleOption o; o.initFrom(this); QPainter p(this); diff --git a/GUI/coregui/Views/AccordionWidget/ContentPane.h b/GUI/coregui/Views/AccordionWidget/ContentPane.h index dc47c378b4682f985aab011c6197f22de81745d7..c39af016b340547429164e0c783821890e65ee7e 100644 --- a/GUI/coregui/Views/AccordionWidget/ContentPane.h +++ b/GUI/coregui/Views/AccordionWidget/ContentPane.h @@ -72,8 +72,7 @@ * @details * The animation speed is influenceable setAnimationDuration(). */ -class ContentPane : public QWidget -{ +class ContentPane : public QWidget { Q_OBJECT public: /** diff --git a/GUI/coregui/Views/CommonWidgets/AdjustingScrollArea.cpp b/GUI/coregui/Views/CommonWidgets/AdjustingScrollArea.cpp index 2216f886842f82f5034653b12b2f344f83957e79..470fa0203169f88ca20b7505cb5c94029d36c7ae 100644 --- a/GUI/coregui/Views/CommonWidgets/AdjustingScrollArea.cpp +++ b/GUI/coregui/Views/CommonWidgets/AdjustingScrollArea.cpp @@ -16,8 +16,7 @@ #include <QEvent> #include <QScrollBar> -AdjustingScrollArea::AdjustingScrollArea(QWidget* parent) : QScrollArea(parent) -{ +AdjustingScrollArea::AdjustingScrollArea(QWidget* parent) : QScrollArea(parent) { setObjectName("MyScrollArea"); setContentsMargins(0, 0, 0, 0); setWidgetResizable(true); @@ -25,21 +24,18 @@ AdjustingScrollArea::AdjustingScrollArea(QWidget* parent) : QScrollArea(parent) setStyleSheet("QScrollArea#MyScrollArea {border: 0px; background-color:transparent;}"); } -void AdjustingScrollArea::setWidget(QWidget* w) -{ +void AdjustingScrollArea::setWidget(QWidget* w) { QScrollArea::setWidget(w); w->installEventFilter(this); } -QSize AdjustingScrollArea::sizeHint() const -{ +QSize AdjustingScrollArea::sizeHint() const { QScrollBar* horizontal = horizontalScrollBar(); QSize result(viewport()->width(), widget()->height() + horizontal->height() * 2); return result; } -bool AdjustingScrollArea::eventFilter(QObject* obj, QEvent* ev) -{ +bool AdjustingScrollArea::eventFilter(QObject* obj, QEvent* ev) { if (obj == widget() && ev->type() != QEvent::Resize) { widget()->setMaximumWidth(viewport()->width()); setMaximumHeight(height() - viewport()->height() + widget()->height()); diff --git a/GUI/coregui/Views/CommonWidgets/AdjustingScrollArea.h b/GUI/coregui/Views/CommonWidgets/AdjustingScrollArea.h index 15dab8d6ceda142515a91889c866fddc9a4f4306..83ff1c5c3ced196468660ebb7fd6fab16cd9dca7 100644 --- a/GUI/coregui/Views/CommonWidgets/AdjustingScrollArea.h +++ b/GUI/coregui/Views/CommonWidgets/AdjustingScrollArea.h @@ -20,8 +20,7 @@ //! Modification of standard scroll area, which makes widget with dynamic layout ocuupy whole //! available space. -class AdjustingScrollArea : public QScrollArea -{ +class AdjustingScrollArea : public QScrollArea { Q_OBJECT public: diff --git a/GUI/coregui/Views/CommonWidgets/ColumnResizer.cpp b/GUI/coregui/Views/CommonWidgets/ColumnResizer.cpp index cd5eeb8893ba94785a2be463907477b5d553b05a..b9c42738d3d3821cb54aef766cd0fa8c7466e0c0 100644 --- a/GUI/coregui/Views/CommonWidgets/ColumnResizer.cpp +++ b/GUI/coregui/Views/CommonWidgets/ColumnResizer.cpp @@ -26,16 +26,12 @@ #include <QTimer> #include <QWidget> -class FormLayoutWidgetItem : public QWidgetItem -{ +class FormLayoutWidgetItem : public QWidgetItem { public: FormLayoutWidgetItem(QWidget* widget, QFormLayout* formLayout, QFormLayout::ItemRole itemRole) - : QWidgetItem(widget), m_width(-1), m_formLayout(formLayout), m_itemRole(itemRole) - { - } + : QWidgetItem(widget), m_width(-1), m_formLayout(formLayout), m_itemRole(itemRole) {} - QSize sizeHint() const - { + QSize sizeHint() const { QSize size = QWidgetItem::sizeHint(); if (m_width != -1) { size.setWidth(m_width); @@ -43,8 +39,7 @@ public: return size; } - QSize minimumSize() const - { + QSize minimumSize() const { QSize size = QWidgetItem::minimumSize(); if (m_width != -1) { size.setWidth(m_width); @@ -52,8 +47,7 @@ public: return size; } - QSize maximumSize() const - { + QSize maximumSize() const { QSize size = QWidgetItem::maximumSize(); if (m_width != -1) { size.setWidth(m_width); @@ -61,16 +55,14 @@ public: return size; } - void setWidth(int width) - { + void setWidth(int width) { if (width != m_width) { m_width = width; invalidate(); } } - void setGeometry(const QRect& _rect) - { + void setGeometry(const QRect& _rect) { QRect rect = _rect; int width = widget()->sizeHint().width(); if (m_itemRole == QFormLayout::LabelRole @@ -90,19 +82,16 @@ private: typedef QPair<QGridLayout*, int> GridColumnInfo; -class ColumnResizerPrivate -{ +class ColumnResizerPrivate { public: ColumnResizerPrivate(ColumnResizer* q_ptr) - : q(q_ptr), m_updateTimer(new QTimer(q)), block_update(false) - { + : q(q_ptr), m_updateTimer(new QTimer(q)), block_update(false) { m_updateTimer->setSingleShot(true); m_updateTimer->setInterval(0); QObject::connect(m_updateTimer, SIGNAL(timeout()), q, SLOT(updateWidth())); } - void scheduleWidthUpdate() - { + void scheduleWidthUpdate() { if (block_update) return; m_updateTimer->start(); @@ -116,25 +105,21 @@ public: bool block_update; }; -ColumnResizer::ColumnResizer(QObject* parent) : QObject(parent), d(new ColumnResizerPrivate(this)) -{ -} +ColumnResizer::ColumnResizer(QObject* parent) + : QObject(parent), d(new ColumnResizerPrivate(this)) {} -ColumnResizer::~ColumnResizer() -{ +ColumnResizer::~ColumnResizer() { delete d; } -void ColumnResizer::addWidget(QWidget* widget) -{ +void ColumnResizer::addWidget(QWidget* widget) { d->m_widgets.append(widget); widget->installEventFilter(this); // connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(onObjectDestroyed(QObject*))); d->scheduleWidthUpdate(); } -void ColumnResizer::updateWidth() -{ +void ColumnResizer::updateWidth() { if (d->block_update) return; int width = 0; @@ -150,24 +135,21 @@ void ColumnResizer::updateWidth() } } -void ColumnResizer::removeWidget(QWidget* widget) -{ +void ColumnResizer::removeWidget(QWidget* widget) { if (d->m_widgets.contains(widget)) { d->m_widgets.removeAll(widget); widget->removeEventFilter(this); } } -bool ColumnResizer::eventFilter(QObject*, QEvent* event) -{ +bool ColumnResizer::eventFilter(QObject*, QEvent* event) { if (event->type() == QEvent::Resize) { d->scheduleWidthUpdate(); } return false; } -void ColumnResizer::addWidgetsFromLayout(QLayout* layout, int column) -{ +void ColumnResizer::addWidgetsFromLayout(QLayout* layout, int column) { ASSERT(column >= 0); QGridLayout* gridLayout = qobject_cast<QGridLayout*>(layout); QFormLayout* formLayout = qobject_cast<QFormLayout*>(layout); @@ -186,8 +168,7 @@ void ColumnResizer::addWidgetsFromLayout(QLayout* layout, int column) } } -void ColumnResizer::addWidgetsFromGridLayout(QGridLayout* layout, int column) -{ +void ColumnResizer::addWidgetsFromGridLayout(QGridLayout* layout, int column) { for (int row = 0; row < layout->rowCount(); ++row) { QLayoutItem* item = layout->itemAtPosition(row, column); if (!item) { @@ -203,8 +184,7 @@ void ColumnResizer::addWidgetsFromGridLayout(QGridLayout* layout, int column) // connect(layout, SIGNAL(destroyed(QObject*)), this, SLOT(onObjectDestroyed(QObject*))); } -void ColumnResizer::addWidgetsFromFormLayout(QFormLayout* layout, QFormLayout::ItemRole role) -{ +void ColumnResizer::addWidgetsFromFormLayout(QFormLayout* layout, QFormLayout::ItemRole role) { for (int row = 0; row < layout->rowCount(); ++row) { QLayoutItem* item = layout->itemAt(row, role); if (!item) { @@ -223,8 +203,7 @@ void ColumnResizer::addWidgetsFromFormLayout(QFormLayout* layout, QFormLayout::I } } -void ColumnResizer::dropWidgetsFromGridLayout(QGridLayout* layout) -{ +void ColumnResizer::dropWidgetsFromGridLayout(QGridLayout* layout) { // d->block_update = true; // removing all widgets from being supervised for (int row = 0; row < layout->rowCount(); ++row) { diff --git a/GUI/coregui/Views/CommonWidgets/ColumnResizer.h b/GUI/coregui/Views/CommonWidgets/ColumnResizer.h index fb92c43a8ce81885c50fed5fa85bbf2bd683b792..1862f97d582d5febe0dad7f6899a5a5cd079f89e 100644 --- a/GUI/coregui/Views/CommonWidgets/ColumnResizer.h +++ b/GUI/coregui/Views/CommonWidgets/ColumnResizer.h @@ -34,8 +34,7 @@ class ColumnResizerPrivate; //! The ColumnResizer class provides vertically aligned widgets from diferent layouts. -class ColumnResizer : public QObject -{ +class ColumnResizer : public QObject { Q_OBJECT public: ColumnResizer(QObject* parent = 0); diff --git a/GUI/coregui/Views/CommonWidgets/DockWidgetInfo.cpp b/GUI/coregui/Views/CommonWidgets/DockWidgetInfo.cpp index 134605292ecd4d22b89e88c59984588afa0e0445..06278a2a37c0762c254a8e0071622009aa9f584a 100644 --- a/GUI/coregui/Views/CommonWidgets/DockWidgetInfo.cpp +++ b/GUI/coregui/Views/CommonWidgets/DockWidgetInfo.cpp @@ -16,26 +16,20 @@ #include <QDockWidget> #include <QWidget> -DockWidgetInfo::DockWidgetInfo() : m_dock(nullptr), m_widget(nullptr), m_area(Qt::NoDockWidgetArea) -{ -} +DockWidgetInfo::DockWidgetInfo() + : m_dock(nullptr), m_widget(nullptr), m_area(Qt::NoDockWidgetArea) {} DockWidgetInfo::DockWidgetInfo(QDockWidget* dock, QWidget* widget, Qt::DockWidgetArea area) - : m_dock(dock), m_widget(widget), m_area(area) -{ -} + : m_dock(dock), m_widget(widget), m_area(area) {} -QDockWidget* DockWidgetInfo::dock() -{ +QDockWidget* DockWidgetInfo::dock() { return m_dock; } -QWidget* DockWidgetInfo::widget() -{ +QWidget* DockWidgetInfo::widget() { return m_widget; } -Qt::DockWidgetArea DockWidgetInfo::area() -{ +Qt::DockWidgetArea DockWidgetInfo::area() { return m_area; } diff --git a/GUI/coregui/Views/CommonWidgets/DockWidgetInfo.h b/GUI/coregui/Views/CommonWidgets/DockWidgetInfo.h index 89bf906388c168220b1569ab991a348bc7cbce72..b976653c21a5de973bc42fb293d6532675e3b832 100644 --- a/GUI/coregui/Views/CommonWidgets/DockWidgetInfo.h +++ b/GUI/coregui/Views/CommonWidgets/DockWidgetInfo.h @@ -22,8 +22,7 @@ class QWidget; //! Holds information about the widget and its dock. -class DockWidgetInfo -{ +class DockWidgetInfo { public: DockWidgetInfo(); DockWidgetInfo(QDockWidget* dock, QWidget* widget, Qt::DockWidgetArea area); diff --git a/GUI/coregui/Views/CommonWidgets/DocksController.cpp b/GUI/coregui/Views/CommonWidgets/DocksController.cpp index 273781a3ea703e78b7b425d0701f9997ef1f1c38..09efa6c58bbf9b355823bcc6ee57fddff6d292ad 100644 --- a/GUI/coregui/Views/CommonWidgets/DocksController.cpp +++ b/GUI/coregui/Views/CommonWidgets/DocksController.cpp @@ -22,16 +22,14 @@ #include <fancymainwindow.h> DocksController::DocksController(Manhattan::FancyMainWindow* mainWindow) - : QObject(mainWindow), m_mainWindow(mainWindow) -{ + : QObject(mainWindow), m_mainWindow(mainWindow) { m_mainWindow->setDocumentMode(true); m_mainWindow->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::South); m_mainWindow->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); m_mainWindow->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); } -void DocksController::addWidget(int id, QWidget* widget, Qt::DockWidgetArea area) -{ +void DocksController::addWidget(int id, QWidget* widget, Qt::DockWidgetArea area) { if (m_docks.find(id) != m_docks.end()) throw GUIHelpers::Error("DocksController::addWidget() -> Error. " "Attempt to add widget id twice"); @@ -44,8 +42,7 @@ void DocksController::addWidget(int id, QWidget* widget, Qt::DockWidgetArea area frames[i]->setFrameStyle(QFrame::NoFrame); } -void DocksController::onResetLayout() -{ +void DocksController::onResetLayout() { m_mainWindow->setTrackingEnabled(false); QList<QDockWidget*> dockWidgetList = m_mainWindow->dockWidgets(); for (QDockWidget* dockWidget : dockWidgetList) { @@ -69,13 +66,11 @@ void DocksController::onResetLayout() m_mainWindow->setTrackingEnabled(true); } -QDockWidget* DocksController::findDock(int id) -{ +QDockWidget* DocksController::findDock(int id) { return get_info(id).dock(); } -QDockWidget* DocksController::findDock(QWidget* widget) -{ +QDockWidget* DocksController::findDock(QWidget* widget) { for (auto& it : m_docks) if (it.second.widget() == widget) return it.second.dock(); @@ -85,8 +80,7 @@ QDockWidget* DocksController::findDock(QWidget* widget) //! Show docks with id's from the list. Other docks will be hidden. -void DocksController::show_docks(const std::vector<int>& docks_to_show) -{ +void DocksController::show_docks(const std::vector<int>& docks_to_show) { for (auto& it : m_docks) { if (std::find(docks_to_show.begin(), docks_to_show.end(), it.first) != docks_to_show.end()) it.second.dock()->show(); @@ -103,8 +97,7 @@ void DocksController::show_docks(const std::vector<int>& docks_to_show) //! single timer shot) we return min/max sizes of QDockWidget back to re-enable splitters //! functionality. -void DocksController::setDockHeightForWidget(int height) -{ +void DocksController::setDockHeightForWidget(int height) { QWidget* widget = qobject_cast<QWidget*>(sender()); ASSERT(widget); QDockWidget* dock = findDock(widget); @@ -124,16 +117,14 @@ void DocksController::setDockHeightForWidget(int height) QTimer::singleShot(1, this, &DocksController::dockToMinMaxSizes); } -void DocksController::dockToMinMaxSizes() -{ +void DocksController::dockToMinMaxSizes() { ASSERT(m_dock_info.m_dock); m_dock_info.m_dock->setMinimumSize(m_dock_info.m_min_size); m_dock_info.m_dock->setMaximumSize(m_dock_info.m_max_size); m_dock_info.m_dock = nullptr; } -void DocksController::onWidgetCloseRequest() -{ +void DocksController::onWidgetCloseRequest() { QWidget* widget = qobject_cast<QWidget*>(sender()); ASSERT(widget); QDockWidget* dock = findDock(widget); @@ -142,13 +133,11 @@ void DocksController::onWidgetCloseRequest() dock->toggleViewAction()->trigger(); } -Manhattan::FancyMainWindow* DocksController::mainWindow() -{ +Manhattan::FancyMainWindow* DocksController::mainWindow() { return m_mainWindow; } -DockWidgetInfo DocksController::get_info(int id) -{ +DockWidgetInfo DocksController::get_info(int id) { if (m_docks.find(id) == m_docks.end()) throw GUIHelpers::Error("DocksController::addWidget() -> Error. Non existing id."); diff --git a/GUI/coregui/Views/CommonWidgets/DocksController.h b/GUI/coregui/Views/CommonWidgets/DocksController.h index 0de5a222764c7c747f28d0204fa5afcd7521b62d..154c11cf5c8392052f4fdb3ab523c1c90e730010 100644 --- a/GUI/coregui/Views/CommonWidgets/DocksController.h +++ b/GUI/coregui/Views/CommonWidgets/DocksController.h @@ -20,15 +20,13 @@ #include <QSize> #include <map> -namespace Manhattan -{ +namespace Manhattan { class FancyMainWindow; } //! Handles appearance of docked widgets in the context of FancyMainWindow. -class DocksController : public QObject -{ +class DocksController : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/CommonWidgets/InfoPanel.cpp b/GUI/coregui/Views/CommonWidgets/InfoPanel.cpp index 33a5193b2b193b77939d47f12468149642a7ad7f..265737ffa4e1bf67eaa55b33f010d3aed8af015a 100644 --- a/GUI/coregui/Views/CommonWidgets/InfoPanel.cpp +++ b/GUI/coregui/Views/CommonWidgets/InfoPanel.cpp @@ -18,8 +18,7 @@ #include <QResizeEvent> #include <QStackedWidget> -namespace -{ +namespace { const int minimum_widget_height = 25; // height of toolbar const int minimum_height_before_collapse = 50; const int default_height = 200; @@ -29,8 +28,7 @@ InfoPanel::InfoPanel(QWidget* parent) : QFrame(parent) , m_toolBar(new InfoPanelToolBar) , m_stackedWidget(new QStackedWidget) - , m_cached_height(default_height) -{ + , m_cached_height(default_height) { auto mainLayout = new QVBoxLayout; mainLayout->addWidget(m_toolBar); mainLayout->addWidget(m_stackedWidget); @@ -47,8 +45,7 @@ InfoPanel::InfoPanel(QWidget* parent) &InfoPanel::onCloseButtonClicked); } -QSize InfoPanel::sizeHint() const -{ +QSize InfoPanel::sizeHint() const { QSize result = m_toolBar->sizeHint(); if (QWidget* widget = m_stackedWidget->currentWidget()) { @@ -61,23 +58,19 @@ QSize InfoPanel::sizeHint() const return result; } -QSize InfoPanel::minimumSizeHint() const -{ +QSize InfoPanel::minimumSizeHint() const { return QSize(minimum_widget_height, minimum_widget_height); } -void InfoPanel::onExpandButtonClicked() -{ +void InfoPanel::onExpandButtonClicked() { setContentVisible(!isContentVisible(), true); } -void InfoPanel::onCloseButtonClicked() -{ +void InfoPanel::onCloseButtonClicked() { emit widgetCloseRequest(); } -void InfoPanel::setContentVisible(bool editor_status, bool dock_notify) -{ +void InfoPanel::setContentVisible(bool editor_status, bool dock_notify) { m_toolBar->setExpandStatus(editor_status); if (editor_status) { if (m_cached_height) @@ -97,16 +90,14 @@ void InfoPanel::setContentVisible(bool editor_status, bool dock_notify) } } -bool InfoPanel::isContentVisible() -{ +bool InfoPanel::isContentVisible() { if (m_stackedWidget->currentWidget()) return m_stackedWidget->currentWidget()->isVisible(); return false; } -void InfoPanel::resizeEvent(QResizeEvent* event) -{ +void InfoPanel::resizeEvent(QResizeEvent* event) { // widget is schrinking in height if (event->oldSize().height() > event->size().height()) { if (event->size().height() <= minimum_height_before_collapse && isContentVisible()) diff --git a/GUI/coregui/Views/CommonWidgets/InfoPanel.h b/GUI/coregui/Views/CommonWidgets/InfoPanel.h index 0faec5611e64cf4421bd4a4c745ce97f79eb2bbe..805027e4a2ccebe34f4158fac093a9c52efffd04 100644 --- a/GUI/coregui/Views/CommonWidgets/InfoPanel.h +++ b/GUI/coregui/Views/CommonWidgets/InfoPanel.h @@ -26,8 +26,7 @@ class QResizeEvent; //! Used in JobMessagePanel. -class InfoPanel : public QFrame -{ +class InfoPanel : public QFrame { Q_OBJECT public: explicit InfoPanel(QWidget* parent); diff --git a/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.cpp b/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.cpp index 1938c4709f00528483ae07f1cf588ca054ceac7e..f2178707ad970a426832c8030046f878c82fa7cb 100644 --- a/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.cpp +++ b/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.cpp @@ -17,8 +17,7 @@ #include <QHBoxLayout> #include <QToolButton> -namespace -{ +namespace { const int minimum_size = 25; const QString icon_up = ":/images/dark-angle-up.svg"; const QString icon_down = ":/images/dark-angle-down.svg"; @@ -31,8 +30,7 @@ InfoPanelToolBar::InfoPanelToolBar(QWidget* parent) : QToolBar(parent) , m_expandAction(new QAction(expand_text, this)) , m_closeAction(new QAction(close_text, this)) - , m_expanded(false) -{ + , m_expanded(false) { setMinimumSize(minimum_size, minimum_size); setProperty("_q_custom_style_disabled", QVariant(true)); @@ -52,8 +50,7 @@ InfoPanelToolBar::InfoPanelToolBar(QWidget* parent) addAction(m_closeAction); } -void InfoPanelToolBar::setExpandStatus(bool status) -{ +void InfoPanelToolBar::setExpandStatus(bool status) { m_expanded = status; if (m_expanded) m_expandAction->setIcon(QIcon(icon_down)); @@ -61,8 +58,7 @@ void InfoPanelToolBar::setExpandStatus(bool status) m_expandAction->setIcon(QIcon(icon_up)); } -void InfoPanelToolBar::onExpandButtonClicked() -{ +void InfoPanelToolBar::onExpandButtonClicked() { m_expanded = !m_expanded; setExpandStatus(m_expanded); emit expandButtonClicked(); diff --git a/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.h b/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.h index 7955e282858b4df481d70f7efd5f0f681b24c03d..2067fd7052f3639bf7f0a115f3d2c1b0e575bdfe 100644 --- a/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.h +++ b/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.h @@ -21,8 +21,7 @@ class QAction; //! Toolbar for InfoPanel with collapse/expand buttons. -class InfoPanelToolBar : public QToolBar -{ +class InfoPanelToolBar : public QToolBar { Q_OBJECT public: diff --git a/GUI/coregui/Views/CommonWidgets/ItemComboToolBar.cpp b/GUI/coregui/Views/CommonWidgets/ItemComboToolBar.cpp index d911f03e97939e4d4328e8331904b2fa7db4bbda..45010ed901dc23d03d9dccaa1a91c8b2c17da992 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemComboToolBar.cpp +++ b/GUI/coregui/Views/CommonWidgets/ItemComboToolBar.cpp @@ -19,8 +19,7 @@ #include <QStandardItemModel> ItemComboToolBar::ItemComboToolBar(QWidget* parent) - : StyledToolBar(parent), m_comboBox(new QComboBox), m_comboBoxAction(nullptr) -{ + : StyledToolBar(parent), m_comboBox(new QComboBox), m_comboBoxAction(nullptr) { setToolButtonStyle(Qt::ToolButtonTextBesideIcon); m_comboBox->setToolTip("Select type of graphical presentation."); @@ -30,16 +29,14 @@ ItemComboToolBar::ItemComboToolBar(QWidget* parent) setComboConnected(true); } -void ItemComboToolBar::setPresentation(const QString& name) -{ +void ItemComboToolBar::setPresentation(const QString& name) { setComboConnected(false); m_comboBox->setCurrentText(name); setComboConnected(true); } void ItemComboToolBar::setPresentationList(const QStringList& presentationList, - const QStringList& activeList) -{ + const QStringList& activeList) { ASSERT(presentationList.size()); QString previous = currentPresentation(); @@ -56,15 +53,13 @@ void ItemComboToolBar::setPresentationList(const QStringList& presentationList, setComboConnected(true); } -QString ItemComboToolBar::currentPresentation() const -{ +QString ItemComboToolBar::currentPresentation() const { return m_comboBox->currentText(); } //! Sets external actions to tool bar (previous actions will be removed). -void ItemComboToolBar::setActionList(const QList<QAction*>& actionList) -{ +void ItemComboToolBar::setActionList(const QList<QAction*>& actionList) { for (auto action : actions()) removeAction(action); @@ -76,8 +71,7 @@ void ItemComboToolBar::setActionList(const QList<QAction*>& actionList) addAction(m_comboBoxAction); } -void ItemComboToolBar::setComboConnected(bool value) -{ +void ItemComboToolBar::setComboConnected(bool value) { if (value) connect(m_comboBox, SIGNAL(currentIndexChanged(QString)), this, SIGNAL(comboChanged(QString)), Qt::UniqueConnection); @@ -88,8 +82,7 @@ void ItemComboToolBar::setComboConnected(bool value) //! All items in QComboBox which are not in given list, will be disabled (gray and unselectable). -void ItemComboToolBar::makeItemsEnabled(const QStringList& activePresentations) -{ +void ItemComboToolBar::makeItemsEnabled(const QStringList& activePresentations) { const QStandardItemModel* model = dynamic_cast<const QStandardItemModel*>(m_comboBox->model()); ASSERT(model); diff --git a/GUI/coregui/Views/CommonWidgets/ItemComboToolBar.h b/GUI/coregui/Views/CommonWidgets/ItemComboToolBar.h index d5d83fb0d074b12c7bfb1f92d90014c30987c8e3..82c52589d4123e1fb20d10e76cd5519a3478c242 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemComboToolBar.h +++ b/GUI/coregui/Views/CommonWidgets/ItemComboToolBar.h @@ -25,8 +25,7 @@ class QComboBox; //! ComboBox to switch ItemComboWidget, and dynamic list of actions, which are updated //! according to current state of ItemComboWidget. -class ItemComboToolBar : public StyledToolBar -{ +class ItemComboToolBar : public StyledToolBar { Q_OBJECT public: diff --git a/GUI/coregui/Views/CommonWidgets/ItemComboWidget.cpp b/GUI/coregui/Views/CommonWidgets/ItemComboWidget.cpp index 540b282a6fab3bee8a7fd890bdfe55adb93457c4..3a5c44c2f0a8cefa3b25ad814c5261db45e9f2f7 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemComboWidget.cpp +++ b/GUI/coregui/Views/CommonWidgets/ItemComboWidget.cpp @@ -24,8 +24,7 @@ ItemComboWidget::ItemComboWidget(QWidget* parent) : SessionItemWidget(parent) , m_toolBar(new ItemComboToolBar) - , m_stackedWidget(new QStackedWidget) -{ + , m_stackedWidget(new QStackedWidget) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_stackedWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -40,15 +39,13 @@ ItemComboWidget::ItemComboWidget(QWidget* parent) connect(m_toolBar, SIGNAL(comboChanged(QString)), this, SLOT(onComboChanged(QString))); } -void ItemComboWidget::registerWidget(const QString& presentationType, factory_function_t f) -{ +void ItemComboWidget::registerWidget(const QString& presentationType, factory_function_t f) { m_widgetFactory.registerItem(presentationType, f); } //! Sets stack to show widget corresponding to given presentation -void ItemComboWidget::setPresentation(const QString& presentationType) -{ +void ItemComboWidget::setPresentation(const QString& presentationType) { if (!activePresentationList(currentItem()).contains(presentationType)) return; @@ -73,8 +70,7 @@ void ItemComboWidget::setPresentation(const QString& presentationType) setSizeToCurrentWidget(); } -void ItemComboWidget::setToolBarVisible(bool value) -{ +void ItemComboWidget::setToolBarVisible(bool value) { m_toolBar->setVisible(value); } @@ -82,49 +78,42 @@ void ItemComboWidget::setToolBarVisible(bool value) //! which is present in QComboBox selector and can be selected. For example, if JobItem //! is fittable, the list will contain "FitComparisonWidgetName". -QStringList ItemComboWidget::activePresentationList(SessionItem* item) -{ +QStringList ItemComboWidget::activePresentationList(SessionItem* item) { Q_UNUSED(item); return QStringList(); } //! Returns full list of presentations available for given item. -QStringList ItemComboWidget::presentationList(SessionItem* item) -{ +QStringList ItemComboWidget::presentationList(SessionItem* item) { return activePresentationList(item); } //! Presentation which should be shown for current item. -QString ItemComboWidget::itemPresentation() const -{ +QString ItemComboWidget::itemPresentation() const { return selectedPresentation(); } //! Presentation selected in combo selector. -QString ItemComboWidget::selectedPresentation() const -{ +QString ItemComboWidget::selectedPresentation() const { return m_toolBar->currentPresentation(); } -void ItemComboWidget::subscribeToItem() -{ +void ItemComboWidget::subscribeToItem() { m_toolBar->setPresentationList(presentationList(currentItem()), activePresentationList(currentItem())); setPresentation(itemPresentation()); } -void ItemComboWidget::onComboChanged(const QString&) -{ +void ItemComboWidget::onComboChanged(const QString&) { setPresentation(selectedPresentation()); } //! Resizes QStackedWidget to currently active page. -void ItemComboWidget::setSizeToCurrentWidget() -{ +void ItemComboWidget::setSizeToCurrentWidget() { for (int i = 0; i < m_stackedWidget->count(); ++i) { // determine the vertical size policy QSizePolicy::Policy policy = QSizePolicy::Ignored; diff --git a/GUI/coregui/Views/CommonWidgets/ItemComboWidget.h b/GUI/coregui/Views/CommonWidgets/ItemComboWidget.h index 70bb251a6b2b58c5fa89fdc27302bd342c74a0e6..8c772753556ed2b356ad060ad1fd73ab9c6b5294 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemComboWidget.h +++ b/GUI/coregui/Views/CommonWidgets/ItemComboWidget.h @@ -32,8 +32,7 @@ class QStackedWidget; //! For example, in JobOutputDataWidget the results of the job can be presented with either //! IntensityDataWidget or FitDataWidget, depending from the JobView's activity type. -class ItemComboWidget : public SessionItemWidget -{ +class ItemComboWidget : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.cpp b/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.cpp index 1315bc677ffeb662d677ee7ad3ed787625e9c921..2db481027344c56f4c647beed32c15651e277c9b 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.cpp +++ b/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.cpp @@ -20,8 +20,7 @@ #include <QVBoxLayout> ItemSelectorWidget::ItemSelectorWidget(QWidget* parent) - : QWidget(parent), m_listView(new QListView), m_model(nullptr) -{ + : QWidget(parent), m_listView(new QListView), m_model(nullptr) { setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); QVBoxLayout* layout = new QVBoxLayout; @@ -39,18 +38,15 @@ ItemSelectorWidget::ItemSelectorWidget(QWidget* parent) ItemSelectorWidget::~ItemSelectorWidget() = default; -QSize ItemSelectorWidget::sizeHint() const -{ +QSize ItemSelectorWidget::sizeHint() const { return QSize(Constants::ITEM_SELECTOR_WIDGET_WIDTH, Constants::ITEM_SELECTOR_WIDGET_HEIGHT); } -QSize ItemSelectorWidget::minimumSizeHint() const -{ +QSize ItemSelectorWidget::minimumSizeHint() const { return QSize(25, 25); } -void ItemSelectorWidget::setModel(SessionModel* model) -{ +void ItemSelectorWidget::setModel(SessionModel* model) { if (model == m_model) return; @@ -59,43 +55,36 @@ void ItemSelectorWidget::setModel(SessionModel* model) connectModel(); } -void ItemSelectorWidget::setItemDelegate(QAbstractItemDelegate* delegate) -{ +void ItemSelectorWidget::setItemDelegate(QAbstractItemDelegate* delegate) { m_listView->setItemDelegate(delegate); } -QItemSelectionModel* ItemSelectorWidget::selectionModel() -{ +QItemSelectionModel* ItemSelectorWidget::selectionModel() { return m_listView->selectionModel(); } -QListView* ItemSelectorWidget::listView() -{ +QListView* ItemSelectorWidget::listView() { return m_listView; } void ItemSelectorWidget::select(const QModelIndex& index, - QItemSelectionModel::SelectionFlags command) -{ + QItemSelectionModel::SelectionFlags command) { selectionModel()->select(index, command); } //! select last item if no selection exists -void ItemSelectorWidget::updateSelection() -{ +void ItemSelectorWidget::updateSelection() { if (!selectionModel()->hasSelection()) selectLast(); } -void ItemSelectorWidget::selectLast() -{ +void ItemSelectorWidget::selectLast() { QModelIndex itemIndex = m_model->index(m_model->rowCount(QModelIndex()) - 1, 0, QModelIndex()); selectionModel()->select(itemIndex, QItemSelectionModel::ClearAndSelect); } -void ItemSelectorWidget::onSelectionChanged(const QItemSelection& selected, const QItemSelection&) -{ +void ItemSelectorWidget::onSelectionChanged(const QItemSelection& selected, const QItemSelection&) { QModelIndexList indexes = selected.indexes(); SessionItem* selectedItem(0); @@ -105,13 +94,11 @@ void ItemSelectorWidget::onSelectionChanged(const QItemSelection& selected, cons emit selectionChanged(selectedItem); } -void ItemSelectorWidget::onCustomContextMenuRequested(const QPoint& point) -{ +void ItemSelectorWidget::onCustomContextMenuRequested(const QPoint& point) { emit contextMenuRequest(m_listView->mapToGlobal(point), m_listView->indexAt(point)); } -void ItemSelectorWidget::connectModel() -{ +void ItemSelectorWidget::connectModel() { if (!m_model) return; @@ -124,15 +111,13 @@ void ItemSelectorWidget::connectModel() Qt::UniqueConnection); } -void ItemSelectorWidget::disconnectModel() -{ +void ItemSelectorWidget::disconnectModel() { m_listView->setModel(nullptr); m_model = nullptr; } //! provide default selection when widget is shown -void ItemSelectorWidget::showEvent(QShowEvent*) -{ +void ItemSelectorWidget::showEvent(QShowEvent*) { if (!m_model || !selectionModel()) return; diff --git a/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.h b/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.h index 534347aa5a8ca256d25d0f4d5c51e8e2d3903289..3bcf0b18a0254e38d8380c071507373b23ee3f15 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.h +++ b/GUI/coregui/Views/CommonWidgets/ItemSelectorWidget.h @@ -30,8 +30,7 @@ class SessionDecorationModel; //! The ItemSelectorWidget class holds QListView to show top level items of SessionModel. //! Used in InstrumentView, ImportDataView, JobSelectorView to switch between items. -class ItemSelectorWidget : public QWidget -{ +class ItemSelectorWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/CommonWidgets/ItemStackPresenter.h b/GUI/coregui/Views/CommonWidgets/ItemStackPresenter.h index ae5b9dba91bff04f71e8f6e222bda47ccdef4528..0d7f54b9abe36c5c6ca12e7e9bb505249a9a836c 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemStackPresenter.h +++ b/GUI/coregui/Views/CommonWidgets/ItemStackPresenter.h @@ -26,8 +26,7 @@ class SessionItem; //! The ItemStackPresenter templated class extends ItemStackWidget so it could operate with //! SesionItem editor's of specified type, while still keeping signal/slots alive. -template <class T> class ItemStackPresenter : public ItemStackWidget -{ +template <class T> class ItemStackPresenter : public ItemStackWidget { public: ItemStackPresenter(bool single_widget = false) : m_single_widget(single_widget) {} @@ -48,8 +47,7 @@ private: bool m_single_widget; //!< Different items will be served by same widget }; -template <class T> template <class U> void ItemStackPresenter<T>::setItem(U* item, bool* isNew) -{ +template <class T> template <class U> void ItemStackPresenter<T>::setItem(U* item, bool* isNew) { validateItem(item); if (isNew) @@ -77,13 +75,11 @@ template <class T> template <class U> void ItemStackPresenter<T>::setItem(U* ite widget->setItem(item); } -template <class T> T* ItemStackPresenter<T>::currentWidget() -{ +template <class T> T* ItemStackPresenter<T>::currentWidget() { return dynamic_cast<T*>(m_stackedWidget->currentWidget()); } -template <class T> T* ItemStackPresenter<T>::itemWidget(SessionItem* item) -{ +template <class T> T* ItemStackPresenter<T>::itemWidget(SessionItem* item) { if (m_single_widget) { if (!m_itemToWidget.empty()) return m_itemToWidget.first(); @@ -94,14 +90,12 @@ template <class T> T* ItemStackPresenter<T>::itemWidget(SessionItem* item) return nullptr; } -template <class T> void ItemStackPresenter<T>::hideWidgets() -{ +template <class T> void ItemStackPresenter<T>::hideWidgets() { if (m_stackedWidget->currentWidget()) m_stackedWidget->currentWidget()->hide(); } -template <class T> void ItemStackPresenter<T>::removeWidgetForItem(SessionItem* item) -{ +template <class T> void ItemStackPresenter<T>::removeWidgetForItem(SessionItem* item) { ASSERT(item); if (m_single_widget) @@ -123,8 +117,7 @@ template <class T> void ItemStackPresenter<T>::removeWidgetForItem(SessionItem* delete widget; } -template <class T> void ItemStackPresenter<T>::removeWidgets() -{ +template <class T> void ItemStackPresenter<T>::removeWidgets() { typename QMap<SessionItem*, T*>::iterator it = m_itemToWidget.begin(); while (it != m_itemToWidget.end()) { m_stackedWidget->removeWidget(it.value()); diff --git a/GUI/coregui/Views/CommonWidgets/ItemStackWidget.cpp b/GUI/coregui/Views/CommonWidgets/ItemStackWidget.cpp index cc00def7f4d583bb8ef5ee747d9c4ed6bc7fdf29..78612e34f6d3b938e6eeff85c40ffd9b4e34e919 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemStackWidget.cpp +++ b/GUI/coregui/Views/CommonWidgets/ItemStackWidget.cpp @@ -22,8 +22,7 @@ ItemStackWidget::ItemStackWidget(QWidget* parent) : QWidget(parent) , m_stackedWidget(new QStackedWidget) , m_model(nullptr) - , m_size_hint(QSize(1024, 1024)) -{ + , m_size_hint(QSize(1024, 1024)) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_stackedWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -35,8 +34,7 @@ ItemStackWidget::ItemStackWidget(QWidget* parent) setLayout(layout); } -void ItemStackWidget::setModel(SessionModel* model) -{ +void ItemStackWidget::setModel(SessionModel* model) { if (model == m_model) return; @@ -45,34 +43,28 @@ void ItemStackWidget::setModel(SessionModel* model) connectModel(); } -QSize ItemStackWidget::sizeHint() const -{ +QSize ItemStackWidget::sizeHint() const { return m_size_hint; } -QSize ItemStackWidget::minimumSizeHint() const -{ +QSize ItemStackWidget::minimumSizeHint() const { return QSize(25, 25); } -void ItemStackWidget::setSizeHint(const QSize& size_hint) -{ +void ItemStackWidget::setSizeHint(const QSize& size_hint) { m_size_hint = size_hint; } -void ItemStackWidget::onModelAboutToBeReset() -{ +void ItemStackWidget::onModelAboutToBeReset() { removeWidgets(); } -void ItemStackWidget::onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int) -{ +void ItemStackWidget::onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int) { SessionItem* item = m_model->itemForIndex(m_model->index(first, 0, parent)); removeWidgetForItem(item); } -void ItemStackWidget::connectModel() -{ +void ItemStackWidget::connectModel() { if (!m_model) return; @@ -83,8 +75,7 @@ void ItemStackWidget::connectModel() SLOT(onRowsAboutToBeRemoved(QModelIndex, int, int)), Qt::UniqueConnection); } -void ItemStackWidget::disconnectModel() -{ +void ItemStackWidget::disconnectModel() { if (!m_model) return; @@ -96,8 +87,7 @@ void ItemStackWidget::disconnectModel() //! Checks if model was set correctly. -void ItemStackWidget::validateItem(SessionItem* item) -{ +void ItemStackWidget::validateItem(SessionItem* item) { if (!item) return; diff --git a/GUI/coregui/Views/CommonWidgets/ItemStackWidget.h b/GUI/coregui/Views/CommonWidgets/ItemStackWidget.h index 5ae80b46bf43f1b8bfdb4df57a1fddf7087c25a3..e395b8802804358673e58b9f54efa0c96277f653 100644 --- a/GUI/coregui/Views/CommonWidgets/ItemStackWidget.h +++ b/GUI/coregui/Views/CommonWidgets/ItemStackWidget.h @@ -27,8 +27,7 @@ class SessionItem; //! specific editor's logic. Used in InstrumentView, ImportDataView, JobView to show editors for //! currently selected items. -class ItemStackWidget : public QWidget -{ +class ItemStackWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/CommonWidgets/ModelTreeView.cpp b/GUI/coregui/Views/CommonWidgets/ModelTreeView.cpp index 10a16c2338de6454a13781ffaac09675be476975..498c4a9a720c38ea02ff999221c9769f5ea7f462 100644 --- a/GUI/coregui/Views/CommonWidgets/ModelTreeView.cpp +++ b/GUI/coregui/Views/CommonWidgets/ModelTreeView.cpp @@ -24,8 +24,7 @@ ModelTreeView::ModelTreeView(QWidget* parent, SessionModel* model) : QWidget(parent) , m_tree(new QTreeView) , m_decorationProxy(new SessionDecorationModel(this, model)) - , m_is_expanded(false) -{ + , m_is_expanded(false) { if (!model) throw GUIHelpers::Error("ModelTreeView::ModelTreeView() -> Error. Nullptr as model."); @@ -47,18 +46,15 @@ ModelTreeView::ModelTreeView(QWidget* parent, SessionModel* model) setLayout(layout); } -void ModelTreeView::setItemDelegate(QAbstractItemDelegate* delegate) -{ +void ModelTreeView::setItemDelegate(QAbstractItemDelegate* delegate) { m_tree->setItemDelegate(delegate); } -void ModelTreeView::toggleExpanded() -{ +void ModelTreeView::toggleExpanded() { setExpanded(!isExpanded()); } -void ModelTreeView::setExpanded(bool expanded) -{ +void ModelTreeView::setExpanded(bool expanded) { ASSERT(m_tree); if (expanded) { m_tree->expandAll(); diff --git a/GUI/coregui/Views/CommonWidgets/ModelTreeView.h b/GUI/coregui/Views/CommonWidgets/ModelTreeView.h index bb0227c4f54bde12fb6d5e43e62b356b75454c56..9acbd659f38cac5fdf58c99b5f0aa0ed878b6a96 100644 --- a/GUI/coregui/Views/CommonWidgets/ModelTreeView.h +++ b/GUI/coregui/Views/CommonWidgets/ModelTreeView.h @@ -25,8 +25,7 @@ class QAbstractItemDelegate; //! Equivalent of QTreeView for SessionModel allowing to add visual decorations to the tree. //! Additionaly provides expand/collapse utility methods. -class ModelTreeView : public QWidget -{ +class ModelTreeView : public QWidget { Q_OBJECT public: ModelTreeView(QWidget* parent, SessionModel* model); diff --git a/GUI/coregui/Views/CommonWidgets/SessionItemController.cpp b/GUI/coregui/Views/CommonWidgets/SessionItemController.cpp index cf790524cfb6dde78801f196e0f54334fe8c2bf8..3393a73ddc8bd64954c6ea07421bac674be66661 100644 --- a/GUI/coregui/Views/CommonWidgets/SessionItemController.cpp +++ b/GUI/coregui/Views/CommonWidgets/SessionItemController.cpp @@ -17,18 +17,15 @@ #include "GUI/coregui/utils/GUIHelpers.h" SessionItemController::SessionItemController(QObject* prt) - : QObject(prt), m_item(nullptr), m_parent_subscribed(false) -{ + : QObject(prt), m_item(nullptr), m_parent_subscribed(false) { ASSERT(parent()); } -SessionItemController::~SessionItemController() -{ +SessionItemController::~SessionItemController() { onControllerDestroy(); } -void SessionItemController::setItem(SessionItem* item) -{ +void SessionItemController::setItem(SessionItem* item) { if (m_item == item) return; @@ -44,25 +41,21 @@ void SessionItemController::setItem(SessionItem* item) m_item->mapper()->setOnItemDestroy([this](SessionItem*) { onItemDestroy(); }, this); } -SessionItem* SessionItemController::currentItem() -{ +SessionItem* SessionItemController::currentItem() { return m_item; } -void SessionItemController::setSubscribeCallback(callback_t fun) -{ +void SessionItemController::setSubscribeCallback(callback_t fun) { m_subscribe_callback = fun; } -void SessionItemController::setUnsubscribeCallback(callback_t fun) -{ +void SessionItemController::setUnsubscribeCallback(callback_t fun) { m_unsubscribe_callback = fun; } //! Subscribe parent to item's signals. -void SessionItemController::subscribe() -{ +void SessionItemController::subscribe() { if (!m_item) return; @@ -73,8 +66,7 @@ void SessionItemController::subscribe() //! Fully unsubscribes the parent from listening item's signals. //! Controller stays active to track item destruction. -void SessionItemController::unsubscribe() -{ +void SessionItemController::unsubscribe() { if (!m_item) return; @@ -84,23 +76,20 @@ void SessionItemController::unsubscribe() m_item->mapper()->unsubscribe(parent()); } -void SessionItemController::onItemDestroy() -{ +void SessionItemController::onItemDestroy() { if (m_parent_subscribed) unsubscribeParent(); m_item = nullptr; } -void SessionItemController::onControllerDestroy() -{ +void SessionItemController::onControllerDestroy() { if (m_item) { m_item->mapper()->unsubscribe(this); m_item->mapper()->unsubscribe(parent()); } } -void SessionItemController::subscribeParent() -{ +void SessionItemController::subscribeParent() { ASSERT(m_subscribe_callback); ASSERT(m_parent_subscribed == false); m_subscribe_callback(); @@ -109,8 +98,7 @@ void SessionItemController::subscribeParent() //! Calls additional callback on un -void SessionItemController::unsubscribeParent() -{ +void SessionItemController::unsubscribeParent() { ASSERT(m_unsubscribe_callback); ASSERT(m_parent_subscribed == true); m_unsubscribe_callback(); diff --git a/GUI/coregui/Views/CommonWidgets/SessionItemController.h b/GUI/coregui/Views/CommonWidgets/SessionItemController.h index 3fa832fff41de5ecf7abd5f29f14e293d1515793..2628ccb366195ae16e049e7a57b53559cb1e3330 100644 --- a/GUI/coregui/Views/CommonWidgets/SessionItemController.h +++ b/GUI/coregui/Views/CommonWidgets/SessionItemController.h @@ -23,8 +23,7 @@ class SessionItem; //! Provides subscribe/unsubscribe mechanism for any QObject to track //! time of life of SessionItem. Mainly intended for SessionItemWidget. -class SessionItemController : public QObject -{ +class SessionItemController : public QObject { Q_OBJECT public: using callback_t = std::function<void(void)>; diff --git a/GUI/coregui/Views/CommonWidgets/SessionItemWidget.cpp b/GUI/coregui/Views/CommonWidgets/SessionItemWidget.cpp index c1671ce87ecc6cb1232a637597bb1e4c465c9daf..5a43776d2ba7b58b8b85cca812f5c51dd5fa37f8 100644 --- a/GUI/coregui/Views/CommonWidgets/SessionItemWidget.cpp +++ b/GUI/coregui/Views/CommonWidgets/SessionItemWidget.cpp @@ -17,43 +17,36 @@ #include "GUI/coregui/Views/CommonWidgets/SessionItemController.h" SessionItemWidget::SessionItemWidget(QWidget* parent) - : QWidget(parent), m_itemController(new SessionItemController(this)) -{ + : QWidget(parent), m_itemController(new SessionItemController(this)) { m_itemController->setSubscribeCallback([this]() { subscribeToItem(); }); m_itemController->setUnsubscribeCallback([this]() { unsubscribeFromItem(); }); } SessionItemWidget::~SessionItemWidget() = default; -void SessionItemWidget::setItem(SessionItem* item) -{ +void SessionItemWidget::setItem(SessionItem* item) { m_itemController->setItem(item); if (isVisible()) m_itemController->subscribe(); } -QList<QAction*> SessionItemWidget::actionList() -{ +QList<QAction*> SessionItemWidget::actionList() { return QList<QAction*>(); } -SessionItem* SessionItemWidget::currentItem() -{ +SessionItem* SessionItemWidget::currentItem() { return const_cast<SessionItem*>(static_cast<const SessionItemWidget*>(this)->currentItem()); } -const SessionItem* SessionItemWidget::currentItem() const -{ +const SessionItem* SessionItemWidget::currentItem() const { return m_itemController->currentItem(); } -void SessionItemWidget::showEvent(QShowEvent*) -{ +void SessionItemWidget::showEvent(QShowEvent*) { m_itemController->subscribe(); } -void SessionItemWidget::hideEvent(QHideEvent*) -{ +void SessionItemWidget::hideEvent(QHideEvent*) { m_itemController->unsubscribe(); } diff --git a/GUI/coregui/Views/CommonWidgets/SessionItemWidget.h b/GUI/coregui/Views/CommonWidgets/SessionItemWidget.h index 1f802da728d687fc010dad171bc11cc3f4add284..e88172d71e93252f8068c45c9f81004e46ef1e74 100644 --- a/GUI/coregui/Views/CommonWidgets/SessionItemWidget.h +++ b/GUI/coregui/Views/CommonWidgets/SessionItemWidget.h @@ -27,8 +27,7 @@ class SessionItemController; //! The main purpose is to save performance, when item keeps changing its properties, while //! widget is hidden. -class SessionItemWidget : public QWidget -{ +class SessionItemWidget : public QWidget { Q_OBJECT public: explicit SessionItemWidget(QWidget* parent = 0); diff --git a/GUI/coregui/Views/CommonWidgets/StatusLabel.cpp b/GUI/coregui/Views/CommonWidgets/StatusLabel.cpp index 425153f17d75a0fbab0f30933eb6fbff61604b08..13d5723e6d71bd1a11e780a2248f53ebc5028f15 100644 --- a/GUI/coregui/Views/CommonWidgets/StatusLabel.cpp +++ b/GUI/coregui/Views/CommonWidgets/StatusLabel.cpp @@ -18,51 +18,42 @@ #include <QFont> #include <QPainter> -namespace -{ -int default_text_size() -{ +namespace { +int default_text_size() { return StyleUtils::SystemPointSize(); } -int default_label_height() -{ +int default_label_height() { return StyleUtils::SizeOfLetterM().height() * 1.75; } } // namespace StatusLabel::StatusLabel(QWidget* parent) - : QFrame(parent), m_font("Monospace", default_text_size(), QFont::Normal, false) -{ + : QFrame(parent), m_font("Monospace", default_text_size(), QFont::Normal, false) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setFixedHeight(default_label_height()); } -void StatusLabel::setText(const QString& text) -{ +void StatusLabel::setText(const QString& text) { m_text = text; update(); } -void StatusLabel::setFont(const QFont& font) -{ +void StatusLabel::setFont(const QFont& font) { m_font = font; update(); } -void StatusLabel::setPointSize(int pointSize) -{ +void StatusLabel::setPointSize(int pointSize) { m_font.setPointSize(pointSize); update(); } -void StatusLabel::setAlignment(Qt::Alignment alignment) -{ +void StatusLabel::setAlignment(Qt::Alignment alignment) { m_alignment = alignment; update(); } -void StatusLabel::paintEvent(QPaintEvent* event) -{ +void StatusLabel::paintEvent(QPaintEvent* event) { QWidget::paintEvent(event); QPainter painter(this); diff --git a/GUI/coregui/Views/CommonWidgets/StatusLabel.h b/GUI/coregui/Views/CommonWidgets/StatusLabel.h index f95d39479e814ea1d3a276c4a00f0527cd21fb99..ae153fc748792c10247c140fb79ecef6de42cf57 100644 --- a/GUI/coregui/Views/CommonWidgets/StatusLabel.h +++ b/GUI/coregui/Views/CommonWidgets/StatusLabel.h @@ -25,8 +25,7 @@ class QPaintEvent; //! This class is intended for ColorMapLabel, where the size of font is adjusted automatically //! depending from available space. -class StatusLabel : public QFrame -{ +class StatusLabel : public QFrame { Q_OBJECT public: diff --git a/GUI/coregui/Views/CommonWidgets/UpdateTimer.cpp b/GUI/coregui/Views/CommonWidgets/UpdateTimer.cpp index 7abcea19450546a158ed67f2d4bfef6ad9df7bdc..ea6352c3400372df99cd33c1affc077f30b6c113 100644 --- a/GUI/coregui/Views/CommonWidgets/UpdateTimer.cpp +++ b/GUI/coregui/Views/CommonWidgets/UpdateTimer.cpp @@ -20,27 +20,23 @@ UpdateTimer::UpdateTimer(int timerInterval, QObject* parent) , m_update_request_count(0) , m_timer_interval(timerInterval) , m_is_busy(false) - , m_timer(new QTimer(this)) -{ + , m_timer(new QTimer(this)) { m_timer->setInterval(m_timer_interval); m_timer->setSingleShot(true); connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimerTimeout())); } -void UpdateTimer::reset() -{ +void UpdateTimer::reset() { m_update_request_count = 0; m_timer->stop(); m_is_busy = false; } -void UpdateTimer::setWallclockTimer(int timerInterval) -{ +void UpdateTimer::setWallclockTimer(int timerInterval) { m_timer_interval = timerInterval; } -void UpdateTimer::scheduleUpdate() -{ +void UpdateTimer::scheduleUpdate() { if (m_is_busy) return; @@ -50,8 +46,7 @@ void UpdateTimer::scheduleUpdate() m_timer->start(m_timer_interval); } -void UpdateTimer::onTimerTimeout() -{ +void UpdateTimer::onTimerTimeout() { m_is_busy = true; if (m_update_request_count > 0) { diff --git a/GUI/coregui/Views/CommonWidgets/UpdateTimer.h b/GUI/coregui/Views/CommonWidgets/UpdateTimer.h index 092b5e51ff993403cca41ce5efcfd625e0117165..79e3912b5b40c5db9281bb7e32efa0b7e8396db8 100644 --- a/GUI/coregui/Views/CommonWidgets/UpdateTimer.h +++ b/GUI/coregui/Views/CommonWidgets/UpdateTimer.h @@ -24,8 +24,7 @@ class QTimer; //! Used in ColorMap plot to avoid often replot of CustomPlot. -class UpdateTimer : public QObject -{ +class UpdateTimer : public QObject { Q_OBJECT public: explicit UpdateTimer(int timerInterval, QObject* parent = 0); diff --git a/GUI/coregui/Views/CommonWidgets/detailsbutton.cpp b/GUI/coregui/Views/CommonWidgets/detailsbutton.cpp index 87563f95461209113ae18ab8735b59ba0b5c4a04..5586fe2bdd93ad7ebd31ffbee3601c822e395abe 100644 --- a/GUI/coregui/Views/CommonWidgets/detailsbutton.cpp +++ b/GUI/coregui/Views/CommonWidgets/detailsbutton.cpp @@ -35,15 +35,13 @@ using namespace Utils; -namespace -{ +namespace { const bool FlatProjectsMode(false); const QColor DetailsButtonBackgroundColorHover("#eff0f1"); } // namespace FadingWidget::FadingWidget(QWidget* parent) - : FadingPanel(parent), m_opacityEffect(new QGraphicsOpacityEffect) -{ + : FadingPanel(parent), m_opacityEffect(new QGraphicsOpacityEffect) { m_opacityEffect->setOpacity(0); setGraphicsEffect(m_opacityEffect); @@ -55,33 +53,28 @@ FadingWidget::FadingWidget(QWidget* parent) setPalette(pal); } -void FadingWidget::setOpacity(qreal value) -{ +void FadingWidget::setOpacity(qreal value) { m_opacityEffect->setOpacity(value); } -void FadingWidget::fadeTo(qreal value) -{ +void FadingWidget::fadeTo(qreal value) { QPropertyAnimation* animation = new QPropertyAnimation(m_opacityEffect, "opacity"); animation->setDuration(200); animation->setEndValue(value); animation->start(QAbstractAnimation::DeleteWhenStopped); } -qreal FadingWidget::opacity() -{ +qreal FadingWidget::opacity() { return m_opacityEffect->opacity(); } -DetailsButton::DetailsButton(QWidget* parent) : QAbstractButton(parent), m_fader(0) -{ +DetailsButton::DetailsButton(QWidget* parent) : QAbstractButton(parent), m_fader(0) { setCheckable(true); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); setText(tr("Details")); } -QSize DetailsButton::sizeHint() const -{ +QSize DetailsButton::sizeHint() const { // TODO: Adjust this when icons become available! #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) @@ -94,8 +87,7 @@ QSize DetailsButton::sizeHint() const return QSize(w, 22); } -bool DetailsButton::event(QEvent* e) -{ +bool DetailsButton::event(QEvent* e) { switch (e->type()) { case QEvent::Enter: { QPropertyAnimation* animation = new QPropertyAnimation(this, "fader"); @@ -115,8 +107,7 @@ bool DetailsButton::event(QEvent* e) return false; } -void DetailsButton::paintEvent(QPaintEvent* e) -{ +void DetailsButton::paintEvent(QPaintEvent* e) { QWidget::paintEvent(e); QPainter p(this); @@ -156,8 +147,7 @@ void DetailsButton::paintEvent(QPaintEvent* e) } } -QPixmap DetailsButton::cacheRendering(const QSize& size, bool checked) -{ +QPixmap DetailsButton::cacheRendering(const QSize& size, bool checked) { const qreal pixelRatio = devicePixelRatio(); QPixmap pixmap(size * pixelRatio); pixmap.setDevicePixelRatio(pixelRatio); diff --git a/GUI/coregui/Views/CommonWidgets/detailsbutton.h b/GUI/coregui/Views/CommonWidgets/detailsbutton.h index cef6a2a284e688aef8d5634d3d166b2ec0ccd959..6d76cd83f8f4005fd6156bc18721b21135722736 100644 --- a/GUI/coregui/Views/CommonWidgets/detailsbutton.h +++ b/GUI/coregui/Views/CommonWidgets/detailsbutton.h @@ -30,10 +30,8 @@ class QGraphicsOpacityEffect; -namespace Utils -{ -class FadingPanel : public QWidget -{ +namespace Utils { +class FadingPanel : public QWidget { Q_OBJECT public: @@ -42,8 +40,7 @@ public: virtual void setOpacity(qreal value) = 0; }; -class FadingWidget : public FadingPanel -{ +class FadingWidget : public FadingPanel { Q_OBJECT public: FadingWidget(QWidget* parent = 0); @@ -55,8 +52,7 @@ protected: QGraphicsOpacityEffect* m_opacityEffect; }; -class DetailsButton : public QAbstractButton -{ +class DetailsButton : public QAbstractButton { Q_OBJECT Q_PROPERTY(float fader READ fader WRITE setFader) @@ -65,8 +61,7 @@ public: QSize sizeHint() const; float fader() { return m_fader; } - void setFader(float value) - { + void setFader(float value) { m_fader = value; update(); } diff --git a/GUI/coregui/Views/CommonWidgets/detailswidget.cpp b/GUI/coregui/Views/CommonWidgets/detailswidget.cpp index 2ea7500ab760577c4c2a7711152b00b30a42de2e..131fb2961f52cb2f6a1082e205a40759e2d1366a 100644 --- a/GUI/coregui/Views/CommonWidgets/detailswidget.cpp +++ b/GUI/coregui/Views/CommonWidgets/detailswidget.cpp @@ -55,18 +55,15 @@ \endcode */ -namespace -{ +namespace { const bool FlatProjectsMode(false); } -namespace Utils -{ +namespace Utils { const int MARGIN = 8; -class DetailsWidgetPrivate -{ +class DetailsWidgetPrivate { public: DetailsWidgetPrivate(QWidget* parent); @@ -103,8 +100,7 @@ DetailsWidgetPrivate::DetailsWidgetPrivate(QWidget* parent) , m_widget(nullptr) , m_state(DetailsWidget::Collapsed) , m_hovered(false) - , m_useCheckBox(false) -{ + , m_useCheckBox(false) { QHBoxLayout* summaryLayout = new QHBoxLayout; summaryLayout->setContentsMargins(MARGIN, MARGIN, MARGIN, MARGIN); summaryLayout->setSpacing(0); @@ -139,8 +135,7 @@ DetailsWidgetPrivate::DetailsWidgetPrivate(QWidget* parent) m_grid->addWidget(m_additionalSummaryLabel, 1, 0, 1, 3); } -QPixmap DetailsWidget::createBackground(const QSize& size, int topHeight, QWidget* widget) -{ +QPixmap DetailsWidget::createBackground(const QSize& size, int topHeight, QWidget* widget) { QPixmap pixmap(size); pixmap.fill(Qt::transparent); QPainter p(&pixmap); @@ -181,8 +176,7 @@ QPixmap DetailsWidget::createBackground(const QSize& size, int topHeight, QWidge return pixmap; } -void DetailsWidgetPrivate::updateControls() -{ +void DetailsWidgetPrivate::updateControls() { if (m_widget) m_widget->setVisible(m_state == DetailsWidget::Expanded || m_state == DetailsWidget::NoSummary); @@ -203,8 +197,7 @@ void DetailsWidgetPrivate::updateControls() } } -void DetailsWidgetPrivate::changeHoverState(bool hovered) -{ +void DetailsWidgetPrivate::changeHoverState(bool hovered) { if (!m_toolWidget) return; if (GUI_OS_Utils::HostOsInfo::isMacHost()) @@ -214,8 +207,7 @@ void DetailsWidgetPrivate::changeHoverState(bool hovered) m_hovered = hovered; } -DetailsWidget::DetailsWidget(QWidget* parent) : QWidget(parent), d(new DetailsWidgetPrivate(this)) -{ +DetailsWidget::DetailsWidget(QWidget* parent) : QWidget(parent), d(new DetailsWidgetPrivate(this)) { setLayout(d->m_grid); setUseCheckBox(false); @@ -226,50 +218,42 @@ DetailsWidget::DetailsWidget(QWidget* parent) : QWidget(parent), d(new DetailsWi d->updateControls(); } -DetailsWidget::~DetailsWidget() -{ +DetailsWidget::~DetailsWidget() { delete d; } -bool DetailsWidget::useCheckBox() -{ +bool DetailsWidget::useCheckBox() { return d->m_useCheckBox; } -void DetailsWidget::setUseCheckBox(bool b) -{ +void DetailsWidget::setUseCheckBox(bool b) { d->m_useCheckBox = b; d->updateControls(); } -void DetailsWidget::setChecked(bool b) -{ +void DetailsWidget::setChecked(bool b) { d->m_summaryCheckBox->setChecked(b); } -bool DetailsWidget::isChecked() const -{ +bool DetailsWidget::isChecked() const { return d->m_useCheckBox && d->m_summaryCheckBox->isChecked(); } -void DetailsWidget::setSummaryFontBold(bool b) -{ +void DetailsWidget::setSummaryFontBold(bool b) { QFont f; f.setBold(b); d->m_summaryCheckBox->setFont(f); d->m_summaryLabel->setFont(f); } -void DetailsWidget::setIcon(const QIcon& icon) -{ +void DetailsWidget::setIcon(const QIcon& icon) { int iconSize = style()->pixelMetric(QStyle::PM_ButtonIconSize, 0, this); d->m_summaryLabelIcon->setFixedWidth(icon.isNull() ? 0 : iconSize); d->m_summaryLabelIcon->setPixmap(icon.pixmap(iconSize, iconSize)); d->m_summaryCheckBox->setIcon(icon); } -void DetailsWidget::paintEvent(QPaintEvent* paintEvent) -{ +void DetailsWidget::paintEvent(QPaintEvent* paintEvent) { QWidget::paintEvent(paintEvent); QPainter p(this); @@ -295,51 +279,43 @@ void DetailsWidget::paintEvent(QPaintEvent* paintEvent) } } -void DetailsWidget::enterEvent(QEvent* event) -{ +void DetailsWidget::enterEvent(QEvent* event) { QWidget::enterEvent(event); d->changeHoverState(true); } -void DetailsWidget::leaveEvent(QEvent* event) -{ +void DetailsWidget::leaveEvent(QEvent* event) { QWidget::leaveEvent(event); d->changeHoverState(false); } -void DetailsWidget::setSummaryText(const QString& text) -{ +void DetailsWidget::setSummaryText(const QString& text) { if (d->m_useCheckBox) d->m_summaryCheckBox->setText(text); else d->m_summaryLabel->setText(text); } -QString DetailsWidget::summaryText() const -{ +QString DetailsWidget::summaryText() const { if (d->m_useCheckBox) return d->m_summaryCheckBox->text(); return d->m_summaryLabel->text(); } -QString DetailsWidget::additionalSummaryText() const -{ +QString DetailsWidget::additionalSummaryText() const { return d->m_additionalSummaryLabel->text(); } -void DetailsWidget::setAdditionalSummaryText(const QString& text) -{ +void DetailsWidget::setAdditionalSummaryText(const QString& text) { d->m_additionalSummaryLabel->setText(text); d->m_additionalSummaryLabel->setVisible(!text.isEmpty()); } -DetailsWidget::State DetailsWidget::state() const -{ +DetailsWidget::State DetailsWidget::state() const { return d->m_state; } -void DetailsWidget::setState(State state) -{ +void DetailsWidget::setState(State state) { if (state == d->m_state) return; d->m_state = state; @@ -347,18 +323,15 @@ void DetailsWidget::setState(State state) emit expanded(d->m_state == Expanded); } -void DetailsWidget::setExpanded(bool expanded) -{ +void DetailsWidget::setExpanded(bool expanded) { setState(expanded ? Expanded : Collapsed); } -QWidget* DetailsWidget::widget() const -{ +QWidget* DetailsWidget::widget() const { return d->m_widget; } -QWidget* DetailsWidget::takeWidget() -{ +QWidget* DetailsWidget::takeWidget() { QWidget* widget = d->m_widget; d->m_widget = 0; d->m_grid->removeWidget(widget); @@ -367,8 +340,7 @@ QWidget* DetailsWidget::takeWidget() return widget; } -void DetailsWidget::setWidget(QWidget* widget) -{ +void DetailsWidget::setWidget(QWidget* widget) { if (d->m_widget == widget) return; @@ -386,8 +358,7 @@ void DetailsWidget::setWidget(QWidget* widget) d->updateControls(); } -void DetailsWidget::setToolWidget(FadingPanel* widget) -{ +void DetailsWidget::setToolWidget(FadingPanel* widget) { if (d->m_toolWidget == widget) return; @@ -404,8 +375,7 @@ void DetailsWidget::setToolWidget(FadingPanel* widget) d->changeHoverState(d->m_hovered); } -QWidget* DetailsWidget::toolWidget() const -{ +QWidget* DetailsWidget::toolWidget() const { return d->m_toolWidget; } diff --git a/GUI/coregui/Views/CommonWidgets/detailswidget.h b/GUI/coregui/Views/CommonWidgets/detailswidget.h index 245d1e77af32e687f0a6f134d9dfb37af60d0fc6..4ce15f2b5955e114eca875b6d81845e4e5393549 100644 --- a/GUI/coregui/Views/CommonWidgets/detailswidget.h +++ b/GUI/coregui/Views/CommonWidgets/detailswidget.h @@ -28,14 +28,12 @@ #include <QWidget> -namespace Utils -{ +namespace Utils { class DetailsWidgetPrivate; class FadingPanel; -class DetailsWidget : public QWidget -{ +class DetailsWidget : public QWidget { Q_OBJECT Q_PROPERTY(QString summaryText READ summaryText WRITE setSummaryText DESIGNABLE true) Q_PROPERTY(QString additionalSummaryText READ additionalSummaryText WRITE diff --git a/GUI/coregui/Views/FitWidgets/FitActivityPanel.cpp b/GUI/coregui/Views/FitWidgets/FitActivityPanel.cpp index f17bd660a2af0136c16bd1d5240116ce8db23f7d..39c026141268843de7cd4ad16f79721cc1c42332 100644 --- a/GUI/coregui/Views/FitWidgets/FitActivityPanel.cpp +++ b/GUI/coregui/Views/FitWidgets/FitActivityPanel.cpp @@ -24,8 +24,7 @@ #include <QPushButton> #include <QVBoxLayout> -namespace -{ +namespace { const bool reuse_widget = true; } @@ -34,8 +33,7 @@ FitActivityPanel::FitActivityPanel(JobModel* jobModel, QWidget* parent) , m_stackedWidget(new ItemStackPresenter<FitSessionWidget>(reuse_widget)) , m_realTimeWidget(nullptr) , m_jobMessagePanel(nullptr) - , m_fitSessionManager(new FitSessionManager(this)) -{ + , m_fitSessionManager(new FitSessionManager(this)) { setWindowTitle(Constants::JobFitPanelName); setObjectName("FitActivityPanel"); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); @@ -51,30 +49,25 @@ FitActivityPanel::FitActivityPanel(JobModel* jobModel, QWidget* parent) m_stackedWidget->setModel(jobModel); } -void FitActivityPanel::setRealTimeWidget(JobRealTimeWidget* realTimeWidget) -{ +void FitActivityPanel::setRealTimeWidget(JobRealTimeWidget* realTimeWidget) { ASSERT(realTimeWidget); m_realTimeWidget = realTimeWidget; } -void FitActivityPanel::setJobMessagePanel(JobMessagePanel* jobMessagePanel) -{ +void FitActivityPanel::setJobMessagePanel(JobMessagePanel* jobMessagePanel) { m_jobMessagePanel = jobMessagePanel; m_fitSessionManager->setMessagePanel(m_jobMessagePanel); } -QSize FitActivityPanel::sizeHint() const -{ +QSize FitActivityPanel::sizeHint() const { return QSize(Constants::REALTIME_WIDGET_WIDTH_HINT, Constants::FIT_ACTIVITY_PANEL_HEIGHT); } -QSize FitActivityPanel::minimumSizeHint() const -{ +QSize FitActivityPanel::minimumSizeHint() const { return QSize(80, 80); } -void FitActivityPanel::setItem(JobItem* item) -{ +void FitActivityPanel::setItem(JobItem* item) { if (!isValidJobItem(item)) { m_jobMessagePanel->onClearLog(); @@ -89,12 +82,10 @@ void FitActivityPanel::setItem(JobItem* item) widget->setSessionController(m_fitSessionManager->sessionController(item)); } -bool FitActivityPanel::isValidJobItem(JobItem* item) -{ +bool FitActivityPanel::isValidJobItem(JobItem* item) { return item ? item->isValidForFitting() : false; } -FitSessionWidget* FitActivityPanel::currentFitSuiteWidget() -{ +FitSessionWidget* FitActivityPanel::currentFitSuiteWidget() { return m_stackedWidget->currentWidget(); } diff --git a/GUI/coregui/Views/FitWidgets/FitActivityPanel.h b/GUI/coregui/Views/FitWidgets/FitActivityPanel.h index bafb87576b9c2ad0c8f7e43e97e7c2afd3762c8b..95762ccd60ac10a42da2c256fae3cb65842882b5 100644 --- a/GUI/coregui/Views/FitWidgets/FitActivityPanel.h +++ b/GUI/coregui/Views/FitWidgets/FitActivityPanel.h @@ -30,8 +30,7 @@ class FitSessionManager; //! Occupies bottom right corner of JobView, contains stack of FitSuiteWidgets for every //! JobItem which is suitable for fitting. -class FitActivityPanel : public QWidget -{ +class FitActivityPanel : public QWidget { Q_OBJECT public: FitActivityPanel(JobModel* jobModel, QWidget* parent = 0); diff --git a/GUI/coregui/Views/FitWidgets/FitComparisonController.cpp b/GUI/coregui/Views/FitWidgets/FitComparisonController.cpp index bd6bf512cb5cec8bba8cc23e40e32f0b063399b8..e97d4ad21f7aa9b1c11dc16310996a79fd3d89f2 100644 --- a/GUI/coregui/Views/FitWidgets/FitComparisonController.cpp +++ b/GUI/coregui/Views/FitWidgets/FitComparisonController.cpp @@ -22,16 +22,14 @@ #include "GUI/coregui/Models/SpecularDataItem.h" #include "GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.h" -namespace -{ +namespace { // different limits on relative difference plot are required // to provide the best appearance const double relative_diff_min_2d = 1e-05; const double relative_diff_max_2d = 1.0; } // namespace -class FitComparisonController2D::DiffItemController : public QObject -{ +class FitComparisonController2D::DiffItemController : public QObject { public: DiffItemController(const QString& data_type, QObject* parent); ~DiffItemController() override; @@ -55,18 +53,14 @@ FitComparisonController2D::FitComparisonController2D(QObject* parent) , m_appearanceRepeater(new PropertyRepeater(this)) , m_xAxisRepeater(new PropertyRepeater(this)) , m_yAxisRepeater(new PropertyRepeater(this)) - , m_zAxisRepeater(new PropertyRepeater(this)) -{ -} + , m_zAxisRepeater(new PropertyRepeater(this)) {} -IntensityDataItem* FitComparisonController2D::diffItem() -{ +IntensityDataItem* FitComparisonController2D::diffItem() { ASSERT(dynamic_cast<IntensityDataItem*>(m_diff_item_controller->diffItem())); return dynamic_cast<IntensityDataItem*>(m_diff_item_controller->diffItem()); } -void FitComparisonController2D::setItem(JobItem* job_item) -{ +void FitComparisonController2D::setItem(JobItem* job_item) { ASSERT(job_item); clear(); @@ -100,19 +94,16 @@ void FitComparisonController2D::setItem(JobItem* job_item) m_zAxisRepeater->addItem(sim_data_item->zAxisItem()); } -void FitComparisonController2D::updateDiffData() -{ +void FitComparisonController2D::updateDiffData() { m_diff_item_controller->updateDiffData(); } -void FitComparisonController2D::resetDiffItem() -{ +void FitComparisonController2D::resetDiffItem() { diffItem()->resetView(); diffItem()->setLowerAndUpperZ(relative_diff_min_2d, relative_diff_max_2d); } -void FitComparisonController2D::clear() -{ +void FitComparisonController2D::clear() { m_diff_item_controller->unsubscribe(); m_appearanceRepeater->clear(); @@ -125,18 +116,15 @@ DiffItemController::DiffItemController(const QString& data_type, QObject* parent : QObject(parent) , m_current_item(nullptr) , m_tempIntensityDataModel(new SessionModel("TempIntensityDataModel", this)) - , m_diff_item(dynamic_cast<DataItem*>(m_tempIntensityDataModel->insertNewItem(data_type))) -{ + , m_diff_item(dynamic_cast<DataItem*>(m_tempIntensityDataModel->insertNewItem(data_type))) { ASSERT(m_diff_item); } -DiffItemController::~DiffItemController() -{ +DiffItemController::~DiffItemController() { unsubscribe(); } -void DiffItemController::setItem(JobItem* job_item) -{ +void DiffItemController::setItem(JobItem* job_item) { ASSERT(job_item); if (m_current_item) unsubscribe(); @@ -145,8 +133,7 @@ void DiffItemController::setItem(JobItem* job_item) updateDiffData(); } -void DiffItemController::updateDiffData() -{ +void DiffItemController::updateDiffData() { ASSERT(m_current_item); auto sim_data = m_current_item->dataItem(); @@ -161,13 +148,11 @@ void DiffItemController::updateDiffData() .release()); } -DataItem* DiffItemController::diffItem() -{ +DataItem* DiffItemController::diffItem() { return m_diff_item; } -void DiffItemController::subscribe() -{ +void DiffItemController::subscribe() { if (!m_current_item) { ASSERT(false); return; @@ -185,8 +170,7 @@ void DiffItemController::subscribe() this); } -void DiffItemController::unsubscribe() -{ +void DiffItemController::unsubscribe() { if (!m_current_item) return; m_current_item->dataItem()->mapper()->unsubscribe(this); diff --git a/GUI/coregui/Views/FitWidgets/FitComparisonController.h b/GUI/coregui/Views/FitWidgets/FitComparisonController.h index 75a168c6364b5097dd689873607377dead5dd8df..1ecddb692c87b51b9f5e8a9bc58c3e1c5a0493f1 100644 --- a/GUI/coregui/Views/FitWidgets/FitComparisonController.h +++ b/GUI/coregui/Views/FitWidgets/FitComparisonController.h @@ -27,8 +27,7 @@ class SpecularDataItem; //! Provides synchronization between certain properties of fit related IntensityDataItems. //! Used solely in FitComparisonWidget. -class FitComparisonController2D : public QObject -{ +class FitComparisonController2D : public QObject { public: class DiffItemController; diff --git a/GUI/coregui/Views/FitWidgets/FitComparisonViewController.cpp b/GUI/coregui/Views/FitWidgets/FitComparisonViewController.cpp index 74deea51922ac0c6b57ef498dc86799e72b30842..8fe189cc4475918ac9fc02ff1a2d607c993894b7 100644 --- a/GUI/coregui/Views/FitWidgets/FitComparisonViewController.cpp +++ b/GUI/coregui/Views/FitWidgets/FitComparisonViewController.cpp @@ -23,8 +23,7 @@ #include "GUI/coregui/Models/SessionModel.h" #include "GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.h" -namespace -{ +namespace { const double relative_diff_min_1d = 1e-05; const double relative_diff_max_1d = 4.0; } // namespace @@ -34,17 +33,13 @@ FitComparison1DViewController::FitComparison1DViewController(QObject* parent) , m_diff_item_controller(new DiffItemController("SpecularData", this)) , m_diff_view_item(nullptr) , m_appearanceRepeater(new PropertyRepeater(this)) - , m_xAxisRepeater(new PropertyRepeater(this)) -{ -} + , m_xAxisRepeater(new PropertyRepeater(this)) {} -Data1DViewItem* FitComparison1DViewController::diffItemView() -{ +Data1DViewItem* FitComparison1DViewController::diffItemView() { return m_diff_view_item; } -void FitComparison1DViewController::setItem(JobItem* job_item) -{ +void FitComparison1DViewController::setItem(JobItem* job_item) { ASSERT(job_item); clear(); @@ -65,13 +60,11 @@ void FitComparison1DViewController::setItem(JobItem* job_item) m_diff_view_item->setUpperY(relative_diff_max_1d); } -void FitComparison1DViewController::updateDiffData() -{ +void FitComparison1DViewController::updateDiffData() { m_diff_item_controller->updateDiffData(); } -void FitComparison1DViewController::resetDiffView() -{ +void FitComparison1DViewController::resetDiffView() { if (!m_diff_view_item) return; m_diff_view_item->resetView(); @@ -79,8 +72,7 @@ void FitComparison1DViewController::resetDiffView() m_diff_view_item->setUpperY(relative_diff_max_1d); } -void FitComparison1DViewController::clear() -{ +void FitComparison1DViewController::clear() { m_diff_item_controller->unsubscribe(); m_appearanceRepeater->clear(); m_xAxisRepeater->clear(); @@ -88,8 +80,7 @@ void FitComparison1DViewController::clear() deleteDiffViewItem(); } -void FitComparison1DViewController::createDiffViewItem(JobItem* job_item) -{ +void FitComparison1DViewController::createDiffViewItem(JobItem* job_item) { m_diff_view_item = dynamic_cast<Data1DViewItem*>( m_diff_item_controller->model()->insertNewItem("Data1DViewItem")); auto container = m_diff_view_item->model()->insertNewItem( @@ -102,8 +93,7 @@ void FitComparison1DViewController::createDiffViewItem(JobItem* job_item) m_diff_view_item->setItemValue(Data1DViewItem::P_AXES_UNITS, units_value); } -void FitComparison1DViewController::deleteDiffViewItem() -{ +void FitComparison1DViewController::deleteDiffViewItem() { auto parent = m_diff_view_item->parent(); auto old_view_item = parent->takeRow(parent->rowOfChild(m_diff_view_item)); ASSERT(old_view_item == m_diff_view_item); @@ -115,18 +105,15 @@ DiffItemController::DiffItemController(const QString& data_type, QObject* parent : QObject(parent) , m_current_item(nullptr) , m_private_model(new SessionModel("TempIntensityDataModel", this)) - , m_diff_item(dynamic_cast<DataItem*>(m_private_model->insertNewItem(data_type))) -{ + , m_diff_item(dynamic_cast<DataItem*>(m_private_model->insertNewItem(data_type))) { ASSERT(m_diff_item); } -DiffItemController::~DiffItemController() -{ +DiffItemController::~DiffItemController() { unsubscribe(); } -void DiffItemController::setJobItem(JobItem* job_item) -{ +void DiffItemController::setJobItem(JobItem* job_item) { ASSERT(job_item); if (m_current_item) unsubscribe(); @@ -135,8 +122,7 @@ void DiffItemController::setJobItem(JobItem* job_item) updateDiffData(); } -void DiffItemController::updateDiffData() -{ +void DiffItemController::updateDiffData() { ASSERT(m_current_item); auto sim_data = m_current_item->dataItem(); @@ -151,8 +137,7 @@ void DiffItemController::updateDiffData() .release()); } -void DiffItemController::subscribe() -{ +void DiffItemController::subscribe() { if (!m_current_item) { ASSERT(false); return; @@ -162,8 +147,7 @@ void DiffItemController::subscribe() m_current_item->dataItem()->mapper()->setOnValueChange([this]() { updateDiffData(); }, this); } -void DiffItemController::unsubscribe() -{ +void DiffItemController::unsubscribe() { m_diff_item->mapper()->unsubscribe(this); if (!m_current_item) return; diff --git a/GUI/coregui/Views/FitWidgets/FitComparisonViewController.h b/GUI/coregui/Views/FitWidgets/FitComparisonViewController.h index 5ca90f484fe8bfb958abb51ce2bdb2fdd4314f1a..39c4cd51fedc73db2e1de8bcefa02c9485fc4cfa 100644 --- a/GUI/coregui/Views/FitWidgets/FitComparisonViewController.h +++ b/GUI/coregui/Views/FitWidgets/FitComparisonViewController.h @@ -23,8 +23,7 @@ class JobItem; class PropertyRepeater; class SessionModel; -class DiffItemController : public QObject -{ +class DiffItemController : public QObject { public: DiffItemController(const QString& data_type, QObject* parent); ~DiffItemController() override; @@ -42,8 +41,7 @@ private: DataItem* m_diff_item; }; -class FitComparison1DViewController : public QObject -{ +class FitComparison1DViewController : public QObject { public: explicit FitComparison1DViewController(QObject* parent); diff --git a/GUI/coregui/Views/FitWidgets/FitComparisonWidget.cpp b/GUI/coregui/Views/FitWidgets/FitComparisonWidget.cpp index f5396fbc2cb09f0833f25b6b34f428da368ed0b5..619dfe21dbe2656a626c1ba1df0ad79f684a5442 100644 --- a/GUI/coregui/Views/FitWidgets/FitComparisonWidget.cpp +++ b/GUI/coregui/Views/FitWidgets/FitComparisonWidget.cpp @@ -36,8 +36,7 @@ FitComparisonWidget::FitComparisonWidget(QWidget* parent) , m_statusLabel(new PlotStatusLabel(nullptr, this)) , m_propertyWidget(new IntensityDataPropertyWidget) , m_resetViewAction(new QAction(this)) - , m_comparisonController(new FitComparisonController2D(this)) -{ + , m_comparisonController(new FitComparisonController2D(this)) { auto vlayout = new QVBoxLayout; vlayout->setMargin(0); vlayout->setSpacing(0); @@ -71,13 +70,11 @@ FitComparisonWidget::FitComparisonWidget(QWidget* parent) FitComparisonWidget::~FitComparisonWidget() = default; -QList<QAction*> FitComparisonWidget::actionList() -{ +QList<QAction*> FitComparisonWidget::actionList() { return QList<QAction*>() << m_resetViewAction << m_propertyWidget->actionList(); } -void FitComparisonWidget::subscribeToItem() -{ +void FitComparisonWidget::subscribeToItem() { if (!jobItem()->isValidForFitting()) return; @@ -104,36 +101,30 @@ void FitComparisonWidget::subscribeToItem() m_propertyWidget->setItem(simulatedDataItem()); } -void FitComparisonWidget::unsubscribeFromItem() -{ +void FitComparisonWidget::unsubscribeFromItem() { m_comparisonController->clear(); } -void FitComparisonWidget::onResetViewAction() -{ +void FitComparisonWidget::onResetViewAction() { if (auto item = realDataItem()) item->resetView(); m_comparisonController->resetDiffItem(); } -JobItem* FitComparisonWidget::jobItem() -{ +JobItem* FitComparisonWidget::jobItem() { JobItem* jobItem = dynamic_cast<JobItem*>(currentItem()); return jobItem; } -IntensityDataItem* FitComparisonWidget::realDataItem() -{ +IntensityDataItem* FitComparisonWidget::realDataItem() { return jobItem()->realDataItem()->intensityDataItem(); } -IntensityDataItem* FitComparisonWidget::simulatedDataItem() -{ +IntensityDataItem* FitComparisonWidget::simulatedDataItem() { return jobItem()->intensityDataItem(); } -IntensityDataItem* FitComparisonWidget::diffItem() -{ +IntensityDataItem* FitComparisonWidget::diffItem() { return m_comparisonController->diffItem(); } diff --git a/GUI/coregui/Views/FitWidgets/FitComparisonWidget.h b/GUI/coregui/Views/FitWidgets/FitComparisonWidget.h index 77ff75c15bf7c10d36a3169b7cbd5e632fb7ecc4..0da965cf4f88b24cf6920543c5d8b9cc98a8b117 100644 --- a/GUI/coregui/Views/FitWidgets/FitComparisonWidget.h +++ b/GUI/coregui/Views/FitWidgets/FitComparisonWidget.h @@ -32,8 +32,7 @@ class FitComparisonController2D; //! The FitComparisonWidget class plots realdata, simulated data and relative difference map //! during the course of the fit. -class FitComparisonWidget : public SessionItemWidget -{ +class FitComparisonWidget : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/FitWidgets/FitComparisonWidget1D.cpp b/GUI/coregui/Views/FitWidgets/FitComparisonWidget1D.cpp index b9670d0b6f794a1bde74c346affdf8e25acf1d7b..3e1939d26240fc768fd5c9bfb83ac0bfba1498d4 100644 --- a/GUI/coregui/Views/FitWidgets/FitComparisonWidget1D.cpp +++ b/GUI/coregui/Views/FitWidgets/FitComparisonWidget1D.cpp @@ -36,8 +36,7 @@ FitComparisonWidget1D::FitComparisonWidget1D(QWidget* parent) , m_statusLabel(new PlotStatusLabel(nullptr, this)) , m_propertyWidget(new IntensityDataPropertyWidget) , m_resetViewAction(new QAction(this)) - , m_comparisonController(new FitComparison1DViewController(this)) -{ + , m_comparisonController(new FitComparison1DViewController(this)) { auto vlayout = new QVBoxLayout; vlayout->setMargin(0); vlayout->setSpacing(0); @@ -71,13 +70,11 @@ FitComparisonWidget1D::FitComparisonWidget1D(QWidget* parent) FitComparisonWidget1D::~FitComparisonWidget1D() = default; -QList<QAction*> FitComparisonWidget1D::actionList() -{ +QList<QAction*> FitComparisonWidget1D::actionList() { return QList<QAction*>() << m_resetViewAction << m_propertyWidget->actionList(); } -void FitComparisonWidget1D::subscribeToItem() -{ +void FitComparisonWidget1D::subscribeToItem() { if (!jobItem()->isValidForFitting()) return; @@ -103,26 +100,22 @@ void FitComparisonWidget1D::subscribeToItem() m_propertyWidget->setItem(viewItem()); } -void FitComparisonWidget1D::unsubscribeFromItem() -{ +void FitComparisonWidget1D::unsubscribeFromItem() { m_diff_plot->setItem(nullptr); m_comparisonController->clear(); } -void FitComparisonWidget1D::onResetViewAction() -{ +void FitComparisonWidget1D::onResetViewAction() { viewItem()->resetView(); m_comparisonController->resetDiffView(); } -JobItem* FitComparisonWidget1D::jobItem() -{ +JobItem* FitComparisonWidget1D::jobItem() { JobItem* jobItem = dynamic_cast<JobItem*>(currentItem()); return jobItem; } -Data1DViewItem* FitComparisonWidget1D::viewItem() -{ +Data1DViewItem* FitComparisonWidget1D::viewItem() { auto view_item = dynamic_cast<Data1DViewItem*>(jobItem()->dataItemView()); ASSERT(view_item); return view_item; diff --git a/GUI/coregui/Views/FitWidgets/FitComparisonWidget1D.h b/GUI/coregui/Views/FitWidgets/FitComparisonWidget1D.h index 882ce8440025e64e3dfee1bbb8be553cb0a878a6..4613f817fbc40952084153738a5b198d33de0348 100644 --- a/GUI/coregui/Views/FitWidgets/FitComparisonWidget1D.h +++ b/GUI/coregui/Views/FitWidgets/FitComparisonWidget1D.h @@ -29,8 +29,7 @@ class QAction; //! The FitComparisonWidget class plots realdata, simulated data and relative difference map //! during the course of the fit. -class FitComparisonWidget1D : public SessionItemWidget -{ +class FitComparisonWidget1D : public SessionItemWidget { Q_OBJECT public: explicit FitComparisonWidget1D(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/FitWidgets/FitFlowWidget.cpp b/GUI/coregui/Views/FitWidgets/FitFlowWidget.cpp index 4457ad88f4bbee9e9bb97afefc46940237746fe8..c787886aae376cc536b66cded9c8d5c022337b93 100644 --- a/GUI/coregui/Views/FitWidgets/FitFlowWidget.cpp +++ b/GUI/coregui/Views/FitWidgets/FitFlowWidget.cpp @@ -18,8 +18,7 @@ #include <QVBoxLayout> FitFlowWidget::FitFlowWidget(QWidget* parent) - : SessionItemWidget(parent), m_histPlot(new HistogramPlot) -{ + : SessionItemWidget(parent), m_histPlot(new HistogramPlot) { setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); auto layout = new QVBoxLayout; @@ -30,8 +29,7 @@ FitFlowWidget::FitFlowWidget(QWidget* parent) setLayout(layout); } -void FitFlowWidget::subscribeToItem() -{ +void FitFlowWidget::subscribeToItem() { fitSuiteItem()->mapper()->setOnPropertyChange( [this](const QString& name) { if (name == FitSuiteItem::P_ITERATION_COUNT) { @@ -45,14 +43,12 @@ void FitFlowWidget::subscribeToItem() this); } -void FitFlowWidget::unsubscribeFromItem() -{ +void FitFlowWidget::unsubscribeFromItem() { m_histPlot->clearData(); m_x.clear(); m_y.clear(); } -FitSuiteItem* FitFlowWidget::fitSuiteItem() -{ +FitSuiteItem* FitFlowWidget::fitSuiteItem() { return dynamic_cast<FitSuiteItem*>(currentItem()); } diff --git a/GUI/coregui/Views/FitWidgets/FitFlowWidget.h b/GUI/coregui/Views/FitWidgets/FitFlowWidget.h index b1674a8e4a16a67d6db6bc412408d0d842e1eb34..084bea3c952473269dccae051932fb5aa840303d 100644 --- a/GUI/coregui/Views/FitWidgets/FitFlowWidget.h +++ b/GUI/coregui/Views/FitWidgets/FitFlowWidget.h @@ -23,8 +23,7 @@ class FitSuiteItem; //! The FitFlowWidget class is intended for showing chi2 .vs interation count dependency. //! The main goal is to fill vacant place in FitComparisonWidget. -class FitFlowWidget : public SessionItemWidget -{ +class FitFlowWidget : public SessionItemWidget { Q_OBJECT public: explicit FitFlowWidget(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/FitWidgets/FitLog.cpp b/GUI/coregui/Views/FitWidgets/FitLog.cpp index adf5c620d6875f727916e3de84daebe8e9df25d7..1cdba14d451bf4df0e3faab48ad6a682dc45599f 100644 --- a/GUI/coregui/Views/FitWidgets/FitLog.cpp +++ b/GUI/coregui/Views/FitWidgets/FitLog.cpp @@ -17,8 +17,7 @@ FitLog::FitLog() : m_messagePanel(nullptr) {} -void FitLog::setMessagePanel(JobMessagePanel* messagePanel) -{ +void FitLog::setMessagePanel(JobMessagePanel* messagePanel) { m_messagePanel = messagePanel; if (!m_messagePanel) return; @@ -31,16 +30,14 @@ void FitLog::setMessagePanel(JobMessagePanel* messagePanel) } } -void FitLog::append(const std::string& text, FitLogFlags::MessageType type) -{ +void FitLog::append(const std::string& text, FitLogFlags::MessageType type) { m_records.push_back({text, type}); if (m_messagePanel) m_messagePanel->onMessage(QString::fromStdString(text), QColor(FitLogFlags::color(type))); } -void FitLog::clearLog() -{ +void FitLog::clearLog() { m_records.clear(); if (m_messagePanel) m_messagePanel->onClearLog(); diff --git a/GUI/coregui/Views/FitWidgets/FitLog.h b/GUI/coregui/Views/FitWidgets/FitLog.h index 93ef1acc27171c8a05e9316995aaadef4982119e..2635101cb71b4aee48d2b17542084422c57c5772 100644 --- a/GUI/coregui/Views/FitWidgets/FitLog.h +++ b/GUI/coregui/Views/FitWidgets/FitLog.h @@ -21,8 +21,7 @@ class JobMessagePanel; -class FitLog -{ +class FitLog { public: FitLog(); diff --git a/GUI/coregui/Views/FitWidgets/FitLogFlags.cpp b/GUI/coregui/Views/FitWidgets/FitLogFlags.cpp index 6be72b1f66c62ec129b862c1b0fca286c5eb553c..84ba9c66ecbfb623b2b39c701ef736d80b057a70 100644 --- a/GUI/coregui/Views/FitWidgets/FitLogFlags.cpp +++ b/GUI/coregui/Views/FitWidgets/FitLogFlags.cpp @@ -15,11 +15,9 @@ #include "GUI/coregui/Views/FitWidgets/FitLogFlags.h" #include <QMap> -namespace -{ +namespace { -QMap<FitLogFlags::MessageType, Qt::GlobalColor> messageTypeToColorMap() -{ +QMap<FitLogFlags::MessageType, Qt::GlobalColor> messageTypeToColorMap() { QMap<FitLogFlags::MessageType, Qt::GlobalColor> result; result[FitLogFlags::DEFAULT] = Qt::black; result[FitLogFlags::SUCCESS] = Qt::darkBlue; @@ -31,8 +29,7 @@ QMap<FitLogFlags::MessageType, Qt::GlobalColor> messageTypeToColorMap() } // namespace -Qt::GlobalColor FitLogFlags::color(MessageType messageType) -{ +Qt::GlobalColor FitLogFlags::color(MessageType messageType) { static auto typeToColor = messageTypeToColorMap(); if (typeToColor.find(messageType) == typeToColor.end()) diff --git a/GUI/coregui/Views/FitWidgets/FitLogFlags.h b/GUI/coregui/Views/FitWidgets/FitLogFlags.h index 7890d26ca593ac84aa58bb9d4801a13d0d06ff7a..8f49f1e1d7cc4f6c7d80e6affa9e4d592f8d781d 100644 --- a/GUI/coregui/Views/FitWidgets/FitLogFlags.h +++ b/GUI/coregui/Views/FitWidgets/FitLogFlags.h @@ -20,8 +20,7 @@ //! Flags for log records related to fitting. -class FitLogFlags -{ +class FitLogFlags { public: enum EMessageType { DEFAULT, SUCCESS, HIGHLIGHT, WARNING, ERROR }; Q_DECLARE_FLAGS(MessageType, EMessageType) diff --git a/GUI/coregui/Views/FitWidgets/FitObjectiveBuilder.cpp b/GUI/coregui/Views/FitWidgets/FitObjectiveBuilder.cpp index 0ffdfe42db3785992028722ba53ddaa967ad85af..597b543ce4dc2afa2ed313d2257cd8f12bd2b186 100644 --- a/GUI/coregui/Views/FitWidgets/FitObjectiveBuilder.cpp +++ b/GUI/coregui/Views/FitWidgets/FitObjectiveBuilder.cpp @@ -28,15 +28,13 @@ #include "GUI/coregui/Views/FitWidgets/GUIFitObserver.h" #include "GUI/coregui/utils/GUIHelpers.h" -FitObjectiveBuilder::FitObjectiveBuilder(JobItem* jobItem) : m_jobItem(jobItem) -{ +FitObjectiveBuilder::FitObjectiveBuilder(JobItem* jobItem) : m_jobItem(jobItem) { ASSERT(m_jobItem->fitSuiteItem()); } FitObjectiveBuilder::~FitObjectiveBuilder() = default; -void FitObjectiveBuilder::runFit() -{ +void FitObjectiveBuilder::runFit() { m_fit_objective = createFitObjective(); auto module = m_jobItem->fitSuiteItem()->minimizerContainerItem()->createMetric(); @@ -66,8 +64,7 @@ void FitObjectiveBuilder::runFit() m_fit_objective->finalize(result); } -std::unique_ptr<FitObjective> FitObjectiveBuilder::createFitObjective() const -{ +std::unique_ptr<FitObjective> FitObjectiveBuilder::createFitObjective() const { std::unique_ptr<FitObjective> result(new FitObjective); simulation_builder_t builder = [&](const mumufit::Parameters& params) { @@ -79,29 +76,24 @@ std::unique_ptr<FitObjective> FitObjectiveBuilder::createFitObjective() const return result; } -std::unique_ptr<IMinimizer> FitObjectiveBuilder::createMinimizer() const -{ +std::unique_ptr<IMinimizer> FitObjectiveBuilder::createMinimizer() const { return m_jobItem->fitSuiteItem()->minimizerContainerItem()->createMinimizer(); } -mumufit::Parameters FitObjectiveBuilder::createParameters() const -{ +mumufit::Parameters FitObjectiveBuilder::createParameters() const { return m_jobItem->fitSuiteItem()->fitParameterContainerItem()->createParameters(); } -void FitObjectiveBuilder::attachObserver(std::shared_ptr<GUIFitObserver> observer) -{ +void FitObjectiveBuilder::attachObserver(std::shared_ptr<GUIFitObserver> observer) { m_observer = observer; } -void FitObjectiveBuilder::interruptFitting() -{ +void FitObjectiveBuilder::interruptFitting() { m_fit_objective->interruptFitting(); } std::unique_ptr<ISimulation> -FitObjectiveBuilder::buildSimulation(const mumufit::Parameters& params) const -{ +FitObjectiveBuilder::buildSimulation(const mumufit::Parameters& params) const { static std::mutex build_simulation_mutex; std::unique_lock<std::mutex> lock(build_simulation_mutex); @@ -111,8 +103,7 @@ FitObjectiveBuilder::buildSimulation(const mumufit::Parameters& params) const m_jobItem->simulationOptionsItem()); } -std::unique_ptr<OutputData<double>> FitObjectiveBuilder::createOutputData() const -{ +std::unique_ptr<OutputData<double>> FitObjectiveBuilder::createOutputData() const { auto realDataItem = m_jobItem->realDataItem(); if (!realDataItem) throw GUIHelpers::Error("FitObjectiveBuilder::createOutputData() -> No Real Data defined."); @@ -124,8 +115,7 @@ std::unique_ptr<OutputData<double>> FitObjectiveBuilder::createOutputData() cons return std::unique_ptr<OutputData<double>>(intensity_item->getOutputData()->clone()); } -void FitObjectiveBuilder::update_fit_parameters(const mumufit::Parameters& params) const -{ +void FitObjectiveBuilder::update_fit_parameters(const mumufit::Parameters& params) const { QVector<double> values = GUIHelpers::fromStdVector(params.values()); auto fitParContainer = m_jobItem->fitParameterContainerItem(); diff --git a/GUI/coregui/Views/FitWidgets/FitObjectiveBuilder.h b/GUI/coregui/Views/FitWidgets/FitObjectiveBuilder.h index 49db4dab23bfcbf09f5b3b1ca187a96c59c60f6a..518f3da546802ad2c46d8e366ef672b742be2757 100644 --- a/GUI/coregui/Views/FitWidgets/FitObjectiveBuilder.h +++ b/GUI/coregui/Views/FitWidgets/FitObjectiveBuilder.h @@ -20,8 +20,7 @@ class JobItem; class FitObjective; class ISimulation; -namespace mumufit -{ +namespace mumufit { class Parameters; } template <class T> class OutputData; @@ -29,8 +28,7 @@ class IMinimizer; class GUIFitObserver; class IChiSquaredModule; -class FitObjectiveBuilder -{ +class FitObjectiveBuilder { public: FitObjectiveBuilder(JobItem* jobItem); ~FitObjectiveBuilder(); diff --git a/GUI/coregui/Views/FitWidgets/FitParameterWidget.cpp b/GUI/coregui/Views/FitWidgets/FitParameterWidget.cpp index 72f88f2414103e44fd8560670910c75f6978fbad..d5a2284a9c31f07a1d025251dc63297cb3815e6b 100644 --- a/GUI/coregui/Views/FitWidgets/FitParameterWidget.cpp +++ b/GUI/coregui/Views/FitWidgets/FitParameterWidget.cpp @@ -41,8 +41,7 @@ FitParameterWidget::FitParameterWidget(QWidget* parent) , m_fitParameterModel(0) , m_delegate(new SessionModelDelegate(this)) , m_keyboardFilter(new DeleteEventFilter(this)) - , m_infoLabel(new OverlayLabelController(this)) -{ + , m_infoLabel(new OverlayLabelController(this)) { QVBoxLayout* layout = new QVBoxLayout; layout->addWidget(m_treeView); layout->setMargin(0); @@ -70,8 +69,7 @@ FitParameterWidget::FitParameterWidget(QWidget* parent) //! Sets ParameterTuningWidget to be able to provide it with context menu and steer //! it behaviour in the course of fit settings or fit runnig -void FitParameterWidget::setParameterTuningWidget(ParameterTuningWidget* tuningWidget) -{ +void FitParameterWidget::setParameterTuningWidget(ParameterTuningWidget* tuningWidget) { if (tuningWidget == m_tuningWidget) { return; @@ -102,8 +100,7 @@ void FitParameterWidget::setParameterTuningWidget(ParameterTuningWidget* tuningW //! Creates context menu for ParameterTuningWidget -void FitParameterWidget::onTuningWidgetContextMenu(const QPoint& point) -{ +void FitParameterWidget::onTuningWidgetContextMenu(const QPoint& point) { QMenu menu; initTuningWidgetContextMenu(menu); menu.exec(point); @@ -112,23 +109,20 @@ void FitParameterWidget::onTuningWidgetContextMenu(const QPoint& point) //! Creates context menu for the tree with fit parameters -void FitParameterWidget::onFitParameterTreeContextMenu(const QPoint& point) -{ +void FitParameterWidget::onFitParameterTreeContextMenu(const QPoint& point) { QMenu menu; initFitParameterTreeContextMenu(menu); menu.exec(m_treeView->mapToGlobal(point + QPoint(2, 22))); setActionsEnabled(true); } -void FitParameterWidget::onTuningWidgetSelectionChanged(const QItemSelection& selection) -{ +void FitParameterWidget::onTuningWidgetSelectionChanged(const QItemSelection& selection) { Q_UNUSED(selection); } //! Propagates selection form the tree with fit parameters to the tuning widget -void FitParameterWidget::onFitParametersSelectionChanged(const QItemSelection& selection) -{ +void FitParameterWidget::onFitParametersSelectionChanged(const QItemSelection& selection) { if (selection.indexes().isEmpty()) return; @@ -145,8 +139,7 @@ void FitParameterWidget::onFitParametersSelectionChanged(const QItemSelection& s //! Creates fit parameters for all selected ParameterItem's in tuning widget -void FitParameterWidget::onCreateFitParAction() -{ +void FitParameterWidget::onCreateFitParAction() { for (auto item : m_tuningWidget->getSelectedParameters()) { if (!FitParameterHelper::getFitParameterItem(jobItem()->fitParameterContainerItem(), item)) { @@ -158,8 +151,7 @@ void FitParameterWidget::onCreateFitParAction() //! All ParameterItem's selected in tuning widget will be removed from link section of //! corresponding fitParameterItem. -void FitParameterWidget::onRemoveFromFitParAction() -{ +void FitParameterWidget::onRemoveFromFitParAction() { for (auto item : m_tuningWidget->getSelectedParameters()) { if (FitParameterHelper::getFitParameterItem(jobItem()->fitParameterContainerItem(), item)) { FitParameterHelper::removeFromFitParameters(jobItem()->fitParameterContainerItem(), @@ -170,8 +162,7 @@ void FitParameterWidget::onRemoveFromFitParAction() //! All selected FitParameterItem's of FitParameterItemLink's will be removed -void FitParameterWidget::onRemoveFitParAction() -{ +void FitParameterWidget::onRemoveFitParAction() { FitParameterContainerItem* container = jobItem()->fitParameterContainerItem(); // retrieve both, selected FitParameterItem and FitParameterItemLink @@ -193,8 +184,7 @@ void FitParameterWidget::onRemoveFitParAction() //! Add all selected parameters to fitParameter with given index -void FitParameterWidget::onAddToFitParAction(int ipar) -{ +void FitParameterWidget::onAddToFitParAction(int ipar) { QStringList fitParNames = FitParameterHelper::getFitParameterNames(jobItem()->fitParameterContainerItem()); for (auto item : m_tuningWidget->getSelectedParameters()) { @@ -203,26 +193,22 @@ void FitParameterWidget::onAddToFitParAction(int ipar) } } -void FitParameterWidget::onFitParameterModelChange() -{ +void FitParameterWidget::onFitParameterModelChange() { spanParameters(); updateInfoLabel(); } //! Context menu reimplemented to suppress the default one -void FitParameterWidget::contextMenuEvent(QContextMenuEvent* event) -{ +void FitParameterWidget::contextMenuEvent(QContextMenuEvent* event) { Q_UNUSED(event); } -void FitParameterWidget::subscribeToItem() -{ +void FitParameterWidget::subscribeToItem() { init_fit_model(); } -void FitParameterWidget::init_actions() -{ +void FitParameterWidget::init_actions() { m_createFitParAction = new QAction("Create fit parameter", this); connect(m_createFitParAction, SIGNAL(triggered()), this, SLOT(onCreateFitParAction())); @@ -237,8 +223,7 @@ void FitParameterWidget::init_actions() //! Fills context menu for ParameterTuningWidget with content. -void FitParameterWidget::initTuningWidgetContextMenu(QMenu& menu) -{ +void FitParameterWidget::initTuningWidgetContextMenu(QMenu& menu) { if (jobItem()->getStatus() == "Fitting") { setActionsEnabled(false); return; @@ -271,8 +256,7 @@ void FitParameterWidget::initTuningWidgetContextMenu(QMenu& menu) //! Fills context menu for FitParameterTree with content. -void FitParameterWidget::initFitParameterTreeContextMenu(QMenu& menu) -{ +void FitParameterWidget::initFitParameterTreeContextMenu(QMenu& menu) { if (jobItem()->getStatus() == "Fitting") { setActionsEnabled(false); return; @@ -282,8 +266,7 @@ void FitParameterWidget::initFitParameterTreeContextMenu(QMenu& menu) //! Initializes FitParameterModel and its tree. -void FitParameterWidget::init_fit_model() -{ +void FitParameterWidget::init_fit_model() { m_treeView->setModel(0); delete m_fitParameterModel; @@ -302,8 +285,7 @@ void FitParameterWidget::init_fit_model() //! Returns true if tuning widget contains selected ParameterItem's which can be used to create //! a fit parameter (i.e. it is not linked with some fit parameter already). -bool FitParameterWidget::canCreateFitParameter() -{ +bool FitParameterWidget::canCreateFitParameter() { QVector<ParameterItem*> selected = m_tuningWidget->getSelectedParameters(); for (auto item : selected) { if (FitParameterHelper::getFitParameterItem(jobItem()->fitParameterContainerItem(), item) @@ -316,8 +298,7 @@ bool FitParameterWidget::canCreateFitParameter() //! Returns true if tuning widget contains selected ParameterItem's which can be removed from //! fit parameters. -bool FitParameterWidget::canRemoveFromFitParameters() -{ +bool FitParameterWidget::canRemoveFromFitParameters() { QVector<ParameterItem*> selected = m_tuningWidget->getSelectedParameters(); for (auto item : selected) { if (FitParameterHelper::getFitParameterItem(jobItem()->fitParameterContainerItem(), item)) @@ -328,8 +309,7 @@ bool FitParameterWidget::canRemoveFromFitParameters() //! Enables/disables all context menu actions. -void FitParameterWidget::setActionsEnabled(bool value) -{ +void FitParameterWidget::setActionsEnabled(bool value) { m_createFitParAction->setEnabled(value); m_removeFromFitParAction->setEnabled(value); m_removeFitParAction->setEnabled(value); @@ -337,8 +317,7 @@ void FitParameterWidget::setActionsEnabled(bool value) //! Returns list of FitParameterItem's currently selected in FitParameterItem tree -QVector<FitParameterItem*> FitParameterWidget::selectedFitParameters() -{ +QVector<FitParameterItem*> FitParameterWidget::selectedFitParameters() { QVector<FitParameterItem*> result; QModelIndexList indexes = m_treeView->selectionModel()->selectedIndexes(); for (auto index : indexes) { @@ -355,8 +334,7 @@ QVector<FitParameterItem*> FitParameterWidget::selectedFitParameters() //! Returns list of FitParameterItem's which doesn't have any links attached. -QVector<FitParameterItem*> FitParameterWidget::emptyFitParameters() -{ +QVector<FitParameterItem*> FitParameterWidget::emptyFitParameters() { QVector<FitParameterItem*> result; for (auto fitParItem : jobItem()->fitParameterContainerItem()->fitParameterItems()) if (fitParItem->getItems(FitParameterItem::T_LINK).empty()) @@ -367,8 +345,7 @@ QVector<FitParameterItem*> FitParameterWidget::emptyFitParameters() //! Returns links of FitParameterLink's item selected in FitParameterItem tree -QVector<FitParameterLinkItem*> FitParameterWidget::selectedFitParameterLinks() -{ +QVector<FitParameterLinkItem*> FitParameterWidget::selectedFitParameterLinks() { QVector<FitParameterLinkItem*> result; QModelIndexList indexes = m_treeView->selectionModel()->selectedIndexes(); for (QModelIndex index : indexes) { @@ -386,8 +363,7 @@ QVector<FitParameterLinkItem*> FitParameterWidget::selectedFitParameterLinks() //! Makes first column in FitParameterItem's tree related to ParameterItem link occupy whole space. -void FitParameterWidget::spanParameters() -{ +void FitParameterWidget::spanParameters() { m_treeView->expandAll(); for (int i = 0; i < m_fitParameterModel->rowCount(QModelIndex()); i++) { QModelIndex parameter = m_fitParameterModel->index(i, 0, QModelIndex()); @@ -403,8 +379,7 @@ void FitParameterWidget::spanParameters() } //! Places overlay label on top of tree view, if there is no fit parameters -void FitParameterWidget::updateInfoLabel() -{ +void FitParameterWidget::updateInfoLabel() { if (!jobItem()) return; @@ -412,8 +387,7 @@ void FitParameterWidget::updateInfoLabel() m_infoLabel->setShown(is_to_show_label); } -void FitParameterWidget::connectTuningWidgetSelection(bool active) -{ +void FitParameterWidget::connectTuningWidgetSelection(bool active) { ASSERT(m_tuningWidget); if (active) { @@ -427,8 +401,7 @@ void FitParameterWidget::connectTuningWidgetSelection(bool active) } } -void FitParameterWidget::connectFitParametersSelection(bool active) -{ +void FitParameterWidget::connectFitParametersSelection(bool active) { if (active) { connect(m_treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, @@ -440,7 +413,6 @@ void FitParameterWidget::connectFitParametersSelection(bool active) } } -JobItem* FitParameterWidget::jobItem() -{ +JobItem* FitParameterWidget::jobItem() { return dynamic_cast<JobItem*>(currentItem()); } diff --git a/GUI/coregui/Views/FitWidgets/FitParameterWidget.h b/GUI/coregui/Views/FitWidgets/FitParameterWidget.h index 95d238c14f901c14f525439754c453a2d1668a2c..34bd69cb30ffc0ff6d3520fe655f54a3f4209084 100644 --- a/GUI/coregui/Views/FitWidgets/FitParameterWidget.h +++ b/GUI/coregui/Views/FitWidgets/FitParameterWidget.h @@ -35,8 +35,7 @@ class OverlayLabelController; //! The FitParametersWidget class contains a tree view to set fit parameters (fix/release, //! starting value, min/max bounds). It occupies buttom right corner of JobView. -class FitParameterWidget : public SessionItemWidget -{ +class FitParameterWidget : public SessionItemWidget { Q_OBJECT public: FitParameterWidget(QWidget* parent = 0); diff --git a/GUI/coregui/Views/FitWidgets/FitProgressInfo.h b/GUI/coregui/Views/FitWidgets/FitProgressInfo.h index 9f9f949abf064138ca58f462c2720116b7d67f37..55f44fb053d6fd2e075138512d9922e52cbf64e5 100644 --- a/GUI/coregui/Views/FitWidgets/FitProgressInfo.h +++ b/GUI/coregui/Views/FitWidgets/FitProgressInfo.h @@ -21,8 +21,7 @@ //! The FitProgressInfo class contains all essential information about fit progress. //! It is send from GUIFitObserver to FitSuiteWidget on every nth iteration. -class FitProgressInfo -{ +class FitProgressInfo { public: FitProgressInfo(); diff --git a/GUI/coregui/Views/FitWidgets/FitResultsWidget.cpp b/GUI/coregui/Views/FitWidgets/FitResultsWidget.cpp index 317efaa8b60b7e0e7cf8e22dab96362c7486eecf..3a59e72c91deb553bce887773ade50aa9a4244b7 100644 --- a/GUI/coregui/Views/FitWidgets/FitResultsWidget.cpp +++ b/GUI/coregui/Views/FitWidgets/FitResultsWidget.cpp @@ -14,7 +14,6 @@ #include "GUI/coregui/Views/FitWidgets/FitResultsWidget.h" -FitResultsWidget::FitResultsWidget(QWidget* parent) : QWidget(parent) -{ +FitResultsWidget::FitResultsWidget(QWidget* parent) : QWidget(parent) { setWindowTitle(QLatin1String("Fit Results")); } diff --git a/GUI/coregui/Views/FitWidgets/FitResultsWidget.h b/GUI/coregui/Views/FitWidgets/FitResultsWidget.h index 8ee87d77a4cb2bac7f5cf547a98f9ab1baa9685c..9a523560fc0a3d3e07bffd43bbb1595b443f472c 100644 --- a/GUI/coregui/Views/FitWidgets/FitResultsWidget.h +++ b/GUI/coregui/Views/FitWidgets/FitResultsWidget.h @@ -19,8 +19,7 @@ //! The FitResultsWidget contains fitting summary. Part of FitSuiteWidget. -class FitResultsWidget : public QWidget -{ +class FitResultsWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/FitWidgets/FitSessionController.cpp b/GUI/coregui/Views/FitWidgets/FitSessionController.cpp index 3f203bc0c5646c965936abe44f60ff04eb851846..61b6399a1f6d773b7c2604abb2d543b9300b5bb3 100644 --- a/GUI/coregui/Views/FitWidgets/FitSessionController.cpp +++ b/GUI/coregui/Views/FitWidgets/FitSessionController.cpp @@ -23,8 +23,7 @@ #include "GUI/coregui/Views/FitWidgets/GUIFitObserver.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { const bool use_fit_objective = true; } @@ -34,8 +33,7 @@ FitSessionController::FitSessionController(QObject* parent) , m_runFitManager(new FitWorkerLauncher(this)) , m_observer(new GUIFitObserver) , m_fitlog(new FitLog) - , m_block_progress_update(false) -{ + , m_block_progress_update(false) { connect(m_observer.get(), &GUIFitObserver::updateReady, this, &FitSessionController::onObserverUpdate); @@ -49,8 +47,7 @@ FitSessionController::FitSessionController(QObject* parent) FitSessionController::~FitSessionController() = default; -void FitSessionController::setItem(JobItem* item) -{ +void FitSessionController::setItem(JobItem* item) { if (m_jobItem && m_jobItem != item) throw GUIHelpers::Error("FitSuiteManager::setItem() -> Item was already set."); @@ -72,8 +69,7 @@ void FitSessionController::setItem(JobItem* item) this); } -void FitSessionController::onStartFittingRequest() -{ +void FitSessionController::onStartFittingRequest() { if (!m_jobItem) return; @@ -92,18 +88,15 @@ void FitSessionController::onStartFittingRequest() } } -FitLog* FitSessionController::fitLog() -{ +FitLog* FitSessionController::fitLog() { return m_fitlog.get(); } -void FitSessionController::onStopFittingRequest() -{ +void FitSessionController::onStopFittingRequest() { m_runFitManager->interruptFitting(); } -void FitSessionController::onObserverUpdate() -{ +void FitSessionController::onObserverUpdate() { auto progressInfo = m_observer->progressInfo(); m_jobItem->dataItem()->setRawDataVector(progressInfo.simValues()); @@ -120,8 +113,7 @@ void FitSessionController::onObserverUpdate() m_observer->finishedPlotting(); } -void FitSessionController::onFittingStarted() -{ +void FitSessionController::onFittingStarted() { m_fitlog->clearLog(); m_jobItem->setStatus("Fitting"); @@ -133,8 +125,7 @@ void FitSessionController::onFittingStarted() emit fittingStarted(); } -void FitSessionController::onFittingFinished() -{ +void FitSessionController::onFittingFinished() { if (m_jobItem->getStatus() != "Failed") m_jobItem->setStatus("Completed"); m_jobItem->setEndTime(GUIHelpers::currentDateTime()); @@ -147,8 +138,7 @@ void FitSessionController::onFittingFinished() emit fittingFinished(); } -void FitSessionController::onFittingError(const QString& text) -{ +void FitSessionController::onFittingError(const QString& text) { QString message; message.append("Current settings cause fitting failure.\n\n"); message.append(text); @@ -157,8 +147,7 @@ void FitSessionController::onFittingError(const QString& text) emit fittingError(message); } -void FitSessionController::updateIterationCount(const FitProgressInfo& info) -{ +void FitSessionController::updateIterationCount(const FitProgressInfo& info) { FitSuiteItem* fitSuiteItem = m_jobItem->fitSuiteItem(); // FIXME FitFlowWidget updates chi2 and n_iteration on P_ITERATION_COUNT change // The order of two lines below is important @@ -166,15 +155,13 @@ void FitSessionController::updateIterationCount(const FitProgressInfo& info) fitSuiteItem->setItemValue(FitSuiteItem::P_ITERATION_COUNT, info.iterationCount()); } -void FitSessionController::updateFitParameterValues(const FitProgressInfo& info) -{ +void FitSessionController::updateFitParameterValues(const FitProgressInfo& info) { QVector<double> values = GUIHelpers::fromStdVector(info.parValues()); FitParameterContainerItem* fitParContainer = m_jobItem->fitParameterContainerItem(); fitParContainer->setValuesInParameterContainer(values, m_jobItem->parameterContainerItem()); } -void FitSessionController::updateLog(const FitProgressInfo& info) -{ +void FitSessionController::updateLog(const FitProgressInfo& info) { QString message = QString("NCalls:%1 chi2:%2 \n").arg(info.iterationCount()).arg(info.chi2()); FitParameterContainerItem* fitParContainer = m_jobItem->fitParameterContainerItem(); int index(0); diff --git a/GUI/coregui/Views/FitWidgets/FitSessionController.h b/GUI/coregui/Views/FitWidgets/FitSessionController.h index 544806e15c6ac58999866b7855400640284d37b7..6d5b6c9c8eb5035139639220c500d36441727cc7 100644 --- a/GUI/coregui/Views/FitWidgets/FitSessionController.h +++ b/GUI/coregui/Views/FitWidgets/FitSessionController.h @@ -28,8 +28,7 @@ class FitObjectiveBuilder; //! Controls all activity related to the single fitting task for JobItem. //! Provides interaction between FitSessionWidget and fit observers. -class FitSessionController : public QObject -{ +class FitSessionController : public QObject { Q_OBJECT public: FitSessionController(QObject* parent = nullptr); diff --git a/GUI/coregui/Views/FitWidgets/FitSessionManager.cpp b/GUI/coregui/Views/FitWidgets/FitSessionManager.cpp index ebf9cf14f52912b5683731530903942671289691..33e20c9b8b378d45cb0041c01964eb1819f3a284 100644 --- a/GUI/coregui/Views/FitWidgets/FitSessionManager.cpp +++ b/GUI/coregui/Views/FitWidgets/FitSessionManager.cpp @@ -20,17 +20,13 @@ #include "GUI/coregui/utils/GUIHelpers.h" FitSessionManager::FitSessionManager(QObject* parent) - : QObject(parent), m_activeController(nullptr), m_jobMessagePanel(nullptr) -{ -} + : QObject(parent), m_activeController(nullptr), m_jobMessagePanel(nullptr) {} -void FitSessionManager::setMessagePanel(JobMessagePanel* messagePanel) -{ +void FitSessionManager::setMessagePanel(JobMessagePanel* messagePanel) { m_jobMessagePanel = messagePanel; } -FitSessionController* FitSessionManager::sessionController(JobItem* item) -{ +FitSessionController* FitSessionManager::sessionController(JobItem* item) { FitSessionController* result(nullptr); auto it = m_item_to_controller.find(item); @@ -49,16 +45,14 @@ FitSessionController* FitSessionManager::sessionController(JobItem* item) return result; } -void FitSessionManager::disableLogging() -{ +void FitSessionManager::disableLogging() { if (m_activeController) m_activeController->fitLog()->setMessagePanel(nullptr); m_jobMessagePanel->onClearLog(); } -FitSessionController* FitSessionManager::createController(JobItem* jobItem) -{ +FitSessionController* FitSessionManager::createController(JobItem* jobItem) { jobItem->mapper()->setOnItemDestroy([this](SessionItem* item) { removeController(item); }, this); @@ -69,8 +63,7 @@ FitSessionController* FitSessionManager::createController(JobItem* jobItem) //! Removes manager for given jobItem -void FitSessionManager::removeController(SessionItem* jobItem) -{ +void FitSessionManager::removeController(SessionItem* jobItem) { auto it = m_item_to_controller.find(jobItem); if (it == m_item_to_controller.end()) throw GUIHelpers::Error("FitActivityManager::removeFitSession() -> Error. " diff --git a/GUI/coregui/Views/FitWidgets/FitSessionManager.h b/GUI/coregui/Views/FitWidgets/FitSessionManager.h index 630969cafc5ebca47365102f4569e534d3f8524f..2b53b86efbf1bc7ed6bce182ae815d8b9926fdfb 100644 --- a/GUI/coregui/Views/FitWidgets/FitSessionManager.h +++ b/GUI/coregui/Views/FitWidgets/FitSessionManager.h @@ -26,8 +26,7 @@ class JobMessagePanel; //! Handles all activity related to the simultaneous running of fitting jobs. -class FitSessionManager : public QObject -{ +class FitSessionManager : public QObject { Q_OBJECT public: FitSessionManager(QObject* parent = nullptr); diff --git a/GUI/coregui/Views/FitWidgets/FitSessionWidget.cpp b/GUI/coregui/Views/FitWidgets/FitSessionWidget.cpp index 689583b605b5dfa509f32180044e10771cb89f35..7ed78da5e501aed80623dcd20717bd12ec91c8b4 100644 --- a/GUI/coregui/Views/FitWidgets/FitSessionWidget.cpp +++ b/GUI/coregui/Views/FitWidgets/FitSessionWidget.cpp @@ -31,8 +31,7 @@ FitSessionWidget::FitSessionWidget(QWidget* parent) , m_minimizerSettingsWidget(new MinimizerSettingsWidget) // , m_fitResultsWidget(new FitResultsWidget) , m_fitResultsWidget(nullptr) // temporary replacement to fix a memory leak - , m_sessionController(nullptr) -{ + , m_sessionController(nullptr) { auto layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->setMargin(0); @@ -48,23 +47,20 @@ FitSessionWidget::FitSessionWidget(QWidget* parent) setLayout(layout); } -void FitSessionWidget::setItem(JobItem* jobItem) -{ +void FitSessionWidget::setItem(JobItem* jobItem) { ASSERT(jobItem); m_fitParametersWidget->setItem(jobItem); m_minimizerSettingsWidget->setItem(jobItem); m_controlWidget->setItem(jobItem); } -void FitSessionWidget::setModelTuningWidget(ParameterTuningWidget* tuningWidget) -{ +void FitSessionWidget::setModelTuningWidget(ParameterTuningWidget* tuningWidget) { ASSERT(m_fitParametersWidget); ASSERT(tuningWidget); m_fitParametersWidget->setParameterTuningWidget(tuningWidget); } -void FitSessionWidget::setSessionController(FitSessionController* sessionController) -{ +void FitSessionWidget::setSessionController(FitSessionController* sessionController) { if (m_sessionController) { disconnect(m_sessionController, 0, this, 0); disconnect(m_controlWidget, 0, m_sessionController, 0); @@ -84,17 +80,14 @@ void FitSessionWidget::setSessionController(FitSessionController* sessionControl } } -QSize FitSessionWidget::sizeHint() const -{ +QSize FitSessionWidget::sizeHint() const { return QSize(Constants::REALTIME_WIDGET_WIDTH_HINT, Constants::FIT_SUITE_WIDGET_HEIGHT); } -QSize FitSessionWidget::minimumSizeHint() const -{ +QSize FitSessionWidget::minimumSizeHint() const { return QSize(25, 25); } -void FitSessionWidget::onFittingError(const QString& text) -{ +void FitSessionWidget::onFittingError(const QString& text) { m_controlWidget->onFittingError(text); } diff --git a/GUI/coregui/Views/FitWidgets/FitSessionWidget.h b/GUI/coregui/Views/FitWidgets/FitSessionWidget.h index 8094aa3629e24a771d80da2faf39c4dea9a516b6..f562d44dbd6af1ad42cabda3621f2df75b561599 100644 --- a/GUI/coregui/Views/FitWidgets/FitSessionWidget.h +++ b/GUI/coregui/Views/FitWidgets/FitSessionWidget.h @@ -31,8 +31,7 @@ class JobMessagePanel; //! Contains all fit settings for given JobItem (fit parameters, //! minimizer settings). Controlled by FitActivityPanel. -class FitSessionWidget : public QWidget -{ +class FitSessionWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/FitWidgets/FitWorker.cpp b/GUI/coregui/Views/FitWidgets/FitWorker.cpp index d12bfce5339a94db3712b0057524597d5a0fa9f7..d84698f8b838f064a6e1a8c8140385f47c651a73 100644 --- a/GUI/coregui/Views/FitWidgets/FitWorker.cpp +++ b/GUI/coregui/Views/FitWidgets/FitWorker.cpp @@ -16,8 +16,7 @@ #include "GUI/coregui/Views/FitWidgets/FitObjectiveBuilder.h" #include <QDateTime> -void FitWorker::startFit() -{ +void FitWorker::startFit() { int duration(0); QDateTime beginTime = QDateTime::currentDateTime(); @@ -33,14 +32,12 @@ void FitWorker::startFit() emit finished(duration); } -void FitWorker::interruptFitting() -{ +void FitWorker::interruptFitting() { if (m_fit_objective) m_fit_objective->interruptFitting(); } -int FitWorker::durationSince(const QDateTime& since) -{ +int FitWorker::durationSince(const QDateTime& since) { QDateTime endTime = QDateTime::currentDateTime(); return int(since.msecsTo(endTime)); } diff --git a/GUI/coregui/Views/FitWidgets/FitWorker.h b/GUI/coregui/Views/FitWidgets/FitWorker.h index c9f04e43b9a806d0b3252f313f19ac902591f5a6..ff0d4e48ede163f5007499de9248aa00ec80b85f 100644 --- a/GUI/coregui/Views/FitWidgets/FitWorker.h +++ b/GUI/coregui/Views/FitWidgets/FitWorker.h @@ -20,8 +20,7 @@ class FitObjectiveBuilder; -class FitWorker : public QObject -{ +class FitWorker : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/FitWidgets/FitWorkerLauncher.cpp b/GUI/coregui/Views/FitWidgets/FitWorkerLauncher.cpp index 032ad96f28f47d372ea7102a387fa4811895194b..39bf16b30f596b58e48e98396c87179d2e5daa5f 100644 --- a/GUI/coregui/Views/FitWidgets/FitWorkerLauncher.cpp +++ b/GUI/coregui/Views/FitWidgets/FitWorkerLauncher.cpp @@ -17,12 +17,9 @@ #include <QThread> FitWorkerLauncher::FitWorkerLauncher(QObject* parent) - : QObject(parent), m_is_fit_running(false), m_duration(0) -{ -} + : QObject(parent), m_is_fit_running(false), m_duration(0) {} -void FitWorkerLauncher::runFitting(std::shared_ptr<FitObjectiveBuilder> suite) -{ +void FitWorkerLauncher::runFitting(std::shared_ptr<FitObjectiveBuilder> suite) { if (!suite || m_is_fit_running) return; @@ -50,30 +47,25 @@ void FitWorkerLauncher::runFitting(std::shared_ptr<FitObjectiveBuilder> suite) //! Returns duration of fit in msec. -int FitWorkerLauncher::getDuration() -{ +int FitWorkerLauncher::getDuration() { return m_duration; } -void FitWorkerLauncher::interruptFitting() -{ +void FitWorkerLauncher::interruptFitting() { if (m_is_fit_running) emit intern_interruptFittingWorker(); } -void FitWorkerLauncher::intern_workerFinished(int duration) -{ +void FitWorkerLauncher::intern_workerFinished(int duration) { m_is_fit_running = false; m_duration = duration; emit fittingFinished(); } -void FitWorkerLauncher::intern_workerStarted() -{ +void FitWorkerLauncher::intern_workerStarted() { emit fittingStarted(); } -void FitWorkerLauncher::intern_error(const QString& mesg) -{ +void FitWorkerLauncher::intern_error(const QString& mesg) { emit fittingError(mesg); } diff --git a/GUI/coregui/Views/FitWidgets/FitWorkerLauncher.h b/GUI/coregui/Views/FitWidgets/FitWorkerLauncher.h index defc8009ac072b66aa6560802902737d694d4f6e..1c710a8750b05310616a6fb1b55c2f5858c5ae87 100644 --- a/GUI/coregui/Views/FitWidgets/FitWorkerLauncher.h +++ b/GUI/coregui/Views/FitWidgets/FitWorkerLauncher.h @@ -21,8 +21,7 @@ class FitObjectiveBuilder; -class FitWorkerLauncher : public QObject -{ +class FitWorkerLauncher : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/FitWidgets/GUIFitObserver.cpp b/GUI/coregui/Views/FitWidgets/GUIFitObserver.cpp index 76448027c60ced35e0a23652ab26be2d047afa52..c8287008bd0f6a24796aa15fec327d524296965b 100644 --- a/GUI/coregui/Views/FitWidgets/GUIFitObserver.cpp +++ b/GUI/coregui/Views/FitWidgets/GUIFitObserver.cpp @@ -18,14 +18,11 @@ #include "GUI/coregui/utils/GUIHelpers.h" GUIFitObserver::GUIFitObserver(QObject* parent) - : QObject(parent), m_block_update_plots(false), m_update_interval(1) -{ -} + : QObject(parent), m_block_update_plots(false), m_update_interval(1) {} GUIFitObserver::~GUIFitObserver() = default; -void GUIFitObserver::update(const FitObjective* subject) -{ +void GUIFitObserver::update(const FitObjective* subject) { if (!is_suitable_iteration(subject)) return; @@ -53,8 +50,7 @@ void GUIFitObserver::update(const FitObjective* subject) //! Returns true if data could be plotted, when there are resources for it. -bool GUIFitObserver::is_suitable_iteration(const FitObjective* fitSuite) const -{ +bool GUIFitObserver::is_suitable_iteration(const FitObjective* fitSuite) const { if (fitSuite->isInterrupted()) return false; @@ -65,28 +61,24 @@ bool GUIFitObserver::is_suitable_iteration(const FitObjective* fitSuite) const //! Returns true if given iteration should be obligary plotted. -bool GUIFitObserver::is_obligatory_iteration(const FitObjective* fitSuite) const -{ +bool GUIFitObserver::is_obligatory_iteration(const FitObjective* fitSuite) const { return fitSuite->isCompleted(); } -void GUIFitObserver::setInterval(int val) -{ +void GUIFitObserver::setInterval(int val) { m_update_interval = val; } //! Informs observer that FitSuiteWidget has finished plotting and is ready for next plot -void GUIFitObserver::finishedPlotting() -{ +void GUIFitObserver::finishedPlotting() { std::unique_lock<std::mutex> lock(m_update_plot_mutex); m_block_update_plots = false; lock.unlock(); m_on_finish_notifier.notify_one(); } -FitProgressInfo GUIFitObserver::progressInfo() -{ +FitProgressInfo GUIFitObserver::progressInfo() { std::unique_lock<std::mutex> lock(m_update_plot_mutex); m_block_update_plots = true; return m_iteration_info; diff --git a/GUI/coregui/Views/FitWidgets/GUIFitObserver.h b/GUI/coregui/Views/FitWidgets/GUIFitObserver.h index bea128e44a4a0129d1661aae8716656b79e9c536..4a6e9e8db72f9a1497434ad045e9b9ed96a8ebe5 100644 --- a/GUI/coregui/Views/FitWidgets/GUIFitObserver.h +++ b/GUI/coregui/Views/FitWidgets/GUIFitObserver.h @@ -27,8 +27,7 @@ class FitObjective; //! Serves as observer for FitObjective and saves fit iteration data for later display //! in GUI widgets. -class GUIFitObserver : public QObject -{ +class GUIFitObserver : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/FitWidgets/HistogramPlot.cpp b/GUI/coregui/Views/FitWidgets/HistogramPlot.cpp index 9a7c3aa31d2b31013d8082a3797d1008e4fe36ca..64c952e828112eae46a7dbcd5b9b98df071e830b 100644 --- a/GUI/coregui/Views/FitWidgets/HistogramPlot.cpp +++ b/GUI/coregui/Views/FitWidgets/HistogramPlot.cpp @@ -15,7 +15,9 @@ #include "GUI/coregui/Views/FitWidgets/HistogramPlot.h" #include "GUI/coregui/Views/FitWidgets/plot_constants.h" -HistogramPlot::HistogramPlot(QWidget* parent) : QWidget(parent), m_customPlot(new QCustomPlot) +HistogramPlot::HistogramPlot(QWidget* parent) + : QWidget(parent) + , m_customPlot(new QCustomPlot) { QVBoxLayout* vlayout = new QVBoxLayout(this); @@ -44,36 +46,31 @@ HistogramPlot::HistogramPlot(QWidget* parent) : QWidget(parent), m_customPlot(ne m_customPlot->yAxis->setLabelFont(QFont(QFont().family(), Constants::plot_axes_label_size())); } -void HistogramPlot::addData(double x, double y) -{ +void HistogramPlot::addData(double x, double y) { m_customPlot->graph()->addData(x, y); m_customPlot->graph()->rescaleAxes(); m_customPlot->replot(); } -void HistogramPlot::addData(const QVector<double>& x, const QVector<double>& y) -{ +void HistogramPlot::addData(const QVector<double>& x, const QVector<double>& y) { m_customPlot->graph()->addData(x, y); m_customPlot->graph()->rescaleAxes(); m_customPlot->replot(); } -void HistogramPlot::setData(const QVector<double>& x, const QVector<double>& y) -{ +void HistogramPlot::setData(const QVector<double>& x, const QVector<double>& y) { m_customPlot->graph()->setData(x, y); m_customPlot->graph()->rescaleAxes(); m_customPlot->replot(); } -void HistogramPlot::clearData() -{ +void HistogramPlot::clearData() { m_customPlot->removeGraph(m_customPlot->graph()); initGraph(); m_customPlot->replot(); } -void HistogramPlot::initGraph() -{ +void HistogramPlot::initGraph() { m_customPlot->addGraph(); QPen pen(QColor(0, 0, 255, 200)); diff --git a/GUI/coregui/Views/FitWidgets/HistogramPlot.h b/GUI/coregui/Views/FitWidgets/HistogramPlot.h index 793f732d3c5045db7d5c050d388576e910311ca4..9289261ad58bd511e2eabaa1dcd4f064a381b2b5 100644 --- a/GUI/coregui/Views/FitWidgets/HistogramPlot.h +++ b/GUI/coregui/Views/FitWidgets/HistogramPlot.h @@ -18,8 +18,7 @@ #include <QWidget> #include <qcustomplot.h> -class HistogramPlot : public QWidget -{ +class HistogramPlot : public QWidget { Q_OBJECT public: explicit HistogramPlot(QWidget* parent = 0); diff --git a/GUI/coregui/Views/FitWidgets/MinimizerSettingsWidget.cpp b/GUI/coregui/Views/FitWidgets/MinimizerSettingsWidget.cpp index 55aefa3832bcde5e1b97d6e3b2190e4a31e34e12..4a7a65805259e6e35a1fcae5d9258f47f06e2d96 100644 --- a/GUI/coregui/Views/FitWidgets/MinimizerSettingsWidget.cpp +++ b/GUI/coregui/Views/FitWidgets/MinimizerSettingsWidget.cpp @@ -21,8 +21,7 @@ #include <QVBoxLayout> MinimizerSettingsWidget::MinimizerSettingsWidget(QWidget* parent) - : QWidget(parent), m_currentItem(nullptr), m_componentEditor(new ComponentEditor) -{ + : QWidget(parent), m_currentItem(nullptr), m_componentEditor(new ComponentEditor) { setWindowTitle(QLatin1String("Minimizer Settings")); auto layout = new QVBoxLayout; @@ -34,19 +33,16 @@ MinimizerSettingsWidget::MinimizerSettingsWidget(QWidget* parent) setLayout(layout); } -QSize MinimizerSettingsWidget::minimumSizeHint() const -{ +QSize MinimizerSettingsWidget::minimumSizeHint() const { return QSize(25, 25); } -void MinimizerSettingsWidget::setItem(JobItem* jobItem) -{ +void MinimizerSettingsWidget::setItem(JobItem* jobItem) { ASSERT(jobItem); setItem(jobItem->fitSuiteItem()->minimizerContainerItem()); } -void MinimizerSettingsWidget::setItem(MinimizerContainerItem* minimizerItem) -{ +void MinimizerSettingsWidget::setItem(MinimizerContainerItem* minimizerItem) { ASSERT(minimizerItem); m_currentItem = minimizerItem; m_componentEditor->setItem(minimizerItem); diff --git a/GUI/coregui/Views/FitWidgets/MinimizerSettingsWidget.h b/GUI/coregui/Views/FitWidgets/MinimizerSettingsWidget.h index 23a77b34ab4a602e173444e1b301c86499b95d48..bb2189f3b89d3111f001630084676bea7d9231dd 100644 --- a/GUI/coregui/Views/FitWidgets/MinimizerSettingsWidget.h +++ b/GUI/coregui/Views/FitWidgets/MinimizerSettingsWidget.h @@ -24,8 +24,7 @@ class MinimizerContainerItem; //! The MinimizerSettingsWidget contains editor for all minnimizer settings and related fit //! options. Part of FitSuiteWidget. -class MinimizerSettingsWidget : public QWidget -{ +class MinimizerSettingsWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/FitWidgets/RunFitControlWidget.cpp b/GUI/coregui/Views/FitWidgets/RunFitControlWidget.cpp index 1afc1b84abec76b1f1c1fb155bd6af57cf057270..36a8a0df7f9523f32a240ca556c505a0ea6f804e 100644 --- a/GUI/coregui/Views/FitWidgets/RunFitControlWidget.cpp +++ b/GUI/coregui/Views/FitWidgets/RunFitControlWidget.cpp @@ -24,8 +24,7 @@ #include <QPushButton> #include <QSlider> -namespace -{ +namespace { const int default_interval = 10; const std::vector<int> slider_to_interval = {1, 2, 3, 4, 5, 10, 15, 20, 25, 30, 50, 100, 200, 500, 1000}; @@ -39,8 +38,7 @@ RunFitControlWidget::RunFitControlWidget(QWidget* parent) , m_intervalSlider(new QSlider) , m_updateIntervalLabel(new QLabel) , m_iterationsCountLabel(new QLabel) - , m_warningSign(new WarningSign(this)) -{ + , m_warningSign(new WarningSign(this)) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setFixedHeight(Constants::RUN_FIT_CONTROL_WIDGET_HEIGHT); @@ -88,36 +86,31 @@ RunFitControlWidget::RunFitControlWidget(QWidget* parent) setEnabled(false); } -RunFitControlWidget::~RunFitControlWidget() -{ +RunFitControlWidget::~RunFitControlWidget() { unsubscribeFromChildren(); } -void RunFitControlWidget::onFittingError(const QString& what) -{ +void RunFitControlWidget::onFittingError(const QString& what) { m_warningSign->clear(); m_iterationsCountLabel->setText(""); m_warningSign->setWarningMessage(what); } -void RunFitControlWidget::onSliderValueChanged(int value) -{ +void RunFitControlWidget::onSliderValueChanged(int value) { int interval = sliderValueToUpdateInterval(value); m_updateIntervalLabel->setText(QString::number(interval)); if (fitSuiteItem()) fitSuiteItem()->setItemValue(FitSuiteItem::P_UPDATE_INTERVAL, interval); } -void RunFitControlWidget::onFitSuitePropertyChange(const QString& name) -{ +void RunFitControlWidget::onFitSuitePropertyChange(const QString& name) { if (name == FitSuiteItem::P_ITERATION_COUNT) { int niter = fitSuiteItem()->getItemValue(FitSuiteItem::P_ITERATION_COUNT).toInt(); m_iterationsCountLabel->setText(QString::number(niter)); } } -void RunFitControlWidget::subscribeToItem() -{ +void RunFitControlWidget::subscribeToItem() { updateControlElements(); fitSuiteItem()->setItemValue(FitSuiteItem::P_UPDATE_INTERVAL, sliderUpdateInterval()); @@ -135,29 +128,25 @@ void RunFitControlWidget::subscribeToItem() this); } -void RunFitControlWidget::unsubscribeFromItem() -{ +void RunFitControlWidget::unsubscribeFromItem() { setEnabled(false); unsubscribeFromChildren(); } -int RunFitControlWidget::sliderUpdateInterval() -{ +int RunFitControlWidget::sliderUpdateInterval() { return sliderValueToUpdateInterval(m_intervalSlider->value()); } //! converts slider value (1-15) to update interval to be propagated to FitSuiteWidget -int RunFitControlWidget::sliderValueToUpdateInterval(int value) -{ +int RunFitControlWidget::sliderValueToUpdateInterval(int value) { size_t svalue = static_cast<size_t>(value); return svalue < slider_to_interval.size() ? slider_to_interval[svalue] : default_interval; } //! Updates button "enabled" status and warning status depending on current job conditions. -void RunFitControlWidget::updateControlElements() -{ +void RunFitControlWidget::updateControlElements() { setEnabled(isValidJobItem()); if (jobItem()->getStatus() == "Fitting") { @@ -170,23 +159,19 @@ void RunFitControlWidget::updateControlElements() } } -JobItem* RunFitControlWidget::jobItem() -{ +JobItem* RunFitControlWidget::jobItem() { return dynamic_cast<JobItem*>(currentItem()); } -FitSuiteItem* RunFitControlWidget::fitSuiteItem() -{ +FitSuiteItem* RunFitControlWidget::fitSuiteItem() { return jobItem() ? jobItem()->fitSuiteItem() : nullptr; } -bool RunFitControlWidget::isValidJobItem() -{ +bool RunFitControlWidget::isValidJobItem() { return jobItem() ? jobItem()->isValidForFitting() : false; } -void RunFitControlWidget::unsubscribeFromChildren() -{ +void RunFitControlWidget::unsubscribeFromChildren() { if (fitSuiteItem()) fitSuiteItem()->mapper()->unsubscribe(this); } diff --git a/GUI/coregui/Views/FitWidgets/RunFitControlWidget.h b/GUI/coregui/Views/FitWidgets/RunFitControlWidget.h index 38ceaa3978fcf05b7d49195acd1da4e7709c813e..039d904f695629cb972855fe38a2428ca7495640 100644 --- a/GUI/coregui/Views/FitWidgets/RunFitControlWidget.h +++ b/GUI/coregui/Views/FitWidgets/RunFitControlWidget.h @@ -29,8 +29,7 @@ class JobMessagePanel; //! The RunFitControlWidget contains elements to start/stop fitting and to provide minimal //! diagnostic. Part of FitSuiteWidget. -class RunFitControlWidget : public SessionItemWidget -{ +class RunFitControlWidget : public SessionItemWidget { Q_OBJECT public: RunFitControlWidget(QWidget* parent = 0); diff --git a/GUI/coregui/Views/FitWidgets/plot_constants.h b/GUI/coregui/Views/FitWidgets/plot_constants.h index 7792202a9e3c1e4decbad84d534e7aad4dcebc27..2fec3aa38adad82aa326023b03558d9fa20c6660 100644 --- a/GUI/coregui/Views/FitWidgets/plot_constants.h +++ b/GUI/coregui/Views/FitWidgets/plot_constants.h @@ -18,21 +18,17 @@ #include "GUI/coregui/utils/StyleUtils.h" #include <QSize> -namespace Constants -{ +namespace Constants { -inline int plot_tick_label_size() -{ +inline int plot_tick_label_size() { return StyleUtils::SystemPointSize() * 0.9; } -inline int plot_axes_label_size() -{ +inline int plot_axes_label_size() { return StyleUtils::SystemPointSize(); } -inline int plot_colorbar_size() -{ +inline int plot_colorbar_size() { return StyleUtils::SizeOfLetterM().width(); } diff --git a/GUI/coregui/Views/ImportDataView.cpp b/GUI/coregui/Views/ImportDataView.cpp index 7d586b2f9f0f7e35bbc24e4c335d92067054d67e..f1228fe88165e68e156cb8c934d47cf6afa47594 100644 --- a/GUI/coregui/Views/ImportDataView.cpp +++ b/GUI/coregui/Views/ImportDataView.cpp @@ -21,8 +21,7 @@ #include <QVBoxLayout> #include <minisplitter.h> -namespace -{ +namespace { const bool reuse_widget = true; } @@ -31,8 +30,7 @@ ImportDataView::ImportDataView(MainWindow* mainWindow) , m_splitter(new Manhattan::MiniSplitter) , m_selectorWidget(new RealDataSelectorWidget) , m_stackedWidget(new ItemStackPresenter<RealDataPresenter>(reuse_widget)) - , m_realDataModel(mainWindow->realDataModel()) -{ + , m_realDataModel(mainWindow->realDataModel()) { auto mainLayout = new QVBoxLayout; mainLayout->setMargin(0); mainLayout->setSpacing(0); @@ -60,13 +58,11 @@ ImportDataView::ImportDataView(MainWindow* mainWindow) m_stackedWidget->setModel(mainWindow->realDataModel()); } -void ImportDataView::onSelectionChanged(SessionItem* item) -{ +void ImportDataView::onSelectionChanged(SessionItem* item) { m_stackedWidget->setItem(item); } -void ImportDataView::setupConnections() -{ +void ImportDataView::setupConnections() { connect(m_selectorWidget, &RealDataSelectorWidget::selectionChanged, this, &ImportDataView::onSelectionChanged); } diff --git a/GUI/coregui/Views/ImportDataView.h b/GUI/coregui/Views/ImportDataView.h index 178a40e1acebf95622b6f478909653ab65525ebb..bb1573908bb9b115fd0e3a007df104a624e9afaa 100644 --- a/GUI/coregui/Views/ImportDataView.h +++ b/GUI/coregui/Views/ImportDataView.h @@ -20,15 +20,13 @@ class RealDataModel; class RealDataSelectorWidget; -namespace Manhattan -{ +namespace Manhattan { class MiniSplitter; } //! The ImportDataView class is a main view for importing experimental data. -class ImportDataView : public QWidget -{ +class ImportDataView : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp index c44a9aa66ab7190ebf1373aca9e11bdd23e0f98d..aa84fecaf481c2d8f1cf6fa315ab272cb8b9d23f 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp @@ -20,44 +20,35 @@ CsvIntensityColumn::CsvIntensityColumn() : m_colNum(-1), m_multiplier(1.0), m_values({}) {} CsvIntensityColumn::CsvIntensityColumn(const CsvIntensityColumn& toCopy) - : m_colNum(toCopy.columnNumber()), m_multiplier(toCopy.multiplier()), m_values(toCopy.values()) -{ -} + : m_colNum(toCopy.columnNumber()) + , m_multiplier(toCopy.multiplier()) + , m_values(toCopy.values()) {} CsvIntensityColumn::CsvIntensityColumn(int colNum, double multiplier, csv::DataColumn values) - : m_colNum(colNum), m_multiplier(multiplier), m_values(values) -{ -} + : m_colNum(colNum), m_multiplier(multiplier), m_values(values) {} // Getters: -int CsvIntensityColumn::columnNumber() const -{ +int CsvIntensityColumn::columnNumber() const { return m_colNum; } -double CsvIntensityColumn::multiplier() const -{ +double CsvIntensityColumn::multiplier() const { return m_multiplier; } -csv::DataColumn CsvIntensityColumn::values() const -{ +csv::DataColumn CsvIntensityColumn::values() const { return m_values; } // Setters: -void CsvIntensityColumn::setColNum(int const colNum) -{ +void CsvIntensityColumn::setColNum(int const colNum) { m_colNum = colNum; } -void CsvIntensityColumn::setMultiplier(double const multiplier) -{ +void CsvIntensityColumn::setMultiplier(double const multiplier) { m_multiplier = multiplier; } -void CsvIntensityColumn::setValues(csv::DataColumn const values) -{ +void CsvIntensityColumn::setValues(csv::DataColumn const values) { m_values = std::move(values); } -void CsvIntensityColumn::resetColumn(int colNum, double multiplier, csv::DataColumn values) -{ +void CsvIntensityColumn::resetColumn(int colNum, double multiplier, csv::DataColumn values) { m_colNum = colNum; m_multiplier = multiplier; m_values = std::move(values); @@ -69,33 +60,25 @@ void CsvIntensityColumn::resetColumn(int colNum, double multiplier, csv::DataCol CsvCoordinateColumn::CsvCoordinateColumn() : CsvIntensityColumn(), m_units(Axes::Units::NBINS) {} CsvCoordinateColumn::CsvCoordinateColumn(const CsvCoordinateColumn& toCopy) - : CsvIntensityColumn(toCopy), m_units(toCopy.units()) -{ -} + : CsvIntensityColumn(toCopy), m_units(toCopy.units()) {} CsvCoordinateColumn::CsvCoordinateColumn(int colNum, double multiplier, csv::DataColumn values, Axes::Units units) - : CsvIntensityColumn(colNum, multiplier, values), m_units(units) -{ -} + : CsvIntensityColumn(colNum, multiplier, values), m_units(units) {} // Getters: -Axes::Units CsvCoordinateColumn::units() const -{ +Axes::Units CsvCoordinateColumn::units() const { return m_units; } // Setters: -void CsvCoordinateColumn::setUnits(Axes::Units const units) -{ +void CsvCoordinateColumn::setUnits(Axes::Units const units) { m_units = units; } -void CsvCoordinateColumn::setName(csv::ColumnType const name) -{ +void CsvCoordinateColumn::setName(csv::ColumnType const name) { m_name = name; } void CsvCoordinateColumn::resetColumn(int colNum, double multiplier, csv::DataColumn values, - Axes::Units units, csv::ColumnType name) -{ + Axes::Units units, csv::ColumnType name) { CsvIntensityColumn::resetColumn(colNum, multiplier, values); m_units = units; m_name = name; diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h index 882f24e0aa60e6d3eef5dd1699a2248ce3a8ac19..363af5ed042396a364f9aa4b58ab605d035d679a 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h @@ -18,8 +18,7 @@ #include "Device/Unit/IUnitConverter.h" #include "GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvNamespace.h" -class CsvIntensityColumn -{ +class CsvIntensityColumn { public: // Constructors: CsvIntensityColumn(); @@ -43,8 +42,7 @@ private: csv::DataColumn m_values; }; -class CsvCoordinateColumn : public CsvIntensityColumn -{ +class CsvCoordinateColumn : public CsvIntensityColumn { public: // Constructors: CsvCoordinateColumn(); diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp index b055e4462b5fed2942f6ec655a4418655e1e322d..5a8229104158afec6592800fa24bdf13016ded8c 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp @@ -39,8 +39,7 @@ CsvImportAssistant::CsvImportAssistant(const QString& file, const bool useGUI, Q , m_firstRow(-1) , m_lastRow(-1) , m_units(Axes::Units::NBINS) - , m_dataAvailable(false) -{ + , m_dataAvailable(false) { if (!loadCsvFile()) { return; } @@ -57,8 +56,7 @@ CsvImportAssistant::CsvImportAssistant(const QString& file, const bool useGUI, Q } } -void CsvImportAssistant::runDataSelector(QWidget* parent) -{ +void CsvImportAssistant::runDataSelector(QWidget* parent) { DataSelector selector(m_csvArray, parent); m_separator = guessSeparator(); selector.setSeparator(guessSeparator()); @@ -89,28 +87,23 @@ void CsvImportAssistant::runDataSelector(QWidget* parent) } } -void CsvImportAssistant::setIntensityColumn(int iCol, double multiplier) -{ +void CsvImportAssistant::setIntensityColumn(int iCol, double multiplier) { m_intensityColNum = iCol - 1; m_intensityMultiplier = multiplier; } -void CsvImportAssistant::setCoordinateColumn(int iCol, Axes::Units units, double multiplier) -{ +void CsvImportAssistant::setCoordinateColumn(int iCol, Axes::Units units, double multiplier) { m_coordinateColNum = iCol - 1; m_units = units; m_coordinateMultiplier = multiplier; } -void CsvImportAssistant::setFirstRow(int iRow) -{ +void CsvImportAssistant::setFirstRow(int iRow) { m_firstRow = iRow - 1; } -void CsvImportAssistant::setLastRow(int iRow) -{ +void CsvImportAssistant::setLastRow(int iRow) { m_lastRow = iRow - 1; } -bool CsvImportAssistant::loadCsvFile() -{ +bool CsvImportAssistant::loadCsvFile() { try { if (m_separator == '\0') @@ -156,14 +149,12 @@ bool CsvImportAssistant::loadCsvFile() return true; } -void CsvImportAssistant::resetAssistant() -{ +void CsvImportAssistant::resetAssistant() { resetSelection(); loadCsvFile(); } -ImportDataInfo CsvImportAssistant::fillData() -{ +ImportDataInfo CsvImportAssistant::fillData() { // In case a 2d import is needed in the future // Use ArrayUtils::Create2dData(vector<vector<double>>) // ArrayUtils::Create2d @@ -184,8 +175,7 @@ ImportDataInfo CsvImportAssistant::fillData() } void CsvImportAssistant::getValuesFromColumns(std::vector<double>& intensityValues, - std::vector<double>& coordinateValues) -{ + std::vector<double>& coordinateValues) { bool intensityOk = true; bool coordinateOk = true; auto firstRow = size_t(m_firstRow); @@ -220,8 +210,7 @@ void CsvImportAssistant::getValuesFromColumns(std::vector<double>& intensityValu } } -void CsvImportAssistant::removeMultipleWhiteSpaces() -{ +void CsvImportAssistant::removeMultipleWhiteSpaces() { if (m_csvArray.empty()) return; @@ -258,8 +247,7 @@ void CsvImportAssistant::removeMultipleWhiteSpaces() m_csvArray.swap(buffer2d); } -void CsvImportAssistant::removeBlankColumns() -{ +void CsvImportAssistant::removeBlankColumns() { if (m_csvArray.empty()) return; @@ -310,8 +298,7 @@ void CsvImportAssistant::removeBlankColumns() } } -char CsvImportAssistant::guessSeparator() const -{ +char CsvImportAssistant::guessSeparator() const { int frequencies[127] = {0}; // The actual characters that may be realistically @@ -361,24 +348,21 @@ char CsvImportAssistant::guessSeparator() const return guessedSep; } -bool CsvImportAssistant::hasEqualLengthLines(csv::DataArray& dataArray) -{ +bool CsvImportAssistant::hasEqualLengthLines(csv::DataArray& dataArray) { auto tf = all_of(begin(dataArray), end(dataArray), [dataArray](const csv::DataRow& x) { return x.size() == dataArray.front().size(); }); return tf; } -void CsvImportAssistant::showErrorMessage(std::string message) -{ +void CsvImportAssistant::showErrorMessage(std::string message) { QMessageBox msgBox; msgBox.setText(QString::fromStdString(message)); msgBox.setIcon(msgBox.Critical); msgBox.exec(); } -void CsvImportAssistant::resetSelection() -{ +void CsvImportAssistant::resetSelection() { m_csvArray.clear(); m_intensityColNum = -1; m_coordinateColNum = -1; diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.h index e706cff92bacd7903d4754e248f8fcf76f934e9e..4655903c9d795f4dff8cbcc0c88798900690958c 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.h @@ -24,8 +24,7 @@ #include <memory> #include <set> -class csvSelectionState -{ +class csvSelectionState { public: csvSelectionState() : m_intensityColNum(-1) @@ -34,9 +33,7 @@ public: , m_coordinateMultiplier(1.) , m_firstRow(-1) , m_lastRow(-1) - , m_units(Axes::Units::NBINS) - { - } + , m_units(Axes::Units::NBINS) {} int m_intensityColNum; double m_intensityMultiplier; @@ -50,8 +47,7 @@ public: }; //! Logic for importing intensity data from csv files -class CsvImportAssistant : public QObject -{ +class CsvImportAssistant : public QObject { Q_OBJECT public: CsvImportAssistant(const QString& file, const bool useGUI = false, QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.cpp index 9813e65651cbda7bfe2b992a450bd520b29941d5..a925bbc79b6e645c3c16c30d2b0e53e95339749d 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.cpp @@ -15,12 +15,10 @@ #include "GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h" #include "GUI/coregui/Views/JobWidgets/ScientificSpinBox.h" -namespace -{ +namespace { ScientificSpinBox* createMultiplierBox(double value = 1.0, bool enabled = false, - QWidget* parent = nullptr) -{ + QWidget* parent = nullptr) { auto result = new ScientificSpinBox(parent); result->setValue(value); result->setEnabled(enabled); @@ -29,12 +27,9 @@ ScientificSpinBox* createMultiplierBox(double value = 1.0, bool enabled = false, } // namespace CsvImportData::CsvImportData(QObject* parent) - : QObject(parent), m_data(new csv::DataArray), m_n_header(0), m_n_footer(0) -{ -} + : QObject(parent), m_data(new csv::DataArray), m_n_header(0), m_n_footer(0) {} -void CsvImportData::setData(csv::DataArray data) -{ +void CsvImportData::setData(csv::DataArray data) { m_data.reset(new csv::DataArray(std::move(data))); m_selected_cols.clear(); m_n_header = 0; @@ -42,8 +37,7 @@ void CsvImportData::setData(csv::DataArray data) m_discarded_rows.clear(); } -int CsvImportData::setColumnAs(int col, csv::ColumnType type) -{ +int CsvImportData::setColumnAs(int col, csv::ColumnType type) { DATA_TYPE role = type == csv::_intensity_ ? Intensity : Coordinate; CsvCoordinateColumn& column = m_selected_cols[role]; @@ -64,30 +58,26 @@ int CsvImportData::setColumnAs(int col, csv::ColumnType type) return prev_assigned; } -void CsvImportData::setMultiplier(CsvImportData::DATA_TYPE type, double value) -{ +void CsvImportData::setMultiplier(CsvImportData::DATA_TYPE type, double value) { if (m_selected_cols.find(type) == m_selected_cols.end()) return; m_selected_cols[type].setMultiplier(value); } -void CsvImportData::setFirstRow(size_t row) -{ +void CsvImportData::setFirstRow(size_t row) { if (row >= nRows()) return; m_n_header = row; } -void CsvImportData::setLastRow(size_t row) -{ +void CsvImportData::setLastRow(size_t row) { if (row + 1 >= nRows()) return; m_n_footer = nRows() - row - 1; } -void CsvImportData::toggleDiscardRows(std::set<int> rows) -{ +void CsvImportData::toggleDiscardRows(std::set<int> rows) { if (rows.empty()) { m_discarded_rows.clear(); return; @@ -101,24 +91,20 @@ void CsvImportData::toggleDiscardRows(std::set<int> rows) } } -std::vector<CsvImportData::DATA_TYPE> CsvImportData::availableTypes() -{ +std::vector<CsvImportData::DATA_TYPE> CsvImportData::availableTypes() { return {Intensity, Coordinate}; } -const csv::DataArray& CsvImportData::data() const -{ +const csv::DataArray& CsvImportData::data() const { return *m_data.get(); } -int CsvImportData::column(DATA_TYPE type) const -{ +int CsvImportData::column(DATA_TYPE type) const { auto iter = m_selected_cols.find(type); return iter == m_selected_cols.end() ? -1 : iter->second.columnNumber(); } -csv::DataColumn CsvImportData::values(int col) const -{ +csv::DataColumn CsvImportData::values(int col) const { if (col < 0 || col >= static_cast<int>(nCols())) return {}; @@ -129,8 +115,7 @@ csv::DataColumn CsvImportData::values(int col) const return result; } -csv::DataColumn CsvImportData::multipliedValues(DATA_TYPE type) const -{ +csv::DataColumn CsvImportData::multipliedValues(DATA_TYPE type) const { csv::DataColumn result; const int col = column(type); if (col < 0 || col >= static_cast<int>(nCols())) @@ -151,22 +136,19 @@ csv::DataColumn CsvImportData::multipliedValues(DATA_TYPE type) const return result; } -double CsvImportData::multiplier(CsvImportData::DATA_TYPE type) const -{ +double CsvImportData::multiplier(CsvImportData::DATA_TYPE type) const { if (m_selected_cols.find(type) == m_selected_cols.end()) return 1.0; return m_selected_cols.at(type).multiplier(); } -QString CsvImportData::columnLabel(CsvImportData::DATA_TYPE type) const -{ +QString CsvImportData::columnLabel(CsvImportData::DATA_TYPE type) const { if (m_selected_cols.find(type) == m_selected_cols.end()) return ""; return csv::HeaderLabels[m_selected_cols.at(type).name()]; } -QList<QString> CsvImportData::availableCoordinateUnits() const -{ +QList<QString> CsvImportData::availableCoordinateUnits() const { if (column(Coordinate) < 0) return {axisUnitLabel.at(Axes::Units::NBINS)}; @@ -178,20 +160,17 @@ QList<QString> CsvImportData::availableCoordinateUnits() const return {axisUnitLabel.at(Axes::Units::NBINS)}; } -size_t CsvImportData::nCols() const -{ +size_t CsvImportData::nCols() const { if (nRows() == 0) return 0; return (*m_data)[0].size(); } -size_t CsvImportData::nRows() const -{ +size_t CsvImportData::nRows() const { return (*m_data).size(); } -bool CsvImportData::rowExcluded(int row) -{ +bool CsvImportData::rowExcluded(int row) { if (static_cast<size_t>(row) < m_n_header || static_cast<size_t>(row) + m_n_footer >= nRows()) return true; if (m_discarded_rows.find(row) != m_discarded_rows.end()) @@ -199,8 +178,7 @@ bool CsvImportData::rowExcluded(int row) return false; } -std::set<std::pair<int, int>> CsvImportData::checkData() -{ +std::set<std::pair<int, int>> CsvImportData::checkData() { std::set<std::pair<int, int>> result; for (auto type : availableTypes()) { auto col_result = checkFormat(multipliedValues(type), type == Coordinate); @@ -211,16 +189,14 @@ std::set<std::pair<int, int>> CsvImportData::checkData() return result; } -void CsvImportData::resetSelection() -{ +void CsvImportData::resetSelection() { m_n_header = 0; m_n_footer = 0; m_selected_cols.clear(); m_discarded_rows.clear(); } -std::set<int> CsvImportData::checkFormat(const csv::DataColumn& values, bool check_ordering) -{ +std::set<int> CsvImportData::checkFormat(const csv::DataColumn& values, bool check_ordering) { std::set<int> result; if (values.empty()) return result; @@ -253,12 +229,9 @@ std::set<int> CsvImportData::checkFormat(const csv::DataColumn& values, bool che } CsvImportTable::CsvImportTable(QWidget* parent) - : QTableWidget(parent), m_import_data(new CsvImportData(this)), m_data_is_suitable(true) -{ -} + : QTableWidget(parent), m_import_data(new CsvImportData(this)), m_data_is_suitable(true) {} -int CsvImportTable::selectedRow() const -{ +int CsvImportTable::selectedRow() const { auto selectedRanges = this->selectedRanges(); if (selectedRanges.empty()) return -1; @@ -267,8 +240,7 @@ int CsvImportTable::selectedRow() const return row - rowOffset(); } -std::set<int> CsvImportTable::selectedRows() const -{ +std::set<int> CsvImportTable::selectedRows() const { std::set<int> accumulator; auto selection = selectedRanges(); @@ -286,8 +258,7 @@ std::set<int> CsvImportTable::selectedRows() const return accumulator; } -int CsvImportTable::selectedColumn() const -{ +int CsvImportTable::selectedColumn() const { auto selectedRanges = this->selectedRanges(); if (selectedRanges.empty()) return -1; @@ -296,8 +267,7 @@ int CsvImportTable::selectedColumn() const return col; } -void CsvImportTable::setData(csv::DataArray data) -{ +void CsvImportTable::setData(csv::DataArray data) { if (data.empty()) { clearContents(); setRowCount(0); @@ -325,58 +295,49 @@ void CsvImportTable::setData(csv::DataArray data) setMultiplierFields(); } -void CsvImportTable::setColumnAs(int col, csv::ColumnType type) -{ +void CsvImportTable::setColumnAs(int col, csv::ColumnType type) { int prev_col = m_import_data->setColumnAs(col, type); resetColumn(prev_col); updateSelection(); } -void CsvImportTable::setFirstRow(size_t row) -{ +void CsvImportTable::setFirstRow(size_t row) { if (row == m_import_data->firstRow()) return; m_import_data->setFirstRow(row); updateSelection(); } -void CsvImportTable::setLastRow(size_t row) -{ +void CsvImportTable::setLastRow(size_t row) { if (row == m_import_data->lastRow()) return; m_import_data->setLastRow(row); updateSelection(); } -void CsvImportTable::discardRows(std::set<int> rows) -{ +void CsvImportTable::discardRows(std::set<int> rows) { m_import_data->toggleDiscardRows(std::move(rows)); updateSelection(); } -void CsvImportTable::resetSelection() -{ +void CsvImportTable::resetSelection() { m_import_data->resetSelection(); updateSelection(); } -double CsvImportTable::intensityMultiplier() const -{ +double CsvImportTable::intensityMultiplier() const { return m_import_data->multiplier(CsvImportData::Intensity); } -double CsvImportTable::coordinateMultiplier() const -{ +double CsvImportTable::coordinateMultiplier() const { return m_import_data->multiplier(CsvImportData::Coordinate); } -QList<QString> CsvImportTable::availableCoordinateUnits() const -{ +QList<QString> CsvImportTable::availableCoordinateUnits() const { return m_import_data->availableCoordinateUnits(); } -void CsvImportTable::updateSelection() -{ +void CsvImportTable::updateSelection() { setHeaders(); // FIXME: replace re-creation of all spin boxes with blocking/unlocking setMultiplierFields(); @@ -389,8 +350,7 @@ void CsvImportTable::updateSelection() } // FIXME: put filling vertical headers here -void CsvImportTable::setHeaders() -{ +void CsvImportTable::setHeaders() { // Reset header labels QStringList headers; @@ -406,8 +366,7 @@ void CsvImportTable::setHeaders() } } -void CsvImportTable::updateSelectedCols() -{ +void CsvImportTable::updateSelectedCols() { // FIXME: replace recreation of sell items with value assignment for (auto type : CsvImportData::availableTypes()) { csv::DataColumn values = m_import_data->multipliedValues(type); @@ -420,8 +379,7 @@ void CsvImportTable::updateSelectedCols() } } -void CsvImportTable::setMultiplierFields() -{ +void CsvImportTable::setMultiplierFields() { const int n_cols = static_cast<int>(m_import_data->nCols()); for (int n = 0; n < n_cols; ++n) @@ -451,8 +409,7 @@ void CsvImportTable::setMultiplierFields() this->setVerticalHeaderLabels(vhlabels); } -void CsvImportTable::greyoutDiscardedRows() -{ +void CsvImportTable::greyoutDiscardedRows() { int nRows = this->rowCount(); int nCols = this->columnCount(); @@ -463,16 +420,14 @@ void CsvImportTable::greyoutDiscardedRows() } } -bool CsvImportTable::checkData() -{ +bool CsvImportTable::checkData() { auto to_highlight = m_import_data->checkData(); for (auto index : to_highlight) markCell(index.first + rowOffset(), index.second, Qt::red); return to_highlight.empty(); } -void CsvImportTable::resetColumn(int col) -{ +void CsvImportTable::resetColumn(int col) { if (columnCount() >= col || col < 0) return; @@ -483,7 +438,6 @@ void CsvImportTable::resetColumn(int col) } } -void CsvImportTable::markCell(int i, int j, Qt::GlobalColor color) -{ +void CsvImportTable::markCell(int i, int j, Qt::GlobalColor color) { item(i, j)->setBackground(color); } diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h index 6e86e2c352ad3ed25ef6fed943d0ec2460be844e..6913be295cf1fb29d647e9e68a8a41a9ab86ed7b 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h @@ -19,8 +19,7 @@ #include <QTableWidget> #include <set> -class CsvImportData : public QObject -{ +class CsvImportData : public QObject { public: // FIXME: move DATA_TYPE enumeration to csv namespace enum DATA_TYPE { Intensity, Coordinate }; @@ -71,8 +70,7 @@ private: std::set<int> m_discarded_rows; }; -class CsvImportTable : public QTableWidget -{ +class CsvImportTable : public QTableWidget { Q_OBJECT public: CsvImportTable(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvNamespace.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvNamespace.cpp index 782df03d5179efc9297d7a0e16a429e481ce6b6a..65c41428632c3555beb3c1d910c968ae8e48686c 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvNamespace.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvNamespace.cpp @@ -16,8 +16,7 @@ #include <fstream> #include <sstream> -bool csv::isAscii(QString filename) -{ +bool csv::isAscii(QString filename) { return true; // TODO // This function needs to be defined properly (if at all) diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvNamespace.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvNamespace.h index b01311a7a07e1b0908a8529d73a32012a711a077..765d3366af71bc58f97c8414cfe2d4711a4de296 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvNamespace.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvNamespace.h @@ -19,8 +19,7 @@ #include <QStringList> #include <vector> -namespace csv -{ +namespace csv { enum ColumnType { _intensity_, _theta_, _q_ }; const QStringList HeaderLabels{"Intensity", "theta", "q"}; const QStringList UnitsLabels{"default", "bin", "rad", "deg", "mm", "1/nm"}; diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvReader.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvReader.cpp index fb0fcdfd6d8d7f02f026df58f53c08505a37db3a..e3239c487f47c4b0a9dbd1b3188af2fdcbb73263 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvReader.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvReader.cpp @@ -16,18 +16,15 @@ #include <fstream> #include <iostream> -std::string const& CSVRow::operator[](unsigned index) const -{ +std::string const& CSVRow::operator[](unsigned index) const { return m_data[index]; } -unsigned long CSVRow::size() const -{ +unsigned long CSVRow::size() const { return static_cast<unsigned long>(m_data.size()); } -void CSVRow::readNextRow(std::istream& str) -{ +void CSVRow::readNextRow(std::istream& str) { std::string line; std::getline(str, line); std::replace(std::begin(line), std::end(line), '\t', ' '); @@ -46,30 +43,25 @@ void CSVRow::readNextRow(std::istream& str) } } -void CSVRow::setSeparator(char sep) -{ +void CSVRow::setSeparator(char sep) { this->separator = sep; return; } -char CSVRow::getSeparator() -{ +char CSVRow::getSeparator() { return this->separator; } -void CSVRow::addCell(std::string str) -{ +void CSVRow::addCell(std::string str) { m_data.push_back(str); } -void CSVFile::Init() -{ +void CSVFile::Init() { Read(); EqualizeRowLengths(); } -void CSVFile::Read() -{ +void CSVFile::Read() { std::ifstream file(filepath); if (!file.is_open()) { throw std::ios_base::failure("Unable to open file \"" + filepath + "\""); @@ -81,8 +73,7 @@ void CSVFile::Read() } } -void CSVFile::EqualizeRowLengths() -{ +void CSVFile::EqualizeRowLengths() { for (unsigned i = 0; i < NumberOfRows(); i++) { while (rows[i].size() < NumberOfColumns()) { rows[i].addCell(""); @@ -93,34 +84,28 @@ void CSVFile::EqualizeRowLengths() } } -std::vector<std::string> const CSVFile::operator[](unsigned index_i) const -{ +std::vector<std::string> const CSVFile::operator[](unsigned index_i) const { return m_data[index_i]; } -unsigned long CSVFile::NumberOfRows() const -{ +unsigned long CSVFile::NumberOfRows() const { return static_cast<unsigned long>(rows.size()); } -unsigned long CSVFile::NumberOfColumns() const -{ +unsigned long CSVFile::NumberOfColumns() const { return this->numberOfColumns; } -void CSVFile::set_separator(char sep) -{ +void CSVFile::set_separator(char sep) { this->separator = sep; return; } -char CSVFile::get_separator() -{ +char CSVFile::get_separator() { return this->separator; } -CSVRow CSVFile::get_headers() -{ +CSVRow CSVFile::get_headers() { if (headersRow > 0) { return this->rows[headersRow - 1]; } else { @@ -131,7 +116,6 @@ CSVRow CSVFile::get_headers() } } -CSVRow CSVFile::get_row(unsigned i) -{ +CSVRow CSVFile::get_row(unsigned i) { return this->rows[i]; } diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvReader.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvReader.h index 5b61b96d657f825fd26e06f6162adfe8a3ee0ce8..691daf43e7322c5e10d5581c3c7137be62fb597a 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvReader.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvReader.h @@ -22,8 +22,7 @@ #include <sstream> #include <vector> -class CSVRow -{ +class CSVRow { public: std::string const& operator[](unsigned index) const; unsigned long size() const; @@ -38,14 +37,12 @@ private: char separator = '-'; }; -inline std::istream& operator>>(std::istream& str, CSVRow& data) -{ +inline std::istream& operator>>(std::istream& str, CSVRow& data) { data.readNextRow(str); return str; } -class CSVIterator -{ +class CSVIterator { public: typedef std::input_iterator_tag iterator_category; typedef CSVRow value_type; @@ -53,16 +50,14 @@ public: typedef CSVRow* pointer; typedef CSVRow& reference; - CSVIterator(std::istream& str, char sep) : m_str(str.good() ? &str : nullptr) - { + CSVIterator(std::istream& str, char sep) : m_str(str.good() ? &str : nullptr) { m_sep = sep; ++(*this); } CSVIterator() : m_str(nullptr) {} // Pre Increment - CSVIterator& operator++() - { + CSVIterator& operator++() { if (m_str) { m_row.setSeparator(m_sep); if (!((*m_str) >> m_row)) { @@ -72,16 +67,14 @@ public: return *this; } // Post increment - CSVIterator operator++(int) - { + CSVIterator operator++(int) { CSVIterator tmp(*this); ++(*this); return tmp; } CSVRow const& operator*() const { return m_row; } CSVRow const* operator->() const { return &m_row; } - bool operator==(CSVIterator const& rhs) - { + bool operator==(CSVIterator const& rhs) { return ((this == &rhs) || ((this->m_str == nullptr) && (rhs.m_str == nullptr))); } bool operator!=(CSVIterator const& rhs) { return !((*this) == rhs); } @@ -92,14 +85,12 @@ private: char m_sep; }; -class CSVFile -{ +class CSVFile { public: CSVFile(std::string path_to_file) : filepath(path_to_file) { Init(); } CSVFile(std::string path_to_file, char sep) : filepath(path_to_file), separator(sep) { Init(); } CSVFile(std::string path_to_file, char sep, unsigned headRow) - : filepath(path_to_file), separator(sep), headersRow(headRow) - { + : filepath(path_to_file), separator(sep), headersRow(headRow) { Init(); } diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/DataSelector.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/DataSelector.cpp index 9534ca9beaae8a940c4f5ac2854edfe075ed01a7..01361c69e65199c576a8985fa2144a8323ed6c15 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/DataSelector.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/DataSelector.cpp @@ -28,8 +28,7 @@ #include <locale> #include <sstream> -namespace -{ +namespace { const QSize default_dialog_size(300, 400); } @@ -43,8 +42,7 @@ DataSelector::DataSelector(csv::DataArray csvArray, QWidget* parent) , m_coordinateUnitsComboBox(nullptr) , m_importButton(nullptr) , m_cancelButton(nullptr) - , m_errorLabel(nullptr) -{ + , m_errorLabel(nullptr) { setWindowTitle("Data Importer"); setMinimumSize(default_dialog_size); resize(600, 600); @@ -56,8 +54,7 @@ DataSelector::DataSelector(csv::DataArray csvArray, QWidget* parent) return; } -bool DataSelector::updateData() -{ +bool DataSelector::updateData() { size_t lastRow = m_data.size(); if (lastRow < 1) { @@ -74,13 +71,11 @@ bool DataSelector::updateData() return true; } -void DataSelector::setColumnSlot(csv::ColumnType ct) -{ +void DataSelector::setColumnSlot(csv::ColumnType ct) { setColumnAs(ct); } -bool DataSelector::isInsideTable(const QPoint position) -{ +bool DataSelector::isInsideTable(const QPoint position) { auto item = m_tableWidget->itemAt(position); if (!item) @@ -94,8 +89,7 @@ bool DataSelector::isInsideTable(const QPoint position) return true; } -void DataSelector::onColumnRightClick(const QPoint& position) -{ +void DataSelector::onColumnRightClick(const QPoint& position) { if (!isInsideTable(position)) return; @@ -113,8 +107,7 @@ void DataSelector::onColumnRightClick(const QPoint& position) contextMenu.exec(globalPos); } -void DataSelector::updateSelection() -{ +void DataSelector::updateSelection() { m_importButton->setEnabled(false); m_coordinateUnitsComboBox->setEnabled(false); m_tableWidget->setFirstRow(firstLine() - 1); @@ -147,23 +140,20 @@ void DataSelector::updateSelection() } } -void DataSelector::setColumnAs(int col, csv::ColumnType coordOrInt) -{ +void DataSelector::setColumnAs(int col, csv::ColumnType coordOrInt) { m_tableWidget->setColumnAs(col, coordOrInt); populateUnitsComboBox(); updateSelection(); } -void DataSelector::populateUnitsComboBox() -{ +void DataSelector::populateUnitsComboBox() { QList<QString> available_units = m_tableWidget->availableCoordinateUnits(); m_coordinateUnitsComboBox->clear(); for (auto units : available_units) m_coordinateUnitsComboBox->addItem(units); } -void DataSelector::setColumnAs(csv::ColumnType coordOrInt) -{ +void DataSelector::setColumnAs(csv::ColumnType coordOrInt) { auto col = m_tableWidget->selectedColumn(); if (col < 0) return; @@ -171,8 +161,7 @@ void DataSelector::setColumnAs(csv::ColumnType coordOrInt) setColumnAs(col, coordOrInt); } -void DataSelector::setFirstRow() -{ +void DataSelector::setFirstRow() { auto row = m_tableWidget->selectedRow(); if (row < 0) return; @@ -185,8 +174,7 @@ void DataSelector::setFirstRow() m_tableWidget->setFirstRow(size_t(row)); } -void DataSelector::setLastRow() -{ +void DataSelector::setLastRow() { auto row = m_tableWidget->selectedRow(); if (row < 0) return; @@ -199,36 +187,30 @@ void DataSelector::setLastRow() m_tableWidget->setLastRow(size_t(row)); } -void DataSelector::discardRow() -{ +void DataSelector::discardRow() { std::set<int> selection = m_tableWidget->selectedRows(); m_tableWidget->discardRows(selection); } -void DataSelector::resetSelection() -{ +void DataSelector::resetSelection() { m_firstDataRowSpinBox->setValue(0); m_lastDataRowSpinBox->setValue(int(maxLines())); m_tableWidget->resetSelection(); } -size_t DataSelector::firstLine() const -{ +size_t DataSelector::firstLine() const { return size_t(m_firstDataRowSpinBox->value()); } -size_t DataSelector::lastLine() const -{ +size_t DataSelector::lastLine() const { return size_t(m_lastDataRowSpinBox->value()); } -size_t DataSelector::maxLines() const -{ +size_t DataSelector::maxLines() const { return size_t(m_lastDataRowSpinBox->maximum()); } -Axes::Units DataSelector::units() const -{ +Axes::Units DataSelector::units() const { for (int i = 0; i < csv::UnitsLabels.size(); i++) { const Axes::Units u = static_cast<Axes::Units>(i); if (m_coordinateUnitsComboBox->currentText() == QString(axisUnitLabel.at(u))) @@ -237,8 +219,7 @@ Axes::Units DataSelector::units() const return Axes::Units::NBINS; // default } -char DataSelector::separator() const -{ +char DataSelector::separator() const { char separator; QString tmpstr = m_separatorField->text(); if (tmpstr.size() < 1) { @@ -249,20 +230,17 @@ char DataSelector::separator() const return separator; } -void DataSelector::onCancelButton() -{ +void DataSelector::onCancelButton() { reject(); } -void DataSelector::onImportButton() -{ +void DataSelector::onImportButton() { // We shouldn't be here if the data is // not previously sanitised. accept(); } -QBoxLayout* DataSelector::createLayout() -{ +QBoxLayout* DataSelector::createLayout() { // table Widget m_tableWidget = new CsvImportTable(); m_tableWidget->setContextMenuPolicy(Qt::CustomContextMenu); diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/DataSelector.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/DataSelector.h index ea1b1536822b53d0ffbd42a8985fc001d18093e1..3fededf711598d093683897fd519ebb872b9d3be 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/DataSelector.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/DataSelector.h @@ -29,8 +29,7 @@ class QBoxLayout; //! Dialog to hold DataSelector. -class DataSelector : public QDialog -{ +class DataSelector : public QDialog { Q_OBJECT public: DataSelector(csv::DataArray csvArray, QWidget* parent = nullptr); @@ -42,14 +41,12 @@ public: double coordinateMultiplier() const { return m_tableWidget->coordinateMultiplier(); } std::set<int> rowsToDiscard() const { return m_tableWidget->rowsToDiscard(); } Axes::Units units() const; - void setDataArray(csv::DataArray csvArray) - { + void setDataArray(csv::DataArray csvArray) { m_data = std::move(csvArray); updateData(); resetSelection(); } - void setSeparator(char newSeparator) - { + void setSeparator(char newSeparator) { m_separatorField->setText(QString(QChar(newSeparator))); } diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/TableContextMenu.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/TableContextMenu.cpp index cd47a421f2e6eec611e934192412e400f53e9635..5f2020c87de809c662d44d28f0de28f04e3b11c6 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/TableContextMenu.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/TableContextMenu.cpp @@ -24,8 +24,7 @@ TableContextMenu::TableContextMenu(QWidget* parent) , m_setAsQ(new QAction(csv::HeaderLabels[csv::_q_], this)) , m_setAsIntensity( new QAction("Set As " + csv::HeaderLabels[csv::_intensity_] + " Column", this)) - , m_discardRow(new QAction("Toogle Discard Selected Rows", this)) -{ + , m_discardRow(new QAction("Toogle Discard Selected Rows", this)) { this->addAction(m_selectFromThisRowOn); this->addAction(m_selectUntilThisRow); this->addAction(m_discardRow); diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/TableContextMenu.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/TableContextMenu.h index adcdc7701baecc4325a6966478c2e9ec45055eb7..1e6d2ecb413c58c304e8ee25c916d89fef72612d 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/TableContextMenu.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/TableContextMenu.h @@ -21,8 +21,7 @@ #include <QStringList> #include <QTableWidget> -class TableContextMenu : public QMenu -{ +class TableContextMenu : public QMenu { Q_OBJECT public: TableContextMenu(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp b/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp index d7324e399eac97c301201c2e3c9cdd52b1f3bf97..5d7a2c4a0ac7a029d953cdafcb288fc67f52f461 100644 --- a/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp @@ -27,26 +27,22 @@ #include <QFileInfo> #include <QMessageBox> -namespace -{ +namespace { const QString filter_string_ba = "Intensity File (*.int *.gz *.tif *.tiff *.txt *.csv);;" "Other (*.*)"; const QString filter_string_ascii = "Intensity File (*.int *.int.gz *.txt *.csv *.dat *.ascii);;" "Ascii column-wise data (*.*)"; -int rank(const RealDataItem& item) -{ +int rank(const RealDataItem& item) { return static_cast<int>(item.shape().size()); } -int rank(const InstrumentItem& item) -{ +int rank(const InstrumentItem& item) { return static_cast<int>(item.shape().size()); } } // namespace -std::unique_ptr<OutputData<double>> ImportDataUtils::ImportKnownData(QString& fileName) -{ +std::unique_ptr<OutputData<double>> ImportDataUtils::ImportKnownData(QString& fileName) { // Try to use the canonical tools for importing data std::unique_ptr<OutputData<double>> result; try { @@ -62,8 +58,7 @@ std::unique_ptr<OutputData<double>> ImportDataUtils::ImportKnownData(QString& fi return result; } -std::unique_ptr<OutputData<double>> ImportDataUtils::ImportReflectometryData(QString& fileName) -{ +std::unique_ptr<OutputData<double>> ImportDataUtils::ImportReflectometryData(QString& fileName) { std::unique_ptr<OutputData<double>> result; try { std::unique_ptr<OutputData<double>> data( @@ -78,13 +73,11 @@ std::unique_ptr<OutputData<double>> ImportDataUtils::ImportReflectometryData(QSt return result; } -std::unique_ptr<OutputData<double>> ImportDataUtils::Import2dData(QString& fileName) -{ +std::unique_ptr<OutputData<double>> ImportDataUtils::Import2dData(QString& fileName) { return ImportKnownData(fileName); } -ImportDataInfo ImportDataUtils::Import1dData(QString& fileName) -{ +ImportDataInfo ImportDataUtils::Import1dData(QString& fileName) { if (DataFormatUtils::isCompressed(fileName.toStdString()) || DataFormatUtils::isIntFile(fileName.toStdString()) || DataFormatUtils::isTiffFile(fileName.toStdString())) { @@ -110,8 +103,7 @@ ImportDataInfo ImportDataUtils::Import1dData(QString& fileName) } } -ImportDataInfo ImportDataUtils::getFromImportAssistant(QString& fileName) -{ +ImportDataInfo ImportDataUtils::getFromImportAssistant(QString& fileName) { if (!csv::isAscii(fileName)) { QString message = QString( @@ -136,14 +128,12 @@ ImportDataInfo ImportDataUtils::getFromImportAssistant(QString& fileName) } bool ImportDataUtils::Compatible(const InstrumentItem& instrumentItem, - const RealDataItem& realDataItem) -{ + const RealDataItem& realDataItem) { return rank(instrumentItem) == rank(realDataItem); } std::unique_ptr<OutputData<double>> -ImportDataUtils::CreateSimplifiedOutputData(const OutputData<double>& data) -{ +ImportDataUtils::CreateSimplifiedOutputData(const OutputData<double>& data) { const size_t data_rank = data.rank(); if (data_rank > 2 || data_rank < 1) throw std::runtime_error("Error in ImportDataUtils::CreateSimplifiedOutputData: passed " @@ -163,8 +153,7 @@ ImportDataUtils::CreateSimplifiedOutputData(const OutputData<double>& data) } QString ImportDataUtils::printShapeMessage(const std::vector<int>& instrument_shape, - const std::vector<int>& data_shape) -{ + const std::vector<int>& data_shape) { auto to_str = [](const std::vector<int>& shape) { std::string result; for (size_t i = 0, size = shape.size(); i < size; ++i) { diff --git a/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.h b/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.h index e7ab94e38407252ce28d347f449f372dd62dd1cf..4d579d7e45e4bd9d7e1df4bbab5a6904ec2c1a48 100644 --- a/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.h +++ b/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.h @@ -27,8 +27,7 @@ class GISASInstrumentItem; //! Provides utility methods to import data files. -namespace ImportDataUtils -{ +namespace ImportDataUtils { std::unique_ptr<OutputData<double>> Import2dData(QString& baseNameOfLoadedFile); ImportDataInfo Import1dData(QString& baseNameOfLoadedFile); std::unique_ptr<OutputData<double>> ImportKnownData(QString& baseNameOfLoadedFile); diff --git a/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.cpp b/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.cpp index 77e40772031256b9806dac3379f66dd83b5061c1..107b9c63ffbf58698e470fbcbe601281dc3e7698 100644 --- a/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.cpp @@ -24,28 +24,22 @@ #include <QMessageBox> #include <QPushButton> -namespace -{ +namespace { const QString undefinedInstrumentName = "Undefined"; bool QuestionOnInstrumentReshaping(const QString& message); } // namespace LinkInstrumentManager::InstrumentInfo::InstrumentInfo() - : m_name(undefinedInstrumentName), m_instrument(nullptr) -{ -} + : m_name(undefinedInstrumentName), m_instrument(nullptr) {} LinkInstrumentManager::LinkInstrumentManager(QObject* parent) - : QObject(parent), m_instrumentModel(nullptr), m_realDataModel(nullptr) -{ -} + : QObject(parent), m_instrumentModel(nullptr), m_realDataModel(nullptr) {} //! Sets models and builds initial links. void LinkInstrumentManager::setModels(InstrumentModel* instrumentModel, - RealDataModel* realDataModel) -{ + RealDataModel* realDataModel) { setInstrumentModel(instrumentModel); setRealDataModel(realDataModel); updateInstrumentMap(); @@ -55,8 +49,7 @@ void LinkInstrumentManager::setModels(InstrumentModel* instrumentModel, //! Returns InstrumentItem for given identifier. -InstrumentItem* LinkInstrumentManager::instrument(const QString& identifier) -{ +InstrumentItem* LinkInstrumentManager::instrument(const QString& identifier) { for (int i = 0; i < m_instrumentVec.size(); ++i) if (m_instrumentVec[i].m_identifier == identifier) return m_instrumentVec[i].m_instrument; @@ -66,8 +59,7 @@ InstrumentItem* LinkInstrumentManager::instrument(const QString& identifier) //! Returns list of instrument names including artificial name "Undefined". -QStringList LinkInstrumentManager::instrumentNames() const -{ +QStringList LinkInstrumentManager::instrumentNames() const { QStringList result; for (int i = 0; i < m_instrumentVec.size(); ++i) result.append(m_instrumentVec[i].m_name); @@ -76,8 +68,7 @@ QStringList LinkInstrumentManager::instrumentNames() const //! Returns combo index for instrument selector from given identifier. -int LinkInstrumentManager::instrumentComboIndex(const QString& identifier) -{ +int LinkInstrumentManager::instrumentComboIndex(const QString& identifier) { for (int i = 0; i < m_instrumentVec.size(); ++i) if (m_instrumentVec[i].m_identifier == identifier) return i; @@ -87,8 +78,7 @@ int LinkInstrumentManager::instrumentComboIndex(const QString& identifier) //! Returns instrument identifier from given index in combo instrument selector. -QString LinkInstrumentManager::instrumentIdentifier(int comboIndex) -{ +QString LinkInstrumentManager::instrumentIdentifier(int comboIndex) { ASSERT(comboIndex >= 0 && comboIndex < m_instrumentVec.size()); return m_instrumentVec[comboIndex].m_identifier; } @@ -97,8 +87,7 @@ QString LinkInstrumentManager::instrumentIdentifier(int comboIndex) //! Also offers dialog to adjust instrument to match shape of real data. bool LinkInstrumentManager::canLinkDataToInstrument(const RealDataItem* realDataItem, - const QString& identifier) -{ + const QString& identifier) { auto instrumentItem = instrument(identifier); // linking to null instrument is possible, it means unlinking from currently linked @@ -128,8 +117,7 @@ bool LinkInstrumentManager::canLinkDataToInstrument(const RealDataItem* realData //! Calls rebuild of instrument map if the name or identifier of the instrument have changed. void LinkInstrumentManager::setOnInstrumentPropertyChange(SessionItem* instrument, - const QString& property) -{ + const QString& property) { Q_UNUSED(instrument); if (property == SessionItem::P_NAME || property == InstrumentItem::P_IDENTIFIER) updateInstrumentMap(); @@ -138,8 +126,7 @@ void LinkInstrumentManager::setOnInstrumentPropertyChange(SessionItem* instrumen //! Link or re-link RealDataItem to the instrument on identifier change. void LinkInstrumentManager::setOnRealDataPropertyChange(SessionItem* dataItem, - const QString& property) -{ + const QString& property) { if (property == RealDataItem::P_INSTRUMENT_ID) { RealDataItem* realDataItem = dynamic_cast<RealDataItem*>(dataItem); QString identifier = dataItem->getItemValue(RealDataItem::P_INSTRUMENT_ID).toString(); @@ -149,8 +136,8 @@ void LinkInstrumentManager::setOnRealDataPropertyChange(SessionItem* dataItem, //! Perform actions on instrument children change. -void LinkInstrumentManager::onInstrumentChildChange(InstrumentItem* instrument, SessionItem* child) -{ +void LinkInstrumentManager::onInstrumentChildChange(InstrumentItem* instrument, + SessionItem* child) { if (child == nullptr) return; @@ -159,8 +146,7 @@ void LinkInstrumentManager::onInstrumentChildChange(InstrumentItem* instrument, //! Updates map of instruments on insert/remove InstrumentItem event. -void LinkInstrumentManager::onInstrumentRowsChange(const QModelIndex& parent, int, int) -{ +void LinkInstrumentManager::onInstrumentRowsChange(const QModelIndex& parent, int, int) { // valid parent means not an instrument (which is top level item) but something below if (parent.isValid()) return; @@ -171,8 +157,7 @@ void LinkInstrumentManager::onInstrumentRowsChange(const QModelIndex& parent, in //! Updates map of data on insert/remove RealDataItem event. -void LinkInstrumentManager::onRealDataRowsChange(const QModelIndex& parent, int, int) -{ +void LinkInstrumentManager::onRealDataRowsChange(const QModelIndex& parent, int, int) { // valid parent means not a data (which is top level item) but something below if (parent.isValid()) return; @@ -183,8 +168,7 @@ void LinkInstrumentManager::onRealDataRowsChange(const QModelIndex& parent, int, //! Runs through all RealDataItem and check all links. -void LinkInstrumentManager::updateLinks() -{ +void LinkInstrumentManager::updateLinks() { for (auto realDataItem : m_realDataModel->topItems<RealDataItem>()) { QString identifier = realDataItem->getItemValue(RealDataItem::P_INSTRUMENT_ID).toString(); auto instrumentItem = instrument(identifier); @@ -201,8 +185,7 @@ void LinkInstrumentManager::updateLinks() //! Builds the map of existing instruments, their names, identifiers and sets up callbacks. -void LinkInstrumentManager::updateInstrumentMap() -{ +void LinkInstrumentManager::updateInstrumentMap() { m_instrumentVec.clear(); m_instrumentVec.append(InstrumentInfo()); // undefined instrument for (auto instrumentItem : m_instrumentModel->topItems<InstrumentItem>()) { @@ -232,8 +215,7 @@ void LinkInstrumentManager::updateInstrumentMap() //! Sets callbacks for all RealDataItem. -void LinkInstrumentManager::updateRealDataMap() -{ +void LinkInstrumentManager::updateRealDataMap() { for (auto dataItem : m_realDataModel->topItems<RealDataItem>()) { dataItem->mapper()->unsubscribe(this); @@ -246,8 +228,7 @@ void LinkInstrumentManager::updateRealDataMap() //! Runs through all RealDataItem and refresh linking to match possible change in detector //! axes definition. -void LinkInstrumentManager::onInstrumentLayoutChange(InstrumentItem* changedInstrument) -{ +void LinkInstrumentManager::onInstrumentLayoutChange(InstrumentItem* changedInstrument) { for (auto realDataItem : linkedItems(changedInstrument)) if (!changedInstrument->alignedWith(realDataItem)) realDataItem->setItemValue(RealDataItem::P_INSTRUMENT_ID, QString()); @@ -257,8 +238,7 @@ void LinkInstrumentManager::onInstrumentLayoutChange(InstrumentItem* changedInst //! Returns list of RealDataItem's linked to given instrument. -QList<RealDataItem*> LinkInstrumentManager::linkedItems(InstrumentItem* instrumentItem) -{ +QList<RealDataItem*> LinkInstrumentManager::linkedItems(InstrumentItem* instrumentItem) { QList<RealDataItem*> result; for (auto realDataItem : m_realDataModel->topItems<RealDataItem>()) { QString linkedIdentifier = @@ -274,8 +254,7 @@ QList<RealDataItem*> LinkInstrumentManager::linkedItems(InstrumentItem* instrume //! Sets connections for instrument model. -void LinkInstrumentManager::setInstrumentModel(InstrumentModel* model) -{ +void LinkInstrumentManager::setInstrumentModel(InstrumentModel* model) { if (m_instrumentModel) { disconnect(m_instrumentModel, &InstrumentModel::rowsInserted, this, &LinkInstrumentManager::onInstrumentRowsChange); @@ -295,8 +274,7 @@ void LinkInstrumentManager::setInstrumentModel(InstrumentModel* model) //! Sets connections for real data model. -void LinkInstrumentManager::setRealDataModel(RealDataModel* model) -{ +void LinkInstrumentManager::setRealDataModel(RealDataModel* model) { if (m_realDataModel) { disconnect(m_realDataModel, &RealDataModel::rowsInserted, this, &LinkInstrumentManager::onRealDataRowsChange); @@ -314,10 +292,8 @@ void LinkInstrumentManager::setRealDataModel(RealDataModel* model) } } -namespace -{ -bool QuestionOnInstrumentReshaping(const QString& message) -{ +namespace { +bool QuestionOnInstrumentReshaping(const QString& message) { QMessageBox msgBox; msgBox.setText("Instrument description conflicts with the experimental data."); diff --git a/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.h b/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.h index 0957fe205d79c570261dcb6a921e7101cfa61194..387745d743741ac53057d66cc0139a851a12d7da 100644 --- a/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.h +++ b/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.h @@ -31,13 +31,11 @@ class SessionModel; //! RealDataModel. Particularly, it notifies RealDataItem about changes in linked instruments //! to adjust axes of IntensityDataItem. -class LinkInstrumentManager : public QObject -{ +class LinkInstrumentManager : public QObject { Q_OBJECT public: - class InstrumentInfo - { + class InstrumentInfo { public: InstrumentInfo(); QString m_identifier; diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataMaskWidget.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataMaskWidget.cpp index b253b6b55d75ba293fcc4659448b12d5c38e9762..4f10bf3385ff00efa2a309de4a783fb466fb49b7 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataMaskWidget.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataMaskWidget.cpp @@ -22,8 +22,7 @@ #include <QBoxLayout> RealDataMaskWidget::RealDataMaskWidget(QWidget* parent) - : SessionItemWidget(parent), m_maskEditor(new MaskEditor) -{ + : SessionItemWidget(parent), m_maskEditor(new MaskEditor) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QHBoxLayout* hlayout = new QHBoxLayout; @@ -40,33 +39,28 @@ RealDataMaskWidget::RealDataMaskWidget(QWidget* parent) setLayout(mainLayout); } -QList<QAction*> RealDataMaskWidget::actionList() -{ +QList<QAction*> RealDataMaskWidget::actionList() { return m_maskEditor->topToolBarActions(); } -void RealDataMaskWidget::subscribeToItem() -{ +void RealDataMaskWidget::subscribeToItem() { auto intensityItem = intensityDataItem(); auto container = maskContainer(intensityItem); m_maskEditor->setMaskContext(intensityItem->model(), container->index(), intensityItem); m_maskEditor->update(); } -void RealDataMaskWidget::unsubscribeFromItem() -{ +void RealDataMaskWidget::unsubscribeFromItem() { m_maskEditor->resetContext(); } -IntensityDataItem* RealDataMaskWidget::intensityDataItem() -{ +IntensityDataItem* RealDataMaskWidget::intensityDataItem() { IntensityDataItem* result = dynamic_cast<RealDataItem*>(currentItem())->intensityDataItem(); ASSERT(result); return result; } -MaskContainerItem* RealDataMaskWidget::maskContainer(IntensityDataItem* intensityData) -{ +MaskContainerItem* RealDataMaskWidget::maskContainer(IntensityDataItem* intensityData) { auto containerItem = intensityData->getItem(IntensityDataItem::T_MASKS); if (!containerItem) containerItem = diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataMaskWidget.h b/GUI/coregui/Views/ImportDataWidgets/RealDataMaskWidget.h index be3f90941f3760ed5af38d0713297984fa9ef0ee..02761c0845dcfaf986485a191a4450b7c8b8afdf 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataMaskWidget.h +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataMaskWidget.h @@ -25,8 +25,7 @@ class MaskContainerItem; //! The RealDataMaskWidget class provides mask editing for RealDataItem on ImportDataView. -class RealDataMaskWidget : public SessionItemWidget -{ +class RealDataMaskWidget : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataPresenter.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataPresenter.cpp index 505839b5ecbeabbd4a5c47293da986e0e135426c..64acde7bbade8b6c8579dff14308c2d840484199 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataPresenter.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataPresenter.cpp @@ -21,21 +21,18 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include <QAction> -RealDataPresenter::RealDataPresenter(QWidget* parent) : ItemComboWidget(parent) -{ +RealDataPresenter::RealDataPresenter(QWidget* parent) : ItemComboWidget(parent) { registerWidget("Color Map", create_new<IntensityDataWidget>); registerWidget("Projections", create_new<IntensityDataProjectionsWidget>); registerWidget("Mask Editor", create_new<RealDataMaskWidget>); registerWidget("Reflectometry", create_new<SpecularDataWidget>); } -QList<QAction*> RealDataPresenter::actionList() -{ +QList<QAction*> RealDataPresenter::actionList() { return QList<QAction*>(); } -QStringList RealDataPresenter::activePresentationList(SessionItem* item) -{ +QStringList RealDataPresenter::activePresentationList(SessionItem* item) { ASSERT(item && dynamic_cast<RealDataItem*>(item)); const auto& underlying_data_model = dynamic_cast<RealDataItem*>(item)->underlyingDataModel(); diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataPresenter.h b/GUI/coregui/Views/ImportDataWidgets/RealDataPresenter.h index f0c57672857e688f59bfba2c4936569bdbf7ecdc..0f4c619334de9ffde7056eb5da6b487e10abc5f5 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataPresenter.h +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataPresenter.h @@ -23,8 +23,7 @@ class QAction; //! Presents imported data (RealDataItem) using stack of different widgets and combo box in the //! right top corner of ImportDataView, to switch between widgets. -class RealDataPresenter : public ItemComboWidget -{ +class RealDataPresenter : public ItemComboWidget { Q_OBJECT public: explicit RealDataPresenter(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataPropertiesWidget.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataPropertiesWidget.cpp index bb150dc7b66eaa823d373f702db14971711a8b26..bbdf0eec3589b64ffdbbaca44fe108fa025cc020 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataPropertiesWidget.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataPropertiesWidget.cpp @@ -22,8 +22,7 @@ #include <QLineEdit> #include <QVBoxLayout> -namespace -{ +namespace { const QString instrumentNameTooltip = "Name of real data"; const QString selectorTooltip = "Select instrument to link with real data"; } // namespace @@ -36,8 +35,7 @@ RealDataPropertiesWidget::RealDataPropertiesWidget(QWidget* parent) , m_dataNameEdit(new QLineEdit) , m_instrumentLabel(new QLabel("Linked instrument")) , m_instrumentCombo(new QComboBox) - , m_currentDataItem(0) -{ + , m_currentDataItem(0) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); setWindowTitle("RealDataPropertiesWidget"); @@ -68,15 +66,13 @@ RealDataPropertiesWidget::RealDataPropertiesWidget(QWidget* parent) //! Sets models to underlying link manager. void RealDataPropertiesWidget::setModels(InstrumentModel* instrumentModel, - RealDataModel* realDataModel) -{ + RealDataModel* realDataModel) { m_linkManager->setModels(instrumentModel, realDataModel); } //! Set current RealDataItem to display in instrument selector. -void RealDataPropertiesWidget::setItem(SessionItem* item) -{ +void RealDataPropertiesWidget::setItem(SessionItem* item) { m_dataNameMapper->clearMapping(); if (item == m_currentDataItem) @@ -114,8 +110,7 @@ void RealDataPropertiesWidget::setItem(SessionItem* item) //! Processes user interaction with instrument selector combo. If there is realDataItem, //! it will be linked with selected instrument. -void RealDataPropertiesWidget::onInstrumentComboIndexChanged(int index) -{ +void RealDataPropertiesWidget::onInstrumentComboIndexChanged(int index) { m_current_id = m_linkManager->instrumentIdentifier(index); if (!m_currentDataItem) @@ -137,8 +132,7 @@ void RealDataPropertiesWidget::onInstrumentComboIndexChanged(int index) //! Updates instrument selector for new instruments and their names. //! Current selection will be preserved. -void RealDataPropertiesWidget::onInstrumentMapUpdate() -{ +void RealDataPropertiesWidget::onInstrumentMapUpdate() { setComboConnected(false); m_instrumentCombo->clear(); m_instrumentCombo->addItems(m_linkManager->instrumentNames()); @@ -155,8 +149,7 @@ void RealDataPropertiesWidget::onInstrumentMapUpdate() //! Updates instrument combo on link change of current RealDataItem. -void RealDataPropertiesWidget::onRealDataPropertyChanged(const QString& name) -{ +void RealDataPropertiesWidget::onRealDataPropertyChanged(const QString& name) { if (name == RealDataItem::P_INSTRUMENT_ID) { setComboToIdentifier( m_currentDataItem->getItemValue(RealDataItem::P_INSTRUMENT_ID).toString()); @@ -165,8 +158,7 @@ void RealDataPropertiesWidget::onRealDataPropertyChanged(const QString& name) //! Sets instrument combo selector to the state corresponding to given instrument identifier. -void RealDataPropertiesWidget::setComboToIdentifier(const QString& identifier) -{ +void RealDataPropertiesWidget::setComboToIdentifier(const QString& identifier) { setComboConnected(false); m_current_id = identifier; int index = m_linkManager->instrumentComboIndex(identifier); @@ -177,8 +169,7 @@ void RealDataPropertiesWidget::setComboToIdentifier(const QString& identifier) //! Sets connected/disconnected for instrument combo selector. -void RealDataPropertiesWidget::setComboConnected(bool isConnected) -{ +void RealDataPropertiesWidget::setComboConnected(bool isConnected) { if (isConnected) { connect(m_instrumentCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onInstrumentComboIndexChanged(int))); @@ -191,8 +182,7 @@ void RealDataPropertiesWidget::setComboConnected(bool isConnected) //! Sets all widget's children enabled/disabled. When no RealDataItem selected all //! will appear in gray. -void RealDataPropertiesWidget::setPropertiesEnabled(bool enabled) -{ +void RealDataPropertiesWidget::setPropertiesEnabled(bool enabled) { m_dataNameLabel->setEnabled(enabled); m_dataNameEdit->setEnabled(enabled); m_instrumentLabel->setEnabled(enabled); diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataPropertiesWidget.h b/GUI/coregui/Views/ImportDataWidgets/RealDataPropertiesWidget.h index 08ddf03cef9d5c9840e51fb3040dd89d9aaa7674..90ad064afaea6d8d1bbf3f15767a4f722ba47533 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataPropertiesWidget.h +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataPropertiesWidget.h @@ -30,8 +30,7 @@ class QLabel; //! The RealDataPropertiesWidget class holds instrument selector to link with RealDataItem. //! Part of RealDataSelectorWidget, resides at lower left corner of ImportDataView. -class RealDataPropertiesWidget : public QWidget -{ +class RealDataPropertiesWidget : public QWidget { Q_OBJECT public: explicit RealDataPropertiesWidget(QWidget* parent = 0); diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.cpp index 09e2070a6b6030e2e2a42c2e4335f290171239b5..1c5d5b0904206a5ea6b0264a55aa21a7814b91fa 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.cpp @@ -29,10 +29,8 @@ #include <QItemSelectionModel> #include <QMenu> -namespace -{ -bool openRotateWarningDialog(QWidget* parent) -{ +namespace { +bool openRotateWarningDialog(QWidget* parent) { const QString title("Rotate data"); const QString message("Rotation will break the link between the data and the instrument. " @@ -44,8 +42,7 @@ bool openRotateWarningDialog(QWidget* parent) //! Returns true, if rotation will affect linked instrument or mask presence. -bool rotationAffectsSetup(IntensityDataItem& intensityItem) -{ +bool rotationAffectsSetup(IntensityDataItem& intensityItem) { if (intensityItem.parent()->getItemValue(RealDataItem::P_INSTRUMENT_ID).toBool()) return true; @@ -61,8 +58,7 @@ bool rotationAffectsSetup(IntensityDataItem& intensityItem) //! Resets linked instruments and masks. -void resetSetup(IntensityDataItem& intensityItem) -{ +void resetSetup(IntensityDataItem& intensityItem) { auto data_parent = intensityItem.parent(); if (data_parent->getItemValue(RealDataItem::P_INSTRUMENT_ID).toBool()) @@ -86,8 +82,7 @@ RealDataSelectorActions::RealDataSelectorActions(QObject* parent) , m_removeDataAction(nullptr) , m_rotateDataAction(new QAction(this)) , m_realDataModel(nullptr) - , m_selectionModel(nullptr) -{ + , m_selectionModel(nullptr) { m_import2dDataAction = new QAction("Import 2D data", parent); m_import2dDataAction->setIcon(QIcon(":/images/import.svg")); m_import2dDataAction->setToolTip("Import 2D data"); @@ -113,18 +108,15 @@ RealDataSelectorActions::RealDataSelectorActions(QObject* parent) &RealDataSelectorActions::onRotateDataRequest); } -void RealDataSelectorActions::setRealDataModel(RealDataModel* model) -{ +void RealDataSelectorActions::setRealDataModel(RealDataModel* model) { m_realDataModel = model; } -void RealDataSelectorActions::setSelectionModel(QItemSelectionModel* selectionModel) -{ +void RealDataSelectorActions::setSelectionModel(QItemSelectionModel* selectionModel) { m_selectionModel = selectionModel; } -void RealDataSelectorActions::importDataLoop(int ndim) -{ +void RealDataSelectorActions::importDataLoop(int ndim) { ASSERT(m_realDataModel); ASSERT(m_selectionModel); QString filter_string_ba; @@ -173,18 +165,15 @@ void RealDataSelectorActions::importDataLoop(int ndim) } } -void RealDataSelectorActions::onImport2dDataAction() -{ +void RealDataSelectorActions::onImport2dDataAction() { importDataLoop(2); } -void RealDataSelectorActions::onImport1dDataAction() -{ +void RealDataSelectorActions::onImport1dDataAction() { importDataLoop(1); } -void RealDataSelectorActions::onRemoveDataAction() -{ +void RealDataSelectorActions::onRemoveDataAction() { QModelIndex currentIndex = m_selectionModel->currentIndex(); if (currentIndex.isValid()) m_realDataModel->removeRows(currentIndex.row(), 1, QModelIndex()); @@ -192,8 +181,7 @@ void RealDataSelectorActions::onRemoveDataAction() updateSelection(); } -void RealDataSelectorActions::onRotateDataRequest() -{ +void RealDataSelectorActions::onRotateDataRequest() { QModelIndex currentIndex = m_selectionModel->currentIndex(); if (!currentIndex.isValid()) return; @@ -223,8 +211,7 @@ void RealDataSelectorActions::onRotateDataRequest() } void RealDataSelectorActions::onContextMenuRequest(const QPoint& point, - const QModelIndex& indexAtPoint) -{ + const QModelIndex& indexAtPoint) { QMenu menu; menu.setToolTipsVisible(true); @@ -241,16 +228,14 @@ void RealDataSelectorActions::onContextMenuRequest(const QPoint& point, menu.exec(point); } -void RealDataSelectorActions::setAllActionsEnabled(bool value) -{ +void RealDataSelectorActions::setAllActionsEnabled(bool value) { m_import2dDataAction->setEnabled(value); m_import1dDataAction->setEnabled(value); m_rotateDataAction->setEnabled(value); m_removeDataAction->setEnabled(value); } -void RealDataSelectorActions::updateSelection() -{ +void RealDataSelectorActions::updateSelection() { if (!m_selectionModel->hasSelection()) { // select last item QModelIndex itemIndex = diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.h b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.h index e4ba5e63ea5de980514b8076747e7e964e0ce475..5856def885625ad5babc2a92169cac8eeaea9db1 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.h +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.h @@ -24,8 +24,7 @@ class QItemSelectionModel; //! The RealDataSelectorActions class contains actions to run/remove real data. //! Actions are used by the toolbar and context menu of selector list. -class RealDataSelectorActions : public QObject -{ +class RealDataSelectorActions : public QObject { Q_OBJECT public: RealDataSelectorActions(QObject* parent = nullptr); diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorHBar.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorHBar.cpp index ac4053af3211017a0f4453e6c7eb26ffd9afcc40..5f2bcc3720746bb97279c6b15a3e52a436d6eb19 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorHBar.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorHBar.cpp @@ -17,14 +17,12 @@ #include <QMenu> #include <QToolButton> -namespace -{ +namespace { const int toolbar_icon_size = 24; } RealDataSelectorHBar::RealDataSelectorHBar(RealDataSelectorActions* actions, QWidget* parent) - : QToolBar(parent), m_dropDownMenuButton(nullptr), m_actions(actions) -{ + : QToolBar(parent), m_dropDownMenuButton(nullptr), m_actions(actions) { setIconSize(QSize(toolbar_icon_size, toolbar_icon_size)); setProperty("_q_custom_style_disabled", QVariant(true)); @@ -40,8 +38,7 @@ RealDataSelectorHBar::RealDataSelectorHBar(RealDataSelectorActions* actions, QWi addWidget(m_dropDownMenuButton); } -void RealDataSelectorHBar::onDropDownMenuRequest() -{ +void RealDataSelectorHBar::onDropDownMenuRequest() { QMenu menu; menu.setToolTipsVisible(true); auto action = menu.addAction("Import 1D data"); diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorHBar.h b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorHBar.h index e2fc9e148854d988ae2c6a8fdbdf3d2b33cdec4c..f360bbcb39275df622d008e97cd038d6e47c04a3 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorHBar.h +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorHBar.h @@ -22,8 +22,7 @@ class QToolButton; //! Toolbar on top of selector tree with hamburger-like menu button. -class RealDataSelectorHBar : public QToolBar -{ +class RealDataSelectorHBar : public QToolBar { Q_OBJECT public: RealDataSelectorHBar(RealDataSelectorActions* actions, QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorToolBar.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorToolBar.cpp index c928ff6493fa427d6b7969f72c02164dfcaff5e4..3d5b2051571a812dd7a5ac6664a5393e30328939 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorToolBar.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorToolBar.cpp @@ -20,8 +20,7 @@ RealDataSelectorToolBar::RealDataSelectorToolBar(RealDataSelectorActions* action : StyledToolBar(parent) , m_import2dDataButton(new QToolButton) , m_import1dDataButton(new QToolButton) - , m_removeDataButton(new QToolButton) -{ + , m_removeDataButton(new QToolButton) { setMinimumSize(minimumHeight(), minimumHeight()); m_import2dDataButton->setText("Import 2D"); diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorToolBar.h b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorToolBar.h index bbebeb840c3208e21cfbd8b7e89ef90a1f14e7db..b71d539da03a4724a5dcdae2908f47072e263e40 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorToolBar.h +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorToolBar.h @@ -23,8 +23,7 @@ class QToolButton; //! The RealDataSelectorToolBar class represents a narrow toolbar on top of //! RealDataSelectorWidget (ImportDataView) -class RealDataSelectorToolBar : public StyledToolBar -{ +class RealDataSelectorToolBar : public StyledToolBar { Q_OBJECT public: RealDataSelectorToolBar(RealDataSelectorActions* actions, QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp index 3922002544cfccecb44e686966cc5f3a88d1d932..fdeb08bcea135d7ffbbf40c0907e0c112346edc2 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp @@ -30,8 +30,7 @@ RealDataSelectorWidget::RealDataSelectorWidget(QWidget* parent) , m_hamBar(new RealDataSelectorHBar(m_selectorActions, this)) , m_splitter(new Manhattan::MiniSplitter) , m_selectorWidget(new ItemSelectorWidget) - , m_propertiesWidget(new RealDataPropertiesWidget) -{ + , m_propertiesWidget(new RealDataPropertiesWidget) { setMinimumSize(128, 600); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); setWindowTitle("RealDataSelectorWidget"); @@ -57,19 +56,16 @@ RealDataSelectorWidget::RealDataSelectorWidget(QWidget* parent) &RealDataSelectorWidget::onSelectionChanged); } -QSize RealDataSelectorWidget::sizeHint() const -{ +QSize RealDataSelectorWidget::sizeHint() const { return QSize(200, 400); } -QSize RealDataSelectorWidget::minimumSizeHint() const -{ +QSize RealDataSelectorWidget::minimumSizeHint() const { return QSize(128, 200); } void RealDataSelectorWidget::setModels(InstrumentModel* instrumentModel, - RealDataModel* realDataModel) -{ + RealDataModel* realDataModel) { m_selectorWidget->setModel(realDataModel); m_propertiesWidget->setModels(instrumentModel, realDataModel); @@ -77,8 +73,7 @@ void RealDataSelectorWidget::setModels(InstrumentModel* instrumentModel, m_selectorActions->setSelectionModel(m_selectorWidget->selectionModel()); } -void RealDataSelectorWidget::onSelectionChanged(SessionItem* item) -{ +void RealDataSelectorWidget::onSelectionChanged(SessionItem* item) { m_propertiesWidget->setItem(item); emit selectionChanged(item); } diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.h b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.h index 5facc3a039c19beccb5025f1af2c03e87471f4e4..988ac4171b8a6be2e92ebe8d17bdb9e3fc98bc2c 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.h +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.h @@ -26,8 +26,7 @@ class SessionItem; class RealDataSelectorActions; class RealDataSelectorToolBar; class RealDataSelectorHBar; -namespace Manhattan -{ +namespace Manhattan { class MiniSplitter; } @@ -35,8 +34,7 @@ class MiniSplitter; //! select data set (ItemSelectorWidget) and properties of currently selected data //! (RealDataPropertiesWidget). -class RealDataSelectorWidget : public QWidget -{ +class RealDataSelectorWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.cpp b/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.cpp index 2b596518a0dfdd57c0dde92f22d0a8ec45694cf0..60419fe11e2bbd84925f7255a612ae0d68ce567c 100644 --- a/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.cpp +++ b/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.cpp @@ -25,8 +25,7 @@ ComboSelectorDialog::ComboSelectorDialog(QWidget* parent) : QDialog(parent) , m_topLabel(new QLabel) , m_comboSelector(new QComboBox) - , m_bottomLabel(new QLabel) -{ + , m_bottomLabel(new QLabel) { QColor bgColor(240, 240, 240, 255); QPalette palette; palette.setColor(QPalette::Window, bgColor); @@ -48,33 +47,28 @@ ComboSelectorDialog::ComboSelectorDialog(QWidget* parent) setLayout(mainLayout); } -void ComboSelectorDialog::addItems(const QStringList& selection, const QString& currentItem) -{ +void ComboSelectorDialog::addItems(const QStringList& selection, const QString& currentItem) { m_comboSelector->addItems(selection); if (selection.contains(currentItem)) m_comboSelector->setCurrentIndex(selection.indexOf(currentItem)); } -void ComboSelectorDialog::setTextTop(const QString& text) -{ +void ComboSelectorDialog::setTextTop(const QString& text) { m_topLabel->setText(text); } -void ComboSelectorDialog::setTextBottom(const QString& text) -{ +void ComboSelectorDialog::setTextBottom(const QString& text) { m_bottomLabel->setText(text); } -QString ComboSelectorDialog::currentText() const -{ +QString ComboSelectorDialog::currentText() const { return m_comboSelector->currentText(); } //! Returns layout with icon for left part of the widget. -QBoxLayout* ComboSelectorDialog::createLogoLayout() -{ +QBoxLayout* ComboSelectorDialog::createLogoLayout() { auto result = new QVBoxLayout; QIcon icon = qApp->style()->standardIcon(QStyle::SP_MessageBoxQuestion); @@ -91,8 +85,7 @@ QBoxLayout* ComboSelectorDialog::createLogoLayout() //! Creates right layout with text and QComboBox selection. -QBoxLayout* ComboSelectorDialog::createInfoLayout() -{ +QBoxLayout* ComboSelectorDialog::createInfoLayout() { auto result = new QVBoxLayout; m_topLabel->setWordWrap(true); @@ -111,8 +104,7 @@ QBoxLayout* ComboSelectorDialog::createInfoLayout() //! Creates button layout with buttons. -QBoxLayout* ComboSelectorDialog::createButtonLayout() -{ +QBoxLayout* ComboSelectorDialog::createButtonLayout() { auto result = new QHBoxLayout; auto cancelButton = new QPushButton("Cancel"); diff --git a/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.h b/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.h index c3d61df5d5f7d50e9f9173f2af2cc1647d38d8f6..ef29e6b6d1d4f858b7cc1570a7acf5063d3acbe5 100644 --- a/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.h +++ b/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.h @@ -24,8 +24,7 @@ class QBoxLayout; //! A dialog similar to standard QMessageBox with combo box selector. -class ComboSelectorDialog : public QDialog -{ +class ComboSelectorDialog : public QDialog { Q_OBJECT public: ComboSelectorDialog(QWidget* parent = 0); diff --git a/GUI/coregui/Views/InfoWidgets/DetailedMessageBox.cpp b/GUI/coregui/Views/InfoWidgets/DetailedMessageBox.cpp index 9512b5a06f63e6d5d6f18f0574db6efe625b5963..95d30f796f43c63de1fbd00a1bd39f40f7e0e3d1 100644 --- a/GUI/coregui/Views/InfoWidgets/DetailedMessageBox.cpp +++ b/GUI/coregui/Views/InfoWidgets/DetailedMessageBox.cpp @@ -22,15 +22,13 @@ #include <QTextEdit> #include <QVBoxLayout> -namespace -{ +namespace { const QSize default_dialog_size(512, 300); } DetailedMessageBox::DetailedMessageBox(QWidget* parent, const QString& title, const QString& text, const QString& details) - : QDialog(parent), m_topLabel(new QLabel), m_textEdit(new QTextEdit) -{ + : QDialog(parent), m_topLabel(new QLabel), m_textEdit(new QTextEdit) { setWindowTitle(title); m_topLabel->setText(text); m_textEdit->setText(details); @@ -62,20 +60,17 @@ DetailedMessageBox::DetailedMessageBox(QWidget* parent, const QString& title, co setSizeGripEnabled(true); } -void DetailedMessageBox::setText(const QString& text) -{ +void DetailedMessageBox::setText(const QString& text) { m_topLabel->setText(text); } -void DetailedMessageBox::setDetailedText(const QString& text) -{ +void DetailedMessageBox::setDetailedText(const QString& text) { m_textEdit->setText(text); } //! Returns layout with icon for left part of the widget. -QBoxLayout* DetailedMessageBox::createLogoLayout() -{ +QBoxLayout* DetailedMessageBox::createLogoLayout() { auto result = new QVBoxLayout; QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); @@ -91,8 +86,7 @@ QBoxLayout* DetailedMessageBox::createLogoLayout() //! Creates right layout with text and QComboBox selection. -QBoxLayout* DetailedMessageBox::createInfoLayout() -{ +QBoxLayout* DetailedMessageBox::createInfoLayout() { m_topLabel->setWordWrap(true); auto result = new QVBoxLayout; @@ -103,8 +97,7 @@ QBoxLayout* DetailedMessageBox::createInfoLayout() //! Creates button layout with buttons. -QBoxLayout* DetailedMessageBox::createButtonLayout() -{ +QBoxLayout* DetailedMessageBox::createButtonLayout() { auto result = new QHBoxLayout; auto okButton = new QPushButton("Ok"); diff --git a/GUI/coregui/Views/InfoWidgets/DetailedMessageBox.h b/GUI/coregui/Views/InfoWidgets/DetailedMessageBox.h index c7fa04d28c51ac59be029fd1c4c0d2d139f112cc..20e09b664724caf034a4e3f982774bb633a3d4d7 100644 --- a/GUI/coregui/Views/InfoWidgets/DetailedMessageBox.h +++ b/GUI/coregui/Views/InfoWidgets/DetailedMessageBox.h @@ -25,8 +25,7 @@ class QBoxLayout; //! A dialog similar to standard QMessageBox intended for detailed warning messages. //! On the contrary to QMessageBox, the dialog has size grip and visible text editor. -class DetailedMessageBox : public QDialog -{ +class DetailedMessageBox : public QDialog { Q_OBJECT public: DetailedMessageBox(QWidget* parent, const QString& title, const QString& text, diff --git a/GUI/coregui/Views/InfoWidgets/DistributionDialog.cpp b/GUI/coregui/Views/InfoWidgets/DistributionDialog.cpp index d321a1e28a0696ebe15a6775e93c105956d00410..ba12c89359ba47785e79c7135bc6cfd44ff80698 100644 --- a/GUI/coregui/Views/InfoWidgets/DistributionDialog.cpp +++ b/GUI/coregui/Views/InfoWidgets/DistributionDialog.cpp @@ -20,8 +20,7 @@ #include <QPushButton> DistributionDialog::DistributionDialog(QWidget* parent) - : QDialog(parent), m_editor(new DistributionEditor) -{ + : QDialog(parent), m_editor(new DistributionEditor) { setMinimumSize(256, 256); resize(700, 480); setWindowTitle("Select Distribution"); @@ -48,12 +47,10 @@ DistributionDialog::DistributionDialog(QWidget* parent) StyleUtils::setResizable(this); } -void DistributionDialog::setItem(SessionItem* item) -{ +void DistributionDialog::setItem(SessionItem* item) { m_editor->setItem(item); } -void DistributionDialog::setNameOfEditor(const QString& name) -{ +void DistributionDialog::setNameOfEditor(const QString& name) { m_editor->setNameOfEditor(name); } diff --git a/GUI/coregui/Views/InfoWidgets/DistributionDialog.h b/GUI/coregui/Views/InfoWidgets/DistributionDialog.h index 76542f261328f8cc48d4e0c398941935ef503a97..4bcbdbd9f8d9c817ce7203aa9fa175600fe74f45 100644 --- a/GUI/coregui/Views/InfoWidgets/DistributionDialog.h +++ b/GUI/coregui/Views/InfoWidgets/DistributionDialog.h @@ -20,8 +20,7 @@ class DistributionEditor; class SessionItem; //! The dialog which shows an editor to change parameters of DistributionItem -class DistributionDialog : public QDialog -{ +class DistributionDialog : public QDialog { Q_OBJECT public: diff --git a/GUI/coregui/Views/InfoWidgets/DistributionEditor.cpp b/GUI/coregui/Views/InfoWidgets/DistributionEditor.cpp index 7364dd22b626618ba4323d12ade6b3fb95a493a5..e46b50d8e84f1928dfe8ea4f45fb5329b0f1994e 100644 --- a/GUI/coregui/Views/InfoWidgets/DistributionEditor.cpp +++ b/GUI/coregui/Views/InfoWidgets/DistributionEditor.cpp @@ -19,8 +19,7 @@ #include "GUI/coregui/Views/PropertyEditor/ComponentFlatView.h" #include <QBoxLayout> -namespace -{ +namespace { int minimum_width = 250; } @@ -29,8 +28,7 @@ DistributionEditor::DistributionEditor(QWidget* parent) , m_propertyEditor(new ComponentFlatView) , m_item(nullptr) , m_plotwidget(new DistributionWidget) - , m_box(new QGroupBox) -{ + , m_box(new QGroupBox) { auto boxLayout = new QVBoxLayout; m_propertyEditor->setMaximumWidth(minimum_width); @@ -50,8 +48,7 @@ DistributionEditor::DistributionEditor(QWidget* parent) setLayout(mainLayout); } -void DistributionEditor::subscribeToItem() -{ +void DistributionEditor::subscribeToItem() { m_propertyEditor->clearEditor(); m_propertyEditor->setItem(currentItem()); @@ -61,28 +58,24 @@ void DistributionEditor::subscribeToItem() m_plotwidget->setItem(distributionItem()); } -void DistributionEditor::onPropertyChanged(const QString& property_name) -{ +void DistributionEditor::onPropertyChanged(const QString& property_name) { if (property_name == GroupItem::T_ITEMS) m_plotwidget->setItem(distributionItem()); } -GroupItem* DistributionEditor::groupItem() -{ +GroupItem* DistributionEditor::groupItem() { auto result = dynamic_cast<GroupItem*>(currentItem()); ASSERT(result); return result; } -DistributionItem* DistributionEditor::distributionItem() -{ +DistributionItem* DistributionEditor::distributionItem() { auto result = dynamic_cast<DistributionItem*>(groupItem()->currentItem()); ASSERT(result); return result; } -void DistributionEditor::setNameOfEditor(QString name) -{ +void DistributionEditor::setNameOfEditor(QString name) { m_box->setTitle(name); m_plotwidget->setXAxisName(name); } diff --git a/GUI/coregui/Views/InfoWidgets/DistributionEditor.h b/GUI/coregui/Views/InfoWidgets/DistributionEditor.h index 603262a903741f8a05a03e06541e9cc064cc3001..61301458dbab44b763c1030f3aaf835f95ca8b38 100644 --- a/GUI/coregui/Views/InfoWidgets/DistributionEditor.h +++ b/GUI/coregui/Views/InfoWidgets/DistributionEditor.h @@ -26,8 +26,7 @@ class DistributionItem; //! The DistributionEditor class, being a child of DistributionDialog, contains a widget //! to show Distribution1D and property editor to change distribution parameters. -class DistributionEditor : public SessionItemWidget -{ +class DistributionEditor : public SessionItemWidget { Q_OBJECT public: DistributionEditor(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/InfoWidgets/DistributionWidget.cpp b/GUI/coregui/Views/InfoWidgets/DistributionWidget.cpp index 5c994b730ddf9d979d182f6a5df46314e217b3f1..52126e384b87b8282faaebcbafaf4110811f0f2b 100644 --- a/GUI/coregui/Views/InfoWidgets/DistributionWidget.cpp +++ b/GUI/coregui/Views/InfoWidgets/DistributionWidget.cpp @@ -22,8 +22,7 @@ #include <algorithm> #include <qcustomplot.h> -namespace -{ +namespace { const QPair<double, double> default_xrange(-0.1, 0.1); const QPair<double, double> default_yrange(0.0, 1.1); @@ -41,8 +40,7 @@ DistributionWidget::DistributionWidget(QWidget* parent) , m_item(0) , m_label(new QLabel) , m_resetAction(new QAction(this)) - , m_warningSign(new WarningSign(this)) -{ + , m_warningSign(new WarningSign(this)) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_resetAction->setText("Reset View"); @@ -64,14 +62,12 @@ DistributionWidget::DistributionWidget(QWidget* parent) connect(m_plot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(onMouseMove(QMouseEvent*))); } -DistributionWidget::~DistributionWidget() -{ +DistributionWidget::~DistributionWidget() { if (m_item) m_item->mapper()->unsubscribe(this); } -void DistributionWidget::setItem(DistributionItem* item) -{ +void DistributionWidget::setItem(DistributionItem* item) { if (m_item == item) { return; @@ -93,8 +89,7 @@ void DistributionWidget::setItem(DistributionItem* item) } } -void DistributionWidget::plotItem() -{ +void DistributionWidget::plotItem() { init_plot(); try { @@ -112,8 +107,7 @@ void DistributionWidget::plotItem() //! Generates label with current mouse position. -void DistributionWidget::onMouseMove(QMouseEvent* event) -{ +void DistributionWidget::onMouseMove(QMouseEvent* event) { QPoint point = event->pos(); double xPos = m_plot->xAxis->pixelToCoord(point.x()); double yPos = m_plot->yAxis->pixelToCoord(point.y()); @@ -124,8 +118,7 @@ void DistributionWidget::onMouseMove(QMouseEvent* event) } } -void DistributionWidget::onMousePress(QMouseEvent* event) -{ +void DistributionWidget::onMousePress(QMouseEvent* event) { if (event->button() == Qt::RightButton) { QPoint point = event->globalPos(); QMenu menu; @@ -136,8 +129,7 @@ void DistributionWidget::onMousePress(QMouseEvent* event) //! Reset zoom range to initial state. -void DistributionWidget::resetView() -{ +void DistributionWidget::resetView() { m_plot->xAxis->setRange(m_xRange); m_plot->yAxis->setRange(m_yRange); m_plot->replot(); @@ -145,8 +137,7 @@ void DistributionWidget::resetView() //! Clears all plottables, resets axes to initial state. -void DistributionWidget::init_plot() -{ +void DistributionWidget::init_plot() { m_warningSign->clear(); m_plot->clearGraphs(); @@ -165,8 +156,7 @@ void DistributionWidget::init_plot() setPlotRange(default_xrange, default_yrange); } -void DistributionWidget::plot_distributions() -{ +void DistributionWidget::plot_distributions() { if (m_item->modelType() == "DistributionNone") plot_single_value(); @@ -176,8 +166,7 @@ void DistributionWidget::plot_distributions() //! Plots a single bar corresponding to the value in DistributionNoteItem. -void DistributionWidget::plot_single_value() -{ +void DistributionWidget::plot_single_value() { ASSERT(m_item->displayName() == "DistributionNone"); double value = m_item->getItemValue(DistributionNoneItem::P_MEAN).toDouble(); @@ -189,8 +178,7 @@ void DistributionWidget::plot_single_value() plotVerticalLine(value, default_yrange.first, value, default_yrange.second); } -void DistributionWidget::plot_multiple_values() -{ +void DistributionWidget::plot_multiple_values() { ASSERT(m_item->displayName() != "DistributionNone"); int numberOfSamples = m_item->getItemValue(DistributionItem::P_NUMBER_OF_SAMPLES).toInt(); @@ -249,16 +237,14 @@ void DistributionWidget::plot_multiple_values() } void DistributionWidget::setPlotRange(const QPair<double, double>& xRange, - const QPair<double, double>& yRange) -{ + const QPair<double, double>& yRange) { m_xRange = QCPRange(xRange.first, xRange.second); m_yRange = QCPRange(yRange.first, yRange.second); m_plot->xAxis->setRange(m_xRange); m_plot->yAxis->setRange(m_yRange); } -void DistributionWidget::plotBars(const QVector<double>& xbars, const QVector<double>& ybars) -{ +void DistributionWidget::plotBars(const QVector<double>& xbars, const QVector<double>& ybars) { ASSERT(xbars.size() > 0); auto xRange = xRangeForValues(xbars); @@ -277,8 +263,7 @@ void DistributionWidget::plotBars(const QVector<double>& xbars, const QVector<do bars->setData(xbars, ybars); } -void DistributionWidget::plotFunction(const QVector<double>& xFunc, const QVector<double>& yFunc) -{ +void DistributionWidget::plotFunction(const QVector<double>& xFunc, const QVector<double>& yFunc) { auto xRange = xRangeForValues(xFunc); auto yRange = yRangeForValues(yFunc); setPlotRange(xRange, yRange); @@ -288,8 +273,7 @@ void DistributionWidget::plotFunction(const QVector<double>& xFunc, const QVecto } void DistributionWidget::plotVerticalLine(double xMin, double yMin, double xMax, double yMax, - const QColor& color) -{ + const QColor& color) { QCPItemLine* line = new QCPItemLine(m_plot); QPen pen(color, 1, Qt::DashLine); @@ -302,8 +286,7 @@ void DistributionWidget::plotVerticalLine(double xMin, double yMin, double xMax, //! Plots red line denoting lower and upper limits, if any. -void DistributionWidget::plotLimits(const RealLimits& limits) -{ +void DistributionWidget::plotLimits(const RealLimits& limits) { if (limits.hasLowerLimit()) { double value = limits.lowerLimit(); plotVerticalLine(value, default_yrange.first, value, default_yrange.second, Qt::red); @@ -315,16 +298,13 @@ void DistributionWidget::plotLimits(const RealLimits& limits) } } -void DistributionWidget::setXAxisName(const QString& xAxisName) -{ +void DistributionWidget::setXAxisName(const QString& xAxisName) { m_plot->xAxis->setLabel(xAxisName); } -namespace -{ +namespace { //! Returns (xmin, xmax) of x-axis to display single value. -QPair<double, double> xRangeForValue(double value) -{ +QPair<double, double> xRangeForValue(double value) { const double range_factor(0.1); double dr = (value == 0.0 ? 1.0 * range_factor : std::abs(value) * range_factor); @@ -336,8 +316,7 @@ QPair<double, double> xRangeForValue(double value) //! Returns (xmin, xmax) of x-axis to display two values. -QPair<double, double> xRangeForValues(double value1, double value2) -{ +QPair<double, double> xRangeForValues(double value1, double value2) { const double range_factor(0.1); double dr = (value2 - value1) * range_factor; ASSERT(dr > 0.0); @@ -345,15 +324,13 @@ QPair<double, double> xRangeForValues(double value1, double value2) return QPair<double, double>(value1 - dr, value2 + dr); } -QPair<double, double> xRangeForValues(const QVector<double>& xvec) -{ +QPair<double, double> xRangeForValues(const QVector<double>& xvec) { ASSERT(!xvec.isEmpty()); return xvec.size() == 1 ? xRangeForValue(xvec.front()) : xRangeForValues(xvec.front(), xvec.back()); } -QPair<double, double> yRangeForValues(const QVector<double>& yvec) -{ +QPair<double, double> yRangeForValues(const QVector<double>& yvec) { const double range_factor(1.1); double ymax = *std::max_element(yvec.begin(), yvec.end()); return QPair<double, double>(default_yrange.first, ymax * range_factor); @@ -361,8 +338,7 @@ QPair<double, double> yRangeForValues(const QVector<double>& yvec) //! Returns width of the bar, which will be optimally looking for x-axis range (xmin, xmax) -double optimalBarWidth(double xmin, double xmax, int nbars) -{ +double optimalBarWidth(double xmin, double xmax, int nbars) { double optimalWidth = (xmax - xmin) / 40.; double width = (xmax - xmin) / nbars; diff --git a/GUI/coregui/Views/InfoWidgets/DistributionWidget.h b/GUI/coregui/Views/InfoWidgets/DistributionWidget.h index 6788385a4e44d2666d41e698a7f9e8be6fd7aec4..b58efe86d756391a6e9a2bd039f25a818c756f70 100644 --- a/GUI/coregui/Views/InfoWidgets/DistributionWidget.h +++ b/GUI/coregui/Views/InfoWidgets/DistributionWidget.h @@ -27,8 +27,7 @@ class RealLimits; class WarningSign; //! The DistributionWidget class plots 1d functions corresponding to domain's Distribution1D -class DistributionWidget : public QWidget -{ +class DistributionWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InfoWidgets/GroupInfoBox.cpp b/GUI/coregui/Views/InfoWidgets/GroupInfoBox.cpp index 5ec94f3868c62d58c6c35c4a743411ad6f36784f..b24569c9ac67d6c40dbfa69b0a4e7600916be71b 100644 --- a/GUI/coregui/Views/InfoWidgets/GroupInfoBox.cpp +++ b/GUI/coregui/Views/InfoWidgets/GroupInfoBox.cpp @@ -24,32 +24,27 @@ #include <QToolTip> #include <iostream> -namespace -{ +namespace { int imageWidth = 16; int imageheigth = 16; int offset_of_tooltip_position = 20; int offset_of_icon_position = 24; } // namespace -GroupInfoBox::GroupInfoBox(QWidget* parent) : QGroupBox(parent), m_xImage(0), m_yImage(0) -{ +GroupInfoBox::GroupInfoBox(QWidget* parent) : QGroupBox(parent), m_xImage(0), m_yImage(0) { init_box(); } GroupInfoBox::GroupInfoBox(const QString& title, QWidget* parent) - : QGroupBox(title, parent), m_title(title) -{ + : QGroupBox(title, parent), m_title(title) { init_box(); } -void GroupInfoBox::setButtonToolTip(const QString& text) -{ +void GroupInfoBox::setButtonToolTip(const QString& text) { m_toolTipText = text; } -void GroupInfoBox::mousePressEvent(QMouseEvent* e) -{ +void GroupInfoBox::mousePressEvent(QMouseEvent* e) { if (e->button() == Qt::LeftButton) { QStyleOptionGroupBox option; initStyleOption(&option); @@ -59,8 +54,7 @@ void GroupInfoBox::mousePressEvent(QMouseEvent* e) } } -void GroupInfoBox::mouseMoveEvent(QMouseEvent* event) -{ +void GroupInfoBox::mouseMoveEvent(QMouseEvent* event) { QRect buttonArea(m_xImage, m_yImage, imageWidth, imageheigth); if (buttonArea.contains(event->pos())) { @@ -70,14 +64,12 @@ void GroupInfoBox::mouseMoveEvent(QMouseEvent* event) } } -void GroupInfoBox::init_box() -{ +void GroupInfoBox::init_box() { setMouseTracking(true); m_toolTipText = "Gives access to the extended distribution viewer."; } -void GroupInfoBox::paintEvent(QPaintEvent*) -{ +void GroupInfoBox::paintEvent(QPaintEvent*) { QStylePainter paint(this); QStyleOptionGroupBox option; initStyleOption(&option); diff --git a/GUI/coregui/Views/InfoWidgets/GroupInfoBox.h b/GUI/coregui/Views/InfoWidgets/GroupInfoBox.h index d38f67193cf12d8346effb9e154a3778d90dfb3d..3a97cfc2cb1564a45ed1a44db0e6d004a721e7ea 100644 --- a/GUI/coregui/Views/InfoWidgets/GroupInfoBox.h +++ b/GUI/coregui/Views/InfoWidgets/GroupInfoBox.h @@ -18,8 +18,7 @@ #include <QGroupBox> //! The class which extends QGroupBox with clickable icon next to the label -class GroupInfoBox : public QGroupBox -{ +class GroupInfoBox : public QGroupBox { Q_OBJECT public: diff --git a/GUI/coregui/Views/InfoWidgets/OverlayLabelController.cpp b/GUI/coregui/Views/InfoWidgets/OverlayLabelController.cpp index 854a9851cd3501c43a636df57507e480a537cf95..eacdc5f5d66ab498ae04ed62e1381293d44d13c4 100644 --- a/GUI/coregui/Views/InfoWidgets/OverlayLabelController.cpp +++ b/GUI/coregui/Views/InfoWidgets/OverlayLabelController.cpp @@ -20,25 +20,20 @@ #include <QRect> OverlayLabelController::OverlayLabelController(QObject* parent) - : QObject(parent), m_label(0), m_area(0) -{ -} + : QObject(parent), m_label(0), m_area(0) {} -void OverlayLabelController::setText(const QString& text) -{ +void OverlayLabelController::setText(const QString& text) { m_text = text; } -void OverlayLabelController::setArea(QAbstractScrollArea* area) -{ +void OverlayLabelController::setArea(QAbstractScrollArea* area) { m_area = area; m_area->installEventFilter(this); } //! Shows/removes a label from the controlled widget -void OverlayLabelController::setShown(bool shown) -{ +void OverlayLabelController::setShown(bool shown) { if (shown) { ASSERT(m_area); if (!m_label) { @@ -54,16 +49,14 @@ void OverlayLabelController::setShown(bool shown) } } -bool OverlayLabelController::eventFilter(QObject* obj, QEvent* event) -{ +bool OverlayLabelController::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::Resize) updateLabelGeometry(); return QObject::eventFilter(obj, event); } -void OverlayLabelController::updateLabelGeometry() -{ +void OverlayLabelController::updateLabelGeometry() { if (!m_label || !m_area) return; m_label->setRectangle(QRect(0, 0, m_area->width(), m_area->height())); diff --git a/GUI/coregui/Views/InfoWidgets/OverlayLabelController.h b/GUI/coregui/Views/InfoWidgets/OverlayLabelController.h index cc67507c3ce60ac8d0a804b9361e455057710733..4bc302aed788dc49a599caf80b8f1fd2523df457 100644 --- a/GUI/coregui/Views/InfoWidgets/OverlayLabelController.h +++ b/GUI/coregui/Views/InfoWidgets/OverlayLabelController.h @@ -24,8 +24,7 @@ class QAbstractScrollArea; //! The OverlayLabelController class controlls appearance of InfoLabelWidget (position, show/hide) //! on top of some scroll area. -class OverlayLabelController : public QObject -{ +class OverlayLabelController : public QObject { Q_OBJECT public: OverlayLabelController(QObject* parent = 0); diff --git a/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.cpp b/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.cpp index 11e65a542c4517b258a9c562d651a3b468ede471..2a4d2ea404427033f9bc7ceb6469869e43d7afd2 100644 --- a/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.cpp +++ b/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.cpp @@ -20,23 +20,19 @@ #include <QPainter> OverlayLabelWidget::OverlayLabelWidget(QWidget* parent) - : QWidget(parent), m_bounding_rect(QRect(0, 0, 10, 10)) -{ + : QWidget(parent), m_bounding_rect(QRect(0, 0, 10, 10)) { setAttribute(Qt::WA_TransparentForMouseEvents); } -void OverlayLabelWidget::setRectangle(const QRect& rect) -{ +void OverlayLabelWidget::setRectangle(const QRect& rect) { m_bounding_rect = rect; } -void OverlayLabelWidget::setPosition(int x, int y) -{ +void OverlayLabelWidget::setPosition(int x, int y) { setGeometry(x, y, m_bounding_rect.width(), m_bounding_rect.height()); } -void OverlayLabelWidget::paintEvent(QPaintEvent* event) -{ +void OverlayLabelWidget::paintEvent(QPaintEvent* event) { Q_UNUSED(event); QPainter painter(this); painter.setBrush(QColor(Qt::lightGray)); diff --git a/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.h b/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.h index 5097cbb06525d93f94c7465742dd3a2ba9935d4d..f63ad95a39a2c2782c9778680c50b91928f7e432 100644 --- a/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.h +++ b/GUI/coregui/Views/InfoWidgets/OverlayLabelWidget.h @@ -22,8 +22,7 @@ //! The OverlayLabelWidget is a semi-transparent overlay label to place on top of other //! widgets outside of any layout context. -class OverlayLabelWidget : public QWidget -{ +class OverlayLabelWidget : public QWidget { Q_OBJECT public: OverlayLabelWidget(QWidget* parent = 0); diff --git a/GUI/coregui/Views/InfoWidgets/ProjectLoadWarningDialog.cpp b/GUI/coregui/Views/InfoWidgets/ProjectLoadWarningDialog.cpp index ed95dbc26b6c50efff3fb05bd824e18a0eaa27b3..cfef0a3c0fc954f4ed6743eda4af4e2ea255188d 100644 --- a/GUI/coregui/Views/InfoWidgets/ProjectLoadWarningDialog.cpp +++ b/GUI/coregui/Views/InfoWidgets/ProjectLoadWarningDialog.cpp @@ -25,16 +25,14 @@ #include <QTableWidget> #include <QTableWidgetItem> -namespace -{ +namespace { const int top_panel_height = 80; } ProjectLoadWarningDialog::ProjectLoadWarningDialog(QWidget* parent, const MessageService* messageService, const QString& documentVersion) - : QDialog(parent), m_messageService(messageService), m_projectDocumentVersion(documentVersion) -{ + : QDialog(parent), m_messageService(messageService), m_projectDocumentVersion(documentVersion) { setMinimumSize(256, 256); resize(520, 620); setWindowTitle("Problems encountered while loading project"); @@ -52,8 +50,7 @@ ProjectLoadWarningDialog::ProjectLoadWarningDialog(QWidget* parent, } //! Top panel with warning icon and the header -QWidget* ProjectLoadWarningDialog::createTopPanel() -{ +QWidget* ProjectLoadWarningDialog::createTopPanel() { auto result = new QWidget(this); auto layout = new QHBoxLayout; @@ -85,8 +82,7 @@ QWidget* ProjectLoadWarningDialog::createTopPanel() } //! Info panel with summary over warnings in different models -QWidget* ProjectLoadWarningDialog::createModelInfoPanel() -{ +QWidget* ProjectLoadWarningDialog::createModelInfoPanel() { auto result = new QWidget(this); auto layout = new QHBoxLayout; @@ -113,8 +109,7 @@ QWidget* ProjectLoadWarningDialog::createModelInfoPanel() } //! Info panel with explanations what had happened and what to do -QWidget* ProjectLoadWarningDialog::createExplanationPanel() -{ +QWidget* ProjectLoadWarningDialog::createExplanationPanel() { auto result = new QWidget(this); auto layout = new QVBoxLayout; @@ -153,8 +148,7 @@ QWidget* ProjectLoadWarningDialog::createExplanationPanel() } //! Info panel with table widget containing error messages -QWidget* ProjectLoadWarningDialog::createDetailsPanel() -{ +QWidget* ProjectLoadWarningDialog::createDetailsPanel() { auto result = new QWidget(this); auto layout = new QVBoxLayout; @@ -176,8 +170,7 @@ QWidget* ProjectLoadWarningDialog::createDetailsPanel() } //! Creates QTableWidget and fills it with error messages -QTableWidget* ProjectLoadWarningDialog::createTableWidget() -{ +QTableWidget* ProjectLoadWarningDialog::createTableWidget() { auto result = new QTableWidget; result->setWordWrap(true); // result->setTextElideMode(Qt::ElideMiddle); @@ -204,8 +197,7 @@ QTableWidget* ProjectLoadWarningDialog::createTableWidget() return result; } -QLayout* ProjectLoadWarningDialog::buttonLayout() -{ +QLayout* ProjectLoadWarningDialog::buttonLayout() { auto result = new QHBoxLayout; auto button = new QPushButton("Close", this); @@ -220,21 +212,18 @@ QLayout* ProjectLoadWarningDialog::buttonLayout() } //! Returns number of rows in table with error messages, each row represents an error message -int ProjectLoadWarningDialog::numberOfTableRows() const -{ +int ProjectLoadWarningDialog::numberOfTableRows() const { return m_messageService->messages().size(); } //! Returns labels for table header -QStringList ProjectLoadWarningDialog::tableHeaderLabels() const -{ +QStringList ProjectLoadWarningDialog::tableHeaderLabels() const { return QStringList() << "Sender" << "Message" << "Description"; } -QTableWidgetItem* ProjectLoadWarningDialog::createTableItem(const QString& name) -{ +QTableWidgetItem* ProjectLoadWarningDialog::createTableItem(const QString& name) { auto result = new QTableWidgetItem(name); result->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); @@ -246,8 +235,7 @@ QTableWidgetItem* ProjectLoadWarningDialog::createTableItem(const QString& name) } //! Returns explanations what went wrong. -QString ProjectLoadWarningDialog::explanationText() const -{ +QString ProjectLoadWarningDialog::explanationText() const { QString result; if (m_projectDocumentVersion != GUIHelpers::getBornAgainVersionString()) { result = diff --git a/GUI/coregui/Views/InfoWidgets/ProjectLoadWarningDialog.h b/GUI/coregui/Views/InfoWidgets/ProjectLoadWarningDialog.h index 0602b0a0177aef5683710a392acf7e0b0d626956..4cdbb01f7e861c634d21b145e39fade47650642c 100644 --- a/GUI/coregui/Views/InfoWidgets/ProjectLoadWarningDialog.h +++ b/GUI/coregui/Views/InfoWidgets/ProjectLoadWarningDialog.h @@ -27,8 +27,7 @@ class QTableWidgetItem; //! @class ProjectLoadWarningDialog //! @brief The dialog to inform user about encountered problems during the loading of old project -class ProjectLoadWarningDialog : public QDialog -{ +class ProjectLoadWarningDialog : public QDialog { Q_OBJECT public: diff --git a/GUI/coregui/Views/InfoWidgets/PySampleWidget.cpp b/GUI/coregui/Views/InfoWidgets/PySampleWidget.cpp index b28d2e6a77601c424b83e1128040264906945ca2..0d489d39b2ab802cf5e486d9bd69c8b529c50995 100644 --- a/GUI/coregui/Views/InfoWidgets/PySampleWidget.cpp +++ b/GUI/coregui/Views/InfoWidgets/PySampleWidget.cpp @@ -27,8 +27,7 @@ #include <QTextEdit> #include <QVBoxLayout> -namespace -{ +namespace { const int accumulate_updates_during_msec = 20.; } @@ -39,8 +38,7 @@ PySampleWidget::PySampleWidget(QWidget* parent) , m_instrumentModel(nullptr) , m_highlighter(nullptr) , m_updateTimer(new UpdateTimer(accumulate_updates_during_msec, this)) - , m_warningSign(new WarningSign(m_textEdit)) -{ + , m_warningSign(new WarningSign(m_textEdit)) { m_textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); auto mainLayout = new QVBoxLayout; @@ -55,8 +53,7 @@ PySampleWidget::PySampleWidget(QWidget* parent) m_textEdit->setFontPointSize(DesignerHelper::getPythonEditorFontSize()); } -void PySampleWidget::setSampleModel(SampleModel* sampleModel) -{ +void PySampleWidget::setSampleModel(SampleModel* sampleModel) { if (sampleModel != m_sampleModel) { if (m_sampleModel) setEditorConnected(false); @@ -64,18 +61,15 @@ void PySampleWidget::setSampleModel(SampleModel* sampleModel) } } -void PySampleWidget::setInstrumentModel(InstrumentModel* instrumentModel) -{ +void PySampleWidget::setInstrumentModel(InstrumentModel* instrumentModel) { m_instrumentModel = instrumentModel; } -void PySampleWidget::onModifiedRow(const QModelIndex&, int, int) -{ +void PySampleWidget::onModifiedRow(const QModelIndex&, int, int) { m_updateTimer->scheduleUpdate(); } -void PySampleWidget::onDataChanged(const QModelIndex& index, const QModelIndex&) -{ +void PySampleWidget::onDataChanged(const QModelIndex& index, const QModelIndex&) { auto item = m_sampleModel->itemForIndex(index); if (!item) return; @@ -85,8 +79,7 @@ void PySampleWidget::onDataChanged(const QModelIndex& index, const QModelIndex&) } //! Update the editor with the script content -void PySampleWidget::updateEditor() -{ +void PySampleWidget::updateEditor() { if (!m_highlighter) { m_highlighter = new PythonSyntaxHighlighter(m_textEdit->document()); m_textEdit->setLineWrapMode(QTextEdit::NoWrap); @@ -104,8 +97,7 @@ void PySampleWidget::updateEditor() m_textEdit->verticalScrollBar()->setValue(old_scrollbar_value); } -void PySampleWidget::setEditorConnected(bool isConnected) -{ +void PySampleWidget::setEditorConnected(bool isConnected) { if (isConnected) { connect(m_sampleModel, &SampleModel::rowsInserted, this, &PySampleWidget::onModifiedRow, Qt::UniqueConnection); @@ -131,20 +123,17 @@ void PySampleWidget::setEditorConnected(bool isConnected) } } -void PySampleWidget::showEvent(QShowEvent*) -{ +void PySampleWidget::showEvent(QShowEvent*) { setEditorConnected(isVisible()); } -void PySampleWidget::hideEvent(QHideEvent*) -{ +void PySampleWidget::hideEvent(QHideEvent*) { setEditorConnected(isVisible()); } //! generates string representing code snippet for all multi layers in the model -QString PySampleWidget::generateCodeSnippet() -{ +QString PySampleWidget::generateCodeSnippet() { m_warningSign->clear(); QString result; diff --git a/GUI/coregui/Views/InfoWidgets/PySampleWidget.h b/GUI/coregui/Views/InfoWidgets/PySampleWidget.h index 654e0c0fc5ecb0d51a576d553ce47f7c0578361c..cd6b8891df8b7181756d8cb3329f8cb2c641b5d7 100644 --- a/GUI/coregui/Views/InfoWidgets/PySampleWidget.h +++ b/GUI/coregui/Views/InfoWidgets/PySampleWidget.h @@ -29,8 +29,7 @@ class QHideEvent; //! Displays Python script representing a MultiLayer at the bottom of SampleView. -class PySampleWidget : public QWidget -{ +class PySampleWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.cpp b/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.cpp index a9a32f8de45d5b9a2927cc4632a48296dd3439fd..2050aba824edf59ebb0df90907e05ec37128c467 100644 --- a/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.cpp +++ b/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.cpp @@ -37,8 +37,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.h" -PythonSyntaxHighlighter::PythonSyntaxHighlighter(QTextDocument* parent) : QSyntaxHighlighter(parent) -{ +PythonSyntaxHighlighter::PythonSyntaxHighlighter(QTextDocument* parent) + : QSyntaxHighlighter(parent) { keywords = QStringList() << "and" << "assert" << "break" @@ -126,8 +126,7 @@ PythonSyntaxHighlighter::PythonSyntaxHighlighter(QTextDocument* parent) : QSynta initializeRules(); } -void PythonSyntaxHighlighter::initializeRules() -{ +void PythonSyntaxHighlighter::initializeRules() { for (QString currKeyword : keywords) { rules.append(HighlightingRule(QString("\\b%1\\b").arg(currKeyword), 0, basicStyles.value("keyword"))); @@ -172,8 +171,7 @@ void PythonSyntaxHighlighter::initializeRules() basicStyles.value("numbers"))); // r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b' } -void PythonSyntaxHighlighter::highlightBlock(const QString& text) -{ +void PythonSyntaxHighlighter::highlightBlock(const QString& text) { for (HighlightingRule currRule : rules) { int idx = currRule.pattern.indexIn(text, 0); while (idx >= 0) { @@ -192,8 +190,7 @@ void PythonSyntaxHighlighter::highlightBlock(const QString& text) } bool PythonSyntaxHighlighter::matchMultiline(const QString& text, const QRegExp& delimiter, - const int inState, const QTextCharFormat& style) -{ + const int inState, const QTextCharFormat& style) { int start = -1; int add = -1; int end = -1; @@ -236,8 +233,7 @@ bool PythonSyntaxHighlighter::matchMultiline(const QString& text, const QRegExp& } const QTextCharFormat PythonSyntaxHighlighter::getTextCharFormat(const QString& colorName, - const QString& style) -{ + const QString& style) { QTextCharFormat charFormat; QColor color(colorName); charFormat.setForeground(color); diff --git a/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.h b/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.h index 4d1de3c70238d45fbd1c3556792939544fe35e59..d75719f5864b04680d3385c8b170ad9e4b9bf46b 100644 --- a/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.h +++ b/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.h @@ -42,11 +42,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. //! Container to describe a highlighting rule. Based on a regular expression, a relevant match # and //! the format. -class HighlightingRule -{ +class HighlightingRule { public: - HighlightingRule(const QString& patternStr, int n, const QTextCharFormat& matchingFormat) - { + HighlightingRule(const QString& patternStr, int n, const QTextCharFormat& matchingFormat) { originalRuleStr = patternStr; pattern = QRegExp(patternStr); nth = n; @@ -59,8 +57,7 @@ public: }; //! Implementation of highlighting for Python code. -class PythonSyntaxHighlighter : public QSyntaxHighlighter -{ +class PythonSyntaxHighlighter : public QSyntaxHighlighter { Q_OBJECT public: PythonSyntaxHighlighter(QTextDocument* parent = 0); diff --git a/GUI/coregui/Views/InfoWidgets/WarningSign.cpp b/GUI/coregui/Views/InfoWidgets/WarningSign.cpp index 4ec9c6fd6d78a1d1eb49155d3462fe6024cb693b..eb23673641b86a46ae7263eded806eecc14f41bd 100644 --- a/GUI/coregui/Views/InfoWidgets/WarningSign.cpp +++ b/GUI/coregui/Views/InfoWidgets/WarningSign.cpp @@ -20,8 +20,7 @@ #include <QScrollBar> #include <QTimer> -namespace -{ +namespace { const int xpos_offset = 40; const int ypos_offset = 40; } // namespace @@ -31,15 +30,13 @@ WarningSign::WarningSign(QWidget* parent) , m_warning_header("Houston, we have a problem.") , m_warningWidget(0) , m_area(nullptr) - , m_clear_just_had_happened(false) -{ + , m_clear_just_had_happened(false) { setArea(parent); } //! Clears warning message; -void WarningSign::clear() -{ +void WarningSign::clear() { delete m_warningWidget; m_warningWidget = 0; m_warning_message.clear(); @@ -48,16 +45,14 @@ void WarningSign::clear() QTimer::singleShot(10, this, [=]() { m_clear_just_had_happened = false; }); } -void WarningSign::setWarningHeader(const QString& warningHeader) -{ +void WarningSign::setWarningHeader(const QString& warningHeader) { m_warning_header = warningHeader; } //! Shows warning sign on the screen. If clear of previous warning sign had happened just //! few msec ago, make a small delay, to stress its reapearance. -void WarningSign::setWarningMessage(const QString& warningMessage) -{ +void WarningSign::setWarningMessage(const QString& warningMessage) { ASSERT(m_area); if (m_clear_just_had_happened) { @@ -76,27 +71,23 @@ void WarningSign::setWarningMessage(const QString& warningMessage) } } -void WarningSign::setArea(QWidget* area) -{ +void WarningSign::setArea(QWidget* area) { m_area = area; m_area->installEventFilter(this); } -bool WarningSign::isShown() const -{ +bool WarningSign::isShown() const { return (m_warningWidget == nullptr ? false : true); } -bool WarningSign::eventFilter(QObject* obj, QEvent* event) -{ +bool WarningSign::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::Resize) updateLabelGeometry(); return QObject::eventFilter(obj, event); } -void WarningSign::updateLabelGeometry() -{ +void WarningSign::updateLabelGeometry() { if (!m_warningWidget || !m_area) return; @@ -104,8 +95,7 @@ void WarningSign::updateLabelGeometry() m_warningWidget->setPosition(pos.x(), pos.y()); } -QPoint WarningSign::positionForWarningSign() const -{ +QPoint WarningSign::positionForWarningSign() const { ASSERT(m_area); int x = m_area->width() - xpos_offset; diff --git a/GUI/coregui/Views/InfoWidgets/WarningSign.h b/GUI/coregui/Views/InfoWidgets/WarningSign.h index 2084a5cd7218bd67952265d58a481c1fb51ac904..8de7974fd0b868c981203221a4f2b4d3558d6245 100644 --- a/GUI/coregui/Views/InfoWidgets/WarningSign.h +++ b/GUI/coregui/Views/InfoWidgets/WarningSign.h @@ -22,8 +22,7 @@ class QWidget; //! The WarningSign controls appearance of WarningSignWidget on top of parent widget. -class WarningSign : public QObject -{ +class WarningSign : public QObject { public: WarningSign(QWidget* parent); diff --git a/GUI/coregui/Views/InfoWidgets/WarningSignWidget.cpp b/GUI/coregui/Views/InfoWidgets/WarningSignWidget.cpp index fd5c99fa0bd0f4d931e7b7ca71d09cc1bea364df..c01bbbba38b97f5fc4f7b5a0e34931ee14ef12bb 100644 --- a/GUI/coregui/Views/InfoWidgets/WarningSignWidget.cpp +++ b/GUI/coregui/Views/InfoWidgets/WarningSignWidget.cpp @@ -20,22 +20,19 @@ WarningSignWidget::WarningSignWidget(QWidget* parent) : QWidget(parent) , m_pixmap(":/images/warning@2x.png") - , m_warning_header("Houston, we have a problem.") -{ + , m_warning_header("Houston, we have a problem.") { setAttribute(Qt::WA_NoSystemBackground); setToolTip(m_warning_header + "\nClick to see details."); } -void WarningSignWidget::paintEvent(QPaintEvent* event) -{ +void WarningSignWidget::paintEvent(QPaintEvent* event) { Q_UNUSED(event); QPainter painter(this); QRect target(m_pixmap.rect()); painter.drawPixmap(target, m_pixmap); } -void WarningSignWidget::mousePressEvent(QMouseEvent* event) -{ +void WarningSignWidget::mousePressEvent(QMouseEvent* event) { Q_UNUSED(event); QMessageBox box; box.setWindowTitle(m_warning_header); @@ -46,13 +43,11 @@ void WarningSignWidget::mousePressEvent(QMouseEvent* event) } //! set geometry of widget around center point -void WarningSignWidget::setPosition(int x, int y) -{ +void WarningSignWidget::setPosition(int x, int y) { setGeometry(x, y, m_pixmap.width(), m_pixmap.height()); } -void WarningSignWidget::setWarningHeader(const QString& message) -{ +void WarningSignWidget::setWarningHeader(const QString& message) { m_warning_header = message; setToolTip(m_warning_header + "\nClick to see details."); } diff --git a/GUI/coregui/Views/InfoWidgets/WarningSignWidget.h b/GUI/coregui/Views/InfoWidgets/WarningSignWidget.h index dd2de63f7f2960d8b187ca7d3dfbfe09f5fdc8e7..19eb46bdb5a6057118c797c216ac6a901eb5e2ff 100644 --- a/GUI/coregui/Views/InfoWidgets/WarningSignWidget.h +++ b/GUI/coregui/Views/InfoWidgets/WarningSignWidget.h @@ -21,8 +21,7 @@ //! The WarningSignWidget is an transparent widget with warning sign pixmap intended to be //! overlayed onto other widget at some arbitrary position. -class WarningSignWidget : public QWidget -{ +class WarningSignWidget : public QWidget { public: WarningSignWidget(QWidget* parent = 0); diff --git a/GUI/coregui/Views/InstrumentView.cpp b/GUI/coregui/Views/InstrumentView.cpp index 6d25d596bf5b5ca947a05f9191408ecb81ac9948..682042d1f16ceefa833882301b957e6d9e515c12 100644 --- a/GUI/coregui/Views/InstrumentView.cpp +++ b/GUI/coregui/Views/InstrumentView.cpp @@ -28,8 +28,7 @@ InstrumentView::InstrumentView(MainWindow* mainWindow) , m_toolBar(new InstrumentViewToolBar(m_actions, this)) , m_instrumentSelector(new InstrumentSelectorWidget) , m_instrumentEditor(new ItemStackPresenter<InstrumentEditorWidget>(true)) - , m_instrumentModel(mainWindow->instrumentModel()) -{ + , m_instrumentModel(mainWindow->instrumentModel()) { auto horizontalLayout = new QHBoxLayout; horizontalLayout->addWidget(m_instrumentSelector); horizontalLayout->addWidget(m_instrumentEditor, 1); @@ -52,19 +51,16 @@ InstrumentView::InstrumentView(MainWindow* mainWindow) &InstrumentView::onItemSelectionChanged); } -void InstrumentView::onExtendedDetectorEditorRequest(DetectorItem* detectorItem) -{ +void InstrumentView::onExtendedDetectorEditorRequest(DetectorItem* detectorItem) { auto dialog = new ExtendedDetectorDialog(this); dialog->setDetectorContext(m_instrumentModel, detectorItem); dialog->show(); } -void InstrumentView::onItemSelectionChanged(SessionItem* instrumentItem) -{ +void InstrumentView::onItemSelectionChanged(SessionItem* instrumentItem) { m_instrumentEditor->setItem(instrumentItem); } -void InstrumentView::showEvent(QShowEvent*) -{ +void InstrumentView::showEvent(QShowEvent*) { m_instrumentSelector->updateSelection(); } diff --git a/GUI/coregui/Views/InstrumentView.h b/GUI/coregui/Views/InstrumentView.h index b1a2e58245ba61568ab29a3ceb71894b59ba8510..cc01f55a773b317926ded07b91b3edb80c9c97e3 100644 --- a/GUI/coregui/Views/InstrumentView.h +++ b/GUI/coregui/Views/InstrumentView.h @@ -26,8 +26,7 @@ class InstrumentSelectorWidget; class InstrumentEditorWidget; class InstrumentModel; -class InstrumentView : public QWidget -{ +class InstrumentView : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.cpp index d51b188cc056e8c1b18e8dcf7b465c09759bb014..d7d91f36cd6bd4c6ac52180e3685c3bd858af2b9 100644 --- a/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.cpp @@ -22,8 +22,7 @@ #include <QGridLayout> #include <QVBoxLayout> -namespace -{ +namespace { const QString wavelength_title("Wavelength [nm]"); const QString inclination_title("Inclination angles [deg]"); const QString depth_axis_title("Depth axis [nm]"); @@ -34,8 +33,7 @@ DepthProbeInstrumentEditor::DepthProbeInstrumentEditor(QWidget* parent) , m_wavelengthEditor(new ComponentEditor(ComponentEditor::InfoWidget, wavelength_title)) , m_inclinationEditor(new ComponentEditor(ComponentEditor::InfoWidget, inclination_title)) , m_depthAxisEditor(new ComponentEditor(ComponentEditor::InfoWidget, depth_axis_title)) - , m_gridLayout(new QGridLayout) -{ + , m_gridLayout(new QGridLayout) { m_gridLayout->addWidget(m_wavelengthEditor, 1, 0); m_gridLayout->addWidget(m_inclinationEditor, 1, 1); m_gridLayout->addWidget(m_depthAxisEditor, 1, 2); @@ -51,8 +49,7 @@ DepthProbeInstrumentEditor::DepthProbeInstrumentEditor(QWidget* parent) &DepthProbeInstrumentEditor::onDialogRequest); } -void DepthProbeInstrumentEditor::subscribeToItem() -{ +void DepthProbeInstrumentEditor::subscribeToItem() { const auto beam_item = instrumentItem()->getItem(DepthProbeInstrumentItem::P_BEAM); auto wavelengthItem = beam_item->getItem(SpecularBeamItem::P_WAVELENGTH); @@ -66,19 +63,16 @@ void DepthProbeInstrumentEditor::subscribeToItem() m_depthAxisEditor->setItem(instrumentItem()->getItem(DepthProbeInstrumentItem::P_Z_AXIS)); } -void DepthProbeInstrumentEditor::unsubscribeFromItem() -{ +void DepthProbeInstrumentEditor::unsubscribeFromItem() { m_wavelengthEditor->clearEditor(); m_inclinationEditor->clearEditor(); } -DepthProbeInstrumentItem* DepthProbeInstrumentEditor::instrumentItem() -{ +DepthProbeInstrumentItem* DepthProbeInstrumentEditor::instrumentItem() { return dynamic_cast<DepthProbeInstrumentItem*>(currentItem()); } -void DepthProbeInstrumentEditor::onDialogRequest(SessionItem* item, const QString& name) -{ +void DepthProbeInstrumentEditor::onDialogRequest(SessionItem* item, const QString& name) { if (!item) return; diff --git a/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.h b/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.h index d5d8295fd7c0ed9eb5dd227cbf7a8a48468a0e77..34a1595e046b1b1323b06e2c0bcde5e615462360 100644 --- a/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/DepthProbeInstrumentEditor.h @@ -21,8 +21,7 @@ class ComponentEditor; class QGridLayout; class DepthProbeInstrumentItem; -class DepthProbeInstrumentEditor : public SessionItemWidget -{ +class DepthProbeInstrumentEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.cpp b/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.cpp index d883a4b585a2ff321e999f5dbd63a87b16a53623..6a00a80fca0450d5100d375d4a7f848d69e37b52 100644 --- a/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.cpp @@ -28,14 +28,11 @@ DetectorMaskDelegate::DetectorMaskDelegate(QObject* parent) , m_tempIntensityDataModel(new SessionModel("TempIntensityDataModel", this)) , m_instrumentModel(nullptr) , m_detectorItem(nullptr) - , m_intensityItem(nullptr) -{ -} + , m_intensityItem(nullptr) {} void DetectorMaskDelegate::initMaskEditorContext(MaskEditor* maskEditor, InstrumentModel* instrumentModel, - DetectorItem* detectorItem) -{ + DetectorItem* detectorItem) { m_instrumentModel = instrumentModel; m_detectorItem = detectorItem; @@ -53,8 +50,7 @@ void DetectorMaskDelegate::initMaskEditorContext(MaskEditor* maskEditor, //! Creates IntensityDataItem from DetectorItem for later usage in MaskEditor. //! As amplitude, value 1.0 is set for each bin. //! The object additionally tuned to appear nicely on ColorMap plot. -void DetectorMaskDelegate::createIntensityDataItem() -{ +void DetectorMaskDelegate::createIntensityDataItem() { m_tempIntensityDataModel->clear(); m_intensityItem = diff --git a/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.h b/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.h index 52cddd1d9caa8d75a5325851b57d715b7735618d..4854cd932d418374a8d1a8d5b3dfa90e266b0764 100644 --- a/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.h +++ b/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.h @@ -28,8 +28,7 @@ class DetectorItem; //! in InstrumentModel) and temporary IntensityDataItem (defined in temporary SessionModel). //! The later one is used by MaskEditor for mask drawing. -class DetectorMaskDelegate : public QObject -{ +class DetectorMaskDelegate : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/DetectorPresenter.cpp b/GUI/coregui/Views/InstrumentWidgets/DetectorPresenter.cpp index cf3ff9c4c690a7b5a9db21a38b25a7559f92cba3..36ec47579db5c596bec46aa6e02152430f5917ab 100644 --- a/GUI/coregui/Views/InstrumentWidgets/DetectorPresenter.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/DetectorPresenter.cpp @@ -18,21 +18,18 @@ #include "GUI/coregui/Views/InstrumentWidgets/SphericalDetectorEditor.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { const QString SphericalDetectorPresentation = "Spherical"; const QString RectangularDetectorPresentation = "Rectangular"; } // namespace -DetectorPresenter::DetectorPresenter(QWidget* parent) : ItemComboWidget(parent) -{ +DetectorPresenter::DetectorPresenter(QWidget* parent) : ItemComboWidget(parent) { registerWidget(SphericalDetectorPresentation, create_new<SphericalDetectorEditor>); registerWidget(RectangularDetectorPresentation, create_new<RectangularDetectorEditor>); setToolBarVisible(false); } -QString DetectorPresenter::itemPresentation() const -{ +QString DetectorPresenter::itemPresentation() const { if (!currentItem()) return {}; @@ -46,8 +43,7 @@ QString DetectorPresenter::itemPresentation() const + currentItem()->modelType() + "'"); } -QStringList DetectorPresenter::activePresentationList(SessionItem* item) -{ +QStringList DetectorPresenter::activePresentationList(SessionItem* item) { Q_UNUSED(item); return QStringList() << SphericalDetectorPresentation << RectangularDetectorPresentation; } diff --git a/GUI/coregui/Views/InstrumentWidgets/DetectorPresenter.h b/GUI/coregui/Views/InstrumentWidgets/DetectorPresenter.h index 818aa2a6ba5517ee45b6e2147e0f91c0ab8a8a44..b06d1577bc61bdf82965c7814049bc86adcf59df 100644 --- a/GUI/coregui/Views/InstrumentWidgets/DetectorPresenter.h +++ b/GUI/coregui/Views/InstrumentWidgets/DetectorPresenter.h @@ -21,8 +21,7 @@ //! of detector item (SphericalDetectorEditor or RectangularDetectorEditor). //! Main component of GISASDetectorEditor. -class DetectorPresenter : public ItemComboWidget -{ +class DetectorPresenter : public ItemComboWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/EnvironmentEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/EnvironmentEditor.cpp index fff95d6bc95b733bccd19a2f68fff47a17549361..82175e144f7caf4ee1dae670773ca804cb9e1586 100644 --- a/GUI/coregui/Views/InstrumentWidgets/EnvironmentEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/EnvironmentEditor.cpp @@ -21,8 +21,7 @@ #include <QGridLayout> #include <QSpacerItem> -namespace -{ +namespace { const QString background_title("Background"); } @@ -30,8 +29,7 @@ EnvironmentEditor::EnvironmentEditor(ColumnResizer* columnResizer, QWidget* pare : SessionItemWidget(parent) , m_columnResizer(columnResizer) , m_backgroundEditor(new ComponentEditor(ComponentEditor::GroupWidget, background_title)) - , m_gridLayout(new QGridLayout) -{ + , m_gridLayout(new QGridLayout) { m_gridLayout->addWidget(m_backgroundEditor, 0, 0); m_gridLayout->addWidget(LayoutUtils::placeHolder(), 0, 1); m_gridLayout->addWidget(LayoutUtils::placeHolder(), 0, 2); @@ -46,18 +44,15 @@ EnvironmentEditor::EnvironmentEditor(ColumnResizer* columnResizer, QWidget* pare m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 2); } -void EnvironmentEditor::subscribeToItem() -{ +void EnvironmentEditor::subscribeToItem() { m_backgroundEditor->setItem(instrumentItem()->backgroundGroup()); } -void EnvironmentEditor::unsubscribeFromItem() -{ +void EnvironmentEditor::unsubscribeFromItem() { m_backgroundEditor->clearEditor(); } -InstrumentItem* EnvironmentEditor::instrumentItem() -{ +InstrumentItem* EnvironmentEditor::instrumentItem() { auto result = dynamic_cast<InstrumentItem*>(currentItem()); ASSERT(result); return result; diff --git a/GUI/coregui/Views/InstrumentWidgets/EnvironmentEditor.h b/GUI/coregui/Views/InstrumentWidgets/EnvironmentEditor.h index 880b65eeee24cd99a4bd804d30a57523455d79d4..e2fd643c387376608396c1114ea5482d43524e38 100644 --- a/GUI/coregui/Views/InstrumentWidgets/EnvironmentEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/EnvironmentEditor.h @@ -25,8 +25,7 @@ class ColumnResizer; //! Environment editor (i.e. background) for instrument editors. //! Operates on InstrumentItem. -class EnvironmentEditor : public SessionItemWidget -{ +class EnvironmentEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/ExtendedDetectorDialog.cpp b/GUI/coregui/Views/InstrumentWidgets/ExtendedDetectorDialog.cpp index 91bf79f4b5ceeea6fded40e14b6c749687cd14a1..8d3b812af4d844c8f47a4fcd68cae7029654c407 100644 --- a/GUI/coregui/Views/InstrumentWidgets/ExtendedDetectorDialog.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/ExtendedDetectorDialog.cpp @@ -22,8 +22,9 @@ #include <QVBoxLayout> ExtendedDetectorDialog::ExtendedDetectorDialog(QWidget* parent) - : QDialog(parent), m_maskEditor(new MaskEditor), m_maskDelegate(new DetectorMaskDelegate(this)) -{ + : QDialog(parent) + , m_maskEditor(new MaskEditor) + , m_maskDelegate(new DetectorMaskDelegate(this)) { setMinimumSize(256, 256); readSettings(); @@ -59,19 +60,16 @@ ExtendedDetectorDialog::ExtendedDetectorDialog(QWidget* parent) } void ExtendedDetectorDialog::setDetectorContext(InstrumentModel* instrumentModel, - DetectorItem* detectorItem) -{ + DetectorItem* detectorItem) { m_maskDelegate->initMaskEditorContext(m_maskEditor, instrumentModel, detectorItem); } -void ExtendedDetectorDialog::reject() -{ +void ExtendedDetectorDialog::reject() { writeSettings(); QDialog::reject(); } -void ExtendedDetectorDialog::readSettings() -{ +void ExtendedDetectorDialog::readSettings() { QSettings settings; if (settings.childGroups().contains(Constants::S_MASKEDITOR)) { settings.beginGroup(Constants::S_MASKEDITOR); @@ -82,8 +80,7 @@ void ExtendedDetectorDialog::readSettings() } } -void ExtendedDetectorDialog::writeSettings() -{ +void ExtendedDetectorDialog::writeSettings() { QSettings settings; settings.beginGroup(Constants::S_MASKEDITOR); settings.setValue(Constants::S_WINDOWSIZE, this->size()); diff --git a/GUI/coregui/Views/InstrumentWidgets/ExtendedDetectorDialog.h b/GUI/coregui/Views/InstrumentWidgets/ExtendedDetectorDialog.h index 34c1f6b15dcfea566a12088796a969769ff37d94..384c6f5ab5558beb8ce527b10b142c4cb298216f 100644 --- a/GUI/coregui/Views/InstrumentWidgets/ExtendedDetectorDialog.h +++ b/GUI/coregui/Views/InstrumentWidgets/ExtendedDetectorDialog.h @@ -24,8 +24,7 @@ class InstrumentModel; //! The dialog which shows a MaskEditor -class ExtendedDetectorDialog : public QDialog -{ +class ExtendedDetectorDialog : public QDialog { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/GISASBeamEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/GISASBeamEditor.cpp index 33566538c80a69e42774919f8865a9929c14fdf1..9135da647b6fbf7f6ec1657490739fa10224857e 100644 --- a/GUI/coregui/Views/InstrumentWidgets/GISASBeamEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/GISASBeamEditor.cpp @@ -21,8 +21,7 @@ #include <QGridLayout> #include <QGroupBox> -namespace -{ +namespace { const QString wavelength_title("Wavelength [nm]"); const QString inclination_title("Inclination angle [deg]"); const QString azimuthal_title("Azimuthal angle [deg]"); @@ -36,8 +35,7 @@ GISASBeamEditor::GISASBeamEditor(ColumnResizer* columnResizer, QWidget* parent) , m_wavelengthEditor(new ComponentEditor(ComponentEditor::InfoWidget, wavelength_title)) , m_inclinationEditor(new ComponentEditor(ComponentEditor::InfoWidget, inclination_title)) , m_azimuthalEditor(new ComponentEditor(ComponentEditor::InfoWidget, azimuthal_title)) - , m_gridLayout(new QGridLayout) -{ + , m_gridLayout(new QGridLayout) { m_gridLayout->addWidget(m_intensityEditor, 0, 0); m_gridLayout->addWidget(m_wavelengthEditor, 1, 0); m_gridLayout->addWidget(m_inclinationEditor, 1, 1); @@ -60,8 +58,7 @@ GISASBeamEditor::GISASBeamEditor(ColumnResizer* columnResizer, QWidget* parent) m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 2); } -void GISASBeamEditor::subscribeToItem() -{ +void GISASBeamEditor::subscribeToItem() { m_intensityEditor->setItem(beamItem()->getItem(BeamItem::P_INTENSITY)); auto wavelengthItem = beamItem()->getItem(BeamItem::P_WAVELENGTH); @@ -74,28 +71,24 @@ void GISASBeamEditor::subscribeToItem() m_azimuthalEditor->setItem(azimuthalItem->getItem(BeamDistributionItem::P_DISTRIBUTION)); } -void GISASBeamEditor::unsubscribeFromItem() -{ +void GISASBeamEditor::unsubscribeFromItem() { m_intensityEditor->clearEditor(); m_wavelengthEditor->clearEditor(); m_inclinationEditor->clearEditor(); m_azimuthalEditor->clearEditor(); } -GISASInstrumentItem* GISASBeamEditor::instrumentItem() -{ +GISASInstrumentItem* GISASBeamEditor::instrumentItem() { auto result = dynamic_cast<GISASInstrumentItem*>(currentItem()); ASSERT(result); return result; } -BeamItem* GISASBeamEditor::beamItem() -{ +BeamItem* GISASBeamEditor::beamItem() { return instrumentItem()->beamItem(); } -void GISASBeamEditor::onDialogRequest(SessionItem* item, const QString& name) -{ +void GISASBeamEditor::onDialogRequest(SessionItem* item, const QString& name) { if (!item) return; diff --git a/GUI/coregui/Views/InstrumentWidgets/GISASBeamEditor.h b/GUI/coregui/Views/InstrumentWidgets/GISASBeamEditor.h index 8eeb15e05fc705ed208568c9b0781a7249bbf401..c6325f2d4c4848e53e74a1cbcff3d70552c1b9ea 100644 --- a/GUI/coregui/Views/InstrumentWidgets/GISASBeamEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/GISASBeamEditor.h @@ -25,8 +25,7 @@ class ColumnResizer; //! GISAS beam editor. Operates on GISASInstrumentItem. -class GISASBeamEditor : public SessionItemWidget -{ +class GISASBeamEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/GISASDetectorEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/GISASDetectorEditor.cpp index 5fe606db6cbef57834ad09d4fba8485bd4caacfc..8c907715474ae2e354602a2ca0732f065bda3c39 100644 --- a/GUI/coregui/Views/InstrumentWidgets/GISASDetectorEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/GISASDetectorEditor.cpp @@ -24,8 +24,7 @@ GISASDetectorEditor::GISASDetectorEditor(QWidget* parent) : SessionItemWidget(parent) , m_detectorTypeEditor( new ComponentEditor(ComponentEditor::PlainWidget | ComponentEditor::W_NoChildren)) - , m_detectorPresenter(new DetectorPresenter) -{ + , m_detectorPresenter(new DetectorPresenter) { auto mainLayout = new QVBoxLayout; mainLayout->addWidget(m_detectorTypeEditor); mainLayout->addWidget(m_detectorPresenter); @@ -33,8 +32,7 @@ GISASDetectorEditor::GISASDetectorEditor(QWidget* parent) setLayout(mainLayout); } -void GISASDetectorEditor::subscribeToItem() -{ +void GISASDetectorEditor::subscribeToItem() { currentItem()->mapper()->setOnPropertyChange( [this](const QString& name) { if (name == Instrument2DItem::P_DETECTOR) @@ -46,13 +44,11 @@ void GISASDetectorEditor::subscribeToItem() updateDetectorPresenter(); } -void GISASDetectorEditor::unsubscribeFromItem() -{ +void GISASDetectorEditor::unsubscribeFromItem() { m_detectorTypeEditor->clearEditor(); } -Instrument2DItem* GISASDetectorEditor::instrumentItem() -{ +Instrument2DItem* GISASDetectorEditor::instrumentItem() { auto result = dynamic_cast<Instrument2DItem*>(currentItem()); ASSERT(result); return result; @@ -60,7 +56,6 @@ Instrument2DItem* GISASDetectorEditor::instrumentItem() //! Shows detector editor corresponding to the currently selected detector in detectorGroup. -void GISASDetectorEditor::updateDetectorPresenter() -{ +void GISASDetectorEditor::updateDetectorPresenter() { m_detectorPresenter->setItem(instrumentItem()->detectorItem()); } diff --git a/GUI/coregui/Views/InstrumentWidgets/GISASDetectorEditor.h b/GUI/coregui/Views/InstrumentWidgets/GISASDetectorEditor.h index db359fa7ad9b7cdbefda3c6510b2470c99e27234..65ff22b4c3d15063b9b593be718d89fb4f46d245 100644 --- a/GUI/coregui/Views/InstrumentWidgets/GISASDetectorEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/GISASDetectorEditor.h @@ -25,8 +25,7 @@ class Instrument2DItem; //! (spherical/rectangular) and stack to show proper editor. //! Operates on GISASInstrumentItem. -class GISASDetectorEditor : public SessionItemWidget -{ +class GISASDetectorEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/GISASInstrumentEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/GISASInstrumentEditor.cpp index 0e7c28976db7c4ddc2ec5fb9ceaa445a03d6ca54..7233d85bb6302841c5ef734a9ca4de22dbceac15 100644 --- a/GUI/coregui/Views/InstrumentWidgets/GISASInstrumentEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/GISASInstrumentEditor.cpp @@ -28,8 +28,7 @@ GISASInstrumentEditor::GISASInstrumentEditor(QWidget* parent) , m_beamEditor(new GISASBeamEditor(m_columnResizer)) , m_detectorEditor(new GISASDetectorEditor) , m_environmentEditor(new EnvironmentEditor(m_columnResizer)) - , m_polarizationAnalysisEditor(new PolarizationAnalysisEditor(m_columnResizer)) -{ + , m_polarizationAnalysisEditor(new PolarizationAnalysisEditor(m_columnResizer)) { auto mainLayout = new QVBoxLayout; mainLayout->addWidget(StyleUtils::createDetailsWidget(m_beamEditor, "Beam parameters")); @@ -43,16 +42,14 @@ GISASInstrumentEditor::GISASInstrumentEditor(QWidget* parent) setLayout(mainLayout); } -void GISASInstrumentEditor::subscribeToItem() -{ +void GISASInstrumentEditor::subscribeToItem() { m_beamEditor->setItem(instrumentItem()); m_detectorEditor->setItem(instrumentItem()); m_environmentEditor->setItem(instrumentItem()); m_polarizationAnalysisEditor->setItem(instrumentItem()); } -GISASInstrumentItem* GISASInstrumentEditor::instrumentItem() -{ +GISASInstrumentItem* GISASInstrumentEditor::instrumentItem() { auto result = dynamic_cast<GISASInstrumentItem*>(currentItem()); ASSERT(result); return result; diff --git a/GUI/coregui/Views/InstrumentWidgets/GISASInstrumentEditor.h b/GUI/coregui/Views/InstrumentWidgets/GISASInstrumentEditor.h index 7ffe2f634727b8ae218883ad3bf7f76243602327..59b703b4b0bb3a18b8885dd4e55c9effa040303b 100644 --- a/GUI/coregui/Views/InstrumentWidgets/GISASInstrumentEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/GISASInstrumentEditor.h @@ -24,8 +24,7 @@ class EnvironmentEditor; class PolarizationAnalysisEditor; class ColumnResizer; -class GISASInstrumentEditor : public SessionItemWidget -{ +class GISASInstrumentEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentEditorWidget.cpp b/GUI/coregui/Views/InstrumentWidgets/InstrumentEditorWidget.cpp index d20ce3789b8c03af85b493426da0c048ab4ad19b..ff756f6fe58e298971e0924305e4040a42610128 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentEditorWidget.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentEditorWidget.cpp @@ -27,8 +27,7 @@ InstrumentEditorWidget::InstrumentEditorWidget(QWidget* parent) , m_nameLineEdit(new QLineEdit) , m_instrumentPresenter(new InstrumentPresenter) , m_currentItem(nullptr) - , m_block_signals(false) -{ + , m_block_signals(false) { setMinimumSize(400, 400); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -47,21 +46,18 @@ InstrumentEditorWidget::InstrumentEditorWidget(QWidget* parent) &InstrumentEditorWidget::onChangedEditor); } -QSize InstrumentEditorWidget::sizeHint() const -{ +QSize InstrumentEditorWidget::sizeHint() const { return QSize(600, 600); } -void InstrumentEditorWidget::setItem(SessionItem* instrument) -{ +void InstrumentEditorWidget::setItem(SessionItem* instrument) { m_currentItem = instrument; updateWidgets(); m_instrumentPresenter->setItem(instrument); } -void InstrumentEditorWidget::onChangedEditor(const QString&) -{ +void InstrumentEditorWidget::onChangedEditor(const QString&) { if (m_block_signals) return; @@ -71,8 +67,7 @@ void InstrumentEditorWidget::onChangedEditor(const QString&) //! top block with instrument name -QLayout* InstrumentEditorWidget::createTopLayout() -{ +QLayout* InstrumentEditorWidget::createTopLayout() { auto result = new QHBoxLayout; m_nameLineEdit->setMinimumWidth(200); @@ -85,8 +80,7 @@ QLayout* InstrumentEditorWidget::createTopLayout() return result; } -void InstrumentEditorWidget::updateWidgets() -{ +void InstrumentEditorWidget::updateWidgets() { m_block_signals = true; if (m_currentItem) { diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentEditorWidget.h b/GUI/coregui/Views/InstrumentWidgets/InstrumentEditorWidget.h index 125738a30d850b59758a7e7ca9d489d3007cfbb6..571e9dbf0c2b096ff28d4dfe370f8f949d871df1 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentEditorWidget.h +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentEditorWidget.h @@ -25,8 +25,7 @@ class InstrumentPresenter; //! Main widget of InstrumentView. Contains InstrumentPresenter //! showing proper insturment editor for given instrument type. -class InstrumentEditorWidget : public QWidget -{ +class InstrumentEditorWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.cpp b/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.cpp index 1d4227c400d746befa04e1080a9ba38fa3c15781..1bc37d8cd46e03829924eca8ea9750c0ee2cc7df 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.cpp @@ -20,16 +20,14 @@ #include "GUI/coregui/Views/InstrumentWidgets/SpecularInstrumentEditor.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { const QString GISASPresentation = "GISAS"; const QString OffSpecPresentation = "OffSpec"; const QString SpecularPresentation = "Specular"; const QString DepthProbePresentation = "DepthProbe"; } // namespace -InstrumentPresenter::InstrumentPresenter(QWidget* parent) : ItemComboWidget(parent) -{ +InstrumentPresenter::InstrumentPresenter(QWidget* parent) : ItemComboWidget(parent) { registerWidget(GISASPresentation, create_new<GISASInstrumentEditor>); registerWidget(OffSpecPresentation, create_new<OffSpecInstrumentEditor>); registerWidget(SpecularPresentation, create_new<SpecularInstrumentEditor>); @@ -37,8 +35,7 @@ InstrumentPresenter::InstrumentPresenter(QWidget* parent) : ItemComboWidget(pare setToolBarVisible(false); } -QString InstrumentPresenter::itemPresentation() const -{ +QString InstrumentPresenter::itemPresentation() const { if (!currentItem()) return {}; @@ -56,8 +53,7 @@ QString InstrumentPresenter::itemPresentation() const + currentItem()->modelType() + "'"); } -QStringList InstrumentPresenter::activePresentationList(SessionItem* item) -{ +QStringList InstrumentPresenter::activePresentationList(SessionItem* item) { Q_UNUSED(item); return QStringList() << GISASPresentation << OffSpecPresentation << SpecularPresentation << DepthProbePresentation; diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.h b/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.h index d08527529e8c0c1bcccd7d396ead3f7f3d67eaa8..885e5bbfe87fc1ea00545b6d21b6c73b779dac60 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.h +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.h @@ -20,8 +20,7 @@ //! Contains stack of instrument editors and the logic to show proper editor for certain type //! of instrument (GISAS, OffSpec and Specular). Main component of InstrumentEditorWidget. -class InstrumentPresenter : public ItemComboWidget -{ +class InstrumentPresenter : public ItemComboWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentSelectorWidget.cpp b/GUI/coregui/Views/InstrumentWidgets/InstrumentSelectorWidget.cpp index ba9a4888e3a190c3700fd78ae74ecae81741ab98..d5a85347ef422c0a73d91af9650edc7f3577dbba 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentSelectorWidget.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentSelectorWidget.cpp @@ -21,8 +21,7 @@ #include <QVBoxLayout> InstrumentSelectorWidget::InstrumentSelectorWidget(InstrumentModel* model, QWidget* parent) - : ItemSelectorWidget(parent) -{ + : ItemSelectorWidget(parent) { setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); listView()->setViewMode(QListView::IconMode); @@ -44,12 +43,10 @@ InstrumentSelectorWidget::InstrumentSelectorWidget(InstrumentModel* model, QWidg layout()->setMargin(10); } -QSize InstrumentSelectorWidget::sizeHint() const -{ +QSize InstrumentSelectorWidget::sizeHint() const { return QSize(170, 400); } -QSize InstrumentSelectorWidget::minimumSizeHint() const -{ +QSize InstrumentSelectorWidget::minimumSizeHint() const { return QSize(96, 200); } diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentSelectorWidget.h b/GUI/coregui/Views/InstrumentWidgets/InstrumentSelectorWidget.h index 246b490aae3eb88dc839dda20100d9ebef775d7f..2a8a8d5179a82c6e3818e06411f2989fe86b161d 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentSelectorWidget.h +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentSelectorWidget.h @@ -21,8 +21,7 @@ class InstrumentModel; //! Instrument selector on the left side of InstrumentView. -class InstrumentSelectorWidget : public ItemSelectorWidget -{ +class InstrumentSelectorWidget : public ItemSelectorWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.cpp b/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.cpp index d04192fc7c5fa235ad8bf924cd116681f2182f8f..9a64d8040ec0bb6c0dba4311b11db3a696955052 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.cpp @@ -31,8 +31,7 @@ InstrumentViewActions::InstrumentViewActions(QWidget* parent) , m_removeInstrumentAction(nullptr) , m_cloneInstrumentAction(nullptr) , m_model(nullptr) - , m_selectionModel(nullptr) -{ + , m_selectionModel(nullptr) { initAddInstrumentMenu(); m_removeInstrumentAction = @@ -47,32 +46,27 @@ InstrumentViewActions::InstrumentViewActions(QWidget* parent) &InstrumentViewActions::onCloneInstrument); } -InstrumentViewActions::~InstrumentViewActions() -{ +InstrumentViewActions::~InstrumentViewActions() { delete m_addInstrumentMenu; } -void InstrumentViewActions::setModel(SessionModel* model) -{ +void InstrumentViewActions::setModel(SessionModel* model) { m_model = model; } -void InstrumentViewActions::setSelectionModel(QItemSelectionModel* selectionModel) -{ +void InstrumentViewActions::setSelectionModel(QItemSelectionModel* selectionModel) { m_selectionModel = selectionModel; } //! Returns menu to create one of available instrument types. -QMenu* InstrumentViewActions::instrumentMenu() -{ +QMenu* InstrumentViewActions::instrumentMenu() { return m_addInstrumentMenu; } //! Adds instrument of certain type. Type of instrument is extracted from sender internal data. -void InstrumentViewActions::onAddInstrument() -{ +void InstrumentViewActions::onAddInstrument() { auto action = qobject_cast<QAction*>(sender()); ASSERT(action && action->data().canConvert(QVariant::String)); @@ -103,8 +97,7 @@ void InstrumentViewActions::onAddInstrument() //! Removes currently selected instrument. -void InstrumentViewActions::onRemoveInstrument() -{ +void InstrumentViewActions::onRemoveInstrument() { QModelIndex currentIndex = m_selectionModel->currentIndex(); if (currentIndex.isValid()) @@ -115,8 +108,7 @@ void InstrumentViewActions::onRemoveInstrument() //! Clones currently selected instrument. -void InstrumentViewActions::onCloneInstrument() -{ +void InstrumentViewActions::onCloneInstrument() { QModelIndex currentIndex = m_selectionModel->currentIndex(); if (currentIndex.isValid()) { @@ -151,8 +143,7 @@ void InstrumentViewActions::onCloneInstrument() } void InstrumentViewActions::onContextMenuRequest(const QPoint& point, - const QModelIndex& indexAtPoint) -{ + const QModelIndex& indexAtPoint) { QMenu menu; setAllActionsEnabled(indexAtPoint.isValid()); @@ -164,14 +155,12 @@ void InstrumentViewActions::onContextMenuRequest(const QPoint& point, menu.exec(point); } -void InstrumentViewActions::setAllActionsEnabled(bool value) -{ +void InstrumentViewActions::setAllActionsEnabled(bool value) { m_removeInstrumentAction->setEnabled(value); m_cloneInstrumentAction->setEnabled(value); } -void InstrumentViewActions::updateSelection() -{ +void InstrumentViewActions::updateSelection() { if (!m_selectionModel->hasSelection()) { // select last item QModelIndex itemIndex = @@ -180,8 +169,7 @@ void InstrumentViewActions::updateSelection() } } -QString InstrumentViewActions::suggestInstrumentName(const QString& currentName) -{ +QString InstrumentViewActions::suggestInstrumentName(const QString& currentName) { auto map_of_names = mapOfNames(); int ncopies = map_of_names[currentName]; @@ -194,8 +182,7 @@ QString InstrumentViewActions::suggestInstrumentName(const QString& currentName) } } -QMap<QString, int> InstrumentViewActions::mapOfNames() -{ +QMap<QString, int> InstrumentViewActions::mapOfNames() { QMap<QString, int> result; for (auto& name : ModelUtils::topItemNames(m_model)) { @@ -214,8 +201,7 @@ QMap<QString, int> InstrumentViewActions::mapOfNames() //! Constructs menu to add instruments of various types. The type of instrument //! is encoded in QAction internal data. -void InstrumentViewActions::initAddInstrumentMenu() -{ +void InstrumentViewActions::initAddInstrumentMenu() { m_addInstrumentMenu = new QMenu("Add new instrument"); m_addInstrumentMenu->setToolTipsVisible(true); diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.h b/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.h index 6388ec400111c2d652bbc0af48207f2993516e0c..0dc0d8056d350354f9443f1bbc00b5d4909e57ef 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.h +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.h @@ -26,8 +26,7 @@ class QMenu; //! Collection of actions to add/remove/clone instrument. -class InstrumentViewActions : public QObject -{ +class InstrumentViewActions : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentViewToolBar.cpp b/GUI/coregui/Views/InstrumentWidgets/InstrumentViewToolBar.cpp index c46e7841d911525c7d2d55f661311a7a83f35b63..1ce0fee481d148e63ee08062432d151ad8c0217d 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentViewToolBar.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentViewToolBar.cpp @@ -22,8 +22,7 @@ InstrumentViewToolBar::InstrumentViewToolBar(InstrumentViewActions* actions, QWi , m_addInstrumentButton(new QToolButton) , m_removeInstrumentButton(new QToolButton) , m_cloneInstrumentButton(new QToolButton) - , m_addInstrumentMenu(actions->instrumentMenu()) -{ + , m_addInstrumentMenu(actions->instrumentMenu()) { m_addInstrumentButton->setText("Add"); m_addInstrumentButton->setIcon(QIcon(":/images/shape-square-plus.svg")); m_addInstrumentButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); @@ -53,7 +52,6 @@ InstrumentViewToolBar::InstrumentViewToolBar(InstrumentViewActions* actions, QWi &InstrumentViewActions::onCloneInstrument); } -void InstrumentViewToolBar::onAddInstrument() -{ +void InstrumentViewToolBar::onAddInstrument() { m_addInstrumentMenu->defaultAction()->triggered(); } diff --git a/GUI/coregui/Views/InstrumentWidgets/InstrumentViewToolBar.h b/GUI/coregui/Views/InstrumentWidgets/InstrumentViewToolBar.h index df35490165d6d0944ef3749a4cabe780d44b5798..409065d0b66278478525c1cb4ad57abdcb2b449b 100644 --- a/GUI/coregui/Views/InstrumentWidgets/InstrumentViewToolBar.h +++ b/GUI/coregui/Views/InstrumentWidgets/InstrumentViewToolBar.h @@ -25,8 +25,7 @@ class QMenu; //! Styled tool bar on top of InstrumentView with add/remove/clone instrument buttons. -class InstrumentViewToolBar : public StyledToolBar -{ +class InstrumentViewToolBar : public StyledToolBar { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/OffSpecBeamEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/OffSpecBeamEditor.cpp index 0134f2b1ea0836a879be53fc4619ec8aa55be7f1..3b310285a52c89186abf805b9aaac40883c9077d 100644 --- a/GUI/coregui/Views/InstrumentWidgets/OffSpecBeamEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/OffSpecBeamEditor.cpp @@ -21,8 +21,7 @@ #include <QGridLayout> #include <QGroupBox> -namespace -{ +namespace { const QString wavelength_title("Wavelength [nm]"); const QString inclination_title("Inclination angle [deg]"); const QString azimuthal_title("Azimuthal angle [deg]"); @@ -36,8 +35,7 @@ OffSpecBeamEditor::OffSpecBeamEditor(ColumnResizer* columnResizer, QWidget* pare , m_wavelengthEditor(new ComponentEditor(ComponentEditor::InfoWidget, wavelength_title)) , m_inclinationEditor(new ComponentEditor(ComponentEditor::GroupWidget, inclination_title)) , m_azimuthalEditor(new ComponentEditor(ComponentEditor::InfoWidget, azimuthal_title)) - , m_gridLayout(new QGridLayout) -{ + , m_gridLayout(new QGridLayout) { m_gridLayout->addWidget(m_intensityEditor, 0, 0); m_gridLayout->addWidget(m_wavelengthEditor, 1, 0); m_gridLayout->addWidget(m_inclinationEditor, 1, 1); @@ -60,8 +58,7 @@ OffSpecBeamEditor::OffSpecBeamEditor(ColumnResizer* columnResizer, QWidget* pare m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 2); } -void OffSpecBeamEditor::subscribeToItem() -{ +void OffSpecBeamEditor::subscribeToItem() { m_intensityEditor->setItem(beamItem()->getItem(BeamItem::P_INTENSITY)); auto wavelengthItem = beamItem()->getItem(BeamItem::P_WAVELENGTH); @@ -74,28 +71,24 @@ void OffSpecBeamEditor::subscribeToItem() m_azimuthalEditor->setItem(azimuthalItem->getItem(BeamDistributionItem::P_DISTRIBUTION)); } -void OffSpecBeamEditor::unsubscribeFromItem() -{ +void OffSpecBeamEditor::unsubscribeFromItem() { m_intensityEditor->clearEditor(); m_wavelengthEditor->clearEditor(); m_inclinationEditor->clearEditor(); m_azimuthalEditor->clearEditor(); } -OffSpecInstrumentItem* OffSpecBeamEditor::instrumentItem() -{ +OffSpecInstrumentItem* OffSpecBeamEditor::instrumentItem() { auto result = dynamic_cast<OffSpecInstrumentItem*>(currentItem()); ASSERT(result); return result; } -BeamItem* OffSpecBeamEditor::beamItem() -{ +BeamItem* OffSpecBeamEditor::beamItem() { return instrumentItem()->beamItem(); } -void OffSpecBeamEditor::onDialogRequest(SessionItem* item, const QString& name) -{ +void OffSpecBeamEditor::onDialogRequest(SessionItem* item, const QString& name) { if (!item) return; diff --git a/GUI/coregui/Views/InstrumentWidgets/OffSpecBeamEditor.h b/GUI/coregui/Views/InstrumentWidgets/OffSpecBeamEditor.h index 9b58271da875ee4f1a1c8fef1a9fce9da31a49d5..87d9c50a6bcc711f0e6c3a7adb81687e78cfe276 100644 --- a/GUI/coregui/Views/InstrumentWidgets/OffSpecBeamEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/OffSpecBeamEditor.h @@ -25,8 +25,7 @@ class ColumnResizer; //! GISAS beam editor. Operates on GISASInstrumentItem. -class OffSpecBeamEditor : public SessionItemWidget -{ +class OffSpecBeamEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/OffSpecInstrumentEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/OffSpecInstrumentEditor.cpp index 26202ba1a1c70fcff31f2057f771015a04f3b33f..5a83492af0c10b0848d78fadcaf9669440a8c4ca 100644 --- a/GUI/coregui/Views/InstrumentWidgets/OffSpecInstrumentEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/OffSpecInstrumentEditor.cpp @@ -31,8 +31,7 @@ OffSpecInstrumentEditor::OffSpecInstrumentEditor(QWidget* parent) //, m_environmentEditor(new EnvironmentEditor(m_columnResizer)) //, m_polarizationAnalysisEditor(new PolarizationAnalysisEditor(m_columnResizer)) , m_environmentEditor(nullptr) - , m_polarizationAnalysisEditor(nullptr) -{ + , m_polarizationAnalysisEditor(nullptr) { auto mainLayout = new QVBoxLayout; mainLayout->addWidget(StyleUtils::createDetailsWidget(m_beamEditor, "Beam parameters")); @@ -42,16 +41,14 @@ OffSpecInstrumentEditor::OffSpecInstrumentEditor(QWidget* parent) setLayout(mainLayout); } -void OffSpecInstrumentEditor::subscribeToItem() -{ +void OffSpecInstrumentEditor::subscribeToItem() { m_beamEditor->setItem(instrumentItem()); m_detectorEditor->setItem(instrumentItem()); // m_environmentEditor->setItem(instrumentItem()); // m_polarizationAnalysisEditor->setItem(instrumentItem()); } -OffSpecInstrumentItem* OffSpecInstrumentEditor::instrumentItem() -{ +OffSpecInstrumentItem* OffSpecInstrumentEditor::instrumentItem() { auto result = dynamic_cast<OffSpecInstrumentItem*>(currentItem()); ASSERT(result); return result; diff --git a/GUI/coregui/Views/InstrumentWidgets/OffSpecInstrumentEditor.h b/GUI/coregui/Views/InstrumentWidgets/OffSpecInstrumentEditor.h index 08f46d9f67cd0661c96e4c573817bb983e8873c0..18ccc5fd818a41c196423687aa8f923a30875b04 100644 --- a/GUI/coregui/Views/InstrumentWidgets/OffSpecInstrumentEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/OffSpecInstrumentEditor.h @@ -24,8 +24,7 @@ class EnvironmentEditor; class PolarizationAnalysisEditor; class ColumnResizer; -class OffSpecInstrumentEditor : public SessionItemWidget -{ +class OffSpecInstrumentEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/PolarizationAnalysisEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/PolarizationAnalysisEditor.cpp index 0adcf785d270db856182cf81e0363f70c4eaaec3..2487e02942345a5a7f552df95f13e77e80d87726 100644 --- a/GUI/coregui/Views/InstrumentWidgets/PolarizationAnalysisEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/PolarizationAnalysisEditor.cpp @@ -21,8 +21,7 @@ #include <QGridLayout> #include <QSpacerItem> -namespace -{ +namespace { const QString beam_pol_title("Polarization (Bloch vector)"); const QString analyzer_orientation_title = "Analyzer orientation"; const QString analyzer_properties_title = "Analyzer properties"; @@ -37,8 +36,7 @@ PolarizationAnalysisEditor::PolarizationAnalysisEditor(ColumnResizer* columnResi new ComponentEditor(ComponentEditor::GroupWidget, analyzer_orientation_title)) , m_analyserPropertiesEditor( new ComponentEditor(ComponentEditor::GroupWidget, analyzer_properties_title)) - , m_gridLayout(new QGridLayout) -{ + , m_gridLayout(new QGridLayout) { m_gridLayout->addWidget(m_polarizationEditor, 0, 0); m_gridLayout->addWidget(m_analyserDirectionEditor, 0, 1); m_gridLayout->addWidget(m_analyserPropertiesEditor, 0, 2); @@ -53,8 +51,7 @@ PolarizationAnalysisEditor::PolarizationAnalysisEditor(ColumnResizer* columnResi m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 2); } -void PolarizationAnalysisEditor::subscribeToItem() -{ +void PolarizationAnalysisEditor::subscribeToItem() { m_polarizationEditor->setItem(beamItem()->getItem(BeamItem::P_POLARIZATION)); currentItem()->mapper()->setOnPropertyChange( @@ -67,35 +64,30 @@ void PolarizationAnalysisEditor::subscribeToItem() updateAnalyserEditor(); } -void PolarizationAnalysisEditor::unsubscribeFromItem() -{ +void PolarizationAnalysisEditor::unsubscribeFromItem() { m_polarizationEditor->clearEditor(); m_analyserDirectionEditor->clearEditor(); m_analyserPropertiesEditor->clearEditor(); } -GISASInstrumentItem* PolarizationAnalysisEditor::instrumentItem() -{ +GISASInstrumentItem* PolarizationAnalysisEditor::instrumentItem() { auto result = dynamic_cast<GISASInstrumentItem*>(currentItem()); ASSERT(result); return result; } -BeamItem* PolarizationAnalysisEditor::beamItem() -{ +BeamItem* PolarizationAnalysisEditor::beamItem() { return instrumentItem()->beamItem(); } -DetectorItem* PolarizationAnalysisEditor::detectorItem() -{ +DetectorItem* PolarizationAnalysisEditor::detectorItem() { return instrumentItem()->detectorItem(); } //! Updates analyser editor to display properties of currently selected detector //! (spherical/rectangular). -void PolarizationAnalysisEditor::updateAnalyserEditor() -{ +void PolarizationAnalysisEditor::updateAnalyserEditor() { m_analyserDirectionEditor->clearEditor(); m_analyserPropertiesEditor->clearEditor(); m_analyserDirectionEditor->addItem(detectorItem()->getItem(DetectorItem::P_ANALYZER_DIRECTION)); diff --git a/GUI/coregui/Views/InstrumentWidgets/PolarizationAnalysisEditor.h b/GUI/coregui/Views/InstrumentWidgets/PolarizationAnalysisEditor.h index 41a05b4161c0b4c2947eb1ede7a6c68d077ec03d..2849ba05d05e87e02f903c581f5400ec4b37a86e 100644 --- a/GUI/coregui/Views/InstrumentWidgets/PolarizationAnalysisEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/PolarizationAnalysisEditor.h @@ -27,8 +27,7 @@ class ColumnResizer; //! Polarization analysis editor (beam polarization, analyzer properies) for GISASInstrumentEditor. //! Operates on GISASInstrumentItem. -class PolarizationAnalysisEditor : public SessionItemWidget -{ +class PolarizationAnalysisEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorEditor.cpp index fbb1174e80d3aba5d016a5ff82c7acc28738c370..7a3fda8a5920b3b002ab4c89b42068f82c5d2c0c 100644 --- a/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorEditor.cpp @@ -27,8 +27,7 @@ RectangularDetectorEditor::RectangularDetectorEditor(QWidget* parent) , m_positionsEditor(nullptr) , m_normalEditor(nullptr) , m_directionEditor(nullptr) - , m_gridLayout(new QGridLayout) -{ + , m_gridLayout(new QGridLayout) { create_editors(); auto mainLayout = new QVBoxLayout; @@ -38,22 +37,19 @@ RectangularDetectorEditor::RectangularDetectorEditor(QWidget* parent) setLayout(mainLayout); } -void RectangularDetectorEditor::onPropertyChanged(const QString& propertyName) -{ +void RectangularDetectorEditor::onPropertyChanged(const QString& propertyName) { if (propertyName == RectangularDetectorItem::P_ALIGNMENT) init_alignment_editors(); } -void RectangularDetectorEditor::subscribeToItem() -{ +void RectangularDetectorEditor::subscribeToItem() { detectorItem()->mapper()->setOnPropertyChange( [this](const QString& name) { onPropertyChanged(name); }, this); init_editors(); } -void RectangularDetectorEditor::unsubscribeFromItem() -{ +void RectangularDetectorEditor::unsubscribeFromItem() { m_xAxisEditor->clearEditor(); m_yAxisEditor->clearEditor(); m_resolutionFunctionEditor->clearEditor(); @@ -63,15 +59,13 @@ void RectangularDetectorEditor::unsubscribeFromItem() m_directionEditor->clearEditor(); } -RectangularDetectorItem* RectangularDetectorEditor::detectorItem() -{ +RectangularDetectorItem* RectangularDetectorEditor::detectorItem() { auto result = dynamic_cast<RectangularDetectorItem*>(currentItem()); ASSERT(result); return result; } -void RectangularDetectorEditor::create_editors() -{ +void RectangularDetectorEditor::create_editors() { // axes and resolution function editors m_xAxisEditor = new ComponentEditor(ComponentEditor::GroupWidget, "X axis"); m_gridLayout->addWidget(m_xAxisEditor, 1, 0); @@ -98,8 +92,7 @@ void RectangularDetectorEditor::create_editors() m_gridLayout->addWidget(m_directionEditor, 3, 2); } -void RectangularDetectorEditor::init_editors() -{ +void RectangularDetectorEditor::init_editors() { m_xAxisEditor->clearEditor(); auto xAxisItem = detectorItem()->getItem(RectangularDetectorItem::P_X_AXIS); m_xAxisEditor->setItem(xAxisItem); @@ -118,8 +111,7 @@ void RectangularDetectorEditor::init_editors() init_alignment_editors(); } -void RectangularDetectorEditor::init_alignment_editors() -{ +void RectangularDetectorEditor::init_alignment_editors() { m_positionsEditor->clearEditor(); m_positionsEditor->hide(); diff --git a/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorEditor.h b/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorEditor.h index fbec9e42a6a60a529558cbac5f6ece89149b67df..e13a39302c299d886bd01f28787f16321b70cd55 100644 --- a/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorEditor.h @@ -20,8 +20,7 @@ class RectangularDetectorItem; class ComponentEditor; class QGridLayout; -class RectangularDetectorEditor : public SessionItemWidget -{ +class RectangularDetectorEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/SpecularBeamEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/SpecularBeamEditor.cpp index 6e10f58f4a99dfc61598aac465beaa5fcfb6ada8..1fa3e3c090e5b7a2ee00b20499d0d00834e1624c 100644 --- a/GUI/coregui/Views/InstrumentWidgets/SpecularBeamEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/SpecularBeamEditor.cpp @@ -22,8 +22,7 @@ #include <QGridLayout> #include <QGroupBox> -namespace -{ +namespace { const QString wavelength_title("Wavelength [nm]"); const QString inclination_title("Inclination angles [deg]"); const QString footprint_title("Footprint correction"); @@ -37,8 +36,7 @@ SpecularBeamEditor::SpecularBeamEditor(ColumnResizer* columnResizer, QWidget* pa , m_wavelengthEditor(new ComponentEditor(ComponentEditor::InfoWidget, wavelength_title)) , m_inclinationEditor(new ComponentEditor(ComponentEditor::InfoWidget, inclination_title)) , m_footprint_editor(new ComponentEditor(ComponentEditor::GroupWidget, footprint_title)) - , m_gridLayout(new QGridLayout) -{ + , m_gridLayout(new QGridLayout) { m_gridLayout->addWidget(m_intensityEditor, 0, 0); m_gridLayout->addWidget(m_wavelengthEditor, 1, 0); m_gridLayout->addWidget(m_inclinationEditor, 1, 1); @@ -60,8 +58,7 @@ SpecularBeamEditor::SpecularBeamEditor(ColumnResizer* columnResizer, QWidget* pa m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 2); } -void SpecularBeamEditor::subscribeToItem() -{ +void SpecularBeamEditor::subscribeToItem() { const auto beam_item = instrumentItem()->beamItem(); ASSERT(beam_item); @@ -79,23 +76,20 @@ void SpecularBeamEditor::subscribeToItem() m_footprint_editor->setItem(beam_item->getItem(SpecularBeamItem::P_FOOPTPRINT)); } -void SpecularBeamEditor::unsubscribeFromItem() -{ +void SpecularBeamEditor::unsubscribeFromItem() { m_intensityEditor->clearEditor(); m_wavelengthEditor->clearEditor(); m_inclinationEditor->clearEditor(); m_footprint_editor->clearEditor(); } -SpecularInstrumentItem* SpecularBeamEditor::instrumentItem() -{ +SpecularInstrumentItem* SpecularBeamEditor::instrumentItem() { auto result = dynamic_cast<SpecularInstrumentItem*>(currentItem()); ASSERT(result); return result; } -void SpecularBeamEditor::onDialogRequest(SessionItem* item, const QString& name) -{ +void SpecularBeamEditor::onDialogRequest(SessionItem* item, const QString& name) { if (!item) return; diff --git a/GUI/coregui/Views/InstrumentWidgets/SpecularBeamEditor.h b/GUI/coregui/Views/InstrumentWidgets/SpecularBeamEditor.h index 5d75e892c017802500019ce7b821f03eb2dd7265..dbeac2a8d5d389466f5686b8c648bc75deadf032 100644 --- a/GUI/coregui/Views/InstrumentWidgets/SpecularBeamEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/SpecularBeamEditor.h @@ -25,8 +25,7 @@ class SpecularInstrumentItem; //! Specular beam editor. Operates on SpecularInstrumentItem. -class SpecularBeamEditor : public SessionItemWidget -{ +class SpecularBeamEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/SpecularInstrumentEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/SpecularInstrumentEditor.cpp index d86ed3161cc56468826b6a96aafa824a5c693fce..620f4db37f8377318c13e4b4a4ef80de6ca38d15 100644 --- a/GUI/coregui/Views/InstrumentWidgets/SpecularInstrumentEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/SpecularInstrumentEditor.cpp @@ -26,8 +26,7 @@ SpecularInstrumentEditor::SpecularInstrumentEditor(QWidget* parent) , m_columnResizer(new ColumnResizer(this)) , m_beamEditor(new SpecularBeamEditor(m_columnResizer)) , m_environmentEditor(new EnvironmentEditor(m_columnResizer)) - , m_polarizationAnalysisEditor(nullptr) -{ + , m_polarizationAnalysisEditor(nullptr) { auto mainLayout = new QVBoxLayout; mainLayout->addWidget(StyleUtils::createDetailsWidget(m_beamEditor, "Beam parameters")); @@ -38,15 +37,13 @@ SpecularInstrumentEditor::SpecularInstrumentEditor(QWidget* parent) setLayout(mainLayout); } -void SpecularInstrumentEditor::subscribeToItem() -{ +void SpecularInstrumentEditor::subscribeToItem() { m_beamEditor->setItem(instrumentItem()); m_environmentEditor->setItem(instrumentItem()); // m_polarizationAnalysisEditor->setItem(instrumentItem()); } -SpecularInstrumentItem* SpecularInstrumentEditor::instrumentItem() -{ +SpecularInstrumentItem* SpecularInstrumentEditor::instrumentItem() { auto result = dynamic_cast<SpecularInstrumentItem*>(currentItem()); ASSERT(result); return result; diff --git a/GUI/coregui/Views/InstrumentWidgets/SpecularInstrumentEditor.h b/GUI/coregui/Views/InstrumentWidgets/SpecularInstrumentEditor.h index f89c77dcdaf336affdf5aea8000143104e3bdb3f..426674a050ffcc56ea4e76951449c5bf2f1fbdaa 100644 --- a/GUI/coregui/Views/InstrumentWidgets/SpecularInstrumentEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/SpecularInstrumentEditor.h @@ -24,8 +24,7 @@ class PolarizationAnalysisEditor; class ColumnResizer; class QVBoxLayout; -class SpecularInstrumentEditor : public SessionItemWidget -{ +class SpecularInstrumentEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorEditor.cpp b/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorEditor.cpp index 67b9f11830b781fb8534771f27c6d7a19d50140a..02512cfa129ca5e8ce8fc0702c656e7904ded34f 100644 --- a/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorEditor.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorEditor.cpp @@ -17,8 +17,7 @@ #include "GUI/coregui/Views/PropertyEditor/ComponentEditor.h" #include <QGridLayout> -namespace -{ +namespace { const QString phi_axis_title = "Phi axis"; const QString alpha_axis_title = "Alpha axis"; const QString resolution_title = "Resolution function"; @@ -31,8 +30,7 @@ SphericalDetectorEditor::SphericalDetectorEditor(QWidget* parent) , m_alphaAxisEditor(new ComponentEditor(ComponentEditor::GroupWidget, alpha_axis_title)) , m_resolutionFunctionEditor( new ComponentEditor(ComponentEditor::GroupWidget, resolution_title)) - , m_gridLayout(new QGridLayout) -{ + , m_gridLayout(new QGridLayout) { m_gridLayout->addWidget(m_phiAxisEditor, 1, 0); m_gridLayout->addWidget(m_alphaAxisEditor, 1, 1); m_gridLayout->addWidget(m_resolutionFunctionEditor, 1, 2); @@ -44,8 +42,7 @@ SphericalDetectorEditor::SphericalDetectorEditor(QWidget* parent) setLayout(mainLayout); } -void SphericalDetectorEditor::subscribeToItem() -{ +void SphericalDetectorEditor::subscribeToItem() { auto phiAxisItem = detectorItem()->getItem(SphericalDetectorItem::P_PHI_AXIS); m_phiAxisEditor->setItem(phiAxisItem); @@ -56,15 +53,13 @@ void SphericalDetectorEditor::subscribeToItem() m_resolutionFunctionEditor->setItem(resFuncGroup); } -void SphericalDetectorEditor::unsubscribeFromItem() -{ +void SphericalDetectorEditor::unsubscribeFromItem() { m_phiAxisEditor->clearEditor(); m_alphaAxisEditor->clearEditor(); m_resolutionFunctionEditor->clearEditor(); } -SphericalDetectorItem* SphericalDetectorEditor::detectorItem() -{ +SphericalDetectorItem* SphericalDetectorEditor::detectorItem() { auto result = dynamic_cast<SphericalDetectorItem*>(currentItem()); ASSERT(result); return result; diff --git a/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorEditor.h b/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorEditor.h index f1c77d7f8b6ed6ef131ecaa9f2fdad524a06078d..029b70e7b64345044f70f24e6cee0dabe2ba2c2b 100644 --- a/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorEditor.h +++ b/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorEditor.h @@ -20,8 +20,7 @@ class SphericalDetectorItem; class ComponentEditor; class QGridLayout; -class SphericalDetectorEditor : public SessionItemWidget -{ +class SphericalDetectorEditor : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp index e4037452f9770186d759965ecb111da01c106780..f9e46f91b51e99d8759cf45de455ea62aad57b6a 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp @@ -21,8 +21,7 @@ #include "GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.h" #include "GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.h" -namespace -{ +namespace { const int replot_update_interval = 10; const int colorbar_width_logz = 50; const int colorbar_width = 80; @@ -35,8 +34,7 @@ ColorMap::ColorMap(QWidget* parent) , m_colorScale(nullptr) , m_updateTimer(new UpdateTimer(replot_update_interval, this)) , m_colorBarLayout(new QCPLayoutGrid) - , m_block_update(true) -{ + , m_block_update(true) { initColorMap(); QVBoxLayout* vlayout = new QVBoxLayout(this); @@ -49,8 +47,7 @@ ColorMap::ColorMap(QWidget* parent) // setFixedColorMapMargins(); } -QRectF ColorMap::viewportRectangleInWidgetCoordinates() -{ +QRectF ColorMap::viewportRectangleInWidgetCoordinates() { QCPRange xrange = m_customPlot->xAxis->range(); QCPRange yrange = m_customPlot->yAxis->range(); double left = xrange.lower; @@ -63,8 +60,7 @@ QRectF ColorMap::viewportRectangleInWidgetCoordinates() yAxisCoordToPixel(bottom) - yAxisCoordToPixel(top)); } -PlotEventInfo ColorMap::eventInfo(double xpos, double ypos) const -{ +PlotEventInfo ColorMap::eventInfo(double xpos, double ypos) const { PlotEventInfo result(plotType()); if (!intensityItem()) return result; @@ -85,28 +81,24 @@ PlotEventInfo ColorMap::eventInfo(double xpos, double ypos) const } //! sets logarithmic scale -void ColorMap::setLogz(bool logz) -{ +void ColorMap::setLogz(bool logz) { m_colorBarLayout->setMinimumSize(logz ? colorbar_width_logz : colorbar_width, 10); ColorMapUtils::setLogz(m_colorScale, logz); } //! reset all axes min,max to initial value -void ColorMap::resetView() -{ +void ColorMap::resetView() { intensityItem()->resetView(); } -void ColorMap::onIntensityModified() -{ +void ColorMap::onIntensityModified() { setAxesRangeFromItem(intensityItem()); setDataFromItem(intensityItem()); replot(); } //! updates color map depending on IntensityDataItem properties -void ColorMap::onPropertyChanged(const QString& property_name) -{ +void ColorMap::onPropertyChanged(const QString& property_name) { if (m_block_update) return; @@ -122,8 +114,7 @@ void ColorMap::onPropertyChanged(const QString& property_name) } } -void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& propertyName) -{ +void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& propertyName) { if (m_block_update) return; @@ -168,16 +159,14 @@ void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& pro } //! Propagate zmin, zmax back to IntensityDataItem -void ColorMap::onDataRangeChanged(QCPRange newRange) -{ +void ColorMap::onDataRangeChanged(QCPRange newRange) { m_block_update = true; intensityItem()->setLowerAndUpperZ(newRange.lower, newRange.upper); m_block_update = false; } //! Propagate xmin, xmax back to IntensityDataItem -void ColorMap::onXaxisRangeChanged(QCPRange newRange) -{ +void ColorMap::onXaxisRangeChanged(QCPRange newRange) { m_block_update = true; intensityItem()->setLowerX(newRange.lower); intensityItem()->setUpperX(newRange.upper); @@ -185,8 +174,7 @@ void ColorMap::onXaxisRangeChanged(QCPRange newRange) } //! Propagate ymin, ymax back to IntensityDataItem -void ColorMap::onYaxisRangeChanged(QCPRange newRange) -{ +void ColorMap::onYaxisRangeChanged(QCPRange newRange) { m_block_update = true; intensityItem()->setLowerY(newRange.lower); intensityItem()->setUpperY(newRange.upper); @@ -195,20 +183,17 @@ void ColorMap::onYaxisRangeChanged(QCPRange newRange) //! Schedule replot for later execution by onTimeReplot() slot. -void ColorMap::replot() -{ +void ColorMap::replot() { m_updateTimer->scheduleUpdate(); } //! Replots ColorMap. -void ColorMap::onTimeToReplot() -{ +void ColorMap::onTimeToReplot() { m_customPlot->replot(); } -void ColorMap::subscribeToItem() -{ +void ColorMap::subscribeToItem() { setColorMapFromItem(intensityItem()); intensityItem()->mapper()->setOnPropertyChange( @@ -226,14 +211,12 @@ void ColorMap::subscribeToItem() setConnected(true); } -void ColorMap::unsubscribeFromItem() -{ +void ColorMap::unsubscribeFromItem() { setConnected(false); } //! creates and initializes the color map -void ColorMap::initColorMap() -{ +void ColorMap::initColorMap() { m_colorMap = new QCPColorMap(m_customPlot->xAxis, m_customPlot->yAxis); m_colorScale = new QCPColorScale(m_customPlot); m_colorMap->setColorScale(m_colorScale); @@ -257,8 +240,7 @@ void ColorMap::initColorMap() connect(m_customPlot, SIGNAL(afterReplot()), this, SLOT(marginsChangedNotify())); } -void ColorMap::setConnected(bool isConnected) -{ +void ColorMap::setConnected(bool isConnected) { setAxesRangeConnected(isConnected); setDataRangeConnected(isConnected); setUpdateTimerConnected(isConnected); @@ -266,8 +248,7 @@ void ColorMap::setConnected(bool isConnected) //! Connects/disconnects signals related to ColorMap's X,Y axes rectangle change. -void ColorMap::setAxesRangeConnected(bool isConnected) -{ +void ColorMap::setAxesRangeConnected(bool isConnected) { if (isConnected) { connect(m_customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(onXaxisRangeChanged(QCPRange)), Qt::UniqueConnection); @@ -286,8 +267,7 @@ void ColorMap::setAxesRangeConnected(bool isConnected) //! Connects/disconnects signals related to ColorMap's Z-axis (min,max) change. -void ColorMap::setDataRangeConnected(bool isConnected) -{ +void ColorMap::setDataRangeConnected(bool isConnected) { if (isConnected) connect(m_colorMap, SIGNAL(dataRangeChanged(QCPRange)), this, SLOT(onDataRangeChanged(QCPRange)), Qt::UniqueConnection); @@ -296,8 +276,7 @@ void ColorMap::setDataRangeConnected(bool isConnected) SLOT(onDataRangeChanged(QCPRange))); } -void ColorMap::setUpdateTimerConnected(bool isConnected) -{ +void ColorMap::setUpdateTimerConnected(bool isConnected) { if (isConnected) connect(m_updateTimer, SIGNAL(timeToUpdate()), this, SLOT(onTimeToReplot()), Qt::UniqueConnection); @@ -306,15 +285,13 @@ void ColorMap::setUpdateTimerConnected(bool isConnected) } //! to make fixed margins for whole colormap (change in axes labels wont affect axes rectangle) -void ColorMap::setFixedColorMapMargins() -{ +void ColorMap::setFixedColorMapMargins() { ColorMapUtils::setDefaultMargins(m_customPlot); } //! Sets initial state of ColorMap to match given intensity item. -void ColorMap::setColorMapFromItem(IntensityDataItem* intensityItem) -{ +void ColorMap::setColorMapFromItem(IntensityDataItem* intensityItem) { ASSERT(intensityItem); m_block_update = true; @@ -333,8 +310,7 @@ void ColorMap::setColorMapFromItem(IntensityDataItem* intensityItem) //! Sets (xmin,xmax,nbins) and (ymin,ymax,nbins) of ColorMap from intensity item. -void ColorMap::setAxesRangeFromItem(IntensityDataItem* item) -{ +void ColorMap::setAxesRangeFromItem(IntensityDataItem* item) { m_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); m_customPlot->axisRect()->setupFullAxesBox(true); m_colorMap->data()->setSize(item->getNbinsX(), item->getNbinsY()); @@ -343,8 +319,7 @@ void ColorMap::setAxesRangeFromItem(IntensityDataItem* item) //! Sets zoom range of X,Y axes as in intensity item. -void ColorMap::setAxesZoomFromItem(IntensityDataItem* item) -{ +void ColorMap::setAxesZoomFromItem(IntensityDataItem* item) { setAxesRangeConnected(false); m_customPlot->xAxis->setRange(item->getLowerX(), item->getUpperX()); m_customPlot->yAxis->setRange(item->getLowerY(), item->getUpperY()); @@ -353,8 +328,7 @@ void ColorMap::setAxesZoomFromItem(IntensityDataItem* item) //! Sets X,Y axes labels from item -void ColorMap::setAxesLabelsFromItem(IntensityDataItem* item) -{ +void ColorMap::setAxesLabelsFromItem(IntensityDataItem* item) { auto xaxis = item->xAxisItem(); if (xaxis->getItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE).toBool()) m_customPlot->xAxis->setLabel(item->getXaxisTitle()); @@ -372,8 +346,7 @@ void ColorMap::setAxesLabelsFromItem(IntensityDataItem* item) //! Sets the intensity values to ColorMap. -void ColorMap::setDataFromItem(IntensityDataItem* item) -{ +void ColorMap::setDataFromItem(IntensityDataItem* item) { auto data = item->getOutputData(); if (!data) { m_colorMap->data()->clear(); @@ -389,8 +362,7 @@ void ColorMap::setDataFromItem(IntensityDataItem* item) //! Sets the appearance of color scale (visibility, gradient type) from intensity item. -void ColorMap::setColorScaleAppearanceFromItem(IntensityDataItem* item) -{ +void ColorMap::setColorScaleAppearanceFromItem(IntensityDataItem* item) { setColorScaleVisible(item->getItem(IntensityDataItem::P_ZAXIS) ->getItemValue(BasicAxisItem::P_IS_VISIBLE) .toBool()); @@ -403,16 +375,14 @@ void ColorMap::setColorScaleAppearanceFromItem(IntensityDataItem* item) m_colorScale->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup); } -void ColorMap::setDataRangeFromItem(IntensityDataItem* item) -{ +void ColorMap::setDataRangeFromItem(IntensityDataItem* item) { setDataRangeConnected(false); m_colorMap->setDataRange(ColorMapUtils::itemDataZoom(item)); setLogz(item->isLogz()); setDataRangeConnected(true); } -void ColorMap::setColorScaleVisible(bool visibility_flag) -{ +void ColorMap::setColorScaleVisible(bool visibility_flag) { m_colorBarLayout->setVisible(visibility_flag); if (visibility_flag) { // add it to the right of the main axis rect @@ -425,8 +395,7 @@ void ColorMap::setColorScaleVisible(bool visibility_flag) //! Calculates left, right margins around color map to report to projection plot. -void ColorMap::marginsChangedNotify() -{ +void ColorMap::marginsChangedNotify() { QMargins axesMargins = m_customPlot->axisRect()->margins(); // QMargins colorBarMargins = m_colorScale->margins(); // QMargins colorScaleMargins = m_colorScale->axis()->axisRect()->margins(); @@ -440,12 +409,10 @@ void ColorMap::marginsChangedNotify() emit marginsChanged(left, right); } -IntensityDataItem* ColorMap::intensityItem() -{ +IntensityDataItem* ColorMap::intensityItem() { return const_cast<IntensityDataItem*>(static_cast<const ColorMap*>(this)->intensityItem()); } -const IntensityDataItem* ColorMap::intensityItem() const -{ +const IntensityDataItem* ColorMap::intensityItem() const { return dynamic_cast<const IntensityDataItem*>(currentItem()); } diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h index 62ea09102638bd5451ae6109d6862d386812208a..5b51102c41a2f9a1f6bb1438507ad524ea315182 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h +++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h @@ -33,8 +33,7 @@ class ScientificPlotEvent; //! Provides a minimal functionality for data plotting and axes interaction. Should be a component //! for more complicated plotting widgets. This is a replacement for ColorMapPlot. -class ColorMap : public ScientificPlot -{ +class ColorMap : public ScientificPlot { Q_OBJECT public: diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMapCanvas.cpp b/GUI/coregui/Views/IntensityDataWidgets/ColorMapCanvas.cpp index a440b4daa33a93c1c8bd92d91055572572ea69e4..20d307ab06191a85376e443adaa957dc854c9fc5 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ColorMapCanvas.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMapCanvas.cpp @@ -24,8 +24,7 @@ ColorMapCanvas::ColorMapCanvas(QWidget* parent) : SessionItemWidget(parent) , m_colorMap(new ColorMap) , m_canvasEvent(new FontScalingEvent(m_colorMap, this)) - , m_statusLabel(new PlotStatusLabel(m_colorMap, this)) -{ + , m_statusLabel(new PlotStatusLabel(m_colorMap, this)) { this->installEventFilter(m_canvasEvent); QVBoxLayout* layout = new QVBoxLayout; layout->setMargin(0); @@ -39,29 +38,24 @@ ColorMapCanvas::ColorMapCanvas(QWidget* parent) setStatusLabelEnabled(false); } -void ColorMapCanvas::setItem(SessionItem* intensityDataItem) -{ +void ColorMapCanvas::setItem(SessionItem* intensityDataItem) { SessionItemWidget::setItem(intensityDataItem); m_colorMap->setItem(dynamic_cast<IntensityDataItem*>(intensityDataItem)); } -ColorMap* ColorMapCanvas::colorMap() -{ +ColorMap* ColorMapCanvas::colorMap() { return m_colorMap; } -QCustomPlot* ColorMapCanvas::customPlot() -{ +QCustomPlot* ColorMapCanvas::customPlot() { return m_colorMap->customPlot(); } -void ColorMapCanvas::setStatusLabelEnabled(bool flag) -{ +void ColorMapCanvas::setStatusLabelEnabled(bool flag) { m_statusLabel->setLabelEnabled(flag); m_statusLabel->setHidden(!flag); } -void ColorMapCanvas::onStatusString(const QString& name) -{ +void ColorMapCanvas::onStatusString(const QString& name) { m_statusLabel->setText(name); } diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMapCanvas.h b/GUI/coregui/Views/IntensityDataWidgets/ColorMapCanvas.h index dfdf5c6fb232983b184ded65a334e2ed7d2e0bb4..1da7c52d30756c6571fdc408b18566fe00a9a0a4 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ColorMapCanvas.h +++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMapCanvas.h @@ -27,8 +27,7 @@ class QCustomPlot; //! control of font size, status string appearance, defines common actions //! (reset view, save plot, show context menu). -class ColorMapCanvas : public SessionItemWidget -{ +class ColorMapCanvas : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.cpp b/GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.cpp index 08a4e7f192c77d3ce7aa87789289601d6e826e21..577a6069be7ab74a70a72571723fdc005f404726 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.cpp @@ -20,10 +20,8 @@ using gradient_map_t = QMap<QString, QCPColorGradient::GradientPreset>; -namespace -{ -gradient_map_t createGradientMap() -{ +namespace { +gradient_map_t createGradientMap() { gradient_map_t result; result["Grayscale"] = QCPColorGradient::gpGrayscale; @@ -44,14 +42,12 @@ gradient_map_t createGradientMap() // Converts xmin (low edge of first bin) and xmax (upper edge of last bin) to the // range expected by QCPColorMapData::setRange. -QCPRange qcpRange(double xmin, double xmax, int nbins) -{ +QCPRange qcpRange(double xmin, double xmax, int nbins) { double dx = (xmax - xmin) / nbins; return QCPRange(xmin + dx / 2., xmax - dx / 2.); } -QMargins defaultMargins(const QWidget& widget) -{ +QMargins defaultMargins(const QWidget& widget) { auto base_size = StyleUtils::SizeOfLetterM(&widget); int left = static_cast<int>(base_size.width() * 6.0); int top = static_cast<int>(base_size.height() * 1.5); @@ -62,8 +58,7 @@ QMargins defaultMargins(const QWidget& widget) } // namespace -QCPColorGradient ColorMapUtils::getGradient(const QString& gradientName) -{ +QCPColorGradient ColorMapUtils::getGradient(const QString& gradientName) { static gradient_map_t gradient_map = createGradientMap(); auto it = gradient_map.find(gradientName); @@ -74,44 +69,36 @@ QCPColorGradient ColorMapUtils::getGradient(const QString& gradientName) return QCPColorGradient(it.value()); } -QCPColorGradient ColorMapUtils::itemGradient(const IntensityDataItem* item) -{ +QCPColorGradient ColorMapUtils::itemGradient(const IntensityDataItem* item) { return getGradient(item->getGradient()); } -QCPRange ColorMapUtils::itemXrange(const IntensityDataItem* item) -{ +QCPRange ColorMapUtils::itemXrange(const IntensityDataItem* item) { return qcpRange(item->getXmin(), item->getXmax(), item->getNbinsX()); } -QCPRange ColorMapUtils::itemZoomX(const IntensityDataItem* item) -{ +QCPRange ColorMapUtils::itemZoomX(const IntensityDataItem* item) { return QCPRange(item->getLowerX(), item->getUpperX()); } -QCPRange ColorMapUtils::itemYrange(const IntensityDataItem* item) -{ +QCPRange ColorMapUtils::itemYrange(const IntensityDataItem* item) { return qcpRange(item->getYmin(), item->getYmax(), item->getNbinsY()); } -QCPRange ColorMapUtils::itemZoomY(const IntensityDataItem* item) -{ +QCPRange ColorMapUtils::itemZoomY(const IntensityDataItem* item) { return QCPRange(item->getLowerY(), item->getUpperY()); } -QCPRange ColorMapUtils::itemDataRange(const IntensityDataItem* item) -{ +QCPRange ColorMapUtils::itemDataRange(const IntensityDataItem* item) { QPair<double, double> range = item->dataRange(); return QCPRange(range.first, range.second); } -QCPRange ColorMapUtils::itemDataZoom(const IntensityDataItem* item) -{ +QCPRange ColorMapUtils::itemDataZoom(const IntensityDataItem* item) { return QCPRange(item->getLowerZ(), item->getUpperZ()); } -void ColorMapUtils::setLogz(QCPColorScale* scale, bool isLogz) -{ +void ColorMapUtils::setLogz(QCPColorScale* scale, bool isLogz) { if (isLogz && scale->dataScaleType() != QCPAxis::stLogarithmic) scale->setDataScaleType(QCPAxis::stLogarithmic); @@ -121,8 +108,7 @@ void ColorMapUtils::setLogz(QCPColorScale* scale, bool isLogz) setLogz(scale->axis(), isLogz); } -void ColorMapUtils::setLogz(QCPAxis* axis, bool isLogz) -{ +void ColorMapUtils::setLogz(QCPAxis* axis, bool isLogz) { if (isLogz) { axis->setNumberFormat("eb"); axis->setNumberPrecision(0); @@ -138,8 +124,7 @@ void ColorMapUtils::setLogz(QCPAxis* axis, bool isLogz) } } -void ColorMapUtils::setDefaultMargins(QCustomPlot* customPlot) -{ +void ColorMapUtils::setDefaultMargins(QCustomPlot* customPlot) { auto* axisRectangle = customPlot->axisRect(); axisRectangle->setAutoMargins(QCP::msTop | QCP::msBottom); axisRectangle->setMargins(defaultMargins(*customPlot)); diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.h b/GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.h index 46207909151db368b687c4eca622e0f454e884cd..db6af118a095bc0b7d5b43d6f81ab88bc0c13cd4 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.h +++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.h @@ -25,8 +25,7 @@ class ColorMap; //! Provides few helper functions for ColorMapPlot. -namespace ColorMapUtils -{ +namespace ColorMapUtils { QCPColorGradient getGradient(const QString& gradientName); QCPColorGradient itemGradient(const IntensityDataItem* item); diff --git a/GUI/coregui/Views/IntensityDataWidgets/FontScalingEvent.cpp b/GUI/coregui/Views/IntensityDataWidgets/FontScalingEvent.cpp index dde7aaee73e259be34619ba8108cd6850e0f1fce..1130be191c1c695d8ec95c3cd94b4e99093ca6f3 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/FontScalingEvent.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/FontScalingEvent.cpp @@ -18,19 +18,15 @@ #include <QResizeEvent> #include <qcustomplot.h> -namespace -{ +namespace { const QString tick_font = "tick-font-key"; const int widget_size_to_switch_font = 500; } // namespace FontScalingEvent::FontScalingEvent(ScientificPlot* plot, QWidget* parent) - : QObject(parent), m_plot(plot) -{ -} + : QObject(parent), m_plot(plot) {} -bool FontScalingEvent::eventFilter(QObject* obj, QEvent* event) -{ +bool FontScalingEvent::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::Resize) { QResizeEvent* resizeEvent = static_cast<QResizeEvent*>(event); ASSERT(resizeEvent); @@ -52,26 +48,22 @@ bool FontScalingEvent::eventFilter(QObject* obj, QEvent* event) //! Backup all fonts. -void FontScalingEvent::backupFonts() -{ +void FontScalingEvent::backupFonts() { m_fonts[tick_font] = m_plot->customPlot()->xAxis->tickLabelFont(); } -void FontScalingEvent::restoreFonts() -{ +void FontScalingEvent::restoreFonts() { QFont ff = m_fonts[tick_font]; setTickLabelFont(ff); } -void FontScalingEvent::scaleFonts(double factor) -{ +void FontScalingEvent::scaleFonts(double factor) { QFont ff = m_fonts[tick_font]; ff.setPointSizeF(ff.pointSizeF() * factor); setTickLabelFont(ff); } -void FontScalingEvent::setTickLabelFont(const QFont& font) -{ +void FontScalingEvent::setTickLabelFont(const QFont& font) { m_plot->customPlot()->xAxis->setTickLabelFont(font); m_plot->customPlot()->yAxis->setTickLabelFont(font); if (m_plot->plotType() != ScientificPlot::PLOT_TYPE::Plot2D) diff --git a/GUI/coregui/Views/IntensityDataWidgets/FontScalingEvent.h b/GUI/coregui/Views/IntensityDataWidgets/FontScalingEvent.h index 4e7725dd066e33a3f766f09dd002805f93912659..5407f6e86589c00a13ba069f15fe7edba7056486 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/FontScalingEvent.h +++ b/GUI/coregui/Views/IntensityDataWidgets/FontScalingEvent.h @@ -25,8 +25,7 @@ class ScientificPlot; //! Provides event filter for ScientificPlot. Its goal is to make font size adjustments //! on resize events. -class FontScalingEvent : public QObject -{ +class FontScalingEvent : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp index 061da6884a86016b5115197ceb4eacb7a915c78e..447d06ecb555d4e14c34cfdd973313ab5927cb38 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp @@ -26,19 +26,15 @@ #include <QSettings> #include <QVBoxLayout> -namespace -{ +namespace { -QString group_name() -{ +QString group_name() { return "IntensityDataCanvas/"; } -QString gradient_setting_name() -{ +QString gradient_setting_name() { return group_name() + IntensityDataItem::P_GRADIENT; } -QString interpolation_setting_name() -{ +QString interpolation_setting_name() { return group_name() + IntensityDataItem::P_IS_INTERPOLATED; } } // namespace @@ -47,8 +43,7 @@ IntensityDataCanvas::IntensityDataCanvas(QWidget* parent) : SessionItemWidget(parent) , m_colorMap(new ColorMapCanvas) , m_resetViewAction(nullptr) - , m_savePlotAction(nullptr) -{ + , m_savePlotAction(nullptr) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); auto layout = new QVBoxLayout; @@ -65,62 +60,52 @@ IntensityDataCanvas::IntensityDataCanvas(QWidget* parent) &IntensityDataCanvas::onMousePress, Qt::UniqueConnection); } -void IntensityDataCanvas::setItem(SessionItem* intensityItem) -{ +void IntensityDataCanvas::setItem(SessionItem* intensityItem) { SessionItemWidget::setItem(intensityItem); m_colorMap->setItem(intensityDataItem()); applyPersistentSettings(); } -QSize IntensityDataCanvas::sizeHint() const -{ +QSize IntensityDataCanvas::sizeHint() const { return QSize(500, 400); } -QSize IntensityDataCanvas::minimumSizeHint() const -{ +QSize IntensityDataCanvas::minimumSizeHint() const { return QSize(128, 128); } -QList<QAction*> IntensityDataCanvas::actionList() -{ +QList<QAction*> IntensityDataCanvas::actionList() { return QList<QAction*>() << m_resetViewAction << m_savePlotAction; } -void IntensityDataCanvas::onResetViewAction() -{ +void IntensityDataCanvas::onResetViewAction() { intensityDataItem()->resetView(); } -void IntensityDataCanvas::onSavePlotAction() -{ +void IntensityDataCanvas::onSavePlotAction() { QString dirname = AppSvc::projectManager()->userExportDir(); SavePlotAssistant saveAssistant; saveAssistant.savePlot(dirname, m_colorMap->customPlot(), intensityDataItem()->getOutputData()); } -void IntensityDataCanvas::onMousePress(QMouseEvent* event) -{ +void IntensityDataCanvas::onMousePress(QMouseEvent* event) { if (event->button() == Qt::RightButton) emit customContextMenuRequested(event->globalPos()); } -void IntensityDataCanvas::subscribeToItem() -{ +void IntensityDataCanvas::subscribeToItem() { intensityDataItem()->mapper()->setOnPropertyChange( [this](const QString& name) { onPropertyChanged(name); }, this); } -IntensityDataItem* IntensityDataCanvas::intensityDataItem() -{ +IntensityDataItem* IntensityDataCanvas::intensityDataItem() { IntensityDataItem* result = dynamic_cast<IntensityDataItem*>(currentItem()); ASSERT(result); return result; } -void IntensityDataCanvas::initActions() -{ +void IntensityDataCanvas::initActions() { m_resetViewAction = new QAction(this); m_resetViewAction->setText("Center view"); m_resetViewAction->setIcon(QIcon(":/images/camera-metering-center.svg")); @@ -138,8 +123,7 @@ void IntensityDataCanvas::initActions() //! Reads gradient/ interpolation settings from IntensityDataItem and writes to persistant //! project settings. -void IntensityDataCanvas::onPropertyChanged(const QString& name) -{ +void IntensityDataCanvas::onPropertyChanged(const QString& name) { if (name == IntensityDataItem::P_GRADIENT) { QSettings settings; settings.setValue(gradient_setting_name(), intensityDataItem()->getGradient()); @@ -151,8 +135,7 @@ void IntensityDataCanvas::onPropertyChanged(const QString& name) //! Apply persistent settings (gradient, interpolation) to IntensityDataItem. -void IntensityDataCanvas::applyPersistentSettings() -{ +void IntensityDataCanvas::applyPersistentSettings() { QSettings settings; if (settings.contains(gradient_setting_name())) { diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.h b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.h index 75ee1ab4793d82b4108e3714b3fd9a4060f80e42..36fc70f9a9873f48daea48f88d32c6d19899ac42 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.h +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.h @@ -27,8 +27,7 @@ class QAction; //! The IntensityDataCanvas class represents IntensityDataItem as color map, //! provides standard actions (reset view, save as) for external toolbars and context menus. -class IntensityDataCanvas : public SessionItemWidget -{ +class IntensityDataCanvas : public SessionItemWidget { Q_OBJECT public: explicit IntensityDataCanvas(QWidget* parent = 0); diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataFFTPresenter.cpp b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataFFTPresenter.cpp index 154f6a7df7478fd752a5c24858d6e9f589101cef..cbe73be754afdfb8d379e45b7f155ff6705cae84 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataFFTPresenter.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataFFTPresenter.cpp @@ -26,8 +26,7 @@ IntensityDataFFTPresenter::IntensityDataFFTPresenter(QWidget* parent) , m_fftAction(nullptr) , m_fftModel(new SessionModel("TempFFTModel", this)) , m_fftItem(nullptr) - , m_in_fft_mode(false) -{ + , m_in_fft_mode(false) { m_fftItem = dynamic_cast<IntensityDataItem*>(m_fftModel->insertNewItem("IntensityData")); m_fftAction = new QAction(this); @@ -37,13 +36,11 @@ IntensityDataFFTPresenter::IntensityDataFFTPresenter(QWidget* parent) connect(m_fftAction, &QAction::triggered, this, &IntensityDataFFTPresenter::onFFTActionRequest); } -void IntensityDataFFTPresenter::reset() -{ +void IntensityDataFFTPresenter::reset() { m_in_fft_mode = false; } -IntensityDataItem* IntensityDataFFTPresenter::fftItem(IntensityDataItem* origItem) -{ +IntensityDataItem* IntensityDataFFTPresenter::fftItem(IntensityDataItem* origItem) { if (!origItem) throw GUIHelpers::Error("IntensityDataFFTPresenter::fftItem() -> Error. Empty item."); @@ -57,18 +54,15 @@ IntensityDataItem* IntensityDataFFTPresenter::fftItem(IntensityDataItem* origIte return m_fftItem; } -QList<QAction*> IntensityDataFFTPresenter::actionList() -{ +QList<QAction*> IntensityDataFFTPresenter::actionList() { return QList<QAction*>() << m_fftAction; } -bool IntensityDataFFTPresenter::inFFTMode() const -{ +bool IntensityDataFFTPresenter::inFFTMode() const { return m_in_fft_mode; } -void IntensityDataFFTPresenter::onFFTActionRequest() -{ +void IntensityDataFFTPresenter::onFFTActionRequest() { m_in_fft_mode = !m_in_fft_mode; fftActionRequest(); } diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataFFTPresenter.h b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataFFTPresenter.h index 559735b30f86cf47268994125525716bc3602d1b..ce17dd19c98fa3a814adb1e3775495f884ff6cd9 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataFFTPresenter.h +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataFFTPresenter.h @@ -25,8 +25,7 @@ class QAction; //! Provides support in Fast Fourier transformation of IntensityDataItem. //! Contains own model to hold IntensityDataItem with fft-transformed results. -class IntensityDataFFTPresenter : public QObject -{ +class IntensityDataFFTPresenter : public QObject { Q_OBJECT public: IntensityDataFFTPresenter(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataProjectionsWidget.cpp b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataProjectionsWidget.cpp index 55bc137ed1b1461d2d6f70e6f9665d4b40148e2a..c424dec4f11fa3ad2e75b3daf56a7589f647ef05 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataProjectionsWidget.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataProjectionsWidget.cpp @@ -22,8 +22,7 @@ #include <QVBoxLayout> IntensityDataProjectionsWidget::IntensityDataProjectionsWidget(QWidget* parent) - : SessionItemWidget(parent), m_projectionsEditor(new ProjectionsEditor) -{ + : SessionItemWidget(parent), m_projectionsEditor(new ProjectionsEditor) { QVBoxLayout* vlayout = new QVBoxLayout(this); vlayout->setMargin(0); vlayout->setSpacing(0); @@ -32,32 +31,27 @@ IntensityDataProjectionsWidget::IntensityDataProjectionsWidget(QWidget* parent) setLayout(vlayout); } -QList<QAction*> IntensityDataProjectionsWidget::actionList() -{ +QList<QAction*> IntensityDataProjectionsWidget::actionList() { return m_projectionsEditor->topToolBarActions(); } -void IntensityDataProjectionsWidget::subscribeToItem() -{ +void IntensityDataProjectionsWidget::subscribeToItem() { auto container = projectionContainer(intensityDataItem()); m_projectionsEditor->setContext(intensityDataItem()->model(), container->index(), intensityDataItem()); } -void IntensityDataProjectionsWidget::unsubscribeFromItem() -{ +void IntensityDataProjectionsWidget::unsubscribeFromItem() { m_projectionsEditor->resetContext(); } -IntensityDataItem* IntensityDataProjectionsWidget::intensityDataItem() -{ +IntensityDataItem* IntensityDataProjectionsWidget::intensityDataItem() { return DataItemUtils::intensityDataItem(currentItem()); } ProjectionContainerItem* -IntensityDataProjectionsWidget::projectionContainer(IntensityDataItem* intensityItem) -{ +IntensityDataProjectionsWidget::projectionContainer(IntensityDataItem* intensityItem) { ASSERT(intensityItem); auto containerItem = intensityItem->getItem(IntensityDataItem::T_PROJECTIONS); diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataProjectionsWidget.h b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataProjectionsWidget.h index ef18eb013bdef2242f9f70708d78955d3779346b..42079e656da22ebdaa3a02082f9b0c27dde67d65 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataProjectionsWidget.h +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataProjectionsWidget.h @@ -24,8 +24,7 @@ class ProjectionContainerItem; //! Main widget to embed projections editor for IntensityDataItem. //! Part of RealDataPresenter and JobResultsPresenter. -class IntensityDataProjectionsWidget : public SessionItemWidget -{ +class IntensityDataProjectionsWidget : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataPropertyWidget.cpp b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataPropertyWidget.cpp index b26705fe158892642a34120d41eb17227d17e799..4cecc76c7de93339bdf6c073f21ff587be2fc786 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataPropertyWidget.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataPropertyWidget.cpp @@ -23,8 +23,7 @@ IntensityDataPropertyWidget::IntensityDataPropertyWidget(QWidget* parent) : SessionItemWidget(parent) , m_togglePanelAction(new QAction(this)) - , m_componentEditor(new ComponentEditor) -{ + , m_componentEditor(new ComponentEditor) { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); setWindowTitle(QLatin1String("Intensity Data Properties")); setObjectName(QLatin1String("Intensity Data Properties")); @@ -42,37 +41,30 @@ IntensityDataPropertyWidget::IntensityDataPropertyWidget(QWidget* parent) &IntensityDataPropertyWidget::onTogglePanelAction); } -QSize IntensityDataPropertyWidget::sizeHint() const -{ +QSize IntensityDataPropertyWidget::sizeHint() const { return QSize(StyleUtils::PropertyPanelWidth() * 1.2, StyleUtils::PropertyPanelWidth() * 2); } -QSize IntensityDataPropertyWidget::minimumSizeHint() const -{ +QSize IntensityDataPropertyWidget::minimumSizeHint() const { return QSize(StyleUtils::PropertyPanelWidth() * 1.2, StyleUtils::PropertyPanelWidth()); } -QList<QAction*> IntensityDataPropertyWidget::actionList() -{ +QList<QAction*> IntensityDataPropertyWidget::actionList() { return QList<QAction*>() << m_togglePanelAction; } -void IntensityDataPropertyWidget::onTogglePanelAction() -{ +void IntensityDataPropertyWidget::onTogglePanelAction() { setVisible(!isVisible()); } -void IntensityDataPropertyWidget::subscribeToItem() -{ +void IntensityDataPropertyWidget::subscribeToItem() { m_componentEditor->setItem(currentItem()); } -void IntensityDataPropertyWidget::unsubscribeFromItem() -{ +void IntensityDataPropertyWidget::unsubscribeFromItem() { m_componentEditor->setItem(nullptr); } -void IntensityDataPropertyWidget::contextMenuEvent(QContextMenuEvent*) -{ +void IntensityDataPropertyWidget::contextMenuEvent(QContextMenuEvent*) { // Reimplemented to suppress menu from main window } diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataPropertyWidget.h b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataPropertyWidget.h index 2544dc54cfd99799d1f081b6ba53ebd51d9eb85f..be8f9c5870f7986cf1e1ecd43b0764267b53de89 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataPropertyWidget.h +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataPropertyWidget.h @@ -23,8 +23,7 @@ class SessionItem; //! The IntensityDataPropertyWidget shows ComponentEditor for given IntensityDataItem. -class IntensityDataPropertyWidget : public SessionItemWidget -{ +class IntensityDataPropertyWidget : public SessionItemWidget { Q_OBJECT public: explicit IntensityDataPropertyWidget(QWidget* parent = 0); diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataWidget.cpp b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataWidget.cpp index 460bbb496b4ad1188a6bc660efd1ba8492e10dad..ae4deacf42b5dc706c972abfbab79f1c9c74879a 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataWidget.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataWidget.cpp @@ -26,8 +26,7 @@ IntensityDataWidget::IntensityDataWidget(QWidget* parent) : SessionItemWidget(parent) , m_intensityCanvas(new IntensityDataCanvas) , m_propertyWidget(new IntensityDataPropertyWidget) - , m_fftPresenter(new IntensityDataFFTPresenter(this)) -{ + , m_fftPresenter(new IntensityDataFFTPresenter(this)) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); auto hlayout = new QHBoxLayout; @@ -52,30 +51,26 @@ IntensityDataWidget::IntensityDataWidget(QWidget* parent) m_propertyWidget->setVisible(false); } -void IntensityDataWidget::setItem(SessionItem* jobItem) -{ +void IntensityDataWidget::setItem(SessionItem* jobItem) { SessionItemWidget::setItem(jobItem); m_intensityCanvas->setItem(intensityDataItem()); m_propertyWidget->setItem(intensityDataItem()); m_fftPresenter->reset(); } -QList<QAction*> IntensityDataWidget::actionList() -{ +QList<QAction*> IntensityDataWidget::actionList() { return m_intensityCanvas->actionList() + m_fftPresenter->actionList() + m_propertyWidget->actionList(); } -void IntensityDataWidget::onContextMenuRequest(const QPoint& point) -{ +void IntensityDataWidget::onContextMenuRequest(const QPoint& point) { QMenu menu; for (auto action : actionList()) menu.addAction(action); menu.exec(point); } -void IntensityDataWidget::onFFTAction() -{ +void IntensityDataWidget::onFFTAction() { if (!intensityDataItem() || !intensityDataItem()->getOutputData()) return; @@ -90,7 +85,6 @@ void IntensityDataWidget::onFFTAction() } } -IntensityDataItem* IntensityDataWidget::intensityDataItem() -{ +IntensityDataItem* IntensityDataWidget::intensityDataItem() { return DataItemUtils::intensityDataItem(currentItem()); } diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataWidget.h b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataWidget.h index a339b5b69f79efc9fc376078d078092fdceebaad..8ba89ebed6848f1a9bc352e02b49fd22245f3d6e 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataWidget.h +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataWidget.h @@ -29,8 +29,7 @@ class IntensityDataFFTPresenter; //! A common widget to display color map (IntensityDataCanvas) and properties //! (IntensityDataPropertyWidget) of intensity data item. -class IntensityDataWidget : public SessionItemWidget -{ +class IntensityDataWidget : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/IntensityDataWidgets/Plot1D.cpp b/GUI/coregui/Views/IntensityDataWidgets/Plot1D.cpp index 7242bc79ac7c9a502469cea3eca954f1ad65a19c..fcaeba76d81c1ec5f73956571957be47865c75ec 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/Plot1D.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/Plot1D.cpp @@ -24,8 +24,7 @@ #include "GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.h" #include "GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.h" -namespace -{ +namespace { const int replot_update_interval = 10; int bin(double x, const QCPGraph* graph); @@ -35,8 +34,7 @@ Plot1D::Plot1D(QWidget* parent) : ScientificPlot(parent, PLOT_TYPE::Plot1D) , m_custom_plot(new QCustomPlot) , m_update_timer(new UpdateTimer(replot_update_interval, this)) - , m_block_update(false) -{ + , m_block_update(false) { QVBoxLayout* vlayout = new QVBoxLayout(this); vlayout->setContentsMargins(0, 0, 0, 0); vlayout->setSpacing(0); @@ -51,8 +49,7 @@ Plot1D::Plot1D(QWidget* parent) setMouseTrackingEnabled(true); } -PlotEventInfo Plot1D::eventInfo(double xpos, double ypos) const -{ +PlotEventInfo Plot1D::eventInfo(double xpos, double ypos) const { PlotEventInfo result(plotType()); if (!viewItem()) return result; @@ -66,19 +63,16 @@ PlotEventInfo Plot1D::eventInfo(double xpos, double ypos) const return result; } -void Plot1D::setLog(bool log) -{ +void Plot1D::setLog(bool log) { ColorMapUtils::setLogz(m_custom_plot->yAxis, log); ColorMapUtils::setLogz(m_custom_plot->yAxis2, log); } -void Plot1D::resetView() -{ +void Plot1D::resetView() { viewItem()->resetView(); } -void Plot1D::onPropertyChanged(const QString& property_name) -{ +void Plot1D::onPropertyChanged(const QString& property_name) { if (m_block_update) return; @@ -89,29 +83,25 @@ void Plot1D::onPropertyChanged(const QString& property_name) } } -void Plot1D::onXaxisRangeChanged(QCPRange newRange) -{ +void Plot1D::onXaxisRangeChanged(QCPRange newRange) { m_block_update = true; viewItem()->setLowerX(newRange.lower); viewItem()->setUpperX(newRange.upper); m_block_update = false; } -void Plot1D::onYaxisRangeChanged(QCPRange newRange) -{ +void Plot1D::onYaxisRangeChanged(QCPRange newRange) { m_block_update = true; viewItem()->setLowerY(newRange.lower); viewItem()->setUpperY(newRange.upper); m_block_update = false; } -void Plot1D::onTimeToReplot() -{ +void Plot1D::onTimeToReplot() { m_custom_plot->replot(); } -void Plot1D::subscribeToItem() -{ +void Plot1D::subscribeToItem() { initPlots(); refreshPlotData(); @@ -134,8 +124,7 @@ void Plot1D::subscribeToItem() setConnected(true); } -void Plot1D::unsubscribeFromItem() -{ +void Plot1D::unsubscribeFromItem() { m_custom_plot->clearGraphs(); std::for_each(m_graph_map.begin(), m_graph_map.end(), [caller = this](auto pair) { pair.first->dataItem()->mapper()->unsubscribe(caller); @@ -144,8 +133,7 @@ void Plot1D::unsubscribeFromItem() setConnected(false); } -void Plot1D::initPlots() -{ +void Plot1D::initPlots() { auto property_items = viewItem()->propertyContainerItem()->propertyItems(); std::for_each(property_items.begin(), property_items.end(), [this](Data1DProperties* item) { auto graph = m_custom_plot->addGraph(); @@ -155,14 +143,12 @@ void Plot1D::initPlots() }); } -void Plot1D::setConnected(bool isConnected) -{ +void Plot1D::setConnected(bool isConnected) { setAxesRangeConnected(isConnected); setUpdateTimerConnected(isConnected); } -void Plot1D::setAxesRangeConnected(bool isConnected) -{ +void Plot1D::setAxesRangeConnected(bool isConnected) { if (isConnected) { connect(m_custom_plot->xAxis, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, @@ -183,8 +169,7 @@ void Plot1D::setAxesRangeConnected(bool isConnected) } } -void Plot1D::setUpdateTimerConnected(bool isConnected) -{ +void Plot1D::setUpdateTimerConnected(bool isConnected) { if (isConnected) connect(m_update_timer, &UpdateTimer::timeToUpdate, this, &Plot1D::onTimeToReplot, Qt::UniqueConnection); @@ -192,8 +177,7 @@ void Plot1D::setUpdateTimerConnected(bool isConnected) disconnect(m_update_timer, &UpdateTimer::timeToUpdate, this, &Plot1D::onTimeToReplot); } -void Plot1D::refreshPlotData() -{ +void Plot1D::refreshPlotData() { if (m_block_update) return; @@ -211,8 +195,7 @@ void Plot1D::refreshPlotData() m_block_update = false; } -void Plot1D::setAxesRangeFromItem(Data1DViewItem* item) -{ +void Plot1D::setAxesRangeFromItem(Data1DViewItem* item) { m_custom_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); m_custom_plot->axisRect()->setupFullAxesBox(true); @@ -223,14 +206,12 @@ void Plot1D::setAxesRangeFromItem(Data1DViewItem* item) setAxesRangeConnected(true); } -void Plot1D::setAxesLabelsFromItem(Data1DViewItem* item) -{ +void Plot1D::setAxesLabelsFromItem(Data1DViewItem* item) { setLabel(item->xAxisItem(), m_custom_plot->xAxis, item->getXaxisTitle()); setLabel(item->yAxisItem(), m_custom_plot->yAxis, item->getYaxisTitle()); } -void Plot1D::setLabel(const BasicAxisItem* item, QCPAxis* axis, QString label) -{ +void Plot1D::setLabel(const BasicAxisItem* item, QCPAxis* axis, QString label) { ASSERT(item && axis); if (item->getItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE).toBool()) axis->setLabel(std::move(label)); @@ -238,35 +219,30 @@ void Plot1D::setLabel(const BasicAxisItem* item, QCPAxis* axis, QString label) axis->setLabel(QString()); } -void Plot1D::updateAllGraphs() -{ +void Plot1D::updateAllGraphs() { auto property_items = viewItem()->propertyContainerItem()->propertyItems(); std::for_each(property_items.begin(), property_items.end(), [this](Data1DProperties* item) { updateGraph(item); }); } -void Plot1D::updateGraph(Data1DProperties* item) -{ +void Plot1D::updateGraph(Data1DProperties* item) { auto data_points = viewItem()->graphData(item); auto graph = m_graph_map.at(item); graph->setData(data_points.first, data_points.second, /*sorted =*/true); } -Data1DViewItem* Plot1D::viewItem() -{ +Data1DViewItem* Plot1D::viewItem() { return const_cast<Data1DViewItem*>(static_cast<const Plot1D*>(this)->viewItem()); } -const Data1DViewItem* Plot1D::viewItem() const -{ +const Data1DViewItem* Plot1D::viewItem() const { const auto result = dynamic_cast<const Data1DViewItem*>(currentItem()); ASSERT(result); return result; } -void Plot1D::modifyAxesProperties(const QString& axisName, const QString& propertyName) -{ +void Plot1D::modifyAxesProperties(const QString& axisName, const QString& propertyName) { if (m_block_update) return; @@ -296,15 +272,12 @@ void Plot1D::modifyAxesProperties(const QString& axisName, const QString& proper } } -void Plot1D::replot() -{ +void Plot1D::replot() { m_update_timer->scheduleUpdate(); } -namespace -{ -int bin(double x, const QCPGraph* graph) -{ +namespace { +int bin(double x, const QCPGraph* graph) { const int key_start = graph->findBegin(x); const int key_end = graph->findBegin(x, false); // false = do not expand range if (key_end == key_start || key_end == graph->dataCount()) diff --git a/GUI/coregui/Views/IntensityDataWidgets/Plot1D.h b/GUI/coregui/Views/IntensityDataWidgets/Plot1D.h index a8b034f475fe423b74ce2e38b140b400b8e15faf..711eec3867c598498c82865de1850dbcacdc4c6e 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/Plot1D.h +++ b/GUI/coregui/Views/IntensityDataWidgets/Plot1D.h @@ -29,8 +29,7 @@ class UpdateTimer; //! Data1DViewItem. Provides minimal functionality for data plotting and axes interaction. Should be //! a component for more complicated plotting widgets. -class Plot1D : public ScientificPlot -{ +class Plot1D : public ScientificPlot { Q_OBJECT public: diff --git a/GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.cpp b/GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.cpp index 0674817959cb0b3c33c74aa7f1119677795ab8bd..c4445c59612f3b740ed2e1e4d6038bd149e9576f 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.cpp @@ -24,12 +24,9 @@ PlotEventInfo::PlotEventInfo(PLOT_TYPE type) , m_value(0.0) , m_nx(0) , m_ny(0) - , m_info_type(type) -{ -} + , m_info_type(type) {} -QString PlotEventInfo::statusString() const -{ +QString PlotEventInfo::statusString() const { QString result; result = m_info_type == PLOT_TYPE::Plot1D ? QString(" [x: %1, y: %2] [binx: %3]") @@ -46,8 +43,7 @@ QString PlotEventInfo::statusString() const return result; } -QString PlotEventInfo::valueToString() const -{ +QString PlotEventInfo::valueToString() const { return m_info_type == PLOT_TYPE::Plot1D || m_log_valued_axis ? QString::fromStdString(pyfmt::printScientificDouble(m_value)) : QString::number(m_value, 'f', 2); diff --git a/GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.h b/GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.h index 833b80b45f00576d4dfe8ef99b2bb73609656267..9b99beb8bb0bed480f66cfa62286a3ec032e2d00 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.h +++ b/GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.h @@ -23,8 +23,7 @@ class SpecularPlot; //! Contains parameters of mouse position in 1D or 2D plot. -class PlotEventInfo -{ +class PlotEventInfo { using PLOT_TYPE = ScientificPlot::PLOT_TYPE; public: diff --git a/GUI/coregui/Views/IntensityDataWidgets/PlotStatusLabel.cpp b/GUI/coregui/Views/IntensityDataWidgets/PlotStatusLabel.cpp index 77ccfde957e7a81a490712f431af96ca9e79b40d..d075e24142d1edd8492a1e0bae0c437860edf6a9 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/PlotStatusLabel.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/PlotStatusLabel.cpp @@ -15,14 +15,12 @@ #include "GUI/coregui/Views/IntensityDataWidgets/PlotStatusLabel.h" #include "GUI/coregui/Views/IntensityDataWidgets/ScientificPlot.h" -PlotStatusLabel::PlotStatusLabel(ScientificPlot* plot, QWidget* parent) : StatusLabel(parent) -{ +PlotStatusLabel::PlotStatusLabel(ScientificPlot* plot, QWidget* parent) : StatusLabel(parent) { if (plot) addPlot(plot); } -void PlotStatusLabel::addPlot(ScientificPlot* plot) -{ +void PlotStatusLabel::addPlot(ScientificPlot* plot) { if (m_plots.contains(plot)) return; @@ -32,8 +30,7 @@ void PlotStatusLabel::addPlot(ScientificPlot* plot) //! Enables/disables label. If disabled, all colorMaps are disconnected and label is hiding. -void PlotStatusLabel::setLabelEnabled(bool flag) -{ +void PlotStatusLabel::setLabelEnabled(bool flag) { for (auto colorMap : m_plots) setPlotLabelEnabled(colorMap, flag); @@ -42,31 +39,27 @@ void PlotStatusLabel::setLabelEnabled(bool flag) //! Disconnects all color maps from the label. -void PlotStatusLabel::reset() -{ +void PlotStatusLabel::reset() { for (auto colorMap : m_plots) setPlotLabelEnabled(colorMap, false); m_plots.clear(); } -void PlotStatusLabel::onPlotStatusString(const QString& text) -{ +void PlotStatusLabel::onPlotStatusString(const QString& text) { setText(text); } //! Enables/disables showing of label for given plot. -void PlotStatusLabel::setPlotLabelEnabled(ScientificPlot* plot, bool flag) -{ +void PlotStatusLabel::setPlotLabelEnabled(ScientificPlot* plot, bool flag) { plot->setMouseTrackingEnabled(flag); setConnected(plot, flag); } //! Connects with colorMap's status string signal. -void PlotStatusLabel::setConnected(ScientificPlot* plot, bool flag) -{ +void PlotStatusLabel::setConnected(ScientificPlot* plot, bool flag) { if (flag) { connect(plot, &ScientificPlot::statusString, this, &PlotStatusLabel::onPlotStatusString, Qt::UniqueConnection); @@ -76,8 +69,7 @@ void PlotStatusLabel::setConnected(ScientificPlot* plot, bool flag) } } -void PlotStatusLabel::onPlotDestroyed(QObject* obj) -{ +void PlotStatusLabel::onPlotDestroyed(QObject* obj) { auto it = std::remove_if(m_plots.begin(), m_plots.end(), [obj](ScientificPlot* cm) { return cm == obj; }); m_plots.erase(it, m_plots.end()); diff --git a/GUI/coregui/Views/IntensityDataWidgets/PlotStatusLabel.h b/GUI/coregui/Views/IntensityDataWidgets/PlotStatusLabel.h index 2a68252961cd819306264e00121422b5791d0e89..54c4ac52326adf5564ade2ef43b080994c8fc9db 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/PlotStatusLabel.h +++ b/GUI/coregui/Views/IntensityDataWidgets/PlotStatusLabel.h @@ -26,8 +26,7 @@ class QResizeEvent; //! depending on available space in parent layout. Also doesn't trigger layout resize, //! being happy with place it has. -class PlotStatusLabel : public StatusLabel -{ +class PlotStatusLabel : public StatusLabel { Q_OBJECT public: PlotStatusLabel(ScientificPlot* plot, QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.cpp b/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.cpp index 6c10492675dba87033583dc8cc7312667a004644..63905f3f532bb0741adccfaa2bb983db1c712eef 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.cpp @@ -27,8 +27,7 @@ ProjectionsPlot::ProjectionsPlot(const QString& projectionType, QWidget* parent) : SessionItemWidget(parent) , m_projectionType(projectionType) , m_customPlot(new QCustomPlot) - , m_block_plot_update(false) -{ + , m_block_plot_update(false) { QVBoxLayout* vlayout = new QVBoxLayout(this); vlayout->setMargin(0); vlayout->setSpacing(0); @@ -43,20 +42,17 @@ ProjectionsPlot::ProjectionsPlot(const QString& projectionType, QWidget* parent) ColorMapUtils::setDefaultMargins(m_customPlot); } -ProjectionsPlot::~ProjectionsPlot() -{ +ProjectionsPlot::~ProjectionsPlot() { unsubscribeFromChildren(); } -void ProjectionsPlot::onMarginsChanged(double left, double right) -{ +void ProjectionsPlot::onMarginsChanged(double left, double right) { QMargins orig = m_customPlot->axisRect()->margins(); m_customPlot->axisRect()->setMargins(QMargins(left, orig.top(), right, orig.bottom())); replot(); } -void ProjectionsPlot::subscribeToItem() -{ +void ProjectionsPlot::subscribeToItem() { // Update projection plot on new item appearance projectionContainerItem()->mapper()->setOnChildrenChange( [this](SessionItem* item) { @@ -98,14 +94,12 @@ void ProjectionsPlot::subscribeToItem() updateProjections(); } -void ProjectionsPlot::unsubscribeFromItem() -{ +void ProjectionsPlot::unsubscribeFromItem() { unsubscribeFromChildren(); clearProjections(); } -void ProjectionsPlot::onProjectionPropertyChanged(SessionItem* item, const QString& property) -{ +void ProjectionsPlot::onProjectionPropertyChanged(SessionItem* item, const QString& property) { if (m_block_plot_update) return; @@ -121,28 +115,24 @@ void ProjectionsPlot::onProjectionPropertyChanged(SessionItem* item, const QStri m_block_plot_update = false; } -IntensityDataItem* ProjectionsPlot::intensityItem() -{ +IntensityDataItem* ProjectionsPlot::intensityItem() { IntensityDataItem* result = dynamic_cast<IntensityDataItem*>(currentItem()); ASSERT(result); return result; } -ProjectionContainerItem* ProjectionsPlot::projectionContainerItem() -{ +ProjectionContainerItem* ProjectionsPlot::projectionContainerItem() { ProjectionContainerItem* result = dynamic_cast<ProjectionContainerItem*>( intensityItem()->getItem(IntensityDataItem::T_PROJECTIONS)); ASSERT(result); return result; } -QVector<SessionItem*> ProjectionsPlot::projectionItems() -{ +QVector<SessionItem*> ProjectionsPlot::projectionItems() { return projectionContainerItem()->getChildrenOfType(m_projectionType); } -QCPGraph* ProjectionsPlot::graphForItem(SessionItem* item) -{ +QCPGraph* ProjectionsPlot::graphForItem(SessionItem* item) { if (item->modelType() != m_projectionType) return nullptr; @@ -160,16 +150,14 @@ QCPGraph* ProjectionsPlot::graphForItem(SessionItem* item) return graph; } -void ProjectionsPlot::unsubscribeFromChildren() -{ +void ProjectionsPlot::unsubscribeFromChildren() { if (currentItem()) projectionContainerItem()->mapper()->unsubscribe(this); } //! Creates cached 2D histogram for later projection calculations. -void ProjectionsPlot::updateProjectionsData() -{ +void ProjectionsPlot::updateProjectionsData() { m_hist2d = std::make_unique<Histogram2D>(*intensityItem()->getOutputData()); updateAxesRange(); updateAxesTitle(); @@ -178,8 +166,7 @@ void ProjectionsPlot::updateProjectionsData() //! Runs through all projection items and generates missed plots. -void ProjectionsPlot::updateProjections() -{ +void ProjectionsPlot::updateProjections() { if (m_block_plot_update) return; @@ -195,8 +182,7 @@ void ProjectionsPlot::updateProjections() //! Updates canva's axes to match current zoom level of IntensityDataItem -void ProjectionsPlot::updateAxesRange() -{ +void ProjectionsPlot::updateAxesRange() { if (isHorizontalType()) m_customPlot->xAxis->setRange(ColorMapUtils::itemZoomX(intensityItem())); else @@ -205,8 +191,7 @@ void ProjectionsPlot::updateAxesRange() m_customPlot->yAxis->setRange(ColorMapUtils::itemDataZoom(intensityItem())); } -void ProjectionsPlot::updateAxesTitle() -{ +void ProjectionsPlot::updateAxesTitle() { if (isHorizontalType()) m_customPlot->xAxis->setLabel(intensityItem()->getXaxisTitle()); else @@ -215,8 +200,7 @@ void ProjectionsPlot::updateAxesTitle() //! Clears all graphs corresponding to projection items. -void ProjectionsPlot::clearProjections() -{ +void ProjectionsPlot::clearProjections() { m_block_plot_update = true; m_customPlot->clearPlottables(); @@ -229,8 +213,7 @@ void ProjectionsPlot::clearProjections() //! Removes plot corresponding to given projection item. -void ProjectionsPlot::clearProjection(SessionItem* item) -{ +void ProjectionsPlot::clearProjection(SessionItem* item) { if (auto graph = graphForItem(item)) { m_block_plot_update = true; m_customPlot->removePlottable(graph); @@ -242,8 +225,7 @@ void ProjectionsPlot::clearProjection(SessionItem* item) //! Updates projection appearance (line style, etc) -void ProjectionsPlot::onIntensityItemPropertyChanged(const QString& propertyName) -{ +void ProjectionsPlot::onIntensityItemPropertyChanged(const QString& propertyName) { if (propertyName == IntensityDataItem::P_IS_INTERPOLATED) { setInterpolate(intensityItem()->isInterpolated()); replot(); @@ -252,8 +234,7 @@ void ProjectionsPlot::onIntensityItemPropertyChanged(const QString& propertyName //! Updates zoom of projections in accordance with IntensityDataItem. -void ProjectionsPlot::onAxisPropertyChanged(const QString& axisName, const QString& propertyName) -{ +void ProjectionsPlot::onAxisPropertyChanged(const QString& axisName, const QString& propertyName) { Q_UNUSED(axisName); if (propertyName == BasicAxisItem::P_MIN_DEG || propertyName == BasicAxisItem::P_MAX_DEG) @@ -268,8 +249,7 @@ void ProjectionsPlot::onAxisPropertyChanged(const QString& axisName, const QStri //! Sets the data to graph from given projection iten. -void ProjectionsPlot::setGraphFromItem(QCPGraph* graph, SessionItem* item) -{ +void ProjectionsPlot::setGraphFromItem(QCPGraph* graph, SessionItem* item) { std::unique_ptr<Histogram1D> hist; if (item->modelType() == "HorizontalLineMask") { @@ -291,25 +271,21 @@ void ProjectionsPlot::setGraphFromItem(QCPGraph* graph, SessionItem* item) #endif } -void ProjectionsPlot::setInterpolate(bool isInterpolated) -{ +void ProjectionsPlot::setInterpolate(bool isInterpolated) { for (auto graph : m_item_to_graph) graph->setLineStyle(isInterpolated ? QCPGraph::lsLine : QCPGraph::lsStepCenter); } -void ProjectionsPlot::setLogz(bool isLogz) -{ +void ProjectionsPlot::setLogz(bool isLogz) { ColorMapUtils::setLogz(m_customPlot->yAxis, isLogz); } -void ProjectionsPlot::replot() -{ +void ProjectionsPlot::replot() { m_customPlot->replot(); } //! Returns true, if widget is intended for horizontal projections. -bool ProjectionsPlot::isHorizontalType() -{ +bool ProjectionsPlot::isHorizontalType() { return m_projectionType == "HorizontalLineMask"; } diff --git a/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.h b/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.h index eb21cec9eab5c2fa34b11f3b6880b8c0fc16a50d..13d3d62c372362e9c9784560a7169a5f3b144482 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.h +++ b/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.h @@ -27,8 +27,7 @@ class QCPGraph; //! A customplot based widget to display projections of IntensityDataItem on X,Y axes. -class ProjectionsPlot : public SessionItemWidget -{ +class ProjectionsPlot : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.cpp b/GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.cpp index 73b87ab5e357accd54b7f4b66fd6bb7f943f0d4c..6874eb4f3914c2f09c39688eea37bfef4301682c 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.cpp @@ -16,18 +16,16 @@ #include "GUI/coregui/Models/IntensityDataItem.h" PropertyRepeater::PropertyRepeater(QObject* parent, bool repeat_child_properties) - : QObject(parent), m_block_repeater(false), m_repeat_child_properties(repeat_child_properties) -{ -} + : QObject(parent) + , m_block_repeater(false) + , m_repeat_child_properties(repeat_child_properties) {} -PropertyRepeater::~PropertyRepeater() -{ +PropertyRepeater::~PropertyRepeater() { for (auto item : m_dataItems) item->mapper()->unsubscribe(this); } -void PropertyRepeater::addItem(SessionItem* sessionItem) -{ +void PropertyRepeater::addItem(SessionItem* sessionItem) { if (!sessionItem || m_dataItems.contains(sessionItem)) return; @@ -47,21 +45,18 @@ void PropertyRepeater::addItem(SessionItem* sessionItem) m_dataItems.push_back(sessionItem); } -void PropertyRepeater::clear() -{ +void PropertyRepeater::clear() { for (auto item : m_dataItems) item->mapper()->unsubscribe(this); m_dataItems.clear(); } -void PropertyRepeater::setActive(bool isActive) -{ +void PropertyRepeater::setActive(bool isActive) { m_block_repeater = !isActive; } -void PropertyRepeater::onPropertyChanged(SessionItem* item, const QString& propertyName) -{ +void PropertyRepeater::onPropertyChanged(SessionItem* item, const QString& propertyName) { if (m_block_repeater) return; @@ -74,8 +69,7 @@ void PropertyRepeater::onPropertyChanged(SessionItem* item, const QString& prope m_block_repeater = false; } -void PropertyRepeater::setOnChildPropertyChange(SessionItem* item, const QString& propertyName) -{ +void PropertyRepeater::setOnChildPropertyChange(SessionItem* item, const QString& propertyName) { if (m_block_repeater) return; @@ -92,8 +86,7 @@ void PropertyRepeater::setOnChildPropertyChange(SessionItem* item, const QString //! Returns list of target items to update their properties. -QVector<SessionItem*> PropertyRepeater::targetItems(SessionItem* sourceItem) -{ +QVector<SessionItem*> PropertyRepeater::targetItems(SessionItem* sourceItem) { QVector<SessionItem*> result = m_dataItems; result.removeAll(sourceItem); return result; diff --git a/GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.h b/GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.h index 696122b541131f146c85189f32b9b8f9d783508b..7458cb33289a0a9af9a581f79987ab25c120c46d 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.h +++ b/GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.h @@ -24,8 +24,7 @@ class SessionItem; //! Tracks property change (axes range, units etc) for the collection of IntensityDataItems //! and sets same properties for all of them. -class PropertyRepeater : public QObject -{ +class PropertyRepeater : public QObject { Q_OBJECT public: explicit PropertyRepeater(QObject* parent = nullptr, bool repeat_child_properties = false); diff --git a/GUI/coregui/Views/IntensityDataWidgets/SavePlotAssistant.cpp b/GUI/coregui/Views/IntensityDataWidgets/SavePlotAssistant.cpp index 2fb4ca9edd6d434882c016b17c9a225914a300ad..b925b19d84990d269cf70e9a77cc24cccfc53ea9 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/SavePlotAssistant.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/SavePlotAssistant.cpp @@ -19,8 +19,7 @@ #include <QFileDialog> #include <QMessageBox> -namespace -{ +namespace { const QString png_extension = ".png"; const QString jpg_extension = ".jpg"; const QString pdf_extension = ".pdf"; @@ -28,8 +27,7 @@ const QString int_extension = ".int"; const QString tif_extension = ".tif"; const QString txt_extension = ".txt"; -QVector<SavePlotAssistant::Format> initializeFormats() -{ +QVector<SavePlotAssistant::Format> initializeFormats() { QVector<SavePlotAssistant::Format> result; result.push_back(SavePlotAssistant::Format(png_extension, "png Image (*.png)")); result.push_back(SavePlotAssistant::Format(jpg_extension, "jpg Image (*.jpg)")); @@ -47,9 +45,7 @@ QVector<SavePlotAssistant::Format> initializeFormats() QVector<SavePlotAssistant::Format> SavePlotAssistant::m_formats = initializeFormats(); SavePlotAssistant::Format::Format(const QString& file_extention, const QString& filter) - : m_file_extention(file_extention), m_filter(filter) -{ -} + : m_file_extention(file_extention), m_filter(filter) {} void SavePlotAssistant::savePlot(const QString& dirname, QCustomPlot* plot, OutputData<double>* output_data) @@ -76,8 +72,7 @@ void SavePlotAssistant::savePlot(const QString& dirname, QCustomPlot* plot, } void SavePlotAssistant::saveToFile(const QString& fileName, QCustomPlot* plot, - OutputData<double>* output_data) -{ + OutputData<double>* output_data) { if (isPngFile(fileName)) { plot->savePng(fileName); } @@ -97,8 +92,7 @@ void SavePlotAssistant::saveToFile(const QString& fileName, QCustomPlot* plot, } //! Returns string contraining all defined filters in the format suitable for QFileDialog -QString SavePlotAssistant::getFilterString() const -{ +QString SavePlotAssistant::getFilterString() const { QString result; for (int i = 0; i < m_formats.size(); ++i) { result.append(m_formats[i].m_filter); @@ -109,8 +103,8 @@ QString SavePlotAssistant::getFilterString() const } //! Compose file name to save plot from information provided by QFileDialog -QString SavePlotAssistant::composeFileName(const QString& fileName, const QString& filterName) const -{ +QString SavePlotAssistant::composeFileName(const QString& fileName, + const QString& filterName) const { QString result; if (!fileName.isEmpty() && !filterName.isEmpty()) { if (isValidExtension(fileName)) { @@ -122,8 +116,7 @@ QString SavePlotAssistant::composeFileName(const QString& fileName, const QStrin return result; } -bool SavePlotAssistant::isValidExtension(const QString& fileName) const -{ +bool SavePlotAssistant::isValidExtension(const QString& fileName) const { for (int i = 0; i < m_formats.size(); ++i) { if (fileName.endsWith(m_formats[i].m_file_extention, Qt::CaseInsensitive)) { return true; @@ -132,8 +125,7 @@ bool SavePlotAssistant::isValidExtension(const QString& fileName) const return false; } -QString SavePlotAssistant::getExtensionFromFilterName(const QString& filterName) const -{ +QString SavePlotAssistant::getExtensionFromFilterName(const QString& filterName) const { for (int i = 0; i < m_formats.size(); ++i) { if (m_formats[i].m_filter == filterName) { return m_formats[i].m_file_extention; @@ -142,17 +134,14 @@ QString SavePlotAssistant::getExtensionFromFilterName(const QString& filterName) return ""; } -bool SavePlotAssistant::isPngFile(const QString& fileName) const -{ +bool SavePlotAssistant::isPngFile(const QString& fileName) const { return fileName.endsWith(png_extension, Qt::CaseInsensitive); } -bool SavePlotAssistant::isJpgFile(const QString& fileName) const -{ +bool SavePlotAssistant::isJpgFile(const QString& fileName) const { return fileName.endsWith(jpg_extension, Qt::CaseInsensitive); } -bool SavePlotAssistant::isPdfFile(const QString& fileName) const -{ +bool SavePlotAssistant::isPdfFile(const QString& fileName) const { return fileName.endsWith(pdf_extension, Qt::CaseInsensitive); } diff --git a/GUI/coregui/Views/IntensityDataWidgets/SavePlotAssistant.h b/GUI/coregui/Views/IntensityDataWidgets/SavePlotAssistant.h index d7690fd1379f64e387b8d40cfc1047fcf85d9052..3d6c2f9b3100a046a03eb976dddbb6d4dd9c0f7b 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/SavePlotAssistant.h +++ b/GUI/coregui/Views/IntensityDataWidgets/SavePlotAssistant.h @@ -24,11 +24,9 @@ template <class T> class OutputData; //! Assistant class which contains all logic for saving IntensityData to various formats //! from IntensityDataPlotWidget. -class SavePlotAssistant -{ +class SavePlotAssistant { public: - class Format - { + class Format { public: Format() {} Format(const QString& file_extention, const QString& filter); diff --git a/GUI/coregui/Views/IntensityDataWidgets/SaveProjectionsAssistant.cpp b/GUI/coregui/Views/IntensityDataWidgets/SaveProjectionsAssistant.cpp index df0b6d1bfcfc19e22533f6b06ecd949c8f37323b..a924c024761a8290ee605dcdab47a78a1b973ce0 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/SaveProjectionsAssistant.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/SaveProjectionsAssistant.cpp @@ -24,19 +24,16 @@ #include <QFileDialog> #include <QTextStream> -namespace -{ +namespace { const int bin_centers_colwidth = 12; const int bin_values_colwidth = 20; -QString to_scientific_str(double value) -{ +QString to_scientific_str(double value) { auto str = pyfmt::printScientificDouble(value); return QString("%1").arg(QString::fromStdString(str), -bin_values_colwidth); } -QString to_double_str(double value) -{ +QString to_double_str(double value) { auto str = pyfmt::printDouble(value); return QString("%1").arg(QString::fromStdString(str), -bin_centers_colwidth); } @@ -47,8 +44,7 @@ SaveProjectionsAssistant::~SaveProjectionsAssistant() = default; //! Calls file open dialog and writes projection data as ASCII -void SaveProjectionsAssistant::saveProjections(QWidget* parent, IntensityDataItem* intensityItem) -{ +void SaveProjectionsAssistant::saveProjections(QWidget* parent, IntensityDataItem* intensityItem) { ASSERT(intensityItem); QString defaultName = ProjectUtils::userExportDir() + "/untitled.txt"; @@ -80,8 +76,7 @@ void SaveProjectionsAssistant::saveProjections(QWidget* parent, IntensityDataIte //! Generates multi-line string with projections data of given type (horizontal, vertical). QString SaveProjectionsAssistant::projectionsToString(const QString& projectionsType, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { QString result; QTextStream out(&result); @@ -108,8 +103,7 @@ QString SaveProjectionsAssistant::projectionsToString(const QString& projections SaveProjectionsAssistant::ProjectionsData SaveProjectionsAssistant::projectionsData(const QString& projectionsType, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { ProjectionsData result; projectionsType == "VerticalLineMask" ? result.is_horizontal = false : result.is_horizontal = true; @@ -146,8 +140,7 @@ SaveProjectionsAssistant::projectionsData(const QString& projectionsType, //! Returns vector of ProjectionItems sorted according to axis value. QVector<SessionItem*> SaveProjectionsAssistant::projectionItems(const QString& projectionsType, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { auto result = intensityItem->projectionContainerItem()->getChildrenOfType(projectionsType); std::sort(result.begin(), result.end(), [=](SessionItem* item1, SessionItem* item2) { QString propertyName = HorizontalLineItem::P_POSY; @@ -163,8 +156,7 @@ QVector<SessionItem*> SaveProjectionsAssistant::projectionItems(const QString& p //! Returns projections header. For projections along x it will be //! "# x y=6.0194 y=33.5922 y=61.9417" -QString SaveProjectionsAssistant::projectionFileHeader(ProjectionsData& projectionsData) -{ +QString SaveProjectionsAssistant::projectionFileHeader(ProjectionsData& projectionsData) { QString xcol, ycol; projectionsData.is_horizontal ? xcol = "# x" : xcol = "# y"; diff --git a/GUI/coregui/Views/IntensityDataWidgets/SaveProjectionsAssistant.h b/GUI/coregui/Views/IntensityDataWidgets/SaveProjectionsAssistant.h index 648ae1e87e030b23653df75eaabe2c47bac1b237..beebbc29937ee0031d6fe1236f2a14757d559ca0 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/SaveProjectionsAssistant.h +++ b/GUI/coregui/Views/IntensityDataWidgets/SaveProjectionsAssistant.h @@ -26,8 +26,7 @@ class SessionItem; //! Assistant class which save all projections of IndensityDataItem into ASCII file. -class SaveProjectionsAssistant -{ +class SaveProjectionsAssistant { public: SaveProjectionsAssistant(); ~SaveProjectionsAssistant(); diff --git a/GUI/coregui/Views/IntensityDataWidgets/ScientificPlot.cpp b/GUI/coregui/Views/IntensityDataWidgets/ScientificPlot.cpp index 2057095ccf0d2a8da6f3868b96c45f3d63bbf819..2b70d272e296e20451a3f68cf2bd725194fae41c 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ScientificPlot.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/ScientificPlot.cpp @@ -16,39 +16,31 @@ #include <qcustomplot.h> ScientificPlot::ScientificPlot(QWidget* parent, PLOT_TYPE plot_type) - : SessionItemWidget(parent), m_plot_type(plot_type), m_event(new ScientificPlotEvent(this)) -{ -} + : SessionItemWidget(parent), m_plot_type(plot_type), m_event(new ScientificPlotEvent(this)) {} ScientificPlot::~ScientificPlot() = default; -double ScientificPlot::xAxisCoordToPixel(double axis_coordinate) const -{ +double ScientificPlot::xAxisCoordToPixel(double axis_coordinate) const { return customPlot()->xAxis->coordToPixel(axis_coordinate); } -double ScientificPlot::yAxisCoordToPixel(double axis_coordinate) const -{ +double ScientificPlot::yAxisCoordToPixel(double axis_coordinate) const { return customPlot()->yAxis->coordToPixel(axis_coordinate); } -double ScientificPlot::pixelToXaxisCoord(double pixel) const -{ +double ScientificPlot::pixelToXaxisCoord(double pixel) const { return customPlot()->xAxis->pixelToCoord(pixel); } -double ScientificPlot::pixelToYaxisCoord(double pixel) const -{ +double ScientificPlot::pixelToYaxisCoord(double pixel) const { return customPlot()->yAxis->pixelToCoord(pixel); } -void ScientificPlot::setMouseTrackingEnabled(bool enable) -{ +void ScientificPlot::setMouseTrackingEnabled(bool enable) { m_event->setMouseTrackingEnabled(enable); } -bool ScientificPlot::axesRangeContains(double xpos, double ypos) const -{ +bool ScientificPlot::axesRangeContains(double xpos, double ypos) const { return customPlot()->xAxis->range().contains(xpos) && customPlot()->yAxis->range().contains(ypos); } diff --git a/GUI/coregui/Views/IntensityDataWidgets/ScientificPlot.h b/GUI/coregui/Views/IntensityDataWidgets/ScientificPlot.h index 4a4bd9cfff14f3148072060b004ec2d8a6ce1c72..385e815f97250dfa1398ef7f656cfadbfcc72a3e 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ScientificPlot.h +++ b/GUI/coregui/Views/IntensityDataWidgets/ScientificPlot.h @@ -24,8 +24,7 @@ class ScientificPlotEvent; //! Common interface for plot-descriptor interaction -class ScientificPlot : public SessionItemWidget -{ +class ScientificPlot : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/IntensityDataWidgets/ScientificPlotEvent.cpp b/GUI/coregui/Views/IntensityDataWidgets/ScientificPlotEvent.cpp index cf46a33a97e508b6db373a7964ad9f3d60b4e3c3..3583180c2f909e9cdabce1e7d936254fd8b2df89 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ScientificPlotEvent.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/ScientificPlotEvent.cpp @@ -17,16 +17,13 @@ #include <qcustomplot.h> ScientificPlotEvent::ScientificPlotEvent(ScientificPlot* scientific_plot) - : QObject(scientific_plot), m_plot(scientific_plot), m_prevPos(scientific_plot->plotType()) -{ -} + : QObject(scientific_plot), m_plot(scientific_plot), m_prevPos(scientific_plot->plotType()) {} ScientificPlotEvent::~ScientificPlotEvent() = default; //! Sets tracking of the mouse for parent DescriptedPlot -void ScientificPlotEvent::setMouseTrackingEnabled(bool enable) -{ +void ScientificPlotEvent::setMouseTrackingEnabled(bool enable) { m_plot->setMouseTracking(enable); customPlot()->setMouseTracking(enable); @@ -42,8 +39,7 @@ void ScientificPlotEvent::setMouseTrackingEnabled(bool enable) //! if mouse is in axes's viewport rectangle. Once mouse goes out of it, an //! empty string is emitted once again. -void ScientificPlotEvent::onCustomMouseMove(QMouseEvent* event) -{ +void ScientificPlotEvent::onCustomMouseMove(QMouseEvent* event) { auto currentPos = currentPlotDescriptor(event); if (currentPos.inAxesRange()) { @@ -61,25 +57,21 @@ void ScientificPlotEvent::onCustomMouseMove(QMouseEvent* event) m_prevPos = std::move(currentPos); } -ScientificPlot* ScientificPlotEvent::scientificPlot() -{ +ScientificPlot* ScientificPlotEvent::scientificPlot() { return m_plot; } -const ScientificPlot* ScientificPlotEvent::scientificPlot() const -{ +const ScientificPlot* ScientificPlotEvent::scientificPlot() const { return m_plot; } -QCustomPlot* ScientificPlotEvent::customPlot() -{ +QCustomPlot* ScientificPlotEvent::customPlot() { return m_plot->customPlot(); } //! Constructs current position of the data. -PlotEventInfo ScientificPlotEvent::currentPlotDescriptor(QMouseEvent* event) const -{ +PlotEventInfo ScientificPlotEvent::currentPlotDescriptor(QMouseEvent* event) const { double x = scientificPlot()->pixelToXaxisCoord(event->pos().x()); double y = scientificPlot()->pixelToYaxisCoord(event->pos().y()); return scientificPlot()->eventInfo(x, y); diff --git a/GUI/coregui/Views/IntensityDataWidgets/ScientificPlotEvent.h b/GUI/coregui/Views/IntensityDataWidgets/ScientificPlotEvent.h index ed8656523b2a739c0c8812a07cdd327a616974c4..e82a60e44f4269ac43e9e689eea475d74fb62eb8 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ScientificPlotEvent.h +++ b/GUI/coregui/Views/IntensityDataWidgets/ScientificPlotEvent.h @@ -26,8 +26,7 @@ class QCustomPlot; //! Helps ScientificPlot to handle mouse events. Particularly, it constructs a valid //! status string. Can be extended to play a role of event filter. -class ScientificPlotEvent : public QObject -{ +class ScientificPlotEvent : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobView.cpp b/GUI/coregui/Views/JobView.cpp index 6cee6c0071fdf64c624c39a724c809dbcf09b471..2069de1e47fc77e5c8061cb00f62f1698d69c399 100644 --- a/GUI/coregui/Views/JobView.cpp +++ b/GUI/coregui/Views/JobView.cpp @@ -29,16 +29,14 @@ JobView::JobView(MainWindow* mainWindow) , m_statusBar(new JobViewStatusBar(mainWindow)) , m_progressAssistant(new JobProgressAssistant(mainWindow)) , m_currentItem(nullptr) - , m_mainWindow(mainWindow) -{ + , m_mainWindow(mainWindow) { setObjectName("JobView"); m_docks->initViews(mainWindow->jobModel()); connectSignals(); } -void JobView::onFocusRequest(JobItem* jobItem) -{ +void JobView::onFocusRequest(JobItem* jobItem) { if (jobItem->runInBackground()) return; @@ -52,45 +50,39 @@ void JobView::onFocusRequest(JobItem* jobItem) //! Sets docks visibility in accordance with required activity. -void JobView::setActivity(int activity) -{ +void JobView::setActivity(int activity) { m_docks->setActivity(activity); emit activityChanged(activity); } //! Creates global dock menu at cursor position. -void JobView::onDockMenuRequest() -{ +void JobView::onDockMenuRequest() { std::unique_ptr<QMenu> menu(createPopupMenu()); menu->exec(QCursor::pos()); } //! Propagates change in JobItem's selection down into main widgets. -void JobView::onSelectionChanged(JobItem* jobItem) -{ +void JobView::onSelectionChanged(JobItem* jobItem) { m_docks->setItem(jobItem); } -void JobView::showEvent(QShowEvent* event) -{ +void JobView::showEvent(QShowEvent* event) { if (isVisible()) m_statusBar->show(); Manhattan::FancyMainWindow::showEvent(event); } -void JobView::hideEvent(QHideEvent* event) -{ +void JobView::hideEvent(QHideEvent* event) { if (isHidden()) m_statusBar->hide(); Manhattan::FancyMainWindow::hideEvent(event); } -void JobView::connectSignals() -{ +void JobView::connectSignals() { connectActivityRelated(); connectLayoutRelated(); connectJobRelated(); @@ -98,8 +90,7 @@ void JobView::connectSignals() //! Connects signal related to activity change. -void JobView::connectActivityRelated() -{ +void JobView::connectActivityRelated() { // Change activity requests: JobViewStatusBar -> this connect(m_statusBar, &JobViewStatusBar::changeActivityRequest, this, &JobView::setActivity); @@ -113,8 +104,7 @@ void JobView::connectActivityRelated() //! Connects signals related to dock layout. -void JobView::connectLayoutRelated() -{ +void JobView::connectLayoutRelated() { connect(this, &JobView::resetLayout, m_docks, &JobViewDocks::onResetLayout); // Toggling of JobSelector request: JobViewStatusBar -> this @@ -127,8 +117,7 @@ void JobView::connectLayoutRelated() //! Connects signals related to JobItem -void JobView::connectJobRelated() -{ +void JobView::connectJobRelated() { // Focus request: JobModel -> this connect(m_mainWindow->jobModel(), &JobModel::focusRequest, this, &JobView::onFocusRequest); @@ -139,8 +128,7 @@ void JobView::connectJobRelated() //! Sets appropriate activity for new JobItem -void JobView::setAppropriateActivityForJob(JobItem* jobItem) -{ +void JobView::setAppropriateActivityForJob(JobItem* jobItem) { if (!jobItem) return; diff --git a/GUI/coregui/Views/JobView.h b/GUI/coregui/Views/JobView.h index 42b2a9761bd917d575fac8cd5f8d2c98888cab59..8c06842d53eb5ab1cced86a0bb1c7bd47b681a6b 100644 --- a/GUI/coregui/Views/JobView.h +++ b/GUI/coregui/Views/JobView.h @@ -26,8 +26,7 @@ class JobItem; //! The JobView class is a main view to show list of jobs, job results and widgets for real time //! and fitting activities. -class JobView : public Manhattan::FancyMainWindow -{ +class JobView : public Manhattan::FancyMainWindow { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/JobListViewDelegate.cpp b/GUI/coregui/Views/JobWidgets/JobListViewDelegate.cpp index 853968fee1f5613ca6848bb9801d39618805f9ed..5f68b46bc27c1b67e4b7adbd579563dd9989ca69 100644 --- a/GUI/coregui/Views/JobWidgets/JobListViewDelegate.cpp +++ b/GUI/coregui/Views/JobWidgets/JobListViewDelegate.cpp @@ -24,8 +24,7 @@ #include <QWidget> #include <progressbar.h> -JobListViewDelegate::JobListViewDelegate(QWidget* parent) : QItemDelegate(parent) -{ +JobListViewDelegate::JobListViewDelegate(QWidget* parent) : QItemDelegate(parent) { m_buttonState = QStyle::State_Enabled; m_status_to_color["Idle"] = QColor(255, 286, 12); m_status_to_color["Running"] = QColor(5, 150, 230); @@ -35,8 +34,7 @@ JobListViewDelegate::JobListViewDelegate(QWidget* parent) : QItemDelegate(parent } void JobListViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ + const QModelIndex& index) const { if (option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); @@ -70,8 +68,8 @@ void JobListViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o } bool JobListViewDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, - const QStyleOptionViewItem& option, const QModelIndex& index) -{ + const QStyleOptionViewItem& option, + const QModelIndex& index) { if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease) { } else { m_buttonState = QStyle::State_Raised; @@ -106,8 +104,7 @@ bool JobListViewDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, } void JobListViewDelegate::drawCustomProjectBar(const JobItem* item, QPainter* painter, - const QStyleOptionViewItem& option) const -{ + const QStyleOptionViewItem& option) const { int progress = item->getProgress(); QRect rect = getProgressBarRect(option.rect); @@ -130,8 +127,7 @@ void JobListViewDelegate::drawCustomProjectBar(const JobItem* item, QPainter* pa } //! returns rectangle for text -QRect JobListViewDelegate::getTextRect(QRect optionRect) const -{ +QRect JobListViewDelegate::getTextRect(QRect optionRect) const { int width = optionRect.width() * 0.4; int height = optionRect.height(); int x = optionRect.x() + 3; @@ -141,8 +137,7 @@ QRect JobListViewDelegate::getTextRect(QRect optionRect) const } //! returns rectangle for progress bar -QRect JobListViewDelegate::getProgressBarRect(QRect optionRect) const -{ +QRect JobListViewDelegate::getProgressBarRect(QRect optionRect) const { int width = optionRect.width() * 0.4; int height = optionRect.height() * 0.6; int x = optionRect.x() + optionRect.width() * 0.5; @@ -152,8 +147,7 @@ QRect JobListViewDelegate::getProgressBarRect(QRect optionRect) const } //! returns rectangle for button -QRect JobListViewDelegate::getButtonRect(QRect optionRect) const -{ +QRect JobListViewDelegate::getButtonRect(QRect optionRect) const { int height = 10; int width = 10; int x = optionRect.x() + optionRect.width() * 0.92; diff --git a/GUI/coregui/Views/JobWidgets/JobListViewDelegate.h b/GUI/coregui/Views/JobWidgets/JobListViewDelegate.h index fdd33a1889f16cfe63b2f24026b736ae76b4f84f..3c2c9869aa2cc1885a117d1561f8e6b2c04ac851 100644 --- a/GUI/coregui/Views/JobWidgets/JobListViewDelegate.h +++ b/GUI/coregui/Views/JobWidgets/JobListViewDelegate.h @@ -22,8 +22,7 @@ class JobItem; //! ViewDelegate to show progress bar JobQueuListView -class JobListViewDelegate : public QItemDelegate -{ +class JobListViewDelegate : public QItemDelegate { Q_OBJECT public: JobListViewDelegate(QWidget* parent); diff --git a/GUI/coregui/Views/JobWidgets/JobListWidget.cpp b/GUI/coregui/Views/JobWidgets/JobListWidget.cpp index 37b2ccea7b1596d6883ccd3e1ec598cbb5974980..416a4fb6abcf7b679481af1deb147a755ff49004 100644 --- a/GUI/coregui/Views/JobWidgets/JobListWidget.cpp +++ b/GUI/coregui/Views/JobWidgets/JobListWidget.cpp @@ -26,8 +26,7 @@ JobListWidget::JobListWidget(QWidget* parent) : QWidget(parent) , m_listViewDelegate(new JobListViewDelegate(this)) , m_listView(new ItemSelectorWidget(this)) - , m_jobModel(nullptr) -{ + , m_jobModel(nullptr) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); m_listView->listView()->setItemDelegate(m_listViewDelegate); @@ -53,8 +52,7 @@ JobListWidget::JobListWidget(QWidget* parent) &JobListWidget::onItemSelectionChanged); } -void JobListWidget::setModel(JobModel* model) -{ +void JobListWidget::setModel(JobModel* model) { ASSERT(model); if (model != m_jobModel) { m_jobModel = model; @@ -65,31 +63,26 @@ void JobListWidget::setModel(JobModel* model) } } -QItemSelectionModel* JobListWidget::selectionModel() -{ +QItemSelectionModel* JobListWidget::selectionModel() { return m_listView->selectionModel(); } //! Returns currently selected JobItem -const JobItem* JobListWidget::currentJobItem() const -{ +const JobItem* JobListWidget::currentJobItem() const { QModelIndexList selected = m_listView->selectionModel()->selectedIndexes(); return selected.size() == 1 ? m_jobModel->getJobItemForIndex(selected.at(0)) : nullptr; } -QSize JobListWidget::sizeHint() const -{ +QSize JobListWidget::sizeHint() const { return QSize(StyleUtils::PropertyPanelWidth(), StyleUtils::PropertyPanelWidth() * 2); } -QSize JobListWidget::minimumSizeHint() const -{ +QSize JobListWidget::minimumSizeHint() const { return QSize(StyleUtils::PropertyPanelWidth(), StyleUtils::PropertyPanelWidth()); } -void JobListWidget::makeJobItemSelected(JobItem* jobItem) -{ +void JobListWidget::makeJobItemSelected(JobItem* jobItem) { ASSERT(jobItem); QModelIndexList selected = m_listView->selectionModel()->selectedIndexes(); @@ -108,8 +101,7 @@ void JobListWidget::makeJobItemSelected(JobItem* jobItem) //! Recieves SeesionItem from ItemSelectorWidget and emits it further as JobItem. //! Null item means the absence of selection. -void JobListWidget::onItemSelectionChanged(SessionItem* item) -{ +void JobListWidget::onItemSelectionChanged(SessionItem* item) { JobItem* jobItem(nullptr); if (item) { jobItem = dynamic_cast<JobItem*>(item); diff --git a/GUI/coregui/Views/JobWidgets/JobListWidget.h b/GUI/coregui/Views/JobWidgets/JobListWidget.h index fb0ad35b3fb05220f544c4851d315da49a1b2a72..13620a9ef97454b2d8f3b69395d570cbc94bcfb3 100644 --- a/GUI/coregui/Views/JobWidgets/JobListWidget.h +++ b/GUI/coregui/Views/JobWidgets/JobListWidget.h @@ -28,8 +28,7 @@ class SessionItem; //! The JobListWidget class contains list view to select job items. -class JobListWidget : public QWidget -{ +class JobListWidget : public QWidget { Q_OBJECT public: explicit JobListWidget(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/JobWidgets/JobMessagePanel.cpp b/GUI/coregui/Views/JobWidgets/JobMessagePanel.cpp index 0fc9a373ce7985ccd3432e49c9e169db3f55ee9c..93c962e050d6ff92c62aa153b6ba4040d035f9c6 100644 --- a/GUI/coregui/Views/JobWidgets/JobMessagePanel.cpp +++ b/GUI/coregui/Views/JobWidgets/JobMessagePanel.cpp @@ -19,8 +19,7 @@ #include <QTextEdit> #include <QVBoxLayout> -JobMessagePanel::JobMessagePanel(QWidget* parent) : InfoPanel(parent), m_plainLog(new QTextEdit) -{ +JobMessagePanel::JobMessagePanel(QWidget* parent) : InfoPanel(parent), m_plainLog(new QTextEdit) { setWindowTitle(Constants::JobMessagePanelName); setObjectName("JobMessagePanel"); @@ -35,13 +34,11 @@ JobMessagePanel::JobMessagePanel(QWidget* parent) : InfoPanel(parent), m_plainLo setContentVisible(false); } -void JobMessagePanel::onClearLog() -{ +void JobMessagePanel::onClearLog() { m_plainLog->clear(); } -void JobMessagePanel::onMessage(const QString& message, const QColor& color) -{ +void JobMessagePanel::onMessage(const QString& message, const QColor& color) { QScrollBar* scrollbar = m_plainLog->verticalScrollBar(); bool autoscroll = scrollbar->value() == scrollbar->maximum(); // m_plainLog->appendPlainText(message); diff --git a/GUI/coregui/Views/JobWidgets/JobMessagePanel.h b/GUI/coregui/Views/JobWidgets/JobMessagePanel.h index 2d8a61abae15fd9d86010cd25d33a5d619fd8891..6381025ebf81853fffdd00853d8aea2093e40950 100644 --- a/GUI/coregui/Views/JobWidgets/JobMessagePanel.h +++ b/GUI/coregui/Views/JobWidgets/JobMessagePanel.h @@ -23,8 +23,7 @@ class QTextEdit; //! The JobMessagePanel class shows log messages from FitActivityPanel at the //! bottom part of JobView. -class JobMessagePanel : public InfoPanel -{ +class JobMessagePanel : public InfoPanel { Q_OBJECT public: JobMessagePanel(QWidget* parent = 0); diff --git a/GUI/coregui/Views/JobWidgets/JobOutputDataWidget.cpp b/GUI/coregui/Views/JobWidgets/JobOutputDataWidget.cpp index 473bd7f1244e173952b15b233216f82d43464456..1bbdfaeaaca355be7999514e71af64d071cf9310 100644 --- a/GUI/coregui/Views/JobWidgets/JobOutputDataWidget.cpp +++ b/GUI/coregui/Views/JobWidgets/JobOutputDataWidget.cpp @@ -19,14 +19,12 @@ #include "GUI/coregui/mainwindow/mainwindow_constants.h" #include <QVBoxLayout> -namespace -{ +namespace { const bool reuse_widget = true; } JobOutputDataWidget::JobOutputDataWidget(JobModel* jobModel, QWidget* parent) - : QWidget(parent), m_stackedWidget(new ItemStackPresenter<JobResultsPresenter>(reuse_widget)) -{ + : QWidget(parent), m_stackedWidget(new ItemStackPresenter<JobResultsPresenter>(reuse_widget)) { setWindowTitle(QLatin1String("Job OutputData")); setObjectName("JobOutputDataWidget"); @@ -45,8 +43,7 @@ JobOutputDataWidget::JobOutputDataWidget(JobModel* jobModel, QWidget* parent) setLayout(mainLayout); } -void JobOutputDataWidget::setItem(JobItem* jobItem) -{ +void JobOutputDataWidget::setItem(JobItem* jobItem) { if (!isValidJobItem(jobItem)) { m_stackedWidget->hideWidgets(); return; @@ -55,14 +52,12 @@ void JobOutputDataWidget::setItem(JobItem* jobItem) m_stackedWidget->setItem(jobItem); } -void JobOutputDataWidget::onActivityChanged(int activity) -{ +void JobOutputDataWidget::onActivityChanged(int activity) { if (auto widget = m_stackedWidget->currentWidget()) widget->setPresentation(static_cast<JobViewFlags::EActivities>(activity)); } -bool JobOutputDataWidget::isValidJobItem(JobItem* item) -{ +bool JobOutputDataWidget::isValidJobItem(JobItem* item) { if (!item) return false; diff --git a/GUI/coregui/Views/JobWidgets/JobOutputDataWidget.h b/GUI/coregui/Views/JobWidgets/JobOutputDataWidget.h index 88ed94d8239df36604385e0b00b7611751f0d05b..5d55448c56883d6abfa56781ed5fcc8a1bc5fcd2 100644 --- a/GUI/coregui/Views/JobWidgets/JobOutputDataWidget.h +++ b/GUI/coregui/Views/JobWidgets/JobOutputDataWidget.h @@ -23,8 +23,7 @@ class JobItem; //! The JobOutputDataWidget class is a central widget of JobView, shows results of the simulation. -class JobOutputDataWidget : public QWidget -{ +class JobOutputDataWidget : public QWidget { Q_OBJECT public: JobOutputDataWidget(JobModel* jobModel, QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/JobWidgets/JobProgressAssistant.cpp b/GUI/coregui/Views/JobWidgets/JobProgressAssistant.cpp index da40a5822048549811de926018f7adcabaa97c92..092222d15f657110de0a99995690409cd0683d75 100644 --- a/GUI/coregui/Views/JobWidgets/JobProgressAssistant.cpp +++ b/GUI/coregui/Views/JobWidgets/JobProgressAssistant.cpp @@ -19,8 +19,7 @@ #include <progressbar.h> JobProgressAssistant::JobProgressAssistant(MainWindow* mainWindow) - : QObject(mainWindow), m_mainWindow(mainWindow) -{ + : QObject(mainWindow), m_mainWindow(mainWindow) { connect(m_mainWindow->jobModel(), SIGNAL(globalProgress(int)), this, SLOT(onGlobalProgress(int))); @@ -28,8 +27,7 @@ JobProgressAssistant::JobProgressAssistant(MainWindow* mainWindow) SLOT(onCancelAllJobs())); } -void JobProgressAssistant::onGlobalProgress(int progress) -{ +void JobProgressAssistant::onGlobalProgress(int progress) { ASSERT(m_mainWindow->progressBar()); if (progress < 0 || progress >= 100) { m_mainWindow->progressBar()->setFinished(true); diff --git a/GUI/coregui/Views/JobWidgets/JobProgressAssistant.h b/GUI/coregui/Views/JobWidgets/JobProgressAssistant.h index a590ab8f29c25e2b3ea827e927ca6bade1677cf3..d4d2a60a10d8636cd8778ecbc9cc0dabdbab7d94 100644 --- a/GUI/coregui/Views/JobWidgets/JobProgressAssistant.h +++ b/GUI/coregui/Views/JobWidgets/JobProgressAssistant.h @@ -21,8 +21,7 @@ class MainWindow; //! The JobProgressAssistant class helps JobView to visualize current progress. -class JobProgressAssistant : public QObject -{ +class JobProgressAssistant : public QObject { Q_OBJECT public: JobProgressAssistant(MainWindow* mainWindow); diff --git a/GUI/coregui/Views/JobWidgets/JobPropertiesWidget.cpp b/GUI/coregui/Views/JobWidgets/JobPropertiesWidget.cpp index e2a0f64adaf2229b3a4b9096fffe0586335e2498..bd0d8952cd7c4980eb20ed45e1a95d64f33ae111 100644 --- a/GUI/coregui/Views/JobWidgets/JobPropertiesWidget.cpp +++ b/GUI/coregui/Views/JobWidgets/JobPropertiesWidget.cpp @@ -27,8 +27,7 @@ JobPropertiesWidget::JobPropertiesWidget(QWidget* parent) , m_tabWidget(new QTabWidget) , m_componentEditor(new ComponentEditor) , m_commentsEditor(new QTextEdit) - , m_block_update(false) -{ + , m_block_update(false) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding); setWindowTitle(Constants::JobPropertiesWidgetName); @@ -47,18 +46,15 @@ JobPropertiesWidget::JobPropertiesWidget(QWidget* parent) connect(m_commentsEditor, &QTextEdit::textChanged, this, &JobPropertiesWidget::onTextChanged); } -QSize JobPropertiesWidget::sizeHint() const -{ +QSize JobPropertiesWidget::sizeHint() const { return QSize(StyleUtils::PropertyPanelWidth(), StyleUtils::PropertyPanelWidth()); } -QSize JobPropertiesWidget::minimumSizeHint() const -{ +QSize JobPropertiesWidget::minimumSizeHint() const { return QSize(StyleUtils::PropertyPanelWidth(), StyleUtils::PropertyPanelWidth()); } -void JobPropertiesWidget::subscribeToItem() -{ +void JobPropertiesWidget::subscribeToItem() { currentItem()->mapper()->setOnPropertyChange( [this](const QString& name) { if (name == JobItem::P_COMMENTS) @@ -71,25 +67,21 @@ void JobPropertiesWidget::subscribeToItem() updateItem(); } -void JobPropertiesWidget::unsubscribeFromItem() -{ +void JobPropertiesWidget::unsubscribeFromItem() { m_componentEditor->setItem(nullptr); } -void JobPropertiesWidget::contextMenuEvent(QContextMenuEvent*) -{ +void JobPropertiesWidget::contextMenuEvent(QContextMenuEvent*) { // Reimplemented to suppress menu from main window } -void JobPropertiesWidget::onTextChanged() -{ +void JobPropertiesWidget::onTextChanged() { m_block_update = true; jobItem()->setComments(m_commentsEditor->toPlainText()); m_block_update = false; } -void JobPropertiesWidget::updateItem() -{ +void JobPropertiesWidget::updateItem() { if (m_block_update) return; @@ -103,7 +95,6 @@ void JobPropertiesWidget::updateItem() } } -JobItem* JobPropertiesWidget::jobItem() -{ +JobItem* JobPropertiesWidget::jobItem() { return dynamic_cast<JobItem*>(currentItem()); } diff --git a/GUI/coregui/Views/JobWidgets/JobPropertiesWidget.h b/GUI/coregui/Views/JobWidgets/JobPropertiesWidget.h index 71ac1073e16b7d1d82405b12a1ca95aaa4c2f370..acc7a094383b6a41ed9655d6af3a89d23d6fd2c6 100644 --- a/GUI/coregui/Views/JobWidgets/JobPropertiesWidget.h +++ b/GUI/coregui/Views/JobWidgets/JobPropertiesWidget.h @@ -25,8 +25,7 @@ class ComponentEditor; //! The JobPropertiesWidget class holds component editor for JobItem. Part of JobSelectorWidget, //! resides at lower left corner of JobView. -class JobPropertiesWidget : public SessionItemWidget -{ +class JobPropertiesWidget : public SessionItemWidget { Q_OBJECT public: enum ETabId { JOB_PROPERTIES, JOB_COMMENTS }; diff --git a/GUI/coregui/Views/JobWidgets/JobRealTimeToolBar.cpp b/GUI/coregui/Views/JobWidgets/JobRealTimeToolBar.cpp index 3de92302a7455f6c69d679433658caeec13dc9f5..61314eade89b284bc54de91e3609854759512189 100644 --- a/GUI/coregui/Views/JobWidgets/JobRealTimeToolBar.cpp +++ b/GUI/coregui/Views/JobWidgets/JobRealTimeToolBar.cpp @@ -16,8 +16,7 @@ #include <QToolButton> JobRealTimeToolBar::JobRealTimeToolBar(QWidget* parent) - : StyledToolBar(parent), m_resetParametersButton(new QToolButton) -{ + : StyledToolBar(parent), m_resetParametersButton(new QToolButton) { setMinimumSize(minimumHeight(), minimumHeight()); m_resetParametersButton->setText("Reset values"); diff --git a/GUI/coregui/Views/JobWidgets/JobRealTimeToolBar.h b/GUI/coregui/Views/JobWidgets/JobRealTimeToolBar.h index feca33bd8b05cfe7f9564b4b2999ebf3d971672b..3f59ef2a6655a36c9375cd7c411d60d8eb30381e 100644 --- a/GUI/coregui/Views/JobWidgets/JobRealTimeToolBar.h +++ b/GUI/coregui/Views/JobWidgets/JobRealTimeToolBar.h @@ -21,8 +21,7 @@ class QToolButton; //! Represents a toolbar with buttons for ParameterTuningWidget. -class JobRealTimeToolBar : public StyledToolBar -{ +class JobRealTimeToolBar : public StyledToolBar { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/JobRealTimeWidget.cpp b/GUI/coregui/Views/JobWidgets/JobRealTimeWidget.cpp index 4f22a3b2d97b24d6f1278eabadbf77ae5556ec3c..8994241858f3f3c1093ea8132560641b088298c6 100644 --- a/GUI/coregui/Views/JobWidgets/JobRealTimeWidget.cpp +++ b/GUI/coregui/Views/JobWidgets/JobRealTimeWidget.cpp @@ -19,14 +19,13 @@ #include "GUI/coregui/mainwindow/mainwindow_constants.h" #include <QVBoxLayout> -namespace -{ +namespace { const bool reuse_widget = true; } JobRealTimeWidget::JobRealTimeWidget(JobModel* jobModel, QWidget* parent) - : QWidget(parent), m_stackedWidget(new ItemStackPresenter<ParameterTuningWidget>(reuse_widget)) -{ + : QWidget(parent) + , m_stackedWidget(new ItemStackPresenter<ParameterTuningWidget>(reuse_widget)) { setWindowTitle(Constants::JobRealTimeWidgetName); setObjectName("JobRealTimeWidget"); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); @@ -40,23 +39,19 @@ JobRealTimeWidget::JobRealTimeWidget(JobModel* jobModel, QWidget* parent) m_stackedWidget->setModel(jobModel); } -ParameterTuningWidget* JobRealTimeWidget::parameterTuningWidget(JobItem* jobItem) -{ +ParameterTuningWidget* JobRealTimeWidget::parameterTuningWidget(JobItem* jobItem) { return m_stackedWidget->itemWidget(jobItem); } -QSize JobRealTimeWidget::sizeHint() const -{ +QSize JobRealTimeWidget::sizeHint() const { return QSize(Constants::REALTIME_WIDGET_WIDTH_HINT, 480); } -QSize JobRealTimeWidget::minimumSizeHint() const -{ +QSize JobRealTimeWidget::minimumSizeHint() const { return QSize(100, 100); } -void JobRealTimeWidget::setItem(JobItem* jobItem) -{ +void JobRealTimeWidget::setItem(JobItem* jobItem) { if (!isValidJobItem(jobItem)) { m_stackedWidget->hideWidgets(); return; @@ -67,8 +62,7 @@ void JobRealTimeWidget::setItem(JobItem* jobItem) //! Returns true if JobItem is valid for real time simulation. -bool JobRealTimeWidget::isValidJobItem(JobItem* item) -{ +bool JobRealTimeWidget::isValidJobItem(JobItem* item) { if (item && (item->isCompleted() || item->isCanceled() || item->isFailed())) return true; diff --git a/GUI/coregui/Views/JobWidgets/JobRealTimeWidget.h b/GUI/coregui/Views/JobWidgets/JobRealTimeWidget.h index 27c6c4844ae891853a6f07456d7b41ca4b0bb660..9dad9c437c13636ecb74dc16edecd23c9d0c47d6 100644 --- a/GUI/coregui/Views/JobWidgets/JobRealTimeWidget.h +++ b/GUI/coregui/Views/JobWidgets/JobRealTimeWidget.h @@ -24,8 +24,7 @@ class ParameterTuningWidget; //! The JobRealTimeWidget class provides tuning of sample parameters in real time. //! Located on the right side of JobView and is visible when realtime activity is selected. -class JobRealTimeWidget : public QWidget -{ +class JobRealTimeWidget : public QWidget { Q_OBJECT public: JobRealTimeWidget(JobModel* jobModel, QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/JobWidgets/JobResultsPresenter.cpp b/GUI/coregui/Views/JobWidgets/JobResultsPresenter.cpp index d4b69fb17b1e1fe59e428c049e3f0ced75901bb8..27e3a44b53c24e2217b8f6fd0f71f39994f3d84d 100644 --- a/GUI/coregui/Views/JobWidgets/JobResultsPresenter.cpp +++ b/GUI/coregui/Views/JobWidgets/JobResultsPresenter.cpp @@ -21,8 +21,7 @@ #include "GUI/coregui/Views/SpecularDataWidgets/SpecularDataWidget.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { // Will switch to the presentation which was used before for given item const bool use_job_last_presentation = true; @@ -50,8 +49,7 @@ const std::map<QString, QStringList> default_active_presentation_list{ template <class QStringObj> QStringObj getPresentations(const SessionItem* job_item, - const std::map<QString, QStringObj>& presentation_map) -{ + const std::map<QString, QStringObj>& presentation_map) { const QString& instrument_type = job_item->getItem(JobItem::T_INSTRUMENT)->modelType(); const auto list_iter = presentation_map.find(instrument_type); if (list_iter == presentation_map.cend()) @@ -60,8 +58,7 @@ QStringObj getPresentations(const SessionItem* job_item, } } // namespace -JobResultsPresenter::JobResultsPresenter(QWidget* parent) : ItemComboWidget(parent) -{ +JobResultsPresenter::JobResultsPresenter(QWidget* parent) : ItemComboWidget(parent) { registerWidget("Color Map", create_new<IntensityDataWidget>); registerWidget("Projections", create_new<IntensityDataProjectionsWidget>); @@ -72,8 +69,7 @@ JobResultsPresenter::JobResultsPresenter(QWidget* parent) : ItemComboWidget(pare registerWidget("Reflectometry", create_new<SpecularDataWidget>); } -QString JobResultsPresenter::itemPresentation() const -{ +QString JobResultsPresenter::itemPresentation() const { if (!currentItem()) return {}; @@ -81,8 +77,7 @@ QString JobResultsPresenter::itemPresentation() const return use_job_last_presentation && value.isValid() ? value.toString() : selectedPresentation(); } -void JobResultsPresenter::setPresentation(const QString& presentationType) -{ +void JobResultsPresenter::setPresentation(const QString& presentationType) { if (!currentItem()) return; @@ -90,8 +85,7 @@ void JobResultsPresenter::setPresentation(const QString& presentationType) currentItem()->setItemValue(JobItem::P_PRESENTATION_TYPE, presentationType); } -void JobResultsPresenter::setPresentation(JobViewFlags::EActivities activity) -{ +void JobResultsPresenter::setPresentation(JobViewFlags::EActivities activity) { if (!currentItem()) return; @@ -105,8 +99,7 @@ void JobResultsPresenter::setPresentation(JobViewFlags::EActivities activity) //! Returns list of presentation types, available for given item. JobItem with fitting abilities //! is valid for IntensityDataWidget and FitComparisonWidget. -QStringList JobResultsPresenter::activePresentationList(SessionItem* item) -{ +QStringList JobResultsPresenter::activePresentationList(SessionItem* item) { auto result = getPresentations(item, default_active_presentation_list); auto job_item = dynamic_cast<JobItem*>(item); @@ -116,8 +109,7 @@ QStringList JobResultsPresenter::activePresentationList(SessionItem* item) return result; } -QStringList JobResultsPresenter::presentationList(SessionItem* item) -{ +QStringList JobResultsPresenter::presentationList(SessionItem* item) { auto result = getPresentations(item, default_active_presentation_list); auto addon = getPresentations(item, instrument_to_fit_presentaion); if (!addon.isEmpty()) diff --git a/GUI/coregui/Views/JobWidgets/JobResultsPresenter.h b/GUI/coregui/Views/JobWidgets/JobResultsPresenter.h index 5249498ef23cb0e14d8cb7ea20cd2ff6077abb6e..0f7d9f6eec84a1608dd805bbd4abc74bc398bc86 100644 --- a/GUI/coregui/Views/JobWidgets/JobResultsPresenter.h +++ b/GUI/coregui/Views/JobWidgets/JobResultsPresenter.h @@ -21,8 +21,7 @@ //! Presents results of job (JobItem) using stack of different widgets and combo box in the //! right top corner of JobView, to switch between widgets. -class JobResultsPresenter : public ItemComboWidget -{ +class JobResultsPresenter : public ItemComboWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/JobSelectorActions.cpp b/GUI/coregui/Views/JobWidgets/JobSelectorActions.cpp index 9eab24bd96ed782293163dee78326b0a40411357..7b4400d4a374d2c54f2ed3d452e4f2b9b50b14ed 100644 --- a/GUI/coregui/Views/JobWidgets/JobSelectorActions.cpp +++ b/GUI/coregui/Views/JobWidgets/JobSelectorActions.cpp @@ -28,8 +28,7 @@ JobSelectorActions::JobSelectorActions(JobModel* jobModel, QObject* parent) , m_runJobAction(nullptr) , m_removeJobAction(nullptr) , m_selectionModel(nullptr) - , m_jobModel(jobModel) -{ + , m_jobModel(jobModel) { m_runJobAction = new QAction("Run", this); m_runJobAction->setIcon(QIcon(":/images/play.svg")); m_runJobAction->setToolTip("Run currently selected job"); @@ -41,13 +40,11 @@ JobSelectorActions::JobSelectorActions(JobModel* jobModel, QObject* parent) connect(m_removeJobAction, &QAction::triggered, this, &JobSelectorActions::onRemoveJob); } -void JobSelectorActions::setSelectionModel(QItemSelectionModel* selectionModel) -{ +void JobSelectorActions::setSelectionModel(QItemSelectionModel* selectionModel) { m_selectionModel = selectionModel; } -void JobSelectorActions::onRunJob() -{ +void JobSelectorActions::onRunJob() { QModelIndexList indexList = m_selectionModel->selectedIndexes(); for (auto index : indexList) { if (canRunJob(index)) @@ -55,8 +52,7 @@ void JobSelectorActions::onRunJob() } } -void JobSelectorActions::onRemoveJob() -{ +void JobSelectorActions::onRemoveJob() { QList<QPersistentModelIndex> toRemove; for (auto index : m_selectionModel->selectedIndexes()) if (canRemoveJob(index)) @@ -69,8 +65,8 @@ void JobSelectorActions::onRemoveJob() //! Generates context menu at given point. If indexAtPoint is provided, the actions will be done //! for corresponding JobItem -void JobSelectorActions::onContextMenuRequest(const QPoint& point, const QModelIndex& indexAtPoint) -{ +void JobSelectorActions::onContextMenuRequest(const QPoint& point, + const QModelIndex& indexAtPoint) { QMenu menu; initItemContextMenu(menu, indexAtPoint); menu.exec(point); @@ -79,8 +75,7 @@ void JobSelectorActions::onContextMenuRequest(const QPoint& point, const QModelI //! Puts all IntensityDataItem axes range to the selected job -void JobSelectorActions::equalizeSelectedToJob(int selected_id) -{ +void JobSelectorActions::equalizeSelectedToJob(int selected_id) { QModelIndexList selectedList = m_selectionModel->selectedIndexes(); if (selected_id >= selectedList.size()) @@ -108,8 +103,7 @@ void JobSelectorActions::equalizeSelectedToJob(int selected_id) } } -void JobSelectorActions::initItemContextMenu(QMenu& menu, const QModelIndex& indexAtPoint) -{ +void JobSelectorActions::initItemContextMenu(QMenu& menu, const QModelIndex& indexAtPoint) { menu.setToolTipsVisible(true); menu.addAction(m_runJobAction); @@ -127,8 +121,7 @@ void JobSelectorActions::initItemContextMenu(QMenu& menu, const QModelIndex& ind setupEqualizeMenu(menu); } -void JobSelectorActions::setupEqualizeMenu(QMenu& menu) -{ +void JobSelectorActions::setupEqualizeMenu(QMenu& menu) { menu.addSeparator(); QMenu* equalize_menu = menu.addMenu("Equalize selected plots"); @@ -151,14 +144,12 @@ void JobSelectorActions::setupEqualizeMenu(QMenu& menu) } } -void JobSelectorActions::setAllActionsEnabled(bool value) -{ +void JobSelectorActions::setAllActionsEnabled(bool value) { m_runJobAction->setEnabled(value); m_removeJobAction->setEnabled(value); } -bool JobSelectorActions::canRunJob(const QModelIndex& index) const -{ +bool JobSelectorActions::canRunJob(const QModelIndex& index) const { if (!index.isValid()) return false; @@ -170,8 +161,7 @@ bool JobSelectorActions::canRunJob(const QModelIndex& index) const return true; } -bool JobSelectorActions::canRemoveJob(const QModelIndex& index) const -{ +bool JobSelectorActions::canRemoveJob(const QModelIndex& index) const { if (!index.isValid()) return false; diff --git a/GUI/coregui/Views/JobWidgets/JobSelectorActions.h b/GUI/coregui/Views/JobWidgets/JobSelectorActions.h index 48a91345a587c8e8d94d68865bcf72b16cfecc73..f961196b2e759f58a999e01a45ab8c9dcda34c8b 100644 --- a/GUI/coregui/Views/JobWidgets/JobSelectorActions.h +++ b/GUI/coregui/Views/JobWidgets/JobSelectorActions.h @@ -27,8 +27,7 @@ class QMenu; //! The JobSelectorActions class contains actions to run/remove jobs. Actions are used by the //! toolbar and JobSelectorList's context menu. -class JobSelectorActions : public QObject -{ +class JobSelectorActions : public QObject { Q_OBJECT public: JobSelectorActions(JobModel* jobModel, QObject* parent = 0); diff --git a/GUI/coregui/Views/JobWidgets/JobSelectorToolBar.cpp b/GUI/coregui/Views/JobWidgets/JobSelectorToolBar.cpp index 0068a4def3f3a4a0fab1f51daef7f94e5772eb53..001d2a7ad7f7e2916a6f320a09eb0ccfddad2da7 100644 --- a/GUI/coregui/Views/JobWidgets/JobSelectorToolBar.cpp +++ b/GUI/coregui/Views/JobWidgets/JobSelectorToolBar.cpp @@ -17,8 +17,7 @@ #include <QToolButton> JobSelectorToolBar::JobSelectorToolBar(JobSelectorActions* actions, QWidget* parent) - : StyledToolBar(parent), m_runJobButton(new QToolButton), m_removeJobButton(new QToolButton) -{ + : StyledToolBar(parent), m_runJobButton(new QToolButton), m_removeJobButton(new QToolButton) { setMinimumSize(minimumHeight(), minimumHeight()); m_runJobButton->setText("Run"); diff --git a/GUI/coregui/Views/JobWidgets/JobSelectorToolBar.h b/GUI/coregui/Views/JobWidgets/JobSelectorToolBar.h index 2e7c588664a31a8442b1a6c9b3ff4e989351733f..32b637a9187f96c3492e33885100a240a6873066 100644 --- a/GUI/coregui/Views/JobWidgets/JobSelectorToolBar.h +++ b/GUI/coregui/Views/JobWidgets/JobSelectorToolBar.h @@ -23,8 +23,7 @@ class JobSelectorActions; //! Styled tool bar on top of JobSelector with run/remove job buttons. -class JobSelectorToolBar : public StyledToolBar -{ +class JobSelectorToolBar : public StyledToolBar { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/JobSelectorWidget.cpp b/GUI/coregui/Views/JobWidgets/JobSelectorWidget.cpp index a7a8a0940b98e34cc4e32019cdd06a8294112410..29c7178b199e3acd53eafaef0f2f59ae1e806e6c 100644 --- a/GUI/coregui/Views/JobWidgets/JobSelectorWidget.cpp +++ b/GUI/coregui/Views/JobWidgets/JobSelectorWidget.cpp @@ -31,8 +31,7 @@ JobSelectorWidget::JobSelectorWidget(JobModel* jobModel, QWidget* parent) , m_toolBar(new JobSelectorToolBar(m_jobSelectorActions, this)) , m_jobListWidget(new JobListWidget) , m_jobProperties(new JobPropertiesWidget) - , m_jobModel(nullptr) -{ + , m_jobModel(nullptr) { setWindowTitle(Constants::JobSelectorWidgetName); setObjectName("JobSelectorWidget"); @@ -61,35 +60,29 @@ JobSelectorWidget::JobSelectorWidget(JobModel* jobModel, QWidget* parent) &JobSelectorWidget::onSelectionChanged); } -void JobSelectorWidget::setModel(JobModel* jobModel) -{ +void JobSelectorWidget::setModel(JobModel* jobModel) { m_jobModel = jobModel; m_jobListWidget->setModel(m_jobModel); } -QSize JobSelectorWidget::sizeHint() const -{ +QSize JobSelectorWidget::sizeHint() const { return QSize(StyleUtils::PropertyPanelWidth(), StyleUtils::PropertyPanelWidth() * 2); } -QSize JobSelectorWidget::minimumSizeHint() const -{ +QSize JobSelectorWidget::minimumSizeHint() const { return QSize(StyleUtils::PropertyPanelWidth(), StyleUtils::PropertyPanelWidth()); } -const JobItem* JobSelectorWidget::currentJobItem() const -{ +const JobItem* JobSelectorWidget::currentJobItem() const { return m_jobListWidget->currentJobItem(); } -void JobSelectorWidget::makeJobItemSelected(JobItem* item) -{ +void JobSelectorWidget::makeJobItemSelected(JobItem* item) { ASSERT(item); m_jobListWidget->makeJobItemSelected(item); } -void JobSelectorWidget::onSelectionChanged(JobItem* jobItem) -{ +void JobSelectorWidget::onSelectionChanged(JobItem* jobItem) { m_jobProperties->setItem(jobItem); emit selectionChanged(jobItem); } diff --git a/GUI/coregui/Views/JobWidgets/JobSelectorWidget.h b/GUI/coregui/Views/JobWidgets/JobSelectorWidget.h index 151ab38e617db526b17cef8c95126722ce1eacb7..816aa3d7a7410ebcc737c7797437c7fcc0b0199b 100644 --- a/GUI/coregui/Views/JobWidgets/JobSelectorWidget.h +++ b/GUI/coregui/Views/JobWidgets/JobSelectorWidget.h @@ -24,16 +24,14 @@ class JobSelectorActions; class JobListWidget; class JobPropertiesWidget; -namespace Manhattan -{ +namespace Manhattan { class MiniSplitter; } //! The JobSelectorWidget class represents left panel of JobView. Contains a tree to select jobs //! on the top and job property editor at the bottom. -class JobSelectorWidget : public QWidget -{ +class JobSelectorWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/JobViewActivities.cpp b/GUI/coregui/Views/JobWidgets/JobViewActivities.cpp index 9c9fb00fee3b21b3585c2ff2f7f0ea2528b3cfd5..3121cb5266a60c34d5f81ef2c760d6051b45d0c8 100644 --- a/GUI/coregui/Views/JobWidgets/JobViewActivities.cpp +++ b/GUI/coregui/Views/JobWidgets/JobViewActivities.cpp @@ -16,10 +16,8 @@ #include "GUI/coregui/mainwindow/mainwindow_constants.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ -JobViewActivities::activity_map_t createActivityMap() -{ +namespace { +JobViewActivities::activity_map_t createActivityMap() { JobViewActivities::activity_map_t result; result[JobViewFlags::JOB_VIEW_ACTIVITY] = QVector<JobViewFlags::Dock>() << JobViewFlags::JOB_LIST_DOCK; @@ -37,8 +35,7 @@ JobViewActivities::activity_map_t JobViewActivities::m_activityToDocks = createA //! Returns list of available activity names. -QStringList JobViewActivities::activityList() -{ +QStringList JobViewActivities::activityList() { QStringList result = QStringList() << Constants::JobViewActivityName << Constants::JobRealTimeActivityName << Constants::JobFittingActivityName; @@ -47,8 +44,7 @@ QStringList JobViewActivities::activityList() //! Returns vector of JobView's dockId which have to be shown for given activity. -QVector<JobViewFlags::Dock> JobViewActivities::activeDocks(JobViewFlags::Activity activity) -{ +QVector<JobViewFlags::Dock> JobViewActivities::activeDocks(JobViewFlags::Activity activity) { activity_map_t::iterator it = m_activityToDocks.find(activity); if (it == m_activityToDocks.end()) { GUIHelpers::Error("JobViewActivities::activeDocks -> Error. Unknown activity"); diff --git a/GUI/coregui/Views/JobWidgets/JobViewActivities.h b/GUI/coregui/Views/JobWidgets/JobViewActivities.h index 6f1b711b3f106b5eb4b4d45986b97cd6423b6373..8008da908f4dedbef54f597b156619ed016152a6 100644 --- a/GUI/coregui/Views/JobWidgets/JobViewActivities.h +++ b/GUI/coregui/Views/JobWidgets/JobViewActivities.h @@ -23,8 +23,7 @@ //! The JobViewActivities class is a helper static class to get info related to JobView activities //! (JobViewActivity, RealTimeActivity and FittingActivity). -class JobViewActivities -{ +class JobViewActivities { public: using activity_map_t = QMap<JobViewFlags::Activity, QVector<JobViewFlags::Dock>>; diff --git a/GUI/coregui/Views/JobWidgets/JobViewDocks.cpp b/GUI/coregui/Views/JobWidgets/JobViewDocks.cpp index 1c7f39d4712552ad444fb6de222a639913fa376b..956cf794047a7c66eba298ea3ac52ff84feeb65d 100644 --- a/GUI/coregui/Views/JobWidgets/JobViewDocks.cpp +++ b/GUI/coregui/Views/JobWidgets/JobViewDocks.cpp @@ -23,8 +23,7 @@ #include "GUI/coregui/Views/JobWidgets/JobViewActivities.h" #include <QDockWidget> -namespace -{ +namespace { const JobViewFlags::Activity default_activity = JobViewFlags::JOB_VIEW_ACTIVITY; } @@ -35,12 +34,9 @@ JobViewDocks::JobViewDocks(JobView* parent) , m_jobRealTimeWidget(nullptr) , m_fitActivityPanel(nullptr) , m_jobMessagePanel(nullptr) - , m_jobView(parent) -{ -} + , m_jobView(parent) {} -void JobViewDocks::initViews(JobModel* jobModel) -{ +void JobViewDocks::initViews(JobModel* jobModel) { m_jobOutputDataWidget = new JobOutputDataWidget(jobModel, m_jobView); m_jobSelector = new JobSelectorWidget(jobModel, m_jobView); @@ -68,35 +64,29 @@ void JobViewDocks::initViews(JobModel* jobModel) onResetLayout(); } -JobRealTimeWidget* JobViewDocks::jobRealTimeWidget() -{ +JobRealTimeWidget* JobViewDocks::jobRealTimeWidget() { return m_jobRealTimeWidget; } -FitActivityPanel* JobViewDocks::fitActivityPanel() -{ +FitActivityPanel* JobViewDocks::fitActivityPanel() { return m_fitActivityPanel; } -JobSelectorWidget* JobViewDocks::jobSelector() -{ +JobSelectorWidget* JobViewDocks::jobSelector() { return m_jobSelector; } -JobOutputDataWidget* JobViewDocks::jobOutputDataWidget() -{ +JobOutputDataWidget* JobViewDocks::jobOutputDataWidget() { return m_jobOutputDataWidget; } -JobMessagePanel* JobViewDocks::jobMessagePanel() -{ +JobMessagePanel* JobViewDocks::jobMessagePanel() { return m_jobMessagePanel; } //! Sets docks visibility so they match the activity flag. -void JobViewDocks::setActivity(int activity) -{ +void JobViewDocks::setActivity(int activity) { QVector<JobViewFlags::Dock> docksToShow = JobViewActivities::activeDocks(JobViewFlags::Activity(activity)); @@ -107,8 +97,7 @@ void JobViewDocks::setActivity(int activity) show_docks(docks_id); } -void JobViewDocks::setItem(JobItem* jobItem) -{ +void JobViewDocks::setItem(JobItem* jobItem) { jobOutputDataWidget()->setItem(jobItem); jobRealTimeWidget()->setItem(jobItem); fitActivityPanel()->setItem(jobItem); @@ -116,16 +105,14 @@ void JobViewDocks::setItem(JobItem* jobItem) //! Sets the state of JobView to the default. -void JobViewDocks::onResetLayout() -{ +void JobViewDocks::onResetLayout() { DocksController::onResetLayout(); setActivity(static_cast<int>(default_activity)); } //! Shows/hides JobSelectorWidget. -void JobViewDocks::onToggleJobSelector() -{ +void JobViewDocks::onToggleJobSelector() { auto selectorDock = findDock(JobViewFlags::JOB_LIST_DOCK); selectorDock->setHidden(!selectorDock->isHidden()); } diff --git a/GUI/coregui/Views/JobWidgets/JobViewDocks.h b/GUI/coregui/Views/JobWidgets/JobViewDocks.h index 74cea81bb6887eb946bd0569fe1e67814cbb8a24..74663bc9056394a7660968d91d86228012898f71 100644 --- a/GUI/coregui/Views/JobWidgets/JobViewDocks.h +++ b/GUI/coregui/Views/JobWidgets/JobViewDocks.h @@ -32,8 +32,7 @@ class JobItem; //! It's main method setActivity handles visibility logic for all of (JobSelectorWidget, //! JobOutputDataWidget, JobRealTimeWidget and FitPanelWidget). -class JobViewDocks : public DocksController -{ +class JobViewDocks : public DocksController { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/JobViewFlags.h b/GUI/coregui/Views/JobWidgets/JobViewFlags.h index c58b5945221ec5a2251fdbc128ca2361b58c8de6..c0634ffa69f520a905861dd0ba95271e731b6e17 100644 --- a/GUI/coregui/Views/JobWidgets/JobViewFlags.h +++ b/GUI/coregui/Views/JobWidgets/JobViewFlags.h @@ -19,8 +19,7 @@ //! The JobViewFlags class is a namespace for various flags used in JobView. -class JobViewFlags -{ +class JobViewFlags { public: enum EDocksId { JOB_LIST_DOCK, diff --git a/GUI/coregui/Views/JobWidgets/JobViewStatusBar.cpp b/GUI/coregui/Views/JobWidgets/JobViewStatusBar.cpp index be9bcc04513c24d430f5062126f9a5212af2bade..1102f0ad1cde0340acf928a5893fb9f8984cec32 100644 --- a/GUI/coregui/Views/JobWidgets/JobViewStatusBar.cpp +++ b/GUI/coregui/Views/JobWidgets/JobViewStatusBar.cpp @@ -26,8 +26,7 @@ JobViewStatusBar::JobViewStatusBar(MainWindow* mainWindow) , m_toggleJobListButton(nullptr) , m_activityCombo(nullptr) , m_dockMenuButton(nullptr) - , m_mainWindow(mainWindow) -{ + , m_mainWindow(mainWindow) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); auto layout = new QHBoxLayout; @@ -61,8 +60,7 @@ JobViewStatusBar::JobViewStatusBar(MainWindow* mainWindow) initAppearance(); } -void JobViewStatusBar::onActivityChanged(int activity) -{ +void JobViewStatusBar::onActivityChanged(int activity) { disconnect(m_activityCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &JobViewStatusBar::changeActivityRequest); @@ -75,8 +73,7 @@ void JobViewStatusBar::onActivityChanged(int activity) //! Init appearance of MainWindow's statusBar. -void JobViewStatusBar::initAppearance() -{ +void JobViewStatusBar::initAppearance() { ASSERT(m_mainWindow); m_mainWindow->statusBar()->addWidget(this, 1); m_mainWindow->statusBar()->setSizeGripEnabled(false); diff --git a/GUI/coregui/Views/JobWidgets/JobViewStatusBar.h b/GUI/coregui/Views/JobWidgets/JobViewStatusBar.h index 091f2092a3aa061d437e131dbbefc2f68aae46bd..5c9db029faaeeb5a422bfa4ba9fa10b661ff5bbd 100644 --- a/GUI/coregui/Views/JobWidgets/JobViewStatusBar.h +++ b/GUI/coregui/Views/JobWidgets/JobViewStatusBar.h @@ -24,8 +24,7 @@ class QComboBox; //! Narrow status bar at very bottom of JobView to switch between activities. //! Added to the status bar of MainWindow when JobView is shown. -class JobViewStatusBar : public QWidget -{ +class JobViewStatusBar : public QWidget { Q_OBJECT public: JobViewStatusBar(MainWindow* mainWindow); diff --git a/GUI/coregui/Views/JobWidgets/ParameterTuningDelegate.cpp b/GUI/coregui/Views/JobWidgets/ParameterTuningDelegate.cpp index d017f1beebfcad48788833770799da51bd32923d..298c5e6d61698bdd356590ff9ba7b923ad4e1d05 100644 --- a/GUI/coregui/Views/JobWidgets/ParameterTuningDelegate.cpp +++ b/GUI/coregui/Views/JobWidgets/ParameterTuningDelegate.cpp @@ -33,29 +33,23 @@ #include <iostream> #include <limits> -namespace -{ +namespace { const double maximum_doublespin_value = std::numeric_limits<double>::max(); const double minimum_doublespin_value = std::numeric_limits<double>::lowest(); } // namespace ParameterTuningDelegate::TuningData::TuningData() - : m_smin(0), m_smax(100), m_rmin(0.0), m_rmax(0.0), m_range_factor(100.0) -{ -} + : m_smin(0), m_smax(100), m_rmin(0.0), m_rmax(0.0), m_range_factor(100.0) {} -void ParameterTuningDelegate::TuningData::setRangeFactor(double range_factor) -{ +void ParameterTuningDelegate::TuningData::setRangeFactor(double range_factor) { m_range_factor = range_factor; } -void ParameterTuningDelegate::TuningData::setItemLimits(const RealLimits& item_limits) -{ +void ParameterTuningDelegate::TuningData::setItemLimits(const RealLimits& item_limits) { m_item_limits = item_limits; } -int ParameterTuningDelegate::TuningData::value_to_slider(double value) -{ +int ParameterTuningDelegate::TuningData::value_to_slider(double value) { double dr(0); if (value == 0.0) { dr = 1.0 * m_range_factor / 100.; @@ -75,13 +69,11 @@ int ParameterTuningDelegate::TuningData::value_to_slider(double value) return static_cast<int>(result); } -double ParameterTuningDelegate::TuningData::slider_to_value(int slider) -{ +double ParameterTuningDelegate::TuningData::slider_to_value(int slider) { return m_rmin + (slider - m_smin) * (m_rmax - m_rmin) / (m_smax - m_smin); } -double ParameterTuningDelegate::TuningData::step() const -{ +double ParameterTuningDelegate::TuningData::step() const { return (m_rmax - m_rmin) / (m_smax - m_smin); } @@ -93,15 +85,12 @@ ParameterTuningDelegate::ParameterTuningDelegate(QObject* parent) , m_contentWidget(nullptr) , m_contentLayout(nullptr) , m_currentItem(nullptr) - , m_isReadOnly(false) -{ -} + , m_isReadOnly(false) {} ParameterTuningDelegate::~ParameterTuningDelegate() = default; void ParameterTuningDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ + const QModelIndex& index) const { if (index.column() == m_valueColumn) { if (!index.parent().isValid()) @@ -127,8 +116,7 @@ void ParameterTuningDelegate::paint(QPainter* painter, const QStyleOptionViewIte } QWidget* ParameterTuningDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ + const QModelIndex& index) const { if (m_isReadOnly) return nullptr; @@ -210,8 +198,7 @@ QWidget* ParameterTuningDelegate::createEditor(QWidget* parent, const QStyleOpti } } -void ParameterTuningDelegate::updateSlider(double value) const -{ +void ParameterTuningDelegate::updateSlider(double value) const { disconnect(m_slider, &QSlider::valueChanged, this, &ParameterTuningDelegate::sliderValueChanged); @@ -220,8 +207,7 @@ void ParameterTuningDelegate::updateSlider(double value) const connect(m_slider, &QSlider::valueChanged, this, &ParameterTuningDelegate::sliderValueChanged); } -void ParameterTuningDelegate::sliderValueChanged(int position) -{ +void ParameterTuningDelegate::sliderValueChanged(int position) { disconnect(m_valueBox, &ScientificSpinBox::valueChanged, this, &ParameterTuningDelegate::editorValueChanged); @@ -233,8 +219,7 @@ void ParameterTuningDelegate::sliderValueChanged(int position) emitSignals(value); } -void ParameterTuningDelegate::editorValueChanged(double value) -{ +void ParameterTuningDelegate::editorValueChanged(double value) { disconnect(m_slider, &QSlider::valueChanged, this, &ParameterTuningDelegate::sliderValueChanged); @@ -244,8 +229,7 @@ void ParameterTuningDelegate::editorValueChanged(double value) emitSignals(value); } -void ParameterTuningDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const -{ +void ParameterTuningDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { if (index.column() == m_valueColumn) { // as using custom widget, doing nothing here } else { @@ -254,8 +238,7 @@ void ParameterTuningDelegate::setEditorData(QWidget* editor, const QModelIndex& } void ParameterTuningDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, - const QModelIndex& index) const -{ + const QModelIndex& index) const { if (index.column() == m_valueColumn) { model->setData(index, m_valueBox->value()); @@ -265,20 +248,17 @@ void ParameterTuningDelegate::setModelData(QWidget* editor, QAbstractItemModel* } } -void ParameterTuningDelegate::emitSignals(double value) -{ +void ParameterTuningDelegate::emitSignals(double value) { if (m_currentItem) { m_currentItem->propagateValueToLink(value); emit currentLinkChanged(m_currentItem); } } -void ParameterTuningDelegate::setSliderRangeFactor(double value) -{ +void ParameterTuningDelegate::setSliderRangeFactor(double value) { m_tuning_info.setRangeFactor(value); } -void ParameterTuningDelegate::setReadOnly(bool isReadOnly) -{ +void ParameterTuningDelegate::setReadOnly(bool isReadOnly) { m_isReadOnly = isReadOnly; } diff --git a/GUI/coregui/Views/JobWidgets/ParameterTuningDelegate.h b/GUI/coregui/Views/JobWidgets/ParameterTuningDelegate.h index d6a91c8b1e5bba5fc4d56509321a66ff3801ed00..7351237fbb4cacdbcfc4ab9fb0cc824bf3abe4d4 100644 --- a/GUI/coregui/Views/JobWidgets/ParameterTuningDelegate.h +++ b/GUI/coregui/Views/JobWidgets/ParameterTuningDelegate.h @@ -25,13 +25,11 @@ class ParameterItem; class ScientificSpinBox; class SessionItem; -class ParameterTuningDelegate : public QItemDelegate -{ +class ParameterTuningDelegate : public QItemDelegate { Q_OBJECT public: - class TuningData - { + class TuningData { public: TuningData(); void setRangeFactor(double range_factor); @@ -50,8 +48,7 @@ public: ParameterTuningDelegate(QObject* parent = 0); ~ParameterTuningDelegate(); - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& /* index */) const - { + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& /* index */) const { return QSize(option.rect.width(), 25); } diff --git a/GUI/coregui/Views/JobWidgets/ParameterTuningWidget.cpp b/GUI/coregui/Views/JobWidgets/ParameterTuningWidget.cpp index 0a7050cfe0ba1133d8a2cfa5b736987cd3f91d5f..e41d2505785280ff871ff210ccaf29060eddae24 100644 --- a/GUI/coregui/Views/JobWidgets/ParameterTuningWidget.cpp +++ b/GUI/coregui/Views/JobWidgets/ParameterTuningWidget.cpp @@ -34,8 +34,7 @@ ParameterTuningWidget::ParameterTuningWidget(QWidget* parent) , m_sliderSettingsWidget(new SliderSettingsWidget(this)) , m_treeView(new QTreeView) , m_delegate(new ParameterTuningDelegate(this)) - , m_warningSign(new WarningSign(m_treeView)) -{ + , m_warningSign(new WarningSign(m_treeView)) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_treeView->setItemDelegate(m_delegate); @@ -63,16 +62,14 @@ ParameterTuningWidget::ParameterTuningWidget(QWidget* parent) &ParameterTuningWidget::restoreModelsOfCurrentJobItem); } -QItemSelectionModel* ParameterTuningWidget::selectionModel() -{ +QItemSelectionModel* ParameterTuningWidget::selectionModel() { ASSERT(m_treeView); return m_treeView->selectionModel(); } //! Returns list of ParameterItem's currently selected in parameter tree -QVector<ParameterItem*> ParameterTuningWidget::getSelectedParameters() -{ +QVector<ParameterItem*> ParameterTuningWidget::getSelectedParameters() { QVector<ParameterItem*> result; QModelIndexList proxyIndexes = selectionModel()->selectedIndexes(); for (auto proxyIndex : proxyIndexes) { @@ -82,8 +79,7 @@ QVector<ParameterItem*> ParameterTuningWidget::getSelectedParameters() return result; } -void ParameterTuningWidget::onCurrentLinkChanged(SessionItem* item) -{ +void ParameterTuningWidget::onCurrentLinkChanged(SessionItem* item) { ASSERT(jobItem()); if (jobItem()->isRunning()) @@ -95,21 +91,18 @@ void ParameterTuningWidget::onCurrentLinkChanged(SessionItem* item) } } -void ParameterTuningWidget::onSliderValueChanged(double value) -{ +void ParameterTuningWidget::onSliderValueChanged(double value) { m_delegate->setSliderRangeFactor(value); } -void ParameterTuningWidget::onLockZValueChanged(bool value) -{ +void ParameterTuningWidget::onLockZValueChanged(bool value) { if (!jobItem()) return; if (IntensityDataItem* intensityDataItem = jobItem()->intensityDataItem()) intensityDataItem->setZAxisLocked(value); } -void ParameterTuningWidget::updateParameterModel() -{ +void ParameterTuningWidget::updateParameterModel() { ASSERT(m_jobModel); if (!jobItem()) @@ -131,13 +124,11 @@ void ParameterTuningWidget::updateParameterModel() m_treeView->expandAll(); } -void ParameterTuningWidget::onCustomContextMenuRequested(const QPoint& point) -{ +void ParameterTuningWidget::onCustomContextMenuRequested(const QPoint& point) { emit itemContextMenuRequest(m_treeView->mapToGlobal(point + QPoint(2, 22))); } -void ParameterTuningWidget::restoreModelsOfCurrentJobItem() -{ +void ParameterTuningWidget::restoreModelsOfCurrentJobItem() { ASSERT(m_jobModel); ASSERT(jobItem()); @@ -150,20 +141,17 @@ void ParameterTuningWidget::restoreModelsOfCurrentJobItem() m_jobModel->runJob(jobItem()->index()); } -void ParameterTuningWidget::makeSelected(ParameterItem* item) -{ +void ParameterTuningWidget::makeSelected(ParameterItem* item) { QModelIndex proxyIndex = m_parameterTuningModel->mapFromSource(item->index()); if (proxyIndex.isValid()) selectionModel()->select(proxyIndex, QItemSelectionModel::Select); } -void ParameterTuningWidget::contextMenuEvent(QContextMenuEvent*) -{ +void ParameterTuningWidget::contextMenuEvent(QContextMenuEvent*) { // reimplemented to suppress context menu from QMainWindow } -void ParameterTuningWidget::subscribeToItem() -{ +void ParameterTuningWidget::subscribeToItem() { m_jobModel = dynamic_cast<JobModel*>(jobItem()->model()); updateParameterModel(); @@ -175,8 +163,7 @@ void ParameterTuningWidget::subscribeToItem() onPropertyChanged(JobItem::P_STATUS); } -void ParameterTuningWidget::onPropertyChanged(const QString& property_name) -{ +void ParameterTuningWidget::onPropertyChanged(const QString& property_name) { if (property_name == JobItem::P_STATUS) { m_warningSign->clear(); @@ -191,15 +178,13 @@ void ParameterTuningWidget::onPropertyChanged(const QString& property_name) } } -JobItem* ParameterTuningWidget::jobItem() -{ +JobItem* ParameterTuningWidget::jobItem() { return dynamic_cast<JobItem*>(currentItem()); } //! Disable drag-and-drop abilities, if job is in fit running state. -void ParameterTuningWidget::updateDragAndDropSettings() -{ +void ParameterTuningWidget::updateDragAndDropSettings() { ASSERT(jobItem()); if (jobItem()->getStatus() == "Fitting") { setTuningDelegateEnabled(false); @@ -214,8 +199,7 @@ void ParameterTuningWidget::updateDragAndDropSettings() //! Sets delegate to enabled/disabled state. //! In 'disabled' state the delegate is in ReadOnlyMode, if it was containing already some //! editing widget, it will be forced to close. -void ParameterTuningWidget::setTuningDelegateEnabled(bool enabled) -{ +void ParameterTuningWidget::setTuningDelegateEnabled(bool enabled) { if (enabled) { m_delegate->setReadOnly(false); } else { @@ -224,8 +208,7 @@ void ParameterTuningWidget::setTuningDelegateEnabled(bool enabled) } } -void ParameterTuningWidget::closeActiveEditors() -{ +void ParameterTuningWidget::closeActiveEditors() { QModelIndex index = m_treeView->currentIndex(); QWidget* editor = m_treeView->indexWidget(index); if (editor) { diff --git a/GUI/coregui/Views/JobWidgets/ParameterTuningWidget.h b/GUI/coregui/Views/JobWidgets/ParameterTuningWidget.h index 466f318f6e266cb7ce37fc391e4f5cfdabbb3040..0b7e39185ca3297e881323690110a37f86bc912d 100644 --- a/GUI/coregui/Views/JobWidgets/ParameterTuningWidget.h +++ b/GUI/coregui/Views/JobWidgets/ParameterTuningWidget.h @@ -32,8 +32,7 @@ class ParameterItem; //! Main widget for real time parameter tuning. //! Contains a tree for parameter tuning and the model to provide drag-and-drop in FitActivityPanel. -class ParameterTuningWidget : public SessionItemWidget -{ +class ParameterTuningWidget : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsEditor.cpp b/GUI/coregui/Views/JobWidgets/ProjectionsEditor.cpp index d606a58f991fd495e50ba599c91af2ab703a6749..afe18bda5bf57af6e92754ee11f03ca6c8ceabb0 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsEditor.cpp +++ b/GUI/coregui/Views/JobWidgets/ProjectionsEditor.cpp @@ -33,8 +33,7 @@ ProjectionsEditor::ProjectionsEditor(QWidget* parent) , m_propertyPanel(new ProjectionsPropertyPanel) , m_selectionModel(nullptr) , m_rightSplitter(new Manhattan::MiniSplitter) - , m_bottomSplitter(new QSplitter) -{ + , m_bottomSplitter(new QSplitter) { addToolBar(Qt::RightToolBarArea, m_toolBar); m_bottomSplitter->setOrientation(Qt::Vertical); @@ -52,8 +51,7 @@ ProjectionsEditor::ProjectionsEditor(QWidget* parent) } void ProjectionsEditor::setContext(SessionModel* model, const QModelIndex& shapeContainerIndex, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { Q_UNUSED(model); Q_UNUSED(shapeContainerIndex); @@ -69,20 +67,17 @@ void ProjectionsEditor::setContext(SessionModel* model, const QModelIndex& shape m_editorActions->setSelectionModel(m_selectionModel); } -void ProjectionsEditor::resetContext() -{ +void ProjectionsEditor::resetContext() { m_propertyPanel->setItem(nullptr); m_projectionsCanvas->resetContext(); m_projectionsWidget->setItem(nullptr); } -QList<QAction*> ProjectionsEditor::topToolBarActions() -{ +QList<QAction*> ProjectionsEditor::topToolBarActions() { return m_editorActions->topToolBarActions(); } -void ProjectionsEditor::setup_connections() -{ +void ProjectionsEditor::setup_connections() { // tool panel request is propagated from editorActions to this MaskEditor connect(m_editorActions, &ProjectionsEditorActions::resetViewRequest, m_projectionsCanvas, &ProjectionsEditorCanvas::onResetViewRequest); diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsEditor.h b/GUI/coregui/Views/JobWidgets/ProjectionsEditor.h index 36dbd886d2d93351126eac8b6ad72c06d6a963e9..042692a2510fb321a7e647b2662ee6a1e7a91b3d 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsEditor.h +++ b/GUI/coregui/Views/JobWidgets/ProjectionsEditor.h @@ -28,15 +28,13 @@ class ProjectionsPropertyPanel; class ProjectionsWidget; class QItemSelectionModel; class QSplitter; -namespace Manhattan -{ +namespace Manhattan { class MiniSplitter; } //! Editor to draw projections on top of intensity plot. Part of -class ProjectionsEditor : public QMainWindow -{ +class ProjectionsEditor : public QMainWindow { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsEditorActions.cpp b/GUI/coregui/Views/JobWidgets/ProjectionsEditorActions.cpp index 837103348ed61a2c3eab38f162140c39f321041c..0e43a2bd38a57c76db79044633492e8e24680548 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsEditorActions.cpp +++ b/GUI/coregui/Views/JobWidgets/ProjectionsEditorActions.cpp @@ -27,8 +27,7 @@ ProjectionsEditorActions::ProjectionsEditorActions(QWidget* parent) , m_model(nullptr) , m_intensityDataItem(nullptr) , m_selectionModel(nullptr) - , m_parent(parent) -{ + , m_parent(parent) { // Actions for top toolbar m_resetViewAction->setText("Center view"); m_resetViewAction->setIcon(QIcon(":/images/camera-metering-center.svg")); @@ -49,25 +48,21 @@ ProjectionsEditorActions::ProjectionsEditorActions(QWidget* parent) } void ProjectionsEditorActions::setContext(SessionModel* model, const QModelIndex& containerIndex, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { m_model = model; m_containerIndex = containerIndex; m_intensityDataItem = intensityItem; } -void ProjectionsEditorActions::setSelectionModel(QItemSelectionModel* selectionModel) -{ +void ProjectionsEditorActions::setSelectionModel(QItemSelectionModel* selectionModel) { m_selectionModel = selectionModel; } -QList<QAction*> ProjectionsEditorActions::topToolBarActions() -{ +QList<QAction*> ProjectionsEditorActions::topToolBarActions() { return QList<QAction*>() << m_resetViewAction << m_togglePanelAction; } -void ProjectionsEditorActions::onDeleteAction() -{ +void ProjectionsEditorActions::onDeleteAction() { ASSERT(m_model); ASSERT(m_selectionModel); @@ -79,8 +74,7 @@ void ProjectionsEditorActions::onDeleteAction() } //! Performs saving of projections in ascii file -void ProjectionsEditorActions::onSaveAction() -{ +void ProjectionsEditorActions::onSaveAction() { if (!m_intensityDataItem) return; diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsEditorActions.h b/GUI/coregui/Views/JobWidgets/ProjectionsEditorActions.h index d51db5c8e896c8c4f53500733217584e97d36fd6..c892fa3eab9dc25321d7df4a7c9ef60518884081 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsEditorActions.h +++ b/GUI/coregui/Views/JobWidgets/ProjectionsEditorActions.h @@ -26,8 +26,7 @@ class IntensityDataItem; //! Provides various actions for ProjectionsEditor. -class ProjectionsEditorActions : public QObject -{ +class ProjectionsEditorActions : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsEditorCanvas.cpp b/GUI/coregui/Views/JobWidgets/ProjectionsEditorCanvas.cpp index 89ef37b4a0b380d68b021079c0c793323d73d91c..aa878d51a14c4b9efc7cd9faa2f0584b087410fe 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsEditorCanvas.cpp +++ b/GUI/coregui/Views/JobWidgets/ProjectionsEditorCanvas.cpp @@ -34,8 +34,7 @@ ProjectionsEditorCanvas::ProjectionsEditorCanvas(QWidget* parent) , m_model(nullptr) , m_intensityDataItem(nullptr) , m_currentActivity(MaskEditorFlags::HORIZONTAL_LINE_MODE) - , m_block_update(false) -{ + , m_block_update(false) { setObjectName("MaskEditorCanvas"); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -53,8 +52,7 @@ ProjectionsEditorCanvas::ProjectionsEditorCanvas(QWidget* parent) void ProjectionsEditorCanvas::setContext(SessionModel* model, const QModelIndex& shapeContainerIndex, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { m_model = model; m_scene->setMaskContext(model, shapeContainerIndex, intensityItem); m_view->updateSize(m_view->size()); @@ -67,8 +65,7 @@ void ProjectionsEditorCanvas::setContext(SessionModel* model, getScene()->onActivityModeChanged(m_currentActivity); } -void ProjectionsEditorCanvas::resetContext() -{ +void ProjectionsEditorCanvas::resetContext() { m_intensityDataItem = nullptr; m_containerIndex = {}; setConnected(false); @@ -76,13 +73,11 @@ void ProjectionsEditorCanvas::resetContext() m_scene->resetContext(); } -void ProjectionsEditorCanvas::setSelectionModel(QItemSelectionModel* model) -{ +void ProjectionsEditorCanvas::setSelectionModel(QItemSelectionModel* model) { getScene()->setSelectionModel(model); } -void ProjectionsEditorCanvas::onEnteringColorMap() -{ +void ProjectionsEditorCanvas::onEnteringColorMap() { if (m_liveProjection || m_block_update) return; @@ -99,8 +94,7 @@ void ProjectionsEditorCanvas::onEnteringColorMap() m_block_update = false; } -void ProjectionsEditorCanvas::onLeavingColorMap() -{ +void ProjectionsEditorCanvas::onLeavingColorMap() { if (m_block_update) return; @@ -116,8 +110,7 @@ void ProjectionsEditorCanvas::onLeavingColorMap() m_block_update = false; } -void ProjectionsEditorCanvas::onPositionChanged(double x, double y) -{ +void ProjectionsEditorCanvas::onPositionChanged(double x, double y) { if (m_block_update) return; @@ -133,21 +126,18 @@ void ProjectionsEditorCanvas::onPositionChanged(double x, double y) m_block_update = false; } -void ProjectionsEditorCanvas::onResetViewRequest() -{ +void ProjectionsEditorCanvas::onResetViewRequest() { m_view->onResetViewRequest(); m_intensityDataItem->resetView(); } -void ProjectionsEditorCanvas::onActivityModeChanged(MaskEditorFlags::Activity value) -{ +void ProjectionsEditorCanvas::onActivityModeChanged(MaskEditorFlags::Activity value) { m_currentActivity = value; getScene()->onActivityModeChanged(value); onLeavingColorMap(); } -void ProjectionsEditorCanvas::setColorMap(ColorMap* colorMap) -{ +void ProjectionsEditorCanvas::setColorMap(ColorMap* colorMap) { ASSERT(colorMap); setConnected(false); @@ -158,8 +148,7 @@ void ProjectionsEditorCanvas::setColorMap(ColorMap* colorMap) m_statusLabel->addPlot(colorMap); } -void ProjectionsEditorCanvas::setConnected(bool isConnected) -{ +void ProjectionsEditorCanvas::setConnected(bool isConnected) { if (!m_colorMap) return; diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsEditorCanvas.h b/GUI/coregui/Views/JobWidgets/ProjectionsEditorCanvas.h index c32ae3f88816390ae4c1562eb9eaa9ca4ec329f5..d21f18626b157c421432a4ebe2b35533f4e0c82b 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsEditorCanvas.h +++ b/GUI/coregui/Views/JobWidgets/ProjectionsEditorCanvas.h @@ -34,8 +34,7 @@ class QItemSelectionModel; //! Particularly, it creates temporary ProjectionItem in projection container, when mouse //! is inside ColorMap viewport. -class ProjectionsEditorCanvas : public QWidget -{ +class ProjectionsEditorCanvas : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsPropertyPanel.cpp b/GUI/coregui/Views/JobWidgets/ProjectionsPropertyPanel.cpp index 577f0353d48d34443622e574fd8624ddc7414083..1b94797b358c09c1632859d06b1d2baf4899d6b4 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsPropertyPanel.cpp +++ b/GUI/coregui/Views/JobWidgets/ProjectionsPropertyPanel.cpp @@ -17,8 +17,7 @@ #include <QVBoxLayout> ProjectionsPropertyPanel::ProjectionsPropertyPanel(QWidget* parent) - : SessionItemWidget(parent), m_componentEditor(new ComponentEditor) -{ + : SessionItemWidget(parent), m_componentEditor(new ComponentEditor) { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); QVBoxLayout* mainLayout = new QVBoxLayout; @@ -29,22 +28,18 @@ ProjectionsPropertyPanel::ProjectionsPropertyPanel(QWidget* parent) setLayout(mainLayout); } -QSize ProjectionsPropertyPanel::sizeHint() const -{ +QSize ProjectionsPropertyPanel::sizeHint() const { return QSize(230, 256); } -QSize ProjectionsPropertyPanel::minimumSizeHint() const -{ +QSize ProjectionsPropertyPanel::minimumSizeHint() const { return QSize(230, 64); } -void ProjectionsPropertyPanel::subscribeToItem() -{ +void ProjectionsPropertyPanel::subscribeToItem() { m_componentEditor->setItem(currentItem()); } -void ProjectionsPropertyPanel::unsubscribeFromItem() -{ +void ProjectionsPropertyPanel::unsubscribeFromItem() { m_componentEditor->setItem(nullptr); } diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsPropertyPanel.h b/GUI/coregui/Views/JobWidgets/ProjectionsPropertyPanel.h index 2bf5e9ae7c00e4b70b35a1915a1d71c3620872cf..054be416b595dade44ede1d329cf4993fe816e1f 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsPropertyPanel.h +++ b/GUI/coregui/Views/JobWidgets/ProjectionsPropertyPanel.h @@ -19,8 +19,7 @@ class ComponentEditor; -class ProjectionsPropertyPanel : public SessionItemWidget -{ +class ProjectionsPropertyPanel : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsToolBar.cpp b/GUI/coregui/Views/JobWidgets/ProjectionsToolBar.cpp index 0e926432e20a088fc0f4b8aeaf0efa7031bc22b4..10e1dfe09b5caa5cc462a7e20f4415f9da05f6aa 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsToolBar.cpp +++ b/GUI/coregui/Views/JobWidgets/ProjectionsToolBar.cpp @@ -19,8 +19,7 @@ #include <QLabel> #include <QToolButton> -namespace -{ +namespace { const QString pan_zoom_tooltip = "Pan/zoom mode (space)\n" "Drag axes with the mouse, use mouse wheel to zoom in/out"; @@ -40,8 +39,7 @@ const QString vertical_mode_tooltip = ProjectionsToolBar::ProjectionsToolBar(ProjectionsEditorActions* editorActions, QWidget* parent) : QToolBar(parent) , m_editorActions(editorActions) - , m_activityButtonGroup(new QButtonGroup(this)) -{ + , m_activityButtonGroup(new QButtonGroup(this)) { setIconSize(QSize(Constants::toolbar_icon_size, Constants::toolbar_icon_size)); setProperty("_q_custom_style_disabled", QVariant(true)); @@ -55,8 +53,7 @@ ProjectionsToolBar::ProjectionsToolBar(ProjectionsEditorActions* editorActions, m_previousActivity = currentActivity(); } -void ProjectionsToolBar::onChangeActivityRequest(MaskEditorFlags::Activity value) -{ +void ProjectionsToolBar::onChangeActivityRequest(MaskEditorFlags::Activity value) { if (value == MaskEditorFlags::PREVIOUS_MODE) { setCurrentActivity(m_previousActivity); } else { @@ -68,20 +65,17 @@ void ProjectionsToolBar::onChangeActivityRequest(MaskEditorFlags::Activity value //! Change activity only if current activity is one of drawing mode (horizontal, vertical //! projections drawing). -void ProjectionsToolBar::onProjectionTabChange(MaskEditorFlags::Activity value) -{ +void ProjectionsToolBar::onProjectionTabChange(MaskEditorFlags::Activity value) { if (currentActivity() == MaskEditorFlags::HORIZONTAL_LINE_MODE || currentActivity() == MaskEditorFlags::VERTICAL_LINE_MODE) onChangeActivityRequest(value); } -void ProjectionsToolBar::onActivityGroupChange(int) -{ +void ProjectionsToolBar::onActivityGroupChange(int) { emit activityModeChanged(currentActivity()); } -void ProjectionsToolBar::setup_selection_group() -{ +void ProjectionsToolBar::setup_selection_group() { auto panButton = new QToolButton(this); panButton->setIcon(QIcon(":/images/hand-right.svg")); panButton->setToolTip(pan_zoom_tooltip); @@ -108,8 +102,7 @@ void ProjectionsToolBar::setup_selection_group() m_activityButtonGroup->addButton(selectionButton, MaskEditorFlags::SELECTION_MODE); } -void ProjectionsToolBar::setup_shapes_group() -{ +void ProjectionsToolBar::setup_shapes_group() { auto horizontalLineButton = new QToolButton(this); horizontalLineButton->setIcon(QIcon(":/MaskWidgets/images/maskeditor_horizontalline.svg")); horizontalLineButton->setToolTip(horizontal_mode_tooltip); @@ -128,8 +121,7 @@ void ProjectionsToolBar::setup_shapes_group() add_separator(); } -void ProjectionsToolBar::setup_extratools_group() -{ +void ProjectionsToolBar::setup_extratools_group() { auto saveButton = new QToolButton(this); saveButton->setIcon(QIcon(":/MaskWidgets/images/maskeditor_save.svg")); saveButton->setToolTip("Save created projections in multi-column ASCII file."); @@ -138,20 +130,17 @@ void ProjectionsToolBar::setup_extratools_group() &ProjectionsEditorActions::onSaveAction); } -void ProjectionsToolBar::add_separator() -{ +void ProjectionsToolBar::add_separator() { addWidget(new QLabel(" ")); addSeparator(); addWidget(new QLabel(" ")); } -MaskEditorFlags::Activity ProjectionsToolBar::currentActivity() const -{ +MaskEditorFlags::Activity ProjectionsToolBar::currentActivity() const { return MaskEditorFlags::EActivityType(m_activityButtonGroup->checkedId()); } -void ProjectionsToolBar::setCurrentActivity(MaskEditorFlags::Activity value) -{ +void ProjectionsToolBar::setCurrentActivity(MaskEditorFlags::Activity value) { int button_index = static_cast<int>(value); m_activityButtonGroup->button(button_index)->setChecked(true); } diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsToolBar.h b/GUI/coregui/Views/JobWidgets/ProjectionsToolBar.h index 6c5344f8ca889fbfd344f4bbb979fd6bfefcfe4c..07356ebebf30b5e9939eafd32531c7c6ae6164b6 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsToolBar.h +++ b/GUI/coregui/Views/JobWidgets/ProjectionsToolBar.h @@ -24,8 +24,7 @@ class QButtonGroup; //! Toolbar with projections buttons (horizontal projections, vertical projections, select, zoom) //! located at the right-hand side of ProjectionsEditor (part of JobProjectionsWidget). -class ProjectionsToolBar : public QToolBar -{ +class ProjectionsToolBar : public QToolBar { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsWidget.cpp b/GUI/coregui/Views/JobWidgets/ProjectionsWidget.cpp index 793c09550fe955f99062fc48604e875b6165481c..a660bbe93662540c622fd1c5115429110faaebd2 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsWidget.cpp +++ b/GUI/coregui/Views/JobWidgets/ProjectionsWidget.cpp @@ -17,8 +17,7 @@ #include <QTabWidget> #include <QVBoxLayout> -namespace -{ +namespace { const int horizontal_projection_tab = 0; const int vertical_projection_tab = 1; } // namespace @@ -27,8 +26,7 @@ ProjectionsWidget::ProjectionsWidget(QWidget* parent) : SessionItemWidget(parent) , m_xProjection(new ProjectionsPlot("HorizontalLineMask")) , m_yProjection(new ProjectionsPlot("VerticalLineMask")) - , m_tabWidget(new QTabWidget) -{ + , m_tabWidget(new QTabWidget) { QVBoxLayout* layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); @@ -43,15 +41,13 @@ ProjectionsWidget::ProjectionsWidget(QWidget* parent) setConnected(true); } -void ProjectionsWidget::setItem(SessionItem* intensityItem) -{ +void ProjectionsWidget::setItem(SessionItem* intensityItem) { SessionItemWidget::setItem(intensityItem); m_xProjection->setItem(intensityItem); m_yProjection->setItem(intensityItem); } -void ProjectionsWidget::onActivityModeChanged(MaskEditorFlags::Activity value) -{ +void ProjectionsWidget::onActivityModeChanged(MaskEditorFlags::Activity value) { setConnected(false); if (value == MaskEditorFlags::HORIZONTAL_LINE_MODE) @@ -62,22 +58,19 @@ void ProjectionsWidget::onActivityModeChanged(MaskEditorFlags::Activity value) setConnected(true); } -void ProjectionsWidget::onMarginsChanged(double left, double right) -{ +void ProjectionsWidget::onMarginsChanged(double left, double right) { m_xProjection->onMarginsChanged(left, right); m_yProjection->onMarginsChanged(left, right); } -void ProjectionsWidget::onTabChanged(int tab_index) -{ +void ProjectionsWidget::onTabChanged(int tab_index) { if (tab_index == horizontal_projection_tab) emit changeActivityRequest(MaskEditorFlags::HORIZONTAL_LINE_MODE); else if (tab_index == vertical_projection_tab) emit changeActivityRequest(MaskEditorFlags::VERTICAL_LINE_MODE); } -void ProjectionsWidget::setConnected(bool isConnected) -{ +void ProjectionsWidget::setConnected(bool isConnected) { if (isConnected) connect(m_tabWidget, &QTabWidget::currentChanged, this, &ProjectionsWidget::onTabChanged); else diff --git a/GUI/coregui/Views/JobWidgets/ProjectionsWidget.h b/GUI/coregui/Views/JobWidgets/ProjectionsWidget.h index 0454450badafbc1c4ba2f79828876aafb01ba4d8..a862b58a73b615e9b1a3db484d0a07568035b0b8 100644 --- a/GUI/coregui/Views/JobWidgets/ProjectionsWidget.h +++ b/GUI/coregui/Views/JobWidgets/ProjectionsWidget.h @@ -23,8 +23,7 @@ class QTabWidget; //! Holds tabs of vertical and horizontal projections, located at the bottom of ProjectionsEditor. -class ProjectionsWidget : public SessionItemWidget -{ +class ProjectionsWidget : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/JobWidgets/ScientificSpinBox.cpp b/GUI/coregui/Views/JobWidgets/ScientificSpinBox.cpp index c9d3b3f64ca1ce02d9f700c3730b338bc0fec810..a32706e53920a168a93d43c6b4e47f1af27f4b40 100644 --- a/GUI/coregui/Views/JobWidgets/ScientificSpinBox.cpp +++ b/GUI/coregui/Views/JobWidgets/ScientificSpinBox.cpp @@ -16,8 +16,7 @@ #include <QLineEdit> #include <cmath> -namespace -{ +namespace { const double upper_switch = 100; const double lower_switch = 0.1; const double min_val = std::numeric_limits<double>::min(); @@ -32,8 +31,7 @@ ScientificSpinBox::ScientificSpinBox(QWidget* parent) , m_min(-max_val) , m_max(max_val) , m_step(1.0) - , m_decimals(3) -{ + , m_decimals(3) { QLocale locale; locale.setNumberOptions(QLocale::RejectGroupSeparator); m_validator.setLocale(locale); @@ -44,13 +42,11 @@ ScientificSpinBox::ScientificSpinBox(QWidget* parent) ScientificSpinBox::~ScientificSpinBox() = default; -double ScientificSpinBox::value() const -{ +double ScientificSpinBox::value() const { return m_value; } -void ScientificSpinBox::setValue(double val) -{ +void ScientificSpinBox::setValue(double val) { double old_val = m_value; m_value = round(val, m_decimals); updateText(); @@ -58,68 +54,57 @@ void ScientificSpinBox::setValue(double val) emit valueChanged(m_value); } -void ScientificSpinBox::updateValue() -{ +void ScientificSpinBox::updateValue() { double new_val = toDouble(text(), m_validator, m_min, m_max, m_value); setValue(new_val); } -double ScientificSpinBox::singleStep() const -{ +double ScientificSpinBox::singleStep() const { return m_step; } -void ScientificSpinBox::setSingleStep(double step) -{ +void ScientificSpinBox::setSingleStep(double step) { m_step = step; } -double ScientificSpinBox::minimum() const -{ +double ScientificSpinBox::minimum() const { return m_min; } -void ScientificSpinBox::setMinimum(double min) -{ +void ScientificSpinBox::setMinimum(double min) { m_min = min; if (m_value < m_min) setValue(m_min); } -double ScientificSpinBox::maximum() const -{ +double ScientificSpinBox::maximum() const { return m_max; } -void ScientificSpinBox::setMaximum(double max) -{ +void ScientificSpinBox::setMaximum(double max) { m_max = max; if (m_value > m_max) setValue(m_max); } -void ScientificSpinBox::setDecimals(int val) -{ +void ScientificSpinBox::setDecimals(int val) { if (val <= 0) return; m_decimals = val; setValue(m_value); } -int ScientificSpinBox::decimals() const -{ +int ScientificSpinBox::decimals() const { return m_decimals; } -void ScientificSpinBox::stepBy(int steps) -{ +void ScientificSpinBox::stepBy(int steps) { double new_val = round(m_value + m_step * steps, m_decimals); if (inRange(new_val)) setValue(new_val); } -QString ScientificSpinBox::toString(double val, int decimal_points) -{ +QString ScientificSpinBox::toString(double val, int decimal_points) { QString result = useExponentialNotation(val) ? QString::number(val, 'e', decimal_points) : QString::number(val, 'f', decimal_points); @@ -127,8 +112,7 @@ QString ScientificSpinBox::toString(double val, int decimal_points) } double ScientificSpinBox::toDouble(QString text, const QDoubleValidator& validator, double min, - double max, double default_value) -{ + double max, double default_value) { int pos = 0; if (validator.validate(text, pos) == QValidator::Acceptable) { double new_val = validator.locale().toDouble(text); @@ -139,32 +123,26 @@ double ScientificSpinBox::toDouble(QString text, const QDoubleValidator& validat return default_value; } -double ScientificSpinBox::round(double val, int decimals) -{ +double ScientificSpinBox::round(double val, int decimals) { return QString::number(val, 'e', decimals).toDouble(); } -QAbstractSpinBox::StepEnabled ScientificSpinBox::stepEnabled() const -{ +QAbstractSpinBox::StepEnabled ScientificSpinBox::stepEnabled() const { return isReadOnly() ? StepNone : StepUpEnabled | StepDownEnabled; } -void ScientificSpinBox::updateText() -{ +void ScientificSpinBox::updateText() { QString new_text = toString(m_value, m_decimals); if (new_text != text()) lineEdit()->setText(new_text); } -bool ScientificSpinBox::inRange(double val) const -{ +bool ScientificSpinBox::inRange(double val) const { return val >= m_min && val <= m_max; } -namespace -{ -bool useExponentialNotation(double val) -{ +namespace { +bool useExponentialNotation(double val) { const double abs_val = std::abs(val); if (abs_val <= min_val) diff --git a/GUI/coregui/Views/JobWidgets/ScientificSpinBox.h b/GUI/coregui/Views/JobWidgets/ScientificSpinBox.h index afc25d964a858b23bf9016c456dc8ed3e987ac3b..702d5e0b94167f36158047ea54e0e76b66e5744a 100644 --- a/GUI/coregui/Views/JobWidgets/ScientificSpinBox.h +++ b/GUI/coregui/Views/JobWidgets/ScientificSpinBox.h @@ -17,8 +17,7 @@ #include <QAbstractSpinBox> -class ScientificSpinBox : public QAbstractSpinBox -{ +class ScientificSpinBox : public QAbstractSpinBox { Q_OBJECT Q_PROPERTY(double value MEMBER m_value READ value WRITE setValue NOTIFY valueChanged USER true) diff --git a/GUI/coregui/Views/JobWidgets/SliderSettingsWidget.cpp b/GUI/coregui/Views/JobWidgets/SliderSettingsWidget.cpp index ef9c688dbe2377da973ba6fdfa66b5c9ded68e80..fd6834d350d25ff6f7ee75c80c1d7fedb01cb89c 100644 --- a/GUI/coregui/Views/JobWidgets/SliderSettingsWidget.cpp +++ b/GUI/coregui/Views/JobWidgets/SliderSettingsWidget.cpp @@ -26,8 +26,7 @@ SliderSettingsWidget::SliderSettingsWidget(QWidget* parent) , m_radio1(0) , m_radio2(0) , m_radio3(0) - , m_lockzCheckBox(0) -{ + , m_lockzCheckBox(0) { // tuning selectors QString tooltip("Allows to tune sample parameters within +/- of given range \nwith the help of " "the slider."); @@ -69,8 +68,7 @@ SliderSettingsWidget::SliderSettingsWidget(QWidget* parent) setLayout(hbox); } -void SliderSettingsWidget::rangeChanged() -{ +void SliderSettingsWidget::rangeChanged() { if (m_radio1->isChecked()) { m_currentSliderRange = 10.0; } else if (m_radio2->isChecked()) { @@ -81,8 +79,7 @@ void SliderSettingsWidget::rangeChanged() emit sliderRangeFactorChanged(m_currentSliderRange); } -void SliderSettingsWidget::onLockZChanged(int state) -{ +void SliderSettingsWidget::onLockZChanged(int state) { if (state == Qt::Unchecked) { emit lockzChanged(false); } else if (state == Qt::Checked) { diff --git a/GUI/coregui/Views/JobWidgets/SliderSettingsWidget.h b/GUI/coregui/Views/JobWidgets/SliderSettingsWidget.h index d454727222e625af403606a55fb5e626c92b4b54..187430a797d83d9f74325d61dd814da18f6a926b 100644 --- a/GUI/coregui/Views/JobWidgets/SliderSettingsWidget.h +++ b/GUI/coregui/Views/JobWidgets/SliderSettingsWidget.h @@ -20,8 +20,7 @@ class QRadioButton; class QCheckBox; -class SliderSettingsWidget : public QWidget -{ +class SliderSettingsWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/ColorMapSceneAdaptor.cpp b/GUI/coregui/Views/MaskWidgets/ColorMapSceneAdaptor.cpp index ebff35dcf80d5c982df19eeb62c56ffcb266caef..bffe1eeb8877838bf0111727d98c9a99b568fbee 100644 --- a/GUI/coregui/Views/MaskWidgets/ColorMapSceneAdaptor.cpp +++ b/GUI/coregui/Views/MaskWidgets/ColorMapSceneAdaptor.cpp @@ -17,35 +17,29 @@ ColorMapSceneAdaptor::ColorMapSceneAdaptor() : m_plot(0) {} -qreal ColorMapSceneAdaptor::toSceneX(qreal mask_x) const -{ +qreal ColorMapSceneAdaptor::toSceneX(qreal mask_x) const { return m_plot ? m_plot->xAxisCoordToPixel(mask_x) : mask_x; } -qreal ColorMapSceneAdaptor::toSceneY(qreal mask_y) const -{ +qreal ColorMapSceneAdaptor::toSceneY(qreal mask_y) const { return m_plot ? m_plot->yAxisCoordToPixel(mask_y) : mask_y; } -qreal ColorMapSceneAdaptor::fromSceneX(qreal scene_x) const -{ +qreal ColorMapSceneAdaptor::fromSceneX(qreal scene_x) const { return m_plot ? m_plot->pixelToXaxisCoord(scene_x) : scene_x; } -qreal ColorMapSceneAdaptor::fromSceneY(qreal scene_y) const -{ +qreal ColorMapSceneAdaptor::fromSceneY(qreal scene_y) const { return m_plot ? m_plot->pixelToYaxisCoord(scene_y) : scene_y; } -void ColorMapSceneAdaptor::setColorMapPlot(ColorMap* plot) -{ +void ColorMapSceneAdaptor::setColorMapPlot(ColorMap* plot) { m_plot = plot; if (m_plot) m_plot->installEventFilter(this); } -bool ColorMapSceneAdaptor::eventFilter(QObject* object, QEvent* event) -{ +bool ColorMapSceneAdaptor::eventFilter(QObject* object, QEvent* event) { Q_UNUSED(object); if (event->type() == QEvent::Resize || event->type() == QEvent::UpdateRequest) { m_viewport_rectangle = m_plot->viewportRectangleInWidgetCoordinates(); @@ -55,7 +49,6 @@ bool ColorMapSceneAdaptor::eventFilter(QObject* object, QEvent* event) return true; } -const QRectF& ColorMapSceneAdaptor::viewportRectangle() const -{ +const QRectF& ColorMapSceneAdaptor::viewportRectangle() const { return m_viewport_rectangle; } diff --git a/GUI/coregui/Views/MaskWidgets/ColorMapSceneAdaptor.h b/GUI/coregui/Views/MaskWidgets/ColorMapSceneAdaptor.h index 8b20e68801acd83ebca51d83ae073a80bda48f59..93cf82374bd03673aa5c6fbbb943f9503d31180c 100644 --- a/GUI/coregui/Views/MaskWidgets/ColorMapSceneAdaptor.h +++ b/GUI/coregui/Views/MaskWidgets/ColorMapSceneAdaptor.h @@ -20,8 +20,7 @@ class ColorMap; //! Performs conversion of MaskItems coordinates between ColorMap and GraphicsScene. -class ColorMapSceneAdaptor : public ISceneAdaptor -{ +class ColorMapSceneAdaptor : public ISceneAdaptor { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/EllipseView.cpp b/GUI/coregui/Views/MaskWidgets/EllipseView.cpp index 62756a33ddc940640d6599004da506fc23d3a1f8..f00e1c413dfb41064adf0fe2a886d71da0301b4d 100644 --- a/GUI/coregui/Views/MaskWidgets/EllipseView.cpp +++ b/GUI/coregui/Views/MaskWidgets/EllipseView.cpp @@ -19,22 +19,19 @@ EllipseView::EllipseView() = default; -void EllipseView::onChangedX() -{ +void EllipseView::onChangedX() { setBlockOnProperty(true); m_item->setItemValue(EllipseItem::P_XCENTER, fromSceneX(this->x())); setBlockOnProperty(false); } -void EllipseView::onChangedY() -{ +void EllipseView::onChangedY() { setBlockOnProperty(true); m_item->setItemValue(EllipseItem::P_YCENTER, fromSceneY(this->y())); setBlockOnProperty(false); } -void EllipseView::onPropertyChange(const QString& propertyName) -{ +void EllipseView::onPropertyChange(const QString& propertyName) { if (propertyName == EllipseItem::P_XRADIUS || propertyName == EllipseItem::P_YRADIUS) { update_view(); } else if (propertyName == EllipseItem::P_XCENTER) { @@ -46,8 +43,7 @@ void EllipseView::onPropertyChange(const QString& propertyName) } } -void EllipseView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void EllipseView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { painter->setRenderHints(QPainter::Antialiasing); bool mask_value = m_item->getItemValue(MaskItem::P_MASK_VALUE).toBool(); painter->setBrush(MaskEditorHelper::getMaskBrush(mask_value)); @@ -55,8 +51,7 @@ void EllipseView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWid painter->drawEllipse(m_mask_rect); } -void EllipseView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) -{ +void EllipseView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (m_activeHandleElement) { QPointF opposPos = mapFromScene(m_resize_opposite_origin); qreal xmin = std::min(event->pos().x(), opposPos.x()); @@ -107,8 +102,7 @@ void EllipseView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) //! updates position of view using item properties -void EllipseView::update_position() -{ +void EllipseView::update_position() { disconnect(this, SIGNAL(xChanged()), this, SLOT(onChangedX())); disconnect(this, SIGNAL(yChanged()), this, SLOT(onChangedY())); @@ -122,35 +116,30 @@ void EllipseView::update_position() setTransform(QTransform().rotate(-1.0 * par(EllipseItem::P_ANGLE))); } -QRectF EllipseView::mask_rectangle() -{ +QRectF EllipseView::mask_rectangle() { return QRectF(-width() / 2., -height() / 2., width(), height()); } //! returns the x-coordinate of the rectangle's left edge -qreal EllipseView::left() const -{ +qreal EllipseView::left() const { return toSceneX(par(EllipseItem::P_XCENTER) - par(EllipseItem::P_XRADIUS)); } //! returns the x-coordinate of the rectangle's right edge -qreal EllipseView::right() const -{ +qreal EllipseView::right() const { return toSceneX(par(EllipseItem::P_XCENTER) + par(EllipseItem::P_XRADIUS)); } //! Returns the y-coordinate of the rectangle's top edge. -qreal EllipseView::top() const -{ +qreal EllipseView::top() const { return toSceneY(par(EllipseItem::P_YCENTER) + par(EllipseItem::P_YRADIUS)); } //! Returns the y-coordinate of the rectangle's bottom edge. -qreal EllipseView::bottom() const -{ +qreal EllipseView::bottom() const { return toSceneY(par(EllipseItem::P_YCENTER) - par(EllipseItem::P_YRADIUS)); } diff --git a/GUI/coregui/Views/MaskWidgets/EllipseView.h b/GUI/coregui/Views/MaskWidgets/EllipseView.h index 72d51b1f593011c07b3114b47484eabc5a298725..5c0ff41c5cf555ba556e7a3edf76e9da00077f4b 100644 --- a/GUI/coregui/Views/MaskWidgets/EllipseView.h +++ b/GUI/coregui/Views/MaskWidgets/EllipseView.h @@ -20,8 +20,7 @@ //! This is a View of ellipse mask (represented by EllipseItem) on GraphicsScene. //! Given view follows standard QGraphicsScene notations: (x,y) is top left corner. -class EllipseView : public RectangleBaseView -{ +class EllipseView : public RectangleBaseView { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/ISceneAdaptor.h b/GUI/coregui/Views/MaskWidgets/ISceneAdaptor.h index f46188d74547f8f8ea03459ae545cb73bf7c9ee4..88c8108d2dc557e0935d61a41d6f7148862d4451 100644 --- a/GUI/coregui/Views/MaskWidgets/ISceneAdaptor.h +++ b/GUI/coregui/Views/MaskWidgets/ISceneAdaptor.h @@ -21,8 +21,7 @@ //! Interface to adapt MaskItems coordinates (expressed in units of IntensityDataItem) //! to/from scene coordinates. -class ISceneAdaptor : public QObject -{ +class ISceneAdaptor : public QObject { Q_OBJECT public: virtual ~ISceneAdaptor() {} @@ -46,8 +45,7 @@ protected: QRectF m_viewport_rectangle; }; -class DefaultSceneAdaptor : public ISceneAdaptor -{ +class DefaultSceneAdaptor : public ISceneAdaptor { Q_OBJECT public: DefaultSceneAdaptor() {} diff --git a/GUI/coregui/Views/MaskWidgets/IShape2DView.cpp b/GUI/coregui/Views/MaskWidgets/IShape2DView.cpp index c2f215bbcd0d80fe60138ff64ec177719eb743cc..e3aa54b208c5a93b2f0e6e8d3fc4349f609a6547 100644 --- a/GUI/coregui/Views/MaskWidgets/IShape2DView.cpp +++ b/GUI/coregui/Views/MaskWidgets/IShape2DView.cpp @@ -21,25 +21,21 @@ #include <QPainter> IShape2DView::IShape2DView() - : m_item(nullptr), m_adaptor(nullptr), m_block_on_property_change(false) -{ + : m_item(nullptr), m_adaptor(nullptr), m_block_on_property_change(false) { connect(this, SIGNAL(xChanged()), this, SLOT(onChangedX())); connect(this, SIGNAL(yChanged()), this, SLOT(onChangedY())); } -IShape2DView::~IShape2DView() -{ +IShape2DView::~IShape2DView() { if (m_item) m_item->mapper()->unsubscribe(this); } -QRectF IShape2DView::boundingRect() const -{ +QRectF IShape2DView::boundingRect() const { return m_bounding_rect; } -void IShape2DView::setParameterizedItem(SessionItem* item) -{ +void IShape2DView::setParameterizedItem(SessionItem* item) { if (m_item == item) { return; @@ -58,13 +54,11 @@ void IShape2DView::setParameterizedItem(SessionItem* item) } } -SessionItem* IShape2DView::parameterizedItem() -{ +SessionItem* IShape2DView::parameterizedItem() { return m_item; } -void IShape2DView::setSceneAdaptor(const ISceneAdaptor* adaptor) -{ +void IShape2DView::setSceneAdaptor(const ISceneAdaptor* adaptor) { ASSERT(adaptor); if (m_adaptor != adaptor) { @@ -78,59 +72,48 @@ void IShape2DView::setSceneAdaptor(const ISceneAdaptor* adaptor) } } -double IShape2DView::par(const QString& property_name) const -{ +double IShape2DView::par(const QString& property_name) const { return m_item->getItemValue(property_name).toReal(); } -qreal IShape2DView::toSceneX(const QString& property_name) const -{ +qreal IShape2DView::toSceneX(const QString& property_name) const { return toSceneX(m_item->getItemValue(property_name).toReal()); } -qreal IShape2DView::toSceneX(qreal value) const -{ +qreal IShape2DView::toSceneX(qreal value) const { return m_adaptor ? m_adaptor->toSceneX(value) : value; } -qreal IShape2DView::toSceneY(const QString& property_name) const -{ +qreal IShape2DView::toSceneY(const QString& property_name) const { return toSceneY(m_item->getItemValue(property_name).toReal()); } -qreal IShape2DView::toSceneY(qreal value) const -{ +qreal IShape2DView::toSceneY(qreal value) const { return m_adaptor ? m_adaptor->toSceneY(value) : value; } -qreal IShape2DView::fromSceneX(qreal value) const -{ +qreal IShape2DView::fromSceneX(qreal value) const { return m_adaptor ? m_adaptor->fromSceneX(value) : value; } -qreal IShape2DView::fromSceneY(qreal value) const -{ +qreal IShape2DView::fromSceneY(qreal value) const { return m_adaptor ? m_adaptor->fromSceneY(value) : value; } -void IShape2DView::addView(IShape2DView* childView, int /* row */) -{ +void IShape2DView::addView(IShape2DView* childView, int /* row */) { if (!childItems().contains(childView)) childView->setParentItem(this); } -void IShape2DView::setBlockOnProperty(bool value) -{ +void IShape2DView::setBlockOnProperty(bool value) { m_block_on_property_change = value; } -bool IShape2DView::blockOnProperty() const -{ +bool IShape2DView::blockOnProperty() const { return m_block_on_property_change; } -void IShape2DView::onItemPropertyChange(const QString& propertyName) -{ +void IShape2DView::onItemPropertyChange(const QString& propertyName) { if (m_block_on_property_change) return; diff --git a/GUI/coregui/Views/MaskWidgets/IShape2DView.h b/GUI/coregui/Views/MaskWidgets/IShape2DView.h index f0e880f969640769a048bf69dcc8204df96980b1..aa90004d140f9973c3697c3c74cea2f1334ee582 100644 --- a/GUI/coregui/Views/MaskWidgets/IShape2DView.h +++ b/GUI/coregui/Views/MaskWidgets/IShape2DView.h @@ -24,8 +24,7 @@ class QPainter; //! Main interface class for views representing MaskItems, Projections on graphics scene. -class IShape2DView : public QGraphicsObject -{ +class IShape2DView : public QGraphicsObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/IntensityDataView.cpp b/GUI/coregui/Views/MaskWidgets/IntensityDataView.cpp index 1543eec15f614e2216e6a15ae009847ccbdaace4..28a85ffd5cd4d563ca52f5bfb23ae34d29122bd7 100644 --- a/GUI/coregui/Views/MaskWidgets/IntensityDataView.cpp +++ b/GUI/coregui/Views/MaskWidgets/IntensityDataView.cpp @@ -18,20 +18,17 @@ #include <QPainter> #include <QStyleOptionGraphicsItem> -IntensityDataView::IntensityDataView() -{ +IntensityDataView::IntensityDataView() { // the key flag to not to draw children going outside ot given shape setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); } -void IntensityDataView::update_view() -{ +void IntensityDataView::update_view() { // prepareGeometryChange(); m_bounding_rect = m_adaptor->viewportRectangle(); update(); } -void IntensityDataView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void IntensityDataView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { Q_UNUSED(painter); } diff --git a/GUI/coregui/Views/MaskWidgets/IntensityDataView.h b/GUI/coregui/Views/MaskWidgets/IntensityDataView.h index 9eb9213fd96c10819e375d7502b6aa220fadfa27..a16f85fed81e1586ba9a77a11d000c23baec6fc1 100644 --- a/GUI/coregui/Views/MaskWidgets/IntensityDataView.h +++ b/GUI/coregui/Views/MaskWidgets/IntensityDataView.h @@ -26,8 +26,7 @@ //! The size of the rectangle always matches axes viewport at any zoom level. //! All MasksViews are added to IntensityDataView as children. -class IntensityDataView : public IShape2DView -{ +class IntensityDataView : public IShape2DView { Q_OBJECT public: IntensityDataView(); diff --git a/GUI/coregui/Views/MaskWidgets/LineViews.cpp b/GUI/coregui/Views/MaskWidgets/LineViews.cpp index 6fc0d0b06ddf60a86c17c54ddc5f4d6a0c9600e5..695648cc95c96c50b88d0f29ba9971d685f6964d 100644 --- a/GUI/coregui/Views/MaskWidgets/LineViews.cpp +++ b/GUI/coregui/Views/MaskWidgets/LineViews.cpp @@ -19,35 +19,30 @@ #include <QPainter> #include <QStyleOptionGraphicsItem> -namespace -{ +namespace { const double mask_width = 8.0; const double mask_visible_width = 3.0; } // namespace -VerticalLineView::VerticalLineView() -{ +VerticalLineView::VerticalLineView() { setFlag(QGraphicsItem::ItemIsSelectable); setFlag(QGraphicsItem::ItemIsMovable); setFlag(QGraphicsItem::ItemSendsGeometryChanges); setCursor(Qt::SizeHorCursor); } -void VerticalLineView::onChangedX() -{ +void VerticalLineView::onChangedX() { setBlockOnProperty(true); m_item->setItemValue(VerticalLineItem::P_POSX, fromSceneX(this->x())); setBlockOnProperty(false); } -void VerticalLineView::onPropertyChange(const QString& propertyName) -{ +void VerticalLineView::onPropertyChange(const QString& propertyName) { if (propertyName == VerticalLineItem::P_POSX) setX(toSceneX(VerticalLineItem::P_POSX)); } -void VerticalLineView::update_view() -{ +void VerticalLineView::update_view() { QRectF plot_scene_rectangle = m_adaptor->viewportRectangle(); setX(toSceneX(VerticalLineItem::P_POSX)); @@ -57,8 +52,7 @@ void VerticalLineView::update_view() update(); } -void VerticalLineView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void VerticalLineView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { bool mask_value = m_item->getItemValue(MaskItem::P_MASK_VALUE).toBool(); painter->setBrush(MaskEditorHelper::getMaskBrush(mask_value)); painter->setPen(MaskEditorHelper::getMaskPen(mask_value)); @@ -77,8 +71,7 @@ void VerticalLineView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, //! Allows item movement along x, prevent movement along y QVariant VerticalLineView::itemChange(QGraphicsItem::GraphicsItemChange change, - const QVariant& value) -{ + const QVariant& value) { if (isSelected() && change == ItemPositionChange && scene()) { QPointF newPos = value.toPointF(); newPos.setY(y()); @@ -89,29 +82,25 @@ QVariant VerticalLineView::itemChange(QGraphicsItem::GraphicsItemChange change, // --------------------------------------------------------------------------------------------- // -HorizontalLineView::HorizontalLineView() -{ +HorizontalLineView::HorizontalLineView() { setFlag(QGraphicsItem::ItemIsSelectable); setFlag(QGraphicsItem::ItemIsMovable); setFlag(QGraphicsItem::ItemSendsGeometryChanges); setCursor(Qt::SizeVerCursor); } -void HorizontalLineView::onChangedY() -{ +void HorizontalLineView::onChangedY() { setBlockOnProperty(true); m_item->setItemValue(HorizontalLineItem::P_POSY, fromSceneY(this->y())); setBlockOnProperty(false); } -void HorizontalLineView::onPropertyChange(const QString& propertyName) -{ +void HorizontalLineView::onPropertyChange(const QString& propertyName) { if (propertyName == HorizontalLineItem::P_POSY) setY(toSceneY(HorizontalLineItem::P_POSY)); } -void HorizontalLineView::update_view() -{ +void HorizontalLineView::update_view() { QRectF plot_scene_rectangle = m_adaptor->viewportRectangle(); setX(plot_scene_rectangle.left()); @@ -121,8 +110,7 @@ void HorizontalLineView::update_view() update(); } -void HorizontalLineView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void HorizontalLineView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { bool mask_value = m_item->getItemValue(MaskItem::P_MASK_VALUE).toBool(); painter->setBrush(MaskEditorHelper::getMaskBrush(mask_value)); painter->setPen(MaskEditorHelper::getMaskPen(mask_value)); @@ -141,8 +129,7 @@ void HorizontalLineView::paint(QPainter* painter, const QStyleOptionGraphicsItem //! Allows item movement along y, prevent movement along x QVariant HorizontalLineView::itemChange(QGraphicsItem::GraphicsItemChange change, - const QVariant& value) -{ + const QVariant& value) { if (isSelected() && change == ItemPositionChange && scene()) { QPointF newPos = value.toPointF(); newPos.setX(x()); diff --git a/GUI/coregui/Views/MaskWidgets/LineViews.h b/GUI/coregui/Views/MaskWidgets/LineViews.h index c18dda3e331f457eea80655e1fbbe7cc65a2fdbc..4743582d93ef4e443e12ec50af13b5b4a2a34544 100644 --- a/GUI/coregui/Views/MaskWidgets/LineViews.h +++ b/GUI/coregui/Views/MaskWidgets/LineViews.h @@ -19,8 +19,7 @@ //! This is a view of VerticalLineItem mask -class VerticalLineView : public IShape2DView -{ +class VerticalLineView : public IShape2DView { Q_OBJECT public: @@ -40,8 +39,7 @@ protected: //! This is a view of HorizontalLineItem mask -class HorizontalLineView : public IShape2DView -{ +class HorizontalLineView : public IShape2DView { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/MaskAllView.cpp b/GUI/coregui/Views/MaskWidgets/MaskAllView.cpp index cb8ebefb8fb21f00901922bd8af3584985c2b545..eae8b2ea666fbb0b38e3b1659247cc47b8c1faa9 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskAllView.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskAllView.cpp @@ -19,20 +19,17 @@ #include <QPainter> #include <QStyleOptionGraphicsItem> -MaskAllView::MaskAllView() -{ +MaskAllView::MaskAllView() { setFlag(QGraphicsItem::ItemIsSelectable); } -void MaskAllView::update_view() -{ +void MaskAllView::update_view() { // prepareGeometryChange(); m_bounding_rect = m_adaptor->viewportRectangle(); update(); } -void MaskAllView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void MaskAllView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { // painter->setRenderHints(QPainter::Antialiasing); QColor color(250, 250, 240, 150); painter->setBrush(color); diff --git a/GUI/coregui/Views/MaskWidgets/MaskAllView.h b/GUI/coregui/Views/MaskWidgets/MaskAllView.h index dabf9ca363e4ced915c0f658fe756b3e92e2d732..adc011f26692b9d132afdc9f397b61261eaf83dd 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskAllView.h +++ b/GUI/coregui/Views/MaskWidgets/MaskAllView.h @@ -19,8 +19,7 @@ //! This is a view of MaskAllItem which covers whole detector plane with mask value=true. -class MaskAllView : public IShape2DView -{ +class MaskAllView : public IShape2DView { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/MaskContainerView.cpp b/GUI/coregui/Views/MaskWidgets/MaskContainerView.cpp index dec6630cec805cc2057c46b0afb96d9c93d96513..21cc5a06f00b48e00851d5b244ae11b4ac9d76bb 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskContainerView.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskContainerView.cpp @@ -18,19 +18,16 @@ #include <QPainter> #include <QStyleOptionGraphicsItem> -MaskContainerView::MaskContainerView() -{ +MaskContainerView::MaskContainerView() { // the key flag to not to draw children going outside ot given shape setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); } -void MaskContainerView::update_view() -{ +void MaskContainerView::update_view() { m_bounding_rect = m_adaptor->viewportRectangle(); update(); } -void MaskContainerView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void MaskContainerView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { Q_UNUSED(painter); } diff --git a/GUI/coregui/Views/MaskWidgets/MaskContainerView.h b/GUI/coregui/Views/MaskWidgets/MaskContainerView.h index b2630811d2304222930eebfe8ae4f9cf93dd6a0a..fa08654fa3b203ed349dd62fe1d224dcd8f10377 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskContainerView.h +++ b/GUI/coregui/Views/MaskWidgets/MaskContainerView.h @@ -26,8 +26,7 @@ //! The size of the rectangle always matches axes viewport at any zoom level. //! All MasksViews are added to MaskContainerView as children. -class MaskContainerView : public IShape2DView -{ +class MaskContainerView : public IShape2DView { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/MaskDrawingContext.cpp b/GUI/coregui/Views/MaskWidgets/MaskDrawingContext.cpp index d1a755127df5bce2977e442c03aef709ec4342c4..96c588cc8bc850208d894aa8df2e35fbe599d184 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskDrawingContext.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskDrawingContext.cpp @@ -17,102 +17,82 @@ MaskDrawingContext::MaskDrawingContext() : m_current_activity(MaskEditorFlags::PAN_ZOOM_MODE) , m_mask_value(MaskEditorFlags::MASK_ON) - , m_drawing_in_progress(false) -{ -} + , m_drawing_in_progress(false) {} -MaskEditorFlags::Activity MaskDrawingContext::getActivityType() const -{ +MaskEditorFlags::Activity MaskDrawingContext::getActivityType() const { return m_current_activity; } -void MaskDrawingContext::setActivityType(MaskEditorFlags::Activity value) -{ +void MaskDrawingContext::setActivityType(MaskEditorFlags::Activity value) { m_current_activity = value; } -void MaskDrawingContext::setMaskValue(MaskEditorFlags::MaskValue value) -{ +void MaskDrawingContext::setMaskValue(MaskEditorFlags::MaskValue value) { m_mask_value = value; } -bool MaskDrawingContext::isSelectionMode() const -{ +bool MaskDrawingContext::isSelectionMode() const { return m_current_activity == MaskEditorFlags::SELECTION_MODE; } -bool MaskDrawingContext::isInZoomMode() const -{ +bool MaskDrawingContext::isInZoomMode() const { return m_current_activity == MaskEditorFlags::PAN_ZOOM_MODE; } -bool MaskDrawingContext::isRectangleShapeMode() const -{ +bool MaskDrawingContext::isRectangleShapeMode() const { return (m_current_activity == MaskEditorFlags::RECTANGLE_MODE) || (m_current_activity == MaskEditorFlags::ELLIPSE_MODE) || (m_current_activity == MaskEditorFlags::ROI_MODE); } -bool MaskDrawingContext::isRectangleMode() const -{ +bool MaskDrawingContext::isRectangleMode() const { return m_current_activity == MaskEditorFlags::RECTANGLE_MODE; } -bool MaskDrawingContext::isEllipseMode() const -{ +bool MaskDrawingContext::isEllipseMode() const { return m_current_activity == MaskEditorFlags::ELLIPSE_MODE; } -bool MaskDrawingContext::isPolygonMode() const -{ +bool MaskDrawingContext::isPolygonMode() const { return m_current_activity == MaskEditorFlags::POLYGON_MODE; } -bool MaskDrawingContext::isLineMode() const -{ +bool MaskDrawingContext::isLineMode() const { return isVerticalLineMode() || isHorizontalLineMode(); } -bool MaskDrawingContext::isVerticalLineMode() const -{ +bool MaskDrawingContext::isVerticalLineMode() const { return m_current_activity == MaskEditorFlags::VERTICAL_LINE_MODE; } -bool MaskDrawingContext::isHorizontalLineMode() const -{ +bool MaskDrawingContext::isHorizontalLineMode() const { return m_current_activity == MaskEditorFlags::HORIZONTAL_LINE_MODE; } -bool MaskDrawingContext::isMaskAllMode() const -{ +bool MaskDrawingContext::isMaskAllMode() const { return m_current_activity == MaskEditorFlags::MASKALL_MODE; } -bool MaskDrawingContext::isROIMode() const -{ +bool MaskDrawingContext::isROIMode() const { return m_current_activity == MaskEditorFlags::ROI_MODE; } -bool MaskDrawingContext::isDrawingInProgress() const -{ +bool MaskDrawingContext::isDrawingInProgress() const { return m_drawing_in_progress; } -void MaskDrawingContext::setDrawingInProgress(bool value) -{ +void MaskDrawingContext::setDrawingInProgress(bool value) { m_drawing_in_progress = value; } -bool MaskDrawingContext::getMaskValue() const -{ +bool MaskDrawingContext::getMaskValue() const { return bool(m_mask_value); } //! return true, if proposed activity requires the cancel of drawing //! i.e. there is an ungoing polygon drawing, but user wants to start other drawing bool MaskDrawingContext::isActivityRequiresDrawingCancel( - MaskEditorFlags::Activity proposed_new_activity) -{ + MaskEditorFlags::Activity proposed_new_activity) { if (isDrawingInProgress() && isPolygonMode() && proposed_new_activity >= MaskEditorFlags::PAN_ZOOM_MODE) return true; @@ -121,8 +101,7 @@ bool MaskDrawingContext::isActivityRequiresDrawingCancel( //! Returns model type corresponding to current activity. -QString MaskDrawingContext::activityToModelType() const -{ +QString MaskDrawingContext::activityToModelType() const { if (isRectangleMode()) return "RectangleMask"; if (isEllipseMode()) @@ -135,8 +114,7 @@ QString MaskDrawingContext::activityToModelType() const //! Returns model row corresponding to given activity. All shapes, except ROI, will be added //! on top of each other. ROI shape will be added at the bottom. -int MaskDrawingContext::activityToRow() const -{ +int MaskDrawingContext::activityToRow() const { if (isROIMode()) return -1; return 0; diff --git a/GUI/coregui/Views/MaskWidgets/MaskDrawingContext.h b/GUI/coregui/Views/MaskWidgets/MaskDrawingContext.h index 249ef2315078a9d45414d5193e0a65a53d7f14e1..57e5a52f1d795333885273aca280ceda0fdfb91e 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskDrawingContext.h +++ b/GUI/coregui/Views/MaskWidgets/MaskDrawingContext.h @@ -19,8 +19,7 @@ //! Helper class for MaskGraphicsScene to hold drawing conditions -class MaskDrawingContext -{ +class MaskDrawingContext { public: MaskDrawingContext(); diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditor.cpp b/GUI/coregui/Views/MaskWidgets/MaskEditor.cpp index 7b29dc789823372264792d337e6355f21bf500b3..8868933b013e99c48fa4d45c0e2d138e70aa2d99 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditor.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskEditor.cpp @@ -29,8 +29,7 @@ MaskEditor::MaskEditor(QWidget* parent) , m_toolBar(new MaskEditorToolBar(m_editorActions)) , m_editorPropertyPanel(new MaskEditorPropertyPanel) , m_editorCanvas(new MaskEditorCanvas) - , m_splitter(new Manhattan::MiniSplitter) -{ + , m_splitter(new Manhattan::MiniSplitter) { setObjectName("MaskEditor"); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -48,8 +47,7 @@ MaskEditor::MaskEditor(QWidget* parent) } void MaskEditor::setMaskContext(SessionModel* model, const QModelIndex& maskContainerIndex, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { m_editorPropertyPanel->setMaskContext(model, maskContainerIndex, intensityItem); ASSERT(intensityItem); @@ -63,33 +61,28 @@ void MaskEditor::setMaskContext(SessionModel* model, const QModelIndex& maskCont m_editorActions->setSelectionModel(m_editorPropertyPanel->selectionModel()); } -void MaskEditor::resetContext() -{ +void MaskEditor::resetContext() { m_editorPropertyPanel->resetContext(); m_editorCanvas->resetContext(); } //! shows/hides right panel with properties -void MaskEditor::onPropertyPanelRequest() -{ +void MaskEditor::onPropertyPanelRequest() { m_editorPropertyPanel->setPanelHidden(!m_editorPropertyPanel->isHidden()); } //! Context menu reimplemented to supress default menu -void MaskEditor::contextMenuEvent(QContextMenuEvent* event) -{ +void MaskEditor::contextMenuEvent(QContextMenuEvent* event) { Q_UNUSED(event); } //! Returns list of actions intended for styled toolbar (on the top). -QList<QAction*> MaskEditor::topToolBarActions() -{ +QList<QAction*> MaskEditor::topToolBarActions() { return m_editorActions->topToolBarActions(); } -void MaskEditor::setup_connections() -{ +void MaskEditor::setup_connections() { // reset view request is propagated from editorActions to graphics view connect(m_editorActions, &MaskEditorActions::resetViewRequest, m_editorCanvas, &MaskEditorCanvas::onResetViewRequest); diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditor.h b/GUI/coregui/Views/MaskWidgets/MaskEditor.h index da010eebcd7d395b39230eb1b32cc7ed436def1b..26bb155319e1e1f8f6fae9eeadb8f63242879dce 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditor.h +++ b/GUI/coregui/Views/MaskWidgets/MaskEditor.h @@ -25,15 +25,13 @@ class MaskEditorToolBar; class MaskEditorCanvas; class SessionModel; class IntensityDataItem; -namespace Manhattan -{ +namespace Manhattan { class MiniSplitter; } //! Main class to draw masks on top of intensity data map -class MaskEditor : public QMainWindow -{ +class MaskEditor : public QMainWindow { Q_OBJECT public: MaskEditor(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorActions.cpp b/GUI/coregui/Views/MaskWidgets/MaskEditorActions.cpp index 865c14db6d719e925949cc51fb48dfce067321fc..d6e130f70ab85fbd6e11b9517932b59c4c20f728 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorActions.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorActions.cpp @@ -69,44 +69,37 @@ MaskEditorActions::MaskEditorActions(QWidget* parent) &MaskEditorActions::propertyPanelRequest); } -void MaskEditorActions::setModel(SessionModel* maskModel, const QModelIndex& rootIndex) -{ +void MaskEditorActions::setModel(SessionModel* maskModel, const QModelIndex& rootIndex) { m_maskModel = maskModel; m_rootIndex = rootIndex; } -void MaskEditorActions::setSelectionModel(QItemSelectionModel* selectionModel) -{ +void MaskEditorActions::setSelectionModel(QItemSelectionModel* selectionModel) { m_selectionModel = selectionModel; } -QAction* MaskEditorActions::sendToBackAction() -{ +QAction* MaskEditorActions::sendToBackAction() { return m_sendToBackAction; } -QAction* MaskEditorActions::bringToFrontAction() -{ +QAction* MaskEditorActions::bringToFrontAction() { return m_bringToFrontAction; } -QList<QAction*> MaskEditorActions::topToolBarActions() -{ +QList<QAction*> MaskEditorActions::topToolBarActions() { return QList<QAction*>() << m_resetViewAction << m_togglePanelAction; } //! Constructs MaskItem context menu following the request from MaskGraphicsScene //! or MaskEditorInfoPanel -void MaskEditorActions::onItemContextMenuRequest(const QPoint& point) -{ +void MaskEditorActions::onItemContextMenuRequest(const QPoint& point) { QMenu menu; initItemContextMenu(menu); menu.exec(point); setAllActionsEnabled(true); } -void MaskEditorActions::onDeleteMaskAction() -{ +void MaskEditorActions::onDeleteMaskAction() { ASSERT(m_maskModel); ASSERT(m_selectionModel); @@ -118,8 +111,7 @@ void MaskEditorActions::onDeleteMaskAction() } //! Performs switch of mask value for all selected items (true -> false, false -> true) -void MaskEditorActions::onToggleMaskValueAction() -{ +void MaskEditorActions::onToggleMaskValueAction() { ASSERT(m_maskModel); ASSERT(m_selectionModel); for (auto itemIndex : m_selectionModel->selectedIndexes()) { @@ -130,19 +122,16 @@ void MaskEditorActions::onToggleMaskValueAction() } } -void MaskEditorActions::onBringToFrontAction() -{ +void MaskEditorActions::onBringToFrontAction() { changeMaskStackingOrder(MaskEditorFlags::BRING_TO_FRONT); } -void MaskEditorActions::onSendToBackAction() -{ +void MaskEditorActions::onSendToBackAction() { changeMaskStackingOrder(MaskEditorFlags::SEND_TO_BACK); } //! Lower mask one level down or rise one level up in the masks stack -void MaskEditorActions::changeMaskStackingOrder(MaskEditorFlags::Stacking value) -{ +void MaskEditorActions::changeMaskStackingOrder(MaskEditorFlags::Stacking value) { if (!m_maskModel || !m_selectionModel) return; @@ -171,8 +160,7 @@ void MaskEditorActions::changeMaskStackingOrder(MaskEditorFlags::Stacking value) //! (Naturally, it is always true, if selection contains more than one item. If selection contains //! only one item, the result will depend on position of item on the stack. //! Top item can't be moved up. Used to disable corresponding context menu line.) -bool MaskEditorActions::isBringToFrontPossible() const -{ +bool MaskEditorActions::isBringToFrontPossible() const { bool result(false); QModelIndexList indexes = m_selectionModel->selectedIndexes(); if (indexes.size() == 1 && indexes.front().row() != 0) @@ -181,8 +169,7 @@ bool MaskEditorActions::isBringToFrontPossible() const } //! Returns true if at least one of MaskItems in the selection can be moved one level down. -bool MaskEditorActions::isSendToBackPossible() const -{ +bool MaskEditorActions::isSendToBackPossible() const { bool result(false); QModelIndexList indexes = m_selectionModel->selectedIndexes(); if (indexes.size() == 1) { @@ -193,8 +180,7 @@ bool MaskEditorActions::isSendToBackPossible() const return result; } -void MaskEditorActions::setAllActionsEnabled(bool value) -{ +void MaskEditorActions::setAllActionsEnabled(bool value) { m_sendToBackAction->setEnabled(value); m_bringToFrontAction->setEnabled(value); m_toggleMaskValueAction->setEnabled(value); @@ -203,8 +189,7 @@ void MaskEditorActions::setAllActionsEnabled(bool value) //! Init external context menu with currently defined actions. //! Triggered from MaskGraphicsScene of MaskEditorInfoPanel (QListView) -void MaskEditorActions::initItemContextMenu(QMenu& menu) -{ +void MaskEditorActions::initItemContextMenu(QMenu& menu) { if (!m_rootIndex.isValid()) return; diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorActions.h b/GUI/coregui/Views/MaskWidgets/MaskEditorActions.h index 48cc44ea681ba30f978240c5ed66634c6a7b5870..57453b626fcad735051234d6f6bb09414d36aa79 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorActions.h +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorActions.h @@ -30,8 +30,7 @@ class QMenu; //! lower/rize mask in the stack, delete mask). If more than one MaskItem is selected, //! action will be applied to the whole selection, if possible. -class MaskEditorActions : public QObject -{ +class MaskEditorActions : public QObject { Q_OBJECT public: MaskEditorActions(QWidget* parent); diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorCanvas.cpp b/GUI/coregui/Views/MaskWidgets/MaskEditorCanvas.cpp index 69bfc87e11fec48397c4685c9481dcc49f26fe03..6332055a786de705cf1b2d758112722102299b8f 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorCanvas.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorCanvas.cpp @@ -31,8 +31,7 @@ MaskEditorCanvas::MaskEditorCanvas(QWidget* parent) , m_view(new MaskGraphicsView(m_scene)) , m_intensityDataItem(0) , m_statusLabel(new PlotStatusLabel(0, this)) - , m_resultsPresenter(new MaskResultsPresenter(this)) -{ + , m_resultsPresenter(new MaskResultsPresenter(this)) { setObjectName("MaskEditorCanvas"); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -49,8 +48,7 @@ MaskEditorCanvas::MaskEditorCanvas(QWidget* parent) } void MaskEditorCanvas::setMaskContext(SessionModel* model, const QModelIndex& maskContainerIndex, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { m_intensityDataItem = intensityItem; m_scene->setMaskContext(model, maskContainerIndex, intensityItem); @@ -60,25 +58,22 @@ void MaskEditorCanvas::setMaskContext(SessionModel* model, const QModelIndex& ma m_statusLabel->addPlot(m_scene->colorMap()); } -void MaskEditorCanvas::resetContext() -{ +void MaskEditorCanvas::resetContext() { m_intensityDataItem = nullptr; m_scene->resetContext(); m_statusLabel->reset(); } -void MaskEditorCanvas::setSelectionModel(QItemSelectionModel* model) -{ +void MaskEditorCanvas::setSelectionModel(QItemSelectionModel* model) { m_scene->setSelectionModel(model); } -MaskGraphicsScene* MaskEditorCanvas::getScene() -{ +MaskGraphicsScene* MaskEditorCanvas::getScene() { return m_scene; } -void MaskEditorCanvas::onPresentationTypeRequest(MaskEditorFlags::PresentationType presentationType) -{ +void MaskEditorCanvas::onPresentationTypeRequest( + MaskEditorFlags::PresentationType presentationType) { m_resultsPresenter->updatePresenter(presentationType); if (auto container = m_intensityDataItem->maskContainerItem()) { @@ -90,8 +85,7 @@ void MaskEditorCanvas::onPresentationTypeRequest(MaskEditorFlags::PresentationTy //! Saves plot into project directory. -void MaskEditorCanvas::onSavePlotRequest() -{ +void MaskEditorCanvas::onSavePlotRequest() { QString dirname = AppSvc::projectManager()->userExportDir(); SavePlotAssistant saveAssistant; @@ -99,8 +93,7 @@ void MaskEditorCanvas::onSavePlotRequest() m_intensityDataItem->getOutputData()); } -void MaskEditorCanvas::onResetViewRequest() -{ +void MaskEditorCanvas::onResetViewRequest() { m_view->onResetViewRequest(); if (isAxisRangeMatchData()) { @@ -112,8 +105,7 @@ void MaskEditorCanvas::onResetViewRequest() //! Returns true if IntensityData is currently at 100% zoom level -bool MaskEditorCanvas::isAxisRangeMatchData() const -{ +bool MaskEditorCanvas::isAxisRangeMatchData() const { ASSERT(m_intensityDataItem); if (m_intensityDataItem->getLowerX() != m_intensityDataItem->getXmin()) @@ -127,8 +119,7 @@ bool MaskEditorCanvas::isAxisRangeMatchData() const return true; } -void MaskEditorCanvas::setZoomToROI() -{ +void MaskEditorCanvas::setZoomToROI() { if (MaskContainerItem* maskContainer = m_intensityDataItem->maskContainerItem()) { if (SessionItem* roiItem = maskContainer->getChildOfType("RegionOfInterest")) { m_intensityDataItem->setLowerX(roiItem->getItemValue(RectangleItem::P_XLOW).toDouble()); diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorCanvas.h b/GUI/coregui/Views/MaskWidgets/MaskEditorCanvas.h index 20625c4f4f53a52ce6e43893e0db9843bb7c21a2..b1d6f46e5eafd221f2adb314ec1b9c6a7bf8c7fd 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorCanvas.h +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorCanvas.h @@ -30,8 +30,7 @@ class IntensityDataItem; //! Painting widget for MaskEditor, contains graphics scene and graphics view -class MaskEditorCanvas : public QWidget -{ +class MaskEditorCanvas : public QWidget { Q_OBJECT public: MaskEditorCanvas(QWidget* parent = 0); diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorFlags.h b/GUI/coregui/Views/MaskWidgets/MaskEditorFlags.h index 982335f669aec728cc09d7b32b4e573c52e09b13..91187039ee7f7d38643b4cadea3a0c18eb4b7a43 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorFlags.h +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorFlags.h @@ -19,8 +19,7 @@ //! Help class to define various flags for MaskEditor operation -class MaskEditorFlags -{ +class MaskEditorFlags { public: enum EActivityType { SELECTION_MODE, diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorHelper.cpp b/GUI/coregui/Views/MaskWidgets/MaskEditorHelper.cpp index bd813d513c13e3c793397b80857dd50d57ecb4a1..3e629c40831dae1b6040d58a5034b832b97a2a4c 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorHelper.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorHelper.cpp @@ -18,21 +18,18 @@ #include <QPen> #include <QRectF> -QBrush MaskEditorHelper::getSelectionMarkerBrush() -{ +QBrush MaskEditorHelper::getSelectionMarkerBrush() { QBrush result; result.setStyle(Qt::SolidPattern); result.setColor(QColor(226, 235, 244)); return result; } -QPen MaskEditorHelper::getSelectionMarkerPen() -{ +QPen MaskEditorHelper::getSelectionMarkerPen() { return QPen(QColor(99, 162, 217)); } -QBrush MaskEditorHelper::getMaskBrush(bool mask_value) -{ +QBrush MaskEditorHelper::getMaskBrush(bool mask_value) { QBrush result; result.setStyle(Qt::SolidPattern); if (mask_value) { @@ -43,8 +40,7 @@ QBrush MaskEditorHelper::getMaskBrush(bool mask_value) return result; } -QPen MaskEditorHelper::getMaskPen(bool mask_value) -{ +QPen MaskEditorHelper::getMaskPen(bool mask_value) { if (mask_value) { return QPen(QColor(165, 80, 76)); // dark red } else { @@ -52,8 +48,7 @@ QPen MaskEditorHelper::getMaskPen(bool mask_value) } } -QRectF MaskEditorHelper::getMarkerRectangle(const QPointF& pos) -{ +QRectF MaskEditorHelper::getMarkerRectangle(const QPointF& pos) { QRectF result(0, 0, 7, 7); result.moveCenter(pos); return result; diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorHelper.h b/GUI/coregui/Views/MaskWidgets/MaskEditorHelper.h index 8d5a46690451e0d7dfd7f192676b1c7bc32a7dbf..363abe25711075acd653c505392a6a478c8331e2 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorHelper.h +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorHelper.h @@ -24,8 +24,7 @@ class QPointF; //! Static class to provide MaskEditor with common settings (colors, gradients, etc) -class MaskEditorHelper -{ +class MaskEditorHelper { public: enum EViewTypes { IMASKVIEW = QGraphicsItem::UserType + 1, // = 65537 diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.cpp b/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.cpp index 8ad894a7ba1399c2c85a8ee509bb0111bd472bd8..97d60e82bb015eaa4a1156016e45859941e39a95 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.cpp @@ -22,11 +22,9 @@ //! Widget to cheat Accordion to resize correctly. -class EnvelopWidget : public QWidget -{ +class EnvelopWidget : public QWidget { public: - EnvelopWidget(QWidget* content) - { + EnvelopWidget(QWidget* content) { QVBoxLayout* mainLayout = new QVBoxLayout; mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); @@ -45,8 +43,7 @@ MaskEditorPropertyPanel::MaskEditorPropertyPanel(QWidget* parent) , m_plotPropertyEditor(new ComponentEditor(ComponentEditor::MiniTree)) , m_accordion(new AccordionWidget) , m_maskModel(nullptr) - , m_intensityDataItem(nullptr) -{ + , m_intensityDataItem(nullptr) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding); setObjectName(QLatin1String("MaskEditorToolPanel")); @@ -68,20 +65,17 @@ MaskEditorPropertyPanel::MaskEditorPropertyPanel(QWidget* parent) setLayout(mainLayout); } -QSize MaskEditorPropertyPanel::sizeHint() const -{ +QSize MaskEditorPropertyPanel::sizeHint() const { return QSize(128, 128); } -QSize MaskEditorPropertyPanel::minimumSizeHint() const -{ +QSize MaskEditorPropertyPanel::minimumSizeHint() const { return QSize(128, 128); } void MaskEditorPropertyPanel::setMaskContext(SessionModel* model, const QModelIndex& maskContainerIndex, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { m_maskModel = model; m_rootIndex = maskContainerIndex; m_intensityDataItem = intensityItem; @@ -97,8 +91,7 @@ void MaskEditorPropertyPanel::setMaskContext(SessionModel* model, m_plotPropertyEditor->setItem(m_intensityDataItem); } -void MaskEditorPropertyPanel::resetContext() -{ +void MaskEditorPropertyPanel::resetContext() { m_maskModel = nullptr; m_rootIndex = {}; m_intensityDataItem = nullptr; @@ -107,15 +100,13 @@ void MaskEditorPropertyPanel::resetContext() m_plotPropertyEditor->setItem(nullptr); } -QItemSelectionModel* MaskEditorPropertyPanel::selectionModel() -{ +QItemSelectionModel* MaskEditorPropertyPanel::selectionModel() { ASSERT(m_listView); return m_listView->selectionModel(); } //! Show/Hide panel. When panel is hidden, all property editors are disabled. -void MaskEditorPropertyPanel::setPanelHidden(bool value) -{ +void MaskEditorPropertyPanel::setPanelHidden(bool value) { this->setHidden(value); if (!m_rootIndex.isValid()) @@ -134,21 +125,18 @@ void MaskEditorPropertyPanel::setPanelHidden(bool value) } void MaskEditorPropertyPanel::onSelectionChanged(const QItemSelection& selected, - const QItemSelection&) -{ + const QItemSelection&) { if (!selected.empty()) m_maskPropertyEditor->setItem(m_maskModel->itemForIndex(selected.indexes().front())); else m_maskPropertyEditor->setItem(nullptr); } -void MaskEditorPropertyPanel::onCustomContextMenuRequested(const QPoint& point) -{ +void MaskEditorPropertyPanel::onCustomContextMenuRequested(const QPoint& point) { emit itemContextMenuRequest(m_listView->mapToGlobal(point)); } -void MaskEditorPropertyPanel::setup_PlotProperties(AccordionWidget* accordion) -{ +void MaskEditorPropertyPanel::setup_PlotProperties(AccordionWidget* accordion) { ContentPane* cp = accordion->getContentPane(accordion->addContentPane("Plot properties")); cp->setMaximumHeight(600); cp->setHeaderTooltip("Plot properties editor"); @@ -162,8 +150,7 @@ void MaskEditorPropertyPanel::setup_PlotProperties(AccordionWidget* accordion) contentFrame->setLayout(layout); } -void MaskEditorPropertyPanel::setup_MaskStack(AccordionWidget* accordion) -{ +void MaskEditorPropertyPanel::setup_MaskStack(AccordionWidget* accordion) { ContentPane* cp = accordion->getContentPane(accordion->addContentPane("Mask stack")); cp->setMaximumHeight(600); cp->setHeaderTooltip("List of created masks representing mask stacking order."); @@ -177,8 +164,7 @@ void MaskEditorPropertyPanel::setup_MaskStack(AccordionWidget* accordion) contentFrame->setLayout(layout); } -void MaskEditorPropertyPanel::setup_MaskProperties(AccordionWidget* accordion) -{ +void MaskEditorPropertyPanel::setup_MaskProperties(AccordionWidget* accordion) { ContentPane* cp = accordion->getContentPane(accordion->addContentPane("Mask properties")); cp->setMaximumHeight(600); cp->setHeaderTooltip("Property editor for currently selected mask."); diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.h b/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.h index a4273c8c6e12d0250a60017b00fdec470ccbd047..8c99c698f794d7446c476aaa0686437bc33a1276 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.h +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorPropertyPanel.h @@ -29,8 +29,7 @@ class AccordionWidget; //! Tool widget for MaskEditor -class MaskEditorPropertyPanel : public QWidget -{ +class MaskEditorPropertyPanel : public QWidget { Q_OBJECT public: MaskEditorPropertyPanel(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorToolBar.cpp b/GUI/coregui/Views/MaskWidgets/MaskEditorToolBar.cpp index dfdf7c807ec5aec210277031bdfaa6e81a3a2973..7ad518a2569cda9c483271fa75dd4579003faa87 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorToolBar.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorToolBar.cpp @@ -27,8 +27,7 @@ MaskEditorToolBar::MaskEditorToolBar(MaskEditorActions* editorActions, QWidget* : QToolBar(parent) , m_editorActions(editorActions) , m_activityButtonGroup(new QButtonGroup(this)) - , m_maskValueGroup(new QButtonGroup(this)) -{ + , m_maskValueGroup(new QButtonGroup(this)) { setIconSize(QSize(Constants::toolbar_icon_size, Constants::toolbar_icon_size)); setProperty("_q_custom_style_disabled", QVariant(true)); @@ -47,8 +46,7 @@ MaskEditorToolBar::MaskEditorToolBar(MaskEditorActions* editorActions, QWidget* //! Handles ZOOM requests from MaskGraphicsView while user press and holds //! space bar. As soon as space bar is released, activity is returned to previous state. -void MaskEditorToolBar::onChangeActivityRequest(MaskEditorFlags::Activity value) -{ +void MaskEditorToolBar::onChangeActivityRequest(MaskEditorFlags::Activity value) { if (value == MaskEditorFlags::PREVIOUS_MODE) { setCurrentActivity(m_previousActivity); } else { @@ -58,30 +56,25 @@ void MaskEditorToolBar::onChangeActivityRequest(MaskEditorFlags::Activity value) emit activityModeChanged(currentActivity()); } -void MaskEditorToolBar::onActivityGroupChange(int value) -{ +void MaskEditorToolBar::onActivityGroupChange(int value) { Q_UNUSED(value); emit activityModeChanged(currentActivity()); } -void MaskEditorToolBar::onMaskValueGroupChange(int value) -{ +void MaskEditorToolBar::onMaskValueGroupChange(int value) { Q_UNUSED(value); emit maskValueChanged(MaskEditorFlags::MaskValue(value)); } -void MaskEditorToolBar::onPresentationTypePressed() -{ +void MaskEditorToolBar::onPresentationTypePressed() { emit presentationTypeRequest(MaskEditorFlags::MASK_PRESENTER); } -void MaskEditorToolBar::onPresentationTypeReleased() -{ +void MaskEditorToolBar::onPresentationTypeReleased() { emit presentationTypeRequest(MaskEditorFlags::MASK_EDITOR); } -void MaskEditorToolBar::setup_selection_group() -{ +void MaskEditorToolBar::setup_selection_group() { QToolButton* panButton = new QToolButton(this); panButton->setIcon(QIcon(":/images/hand-right.svg")); panButton->setToolTip("Pan/zoom mode (space)"); @@ -107,8 +100,7 @@ void MaskEditorToolBar::setup_selection_group() m_activityButtonGroup->addButton(selectionButton, MaskEditorFlags::SELECTION_MODE); } -void MaskEditorToolBar::setup_maskvalue_group() -{ +void MaskEditorToolBar::setup_maskvalue_group() { addWidget(new QLabel(" ")); QRadioButton* maskTrueButton = new QRadioButton(this); @@ -130,8 +122,7 @@ void MaskEditorToolBar::setup_maskvalue_group() m_maskValueGroup->addButton(maskFalseButton, MaskEditorFlags::MASK_OFF); } -void MaskEditorToolBar::setup_shapes_group() -{ +void MaskEditorToolBar::setup_shapes_group() { QToolButton* roiButton = new QToolButton(this); roiButton->setIcon(QIcon(":/MaskWidgets/images/maskeditor_roi.svg")); roiButton->setToolTip("Create region of interest"); @@ -186,16 +177,14 @@ void MaskEditorToolBar::setup_shapes_group() add_separator(); } -void MaskEditorToolBar::setup_maskmodify_group() -{ +void MaskEditorToolBar::setup_maskmodify_group() { ASSERT(m_editorActions); addAction(m_editorActions->bringToFrontAction()); addAction(m_editorActions->sendToBackAction()); add_separator(); } -void MaskEditorToolBar::setup_extratools_group() -{ +void MaskEditorToolBar::setup_extratools_group() { QToolButton* presentationButton = new QToolButton(this); presentationButton->setIcon(QIcon(":/MaskWidgets/images/maskeditor_lightbulb.svg")); presentationButton->setToolTip("Press and hold to see mask results."); @@ -214,19 +203,16 @@ void MaskEditorToolBar::setup_extratools_group() add_separator(); } -void MaskEditorToolBar::add_separator() -{ +void MaskEditorToolBar::add_separator() { addWidget(new QLabel(" ")); addSeparator(); addWidget(new QLabel(" ")); } -MaskEditorFlags::Activity MaskEditorToolBar::currentActivity() const -{ +MaskEditorFlags::Activity MaskEditorToolBar::currentActivity() const { return MaskEditorFlags::EActivityType(m_activityButtonGroup->checkedId()); } -void MaskEditorToolBar::setCurrentActivity(MaskEditorFlags::Activity value) -{ +void MaskEditorToolBar::setCurrentActivity(MaskEditorFlags::Activity value) { m_activityButtonGroup->button(value)->setChecked(true); } diff --git a/GUI/coregui/Views/MaskWidgets/MaskEditorToolBar.h b/GUI/coregui/Views/MaskWidgets/MaskEditorToolBar.h index c5cfc0db53b4ebe5266b45ff223d0d805467f519..d4895c693b7fef63b342c860e6afef931b194eb0 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskEditorToolBar.h +++ b/GUI/coregui/Views/MaskWidgets/MaskEditorToolBar.h @@ -23,8 +23,7 @@ class QButtonGroup; //! Main class to draw masks on top of intensity data map -class MaskEditorToolBar : public QToolBar -{ +class MaskEditorToolBar : public QToolBar { Q_OBJECT public: MaskEditorToolBar(MaskEditorActions* editorActions, QWidget* parent = 0); diff --git a/GUI/coregui/Views/MaskWidgets/MaskGraphicsProxy.cpp b/GUI/coregui/Views/MaskWidgets/MaskGraphicsProxy.cpp index 67a2a44dc0e1ed6e5be5ec5c4b6b358321d45185..018d47982c6406663667ec90d379d3f4ae2ead06 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskGraphicsProxy.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskGraphicsProxy.cpp @@ -19,28 +19,24 @@ #include <QGraphicsSceneMouseEvent> MaskGraphicsProxy::MaskGraphicsProxy() - : m_colorMap(new ColorMap), m_sceneAdaptor(0), m_send_signals_to_colormap(false) -{ + : m_colorMap(new ColorMap), m_sceneAdaptor(0), m_send_signals_to_colormap(false) { resize(1200, 1000); setInZoomMode(true); } -MaskGraphicsProxy::~MaskGraphicsProxy() -{ +MaskGraphicsProxy::~MaskGraphicsProxy() { // no need to delete m_colorMap, base QGraphicsProxyWidget will take care about it if (m_sceneAdaptor) m_sceneAdaptor->setColorMapPlot(0); } -void MaskGraphicsProxy::setIntensityItem(IntensityDataItem* intensityDataItem) -{ +void MaskGraphicsProxy::setIntensityItem(IntensityDataItem* intensityDataItem) { m_colorMap->setItem(intensityDataItem); if (widget() != m_colorMap) setWidget(m_colorMap); } -void MaskGraphicsProxy::setSceneAdaptor(ISceneAdaptor* sceneAdaptor) -{ +void MaskGraphicsProxy::setSceneAdaptor(ISceneAdaptor* sceneAdaptor) { if (m_sceneAdaptor) m_sceneAdaptor->setColorMapPlot(0); @@ -52,8 +48,7 @@ void MaskGraphicsProxy::setSceneAdaptor(ISceneAdaptor* sceneAdaptor) //! Sets widget to zoom mode, when signals (zoom wheel, mouse clicks) are send down to //! ColorMap plot. In non-zoom mode, widget doesn't react on clicks. -void MaskGraphicsProxy::setInZoomMode(bool value) -{ +void MaskGraphicsProxy::setInZoomMode(bool value) { m_send_signals_to_colormap = value; if (value) { setAcceptedMouseButtons(Qt::LeftButton); @@ -62,35 +57,30 @@ void MaskGraphicsProxy::setInZoomMode(bool value) } } -ColorMap* MaskGraphicsProxy::colorMap() -{ +ColorMap* MaskGraphicsProxy::colorMap() { return m_colorMap; } -void MaskGraphicsProxy::mousePressEvent(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsProxy::mousePressEvent(QGraphicsSceneMouseEvent* event) { if (!m_send_signals_to_colormap) return; QGraphicsProxyWidget::mousePressEvent(event); event->accept(); } -void MaskGraphicsProxy::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsProxy::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { if (!m_send_signals_to_colormap) return; QGraphicsProxyWidget::mouseReleaseEvent(event); } -void MaskGraphicsProxy::wheelEvent(QGraphicsSceneWheelEvent* event) -{ +void MaskGraphicsProxy::wheelEvent(QGraphicsSceneWheelEvent* event) { if (!m_send_signals_to_colormap) return; QGraphicsProxyWidget::wheelEvent(event); } -void MaskGraphicsProxy::mouseMoveEvent(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsProxy::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (!m_send_signals_to_colormap) return; QGraphicsProxyWidget::mouseMoveEvent(event); diff --git a/GUI/coregui/Views/MaskWidgets/MaskGraphicsProxy.h b/GUI/coregui/Views/MaskWidgets/MaskGraphicsProxy.h index bf8a2a1002bf9f1273203d0084a1310524a5f633..c631279318ea342674f30d4b553c644614a7146a 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskGraphicsProxy.h +++ b/GUI/coregui/Views/MaskWidgets/MaskGraphicsProxy.h @@ -26,8 +26,7 @@ class IntensityDataItem; //! Graphics proxy to place QWidget inside QGraphicsScene, used by MaskEditorCanvas. -class MaskGraphicsProxy : public QGraphicsProxyWidget -{ +class MaskGraphicsProxy : public QGraphicsProxyWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/MaskGraphicsScene.cpp b/GUI/coregui/Views/MaskWidgets/MaskGraphicsScene.cpp index 2610be8a7951b1cb4b1ad9e4b444bcb85b94aa3b..e9b7dd98b2bdcd0c1b3d4bf378229283d9a7e5fd 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskGraphicsScene.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskGraphicsScene.cpp @@ -27,8 +27,7 @@ #include <QLineF> #include <QPainter> -namespace -{ +namespace { const QRectF default_scene_rect(0, 0, 800, 600); const qreal min_distance_to_create_rect = 10; } // namespace @@ -40,22 +39,19 @@ MaskGraphicsScene::MaskGraphicsScene(QObject* parent) , m_proxy(0) , m_block_selection(false) , m_intensityItem(0) - , m_currentItem(0) -{ + , m_currentItem(0) { setSceneRect(default_scene_rect); connect(this, SIGNAL(selectionChanged()), this, SLOT(onSceneSelectionChanged())); } -MaskGraphicsScene::~MaskGraphicsScene() -{ +MaskGraphicsScene::~MaskGraphicsScene() { // Fix within #1792 if (m_proxy) m_proxy->setSceneAdaptor(0); } void MaskGraphicsScene::setMaskContext(SessionModel* model, const QModelIndex& maskContainerIndex, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { m_intensityItem = intensityItem; if (model != m_maskModel || m_maskContainerIndex != maskContainerIndex) { @@ -96,8 +92,7 @@ void MaskGraphicsScene::setMaskContext(SessionModel* model, const QModelIndex& m } } -void MaskGraphicsScene::resetContext() -{ +void MaskGraphicsScene::resetContext() { m_intensityItem = nullptr; if (m_maskModel) { disconnect(m_maskModel, SIGNAL(modelAboutToBeReset()), this, SLOT(resetScene())); @@ -114,22 +109,19 @@ void MaskGraphicsScene::resetContext() resetScene(); } -void MaskGraphicsScene::setSelectionModel(QItemSelectionModel* model) -{ +void MaskGraphicsScene::setSelectionModel(QItemSelectionModel* model) { ASSERT(model); m_selectionModel = model; connect(m_selectionModel, &QItemSelectionModel::selectionChanged, this, &MaskGraphicsScene::onSessionSelectionChanged, Qt::UniqueConnection); } -ColorMap* MaskGraphicsScene::colorMap() -{ +ColorMap* MaskGraphicsScene::colorMap() { ASSERT(m_proxy); return m_proxy->colorMap(); } -void MaskGraphicsScene::onActivityModeChanged(MaskEditorFlags::Activity value) -{ +void MaskGraphicsScene::onActivityModeChanged(MaskEditorFlags::Activity value) { if (!m_proxy) return; @@ -142,18 +134,15 @@ void MaskGraphicsScene::onActivityModeChanged(MaskEditorFlags::Activity value) updateCursors(); } -void MaskGraphicsScene::onMaskValueChanged(MaskEditorFlags::MaskValue value) -{ +void MaskGraphicsScene::onMaskValueChanged(MaskEditorFlags::MaskValue value) { m_context.setMaskValue(value); } -void MaskGraphicsScene::onRowsInserted(const QModelIndex&, int, int) -{ +void MaskGraphicsScene::onRowsInserted(const QModelIndex&, int, int) { updateScene(); } -void MaskGraphicsScene::onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last) -{ +void MaskGraphicsScene::onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last) { m_block_selection = true; for (int irow = first; irow <= last; ++irow) { QModelIndex itemIndex = m_maskModel->index(irow, 0, parent); @@ -162,13 +151,11 @@ void MaskGraphicsScene::onRowsAboutToBeRemoved(const QModelIndex& parent, int fi m_block_selection = false; } -void MaskGraphicsScene::onRowsRemoved(const QModelIndex&, int, int) -{ +void MaskGraphicsScene::onRowsRemoved(const QModelIndex&, int, int) { updateScene(); } -void MaskGraphicsScene::cancelCurrentDrawing() -{ +void MaskGraphicsScene::cancelCurrentDrawing() { if (isDrawingInProgress()) { ASSERT(m_currentItem); QModelIndex index = m_maskModel->indexOfItem(m_currentItem); @@ -177,8 +164,7 @@ void MaskGraphicsScene::cancelCurrentDrawing() } } -void MaskGraphicsScene::resetScene() -{ +void MaskGraphicsScene::resetScene() { ASSERT(m_selectionModel); m_block_selection = true; m_selectionModel->clearSelection(); @@ -194,8 +180,7 @@ void MaskGraphicsScene::resetScene() //! Main method to update scene on various changes in the model. -void MaskGraphicsScene::updateScene() -{ +void MaskGraphicsScene::updateScene() { if (!m_maskModel) return; @@ -207,8 +192,7 @@ void MaskGraphicsScene::updateScene() //! Propagates selection from model to scene. -void MaskGraphicsScene::onSessionSelectionChanged(const QItemSelection&, const QItemSelection&) -{ +void MaskGraphicsScene::onSessionSelectionChanged(const QItemSelection&, const QItemSelection&) { if (m_block_selection) return; @@ -224,8 +208,7 @@ void MaskGraphicsScene::onSessionSelectionChanged(const QItemSelection&, const Q //! Propagates selection from scene to model. -void MaskGraphicsScene::onSceneSelectionChanged() -{ +void MaskGraphicsScene::onSceneSelectionChanged() { if (m_block_selection) return; @@ -244,8 +227,7 @@ void MaskGraphicsScene::onSceneSelectionChanged() m_block_selection = false; } -void MaskGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* event) { if (event->buttons() & Qt::RightButton) { if (isDrawingInProgress()) { cancelCurrentDrawing(); @@ -273,8 +255,7 @@ void MaskGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* event) QGraphicsScene::mousePressEvent(event); } -void MaskGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (isDrawingInProgress() && m_context.isRectangleShapeMode()) { processRectangleShapeItem(event); return; @@ -289,8 +270,7 @@ void MaskGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) //! Finalizes item drawing or pass events to other items. -void MaskGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { if (isDrawingInProgress()) { if (m_context.isRectangleShapeMode()) { clearSelection(); @@ -314,8 +294,7 @@ void MaskGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) //! Draws dashed line to the current mouse position in the case of ungoing //! line or polygon drawing. -void MaskGraphicsScene::drawForeground(QPainter* painter, const QRectF&) -{ +void MaskGraphicsScene::drawForeground(QPainter* painter, const QRectF&) { // if(!isDrawingInProgress()) // return; @@ -348,8 +327,7 @@ void MaskGraphicsScene::drawForeground(QPainter* painter, const QRectF&) //! Creates item context menu if there is IMaskView beneath the mouse right click. -void MaskGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) -{ +void MaskGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) { if (isDrawingInProgress()) return; @@ -359,8 +337,7 @@ void MaskGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) //! Updates proxy widget for intensity data item. -void MaskGraphicsScene::updateProxyWidget() -{ +void MaskGraphicsScene::updateProxyWidget() { ASSERT(m_intensityItem); if (!m_proxy) { m_proxy = new MaskGraphicsProxy; @@ -372,8 +349,7 @@ void MaskGraphicsScene::updateProxyWidget() //! Recutsively runs through the model and creates corresponding views. -void MaskGraphicsScene::updateViews(const QModelIndex& parentIndex, IShape2DView* parentView) -{ +void MaskGraphicsScene::updateViews(const QModelIndex& parentIndex, IShape2DView* parentView) { ASSERT(m_maskModel); IShape2DView* childView(0); for (int i_row = 0; i_row < m_maskModel->rowCount(parentIndex); ++i_row) { @@ -394,8 +370,7 @@ void MaskGraphicsScene::updateViews(const QModelIndex& parentIndex, IShape2DView //! Creates a view for given item. -IShape2DView* MaskGraphicsScene::addViewForItem(SessionItem* item) -{ +IShape2DView* MaskGraphicsScene::addViewForItem(SessionItem* item) { ASSERT(item); IShape2DView* view = m_ItemToView[item]; if (!view) { @@ -411,8 +386,7 @@ IShape2DView* MaskGraphicsScene::addViewForItem(SessionItem* item) //! Recursive delete of all views corresponding to given index. -void MaskGraphicsScene::deleteViews(const QModelIndex& parentIndex) -{ +void MaskGraphicsScene::deleteViews(const QModelIndex& parentIndex) { for (int i_row = 0; i_row < m_maskModel->rowCount(parentIndex); ++i_row) { QModelIndex itemIndex = m_maskModel->index(i_row, 0, parentIndex); @@ -426,8 +400,7 @@ void MaskGraphicsScene::deleteViews(const QModelIndex& parentIndex) //! Removes single view from scene. -void MaskGraphicsScene::removeItemViewFromScene(SessionItem* item) -{ +void MaskGraphicsScene::removeItemViewFromScene(SessionItem* item) { for (auto it = m_ItemToView.begin(); it != m_ItemToView.end(); ++it) { if (it.key() == item) { IShape2DView* view = it.value(); @@ -441,8 +414,7 @@ void MaskGraphicsScene::removeItemViewFromScene(SessionItem* item) //! Returns true if left mouse bottom click was inside ColorMap viewport rectangle. -bool MaskGraphicsScene::isValidMouseClick(QGraphicsSceneMouseEvent* event) -{ +bool MaskGraphicsScene::isValidMouseClick(QGraphicsSceneMouseEvent* event) { if (!m_adaptor) return false; if (!(event->buttons() & Qt::LeftButton)) @@ -454,8 +426,7 @@ bool MaskGraphicsScene::isValidMouseClick(QGraphicsSceneMouseEvent* event) //! Returns true if mouse click is valid for rectangular/elliptic/ROI shapes. -bool MaskGraphicsScene::isValidForRectangleShapeDrawing(QGraphicsSceneMouseEvent* event) -{ +bool MaskGraphicsScene::isValidForRectangleShapeDrawing(QGraphicsSceneMouseEvent* event) { if (isDrawingInProgress()) return false; if (!isValidMouseClick(event)) @@ -475,8 +446,7 @@ bool MaskGraphicsScene::isValidForRectangleShapeDrawing(QGraphicsSceneMouseEvent //! Returns true if mouse click is in context suitable for polygon drawing. -bool MaskGraphicsScene::isValidForPolygonDrawing(QGraphicsSceneMouseEvent* event) -{ +bool MaskGraphicsScene::isValidForPolygonDrawing(QGraphicsSceneMouseEvent* event) { if (!isValidMouseClick(event)) return false; if (!m_context.isPolygonMode()) @@ -490,8 +460,7 @@ bool MaskGraphicsScene::isValidForPolygonDrawing(QGraphicsSceneMouseEvent* event //! Returns true if mouse click is in context suitable for line drawing. -bool MaskGraphicsScene::isValidForLineDrawing(QGraphicsSceneMouseEvent* event) -{ +bool MaskGraphicsScene::isValidForLineDrawing(QGraphicsSceneMouseEvent* event) { if (!isValidMouseClick(event)) return false; if (isDrawingInProgress()) @@ -508,8 +477,7 @@ bool MaskGraphicsScene::isValidForLineDrawing(QGraphicsSceneMouseEvent* event) //! Returns true if MaskAllItem can be drawn. Only one item of such type is allowed. -bool MaskGraphicsScene::isValidForMaskAllDrawing(QGraphicsSceneMouseEvent* event) -{ +bool MaskGraphicsScene::isValidForMaskAllDrawing(QGraphicsSceneMouseEvent* event) { if (!isValidMouseClick(event)) return false; if (isDrawingInProgress()) @@ -525,21 +493,18 @@ bool MaskGraphicsScene::isValidForMaskAllDrawing(QGraphicsSceneMouseEvent* event //! Return true if area beneath the mouse contains views of given type. bool MaskGraphicsScene::isAreaContains(QGraphicsSceneMouseEvent* event, - MaskEditorHelper::EViewTypes viewType) -{ + MaskEditorHelper::EViewTypes viewType) { for (QGraphicsItem* graphicsItem : this->items(event->scenePos())) if (graphicsItem->type() == viewType) return true; return false; } -bool MaskGraphicsScene::isDrawingInProgress() const -{ +bool MaskGraphicsScene::isDrawingInProgress() const { return m_context.isDrawingInProgress(); } -void MaskGraphicsScene::setDrawingInProgress(bool value) -{ +void MaskGraphicsScene::setDrawingInProgress(bool value) { m_context.setDrawingInProgress(value); if (value == false) m_currentItem = 0; @@ -549,8 +514,7 @@ void MaskGraphicsScene::setDrawingInProgress(bool value) //! In pan&zoom mode, the selection is removed, all items can't receive mouse clicks, and all //! events are propagated down to ColorMap plot. -void MaskGraphicsScene::setInPanAndZoomMode(bool value) -{ +void MaskGraphicsScene::setInPanAndZoomMode(bool value) { if (value) m_selectionModel->clearSelection(); @@ -563,8 +527,7 @@ void MaskGraphicsScene::setInPanAndZoomMode(bool value) //! Change cursor to stress that hovered item is movable (when not in PanZoom mode) -void MaskGraphicsScene::updateCursors() -{ +void MaskGraphicsScene::updateCursors() { for (auto it = m_ItemToView.begin(); it != m_ItemToView.end(); ++it) { if (it.key()->modelType() == "VerticalLineMask") { it.value()->setCursor(m_context.isInZoomMode() ? Qt::ArrowCursor : Qt::SizeHorCursor); @@ -574,8 +537,7 @@ void MaskGraphicsScene::updateCursors() } } -void MaskGraphicsScene::makeViewAtMousePosSelected(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsScene::makeViewAtMousePosSelected(QGraphicsSceneMouseEvent* event) { if (QGraphicsItem* graphicsItem = itemAt(event->scenePos(), QTransform())) graphicsItem->setSelected(true); } @@ -585,8 +547,7 @@ void MaskGraphicsScene::makeViewAtMousePosSelected(QGraphicsSceneMouseEvent* eve //! new item will be created. Further, this function will update size and position //! of current rectangle if mouse keep moving. -void MaskGraphicsScene::processRectangleShapeItem(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsScene::processRectangleShapeItem(QGraphicsSceneMouseEvent* event) { if (!isDrawingInProgress()) setDrawingInProgress(true); @@ -629,8 +590,7 @@ void MaskGraphicsScene::processRectangleShapeItem(QGraphicsSceneMouseEvent* even } } -void MaskGraphicsScene::processPolygonItem(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsScene::processPolygonItem(QGraphicsSceneMouseEvent* event) { ASSERT(m_context.isPolygonMode()); if (!m_currentItem) { @@ -659,8 +619,7 @@ void MaskGraphicsScene::processPolygonItem(QGraphicsSceneMouseEvent* event) point->setItemValue(PolygonPointItem::P_POSY, m_adaptor->fromSceneY(click_pos.y())); } -void MaskGraphicsScene::processLineItem(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsScene::processLineItem(QGraphicsSceneMouseEvent* event) { setDrawingInProgress(true); QPointF click_pos = event->buttonDownScenePos(Qt::LeftButton); @@ -678,20 +637,17 @@ void MaskGraphicsScene::processLineItem(QGraphicsSceneMouseEvent* event) setDrawingInProgress(false); } -void MaskGraphicsScene::processVerticalLineItem(const QPointF& pos) -{ +void MaskGraphicsScene::processVerticalLineItem(const QPointF& pos) { m_currentItem = m_maskModel->insertNewItem("VerticalLineMask", m_maskContainerIndex, 0); m_currentItem->setItemValue(VerticalLineItem::P_POSX, m_adaptor->fromSceneX(pos.x())); } -void MaskGraphicsScene::processHorizontalLineItem(const QPointF& pos) -{ +void MaskGraphicsScene::processHorizontalLineItem(const QPointF& pos) { m_currentItem = m_maskModel->insertNewItem("HorizontalLineMask", m_maskContainerIndex, 0); m_currentItem->setItemValue(HorizontalLineItem::P_POSY, m_adaptor->fromSceneY(pos.y())); } -void MaskGraphicsScene::processMaskAllItem(QGraphicsSceneMouseEvent* event) -{ +void MaskGraphicsScene::processMaskAllItem(QGraphicsSceneMouseEvent* event) { Q_UNUSED(event); setDrawingInProgress(true); m_currentItem = m_maskModel->insertNewItem("MaskAllMask", m_maskContainerIndex); @@ -702,8 +658,7 @@ void MaskGraphicsScene::processMaskAllItem(QGraphicsSceneMouseEvent* event) //! Update Z-values of all IMaskView to reflect stacking order in SessionModel. //! Item with irow=0 is the top most on graphics scene (and so is having largest z-values). -void MaskGraphicsScene::setZValues() -{ +void MaskGraphicsScene::setZValues() { ASSERT(m_maskContainerIndex.isValid()); for (int i = 0; i < m_maskModel->rowCount(m_maskContainerIndex); i++) { QModelIndex itemIndex = m_maskModel->index(i, 0, m_maskContainerIndex); @@ -715,8 +670,7 @@ void MaskGraphicsScene::setZValues() //! Returns polygon which is currently under the drawing. -PolygonView* MaskGraphicsScene::currentPolygon() const -{ +PolygonView* MaskGraphicsScene::currentPolygon() const { PolygonView* result(0); if (isDrawingInProgress() && m_context.isPolygonMode()) { if (m_currentItem) @@ -728,8 +682,7 @@ PolygonView* MaskGraphicsScene::currentPolygon() const //! Sets item name depending on alreay existent items. //! If there is already "Rectangle1", the new name will be "Rectangle2" -void MaskGraphicsScene::setItemName(SessionItem* itemToChange) -{ +void MaskGraphicsScene::setItemName(SessionItem* itemToChange) { if (itemToChange->modelType() == "RegionOfInterest") return; diff --git a/GUI/coregui/Views/MaskWidgets/MaskGraphicsScene.h b/GUI/coregui/Views/MaskWidgets/MaskGraphicsScene.h index 6afaa60274f22546b86b9bf1b61185f74fe57065..4066a0f99b6cdde0fe4d413a5b3245d1d1fc6e15 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskGraphicsScene.h +++ b/GUI/coregui/Views/MaskWidgets/MaskGraphicsScene.h @@ -38,8 +38,7 @@ class ColorMap; //! Graphics scene for MaskEditorCanvas to draw masks on top of intensity data widgets. -class MaskGraphicsScene : public QGraphicsScene -{ +class MaskGraphicsScene : public QGraphicsScene { Q_OBJECT public: MaskGraphicsScene(QObject* parent = 0); diff --git a/GUI/coregui/Views/MaskWidgets/MaskGraphicsView.cpp b/GUI/coregui/Views/MaskWidgets/MaskGraphicsView.cpp index 2dc08295145ad613af7b9089971640947e00fb08..c7ba873becb0a4e8c357b22225ec12f91d77fa9c 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskGraphicsView.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskGraphicsView.cpp @@ -20,16 +20,14 @@ #include <QTransform> #include <QWheelEvent> -namespace -{ +namespace { const double min_zoom_value = 1.0; const double max_zoom_value = 5.0; const double zoom_step = 0.05; } // namespace MaskGraphicsView::MaskGraphicsView(QGraphicsScene* scene, QWidget* parent) - : QGraphicsView(scene, parent), m_current_zoom_value(1.0) -{ + : QGraphicsView(scene, parent), m_current_zoom_value(1.0) { setObjectName("MaskGraphicsView"); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); @@ -38,13 +36,11 @@ MaskGraphicsView::MaskGraphicsView(QGraphicsScene* scene, QWidget* parent) } //! Reset given view to original zoom state. Also asks graphics scene to do the same with color map. -void MaskGraphicsView::onResetViewRequest() -{ +void MaskGraphicsView::onResetViewRequest() { setZoomValue(1.0); } -void MaskGraphicsView::wheelEvent(QWheelEvent* event) -{ +void MaskGraphicsView::wheelEvent(QWheelEvent* event) { // hold control button if (isControlButtonIsPressed(event)) { centerOn(mapToScene(event->pos())); // TODO upon Qt5.14: pos() -> position().toPoint() @@ -63,8 +59,7 @@ void MaskGraphicsView::wheelEvent(QWheelEvent* event) } //! On resize event changes scene size and MaskGraphicsProxy so they would get the size of viewport -void MaskGraphicsView::resizeEvent(QResizeEvent* event) -{ +void MaskGraphicsView::resizeEvent(QResizeEvent* event) { QWidget::resizeEvent(event); updateSize(event->size()); // for(QGraphicsItem *graphicsItem : scene()->items()) { @@ -76,8 +71,7 @@ void MaskGraphicsView::resizeEvent(QResizeEvent* event) // } } -void MaskGraphicsView::keyPressEvent(QKeyEvent* event) -{ +void MaskGraphicsView::keyPressEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_Left: break; @@ -100,8 +94,7 @@ void MaskGraphicsView::keyPressEvent(QKeyEvent* event) } } -void MaskGraphicsView::keyReleaseEvent(QKeyEvent* event) -{ +void MaskGraphicsView::keyReleaseEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_Space: if (!event->isAutoRepeat()) { @@ -113,22 +106,19 @@ void MaskGraphicsView::keyReleaseEvent(QKeyEvent* event) } } -bool MaskGraphicsView::isControlButtonIsPressed(QWheelEvent* event) -{ +bool MaskGraphicsView::isControlButtonIsPressed(QWheelEvent* event) { if (event->modifiers().testFlag(Qt::ControlModifier)) { return true; } return false; } -void MaskGraphicsView::cancelCurrentDrawing() -{ +void MaskGraphicsView::cancelCurrentDrawing() { MaskGraphicsScene* maskScene = dynamic_cast<MaskGraphicsScene*>(scene()); maskScene->cancelCurrentDrawing(); } -void MaskGraphicsView::setZoomValue(double zoom_value) -{ +void MaskGraphicsView::setZoomValue(double zoom_value) { if (zoom_value == m_current_zoom_value) return; const QTransform oldMatrix = transform(); @@ -138,24 +128,21 @@ void MaskGraphicsView::setZoomValue(double zoom_value) m_current_zoom_value = zoom_value; } -void MaskGraphicsView::decreazeZoomValue() -{ +void MaskGraphicsView::decreazeZoomValue() { double zoom_value = m_current_zoom_value - zoom_step; if (zoom_value < min_zoom_value) zoom_value = min_zoom_value; setZoomValue(zoom_value); } -void MaskGraphicsView::increazeZoomValue() -{ +void MaskGraphicsView::increazeZoomValue() { double zoom_value = m_current_zoom_value + zoom_step; if (zoom_value > max_zoom_value) zoom_value = max_zoom_value; setZoomValue(zoom_value); } -void MaskGraphicsView::updateSize(const QSize& newSize) -{ +void MaskGraphicsView::updateSize(const QSize& newSize) { for (QGraphicsItem* graphicsItem : scene()->items()) { if (MaskGraphicsProxy* proxy = dynamic_cast<MaskGraphicsProxy*>(graphicsItem)) { proxy->resize(newSize); diff --git a/GUI/coregui/Views/MaskWidgets/MaskGraphicsView.h b/GUI/coregui/Views/MaskWidgets/MaskGraphicsView.h index ed0229ad6aea2db67bc45aeacedc92eaf46758cd..f281b55c6f7dc356fbaad8255860ff6709af0ff3 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskGraphicsView.h +++ b/GUI/coregui/Views/MaskWidgets/MaskGraphicsView.h @@ -23,8 +23,7 @@ class MaskGraphicsProxy; //! Graphics view for MaskEditorCanvas -class MaskGraphicsView : public QGraphicsView -{ +class MaskGraphicsView : public QGraphicsView { Q_OBJECT public: MaskGraphicsView(QGraphicsScene* scene, QWidget* parent = 0); diff --git a/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp b/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp index ec74cbf3a50e2753d83bd9d78170155871c210b5..341e744c3f8993c53a2756f2fe4ebed96c5ba7be 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp @@ -21,26 +21,21 @@ #include <QVBoxLayout> MaskResultsPresenter::MaskResultsPresenter(QWidget* parent) - : QObject(parent), m_interpolation_flag_backup(false) -{ -} + : QObject(parent), m_interpolation_flag_backup(false) {} void MaskResultsPresenter::setMaskContext(SessionModel* maskModel, const QModelIndex& maskContainerIndex, - IntensityDataItem* intensityItem) -{ + IntensityDataItem* intensityItem) { m_maskModel = maskModel; m_maskContainerIndex = maskContainerIndex; m_intensityDataItem = intensityItem; } -void MaskResultsPresenter::resetContext() -{ +void MaskResultsPresenter::resetContext() { setMaskContext(nullptr, QModelIndex(), nullptr); } -void MaskResultsPresenter::updatePresenter(MaskEditorFlags::PresentationType presentationType) -{ +void MaskResultsPresenter::updatePresenter(MaskEditorFlags::PresentationType presentationType) { if (!m_maskContainerIndex.isValid()) return; @@ -54,8 +49,7 @@ void MaskResultsPresenter::updatePresenter(MaskEditorFlags::PresentationType pre //! Update IntensityDataItem in SessionModel to represent masked areas. Corresponding //! bins of OutputData will be put to zero. -void MaskResultsPresenter::setShowMaskMode() -{ +void MaskResultsPresenter::setShowMaskMode() { if (OutputData<double>* maskedData = createMaskPresentation()) { backup_data(); m_intensityDataItem->setOutputData(maskedData); @@ -67,8 +61,7 @@ void MaskResultsPresenter::setShowMaskMode() //! Restores original state of IntensityDataItem -void MaskResultsPresenter::setOriginalMode() -{ +void MaskResultsPresenter::setOriginalMode() { if (m_dataBackup) { m_intensityDataItem->setOutputData(m_dataBackup->clone()); m_intensityDataItem->setItemValue(IntensityDataItem::P_IS_INTERPOLATED, @@ -76,8 +69,7 @@ void MaskResultsPresenter::setOriginalMode() } } -void MaskResultsPresenter::backup_data() -{ +void MaskResultsPresenter::backup_data() { m_interpolation_flag_backup = m_intensityDataItem->getItemValue(IntensityDataItem::P_IS_INTERPOLATED).toBool(); m_dataBackup.reset(m_intensityDataItem->getOutputData()->clone()); @@ -86,8 +78,7 @@ void MaskResultsPresenter::backup_data() //! Constructs OutputData which contains original intensity data except masked areas, //! and areas outside of ROI, where bin content is set to zero. -OutputData<double>* MaskResultsPresenter::createMaskPresentation() const -{ +OutputData<double>* MaskResultsPresenter::createMaskPresentation() const { // Requesting mask information std::unique_ptr<RegionOfInterest> roi; DetectorMask detectorMask; diff --git a/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.h b/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.h index e687a61531149cc9b4a52fa77a3e6fad0e488513..39cc62658e61c529d85b3c02069162fe7bccc743 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.h +++ b/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.h @@ -27,8 +27,7 @@ template <class T> class OutputData; //! Updates bin values inside IntensityData to display current mask state. Returns IntensityData //! to original state when requested. -class MaskResultsPresenter : public QObject -{ +class MaskResultsPresenter : public QObject { public: MaskResultsPresenter(QWidget* parent = 0); diff --git a/GUI/coregui/Views/MaskWidgets/MaskUnitsConverter.cpp b/GUI/coregui/Views/MaskWidgets/MaskUnitsConverter.cpp index 7d12ae6aae7569f4903a0763e4d9325a197a9f71..d485b0f3a292987cb9462ff6532d02ce26a57363 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskUnitsConverter.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskUnitsConverter.cpp @@ -23,8 +23,7 @@ MaskUnitsConverter::MaskUnitsConverter() : m_data(nullptr), m_direction(UNDEFINE //! Converts all masks on board of IntensityDataItem into bin-fraction coordinates. -void MaskUnitsConverter::convertToNbins(IntensityDataItem* intensityData) -{ +void MaskUnitsConverter::convertToNbins(IntensityDataItem* intensityData) { m_direction = TO_NBINS; convertIntensityDataItem(intensityData); } @@ -32,16 +31,14 @@ void MaskUnitsConverter::convertToNbins(IntensityDataItem* intensityData) //! Converts all masks on board of IntensityDataItem from bin-fraction coordinates to coordinates //! of axes currently defined in OutputData. -void MaskUnitsConverter::convertFromNbins(IntensityDataItem* intensityData) -{ +void MaskUnitsConverter::convertFromNbins(IntensityDataItem* intensityData) { m_direction = FROM_NBINS; convertIntensityDataItem(intensityData); } //! Converts all masks on board of IntensityDataItem from/to bin-fraction coordinates -void MaskUnitsConverter::convertIntensityDataItem(IntensityDataItem* intensityData) -{ +void MaskUnitsConverter::convertIntensityDataItem(IntensityDataItem* intensityData) { if (!intensityData || !intensityData->getOutputData()) return; @@ -58,8 +55,7 @@ void MaskUnitsConverter::convertIntensityDataItem(IntensityDataItem* intensityDa //! Converts single mask from/to bin-fraction coordinates -void MaskUnitsConverter::convertMask(SessionItem* maskItem) -{ +void MaskUnitsConverter::convertMask(SessionItem* maskItem) { if (maskItem->modelType() == "RectangleMask" || maskItem->modelType() == "RegionOfInterest") { convertCoordinate(maskItem, RectangleItem::P_XLOW, RectangleItem::P_YLOW); convertCoordinate(maskItem, RectangleItem::P_XUP, RectangleItem::P_YUP); @@ -97,8 +93,7 @@ void MaskUnitsConverter::convertMask(SessionItem* maskItem) //! bin-fraction coordinates. Result of operation are new values for registered properties. void MaskUnitsConverter::convertCoordinate(SessionItem* maskItem, const QString& xname, - const QString& yname) -{ + const QString& yname) { if (maskItem->isTag(xname)) { double x = convert(maskItem->getItemValue(xname).toDouble(), 0); maskItem->setItemValue(xname, x); @@ -111,8 +106,7 @@ void MaskUnitsConverter::convertCoordinate(SessionItem* maskItem, const QString& //! Convert value of axis from/to bin-fraction coordinates. -double MaskUnitsConverter::convert(double value, int axis_index) -{ +double MaskUnitsConverter::convert(double value, int axis_index) { ASSERT(m_data); ASSERT(axis_index == 0 || axis_index == 1); diff --git a/GUI/coregui/Views/MaskWidgets/MaskUnitsConverter.h b/GUI/coregui/Views/MaskWidgets/MaskUnitsConverter.h index b8ca5c0e65e111bbe5ad28e096f97731fdc9d5dd..2c8fe1129e2ce5aade231253ad024ebc79ba5f78 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskUnitsConverter.h +++ b/GUI/coregui/Views/MaskWidgets/MaskUnitsConverter.h @@ -28,8 +28,7 @@ class QString; //! On second step masks are converted from bin-fraction coordinates into current axes of //! OutputData. -class MaskUnitsConverter -{ +class MaskUnitsConverter { public: enum EConvertionDirection { TO_NBINS, FROM_NBINS, UNDEFINED }; diff --git a/GUI/coregui/Views/MaskWidgets/MaskViewFactory.cpp b/GUI/coregui/Views/MaskWidgets/MaskViewFactory.cpp index 00913c02f9e1aa62217439ea310b3ebdc36a005f..811a37acc621c8bf00b034c0d32c441101e82ab2 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskViewFactory.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskViewFactory.cpp @@ -24,8 +24,7 @@ #include "GUI/coregui/Views/MaskWidgets/RegionOfInterestView.h" #include "GUI/coregui/utils/GUIHelpers.h" -IShape2DView* MaskViewFactory::createMaskView(SessionItem* item, ISceneAdaptor* adaptor) -{ +IShape2DView* MaskViewFactory::createMaskView(SessionItem* item, ISceneAdaptor* adaptor) { IShape2DView* result(0); QString model_type = item->modelType(); diff --git a/GUI/coregui/Views/MaskWidgets/MaskViewFactory.h b/GUI/coregui/Views/MaskWidgets/MaskViewFactory.h index 6fae0513ca49d533e756f17e4019b452ddba98bc..4717baaa5cdade027d438e7a9335a89ffb07cf67 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskViewFactory.h +++ b/GUI/coregui/Views/MaskWidgets/MaskViewFactory.h @@ -23,8 +23,7 @@ class ISceneAdaptor; //! Factory to construct views out of MaskItems for MaskGraphicsScene -class MaskViewFactory -{ +class MaskViewFactory { public: static IShape2DView* createMaskView(SessionItem* item, ISceneAdaptor* adaptor = 0); }; diff --git a/GUI/coregui/Views/MaskWidgets/PolygonPointView.cpp b/GUI/coregui/Views/MaskWidgets/PolygonPointView.cpp index 41041b5e6b59c5205f969ad3c671b41f7432ccce..9760e38054e4160a480bc61ce2c9fbdff5806cfe 100644 --- a/GUI/coregui/Views/MaskWidgets/PolygonPointView.cpp +++ b/GUI/coregui/Views/MaskWidgets/PolygonPointView.cpp @@ -17,35 +17,29 @@ #include <QGraphicsSceneMouseEvent> #include <QPainter> -PolygonPointView::PolygonPointView() : m_on_hover(false) -{ +PolygonPointView::PolygonPointView() : m_on_hover(false) { setFlag(QGraphicsItem::ItemIsMovable); setFlag(QGraphicsItem::ItemSendsGeometryChanges); } -QRectF PolygonPointView::boundingRect() const -{ +QRectF PolygonPointView::boundingRect() const { return QRectF(-4, -4, 8, 8); } -void PolygonPointView::updateParameterizedItem(const QPointF& pos) -{ +void PolygonPointView::updateParameterizedItem(const QPointF& pos) { m_item->setItemValue(PolygonPointItem::P_POSX, fromSceneX(pos.x())); m_item->setItemValue(PolygonPointItem::P_POSY, fromSceneY(pos.y())); } -void PolygonPointView::update_view() -{ +void PolygonPointView::update_view() { update(); } -void PolygonPointView::onPropertyChange(const QString&) -{ +void PolygonPointView::onPropertyChange(const QString&) { emit propertyChanged(); } -void PolygonPointView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void PolygonPointView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { painter->setRenderHints(QPainter::Antialiasing); QBrush brush = MaskEditorHelper::getSelectionMarkerBrush(); if (acceptHoverEvents() && m_on_hover) { @@ -56,20 +50,17 @@ void PolygonPointView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, painter->drawEllipse(boundingRect()); } -void PolygonPointView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) -{ +void PolygonPointView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { updateParameterizedItem(event->scenePos()); } -void PolygonPointView::hoverEnterEvent(QGraphicsSceneHoverEvent* event) -{ +void PolygonPointView::hoverEnterEvent(QGraphicsSceneHoverEvent* event) { m_on_hover = true; emit closePolygonRequest(m_on_hover); IShape2DView::hoverEnterEvent(event); } -void PolygonPointView::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) -{ +void PolygonPointView::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) { m_on_hover = false; emit closePolygonRequest(m_on_hover); IShape2DView::hoverLeaveEvent(event); diff --git a/GUI/coregui/Views/MaskWidgets/PolygonPointView.h b/GUI/coregui/Views/MaskWidgets/PolygonPointView.h index 89ba6e971f2f6e206308f64b6cd2fb8070c29a72..5e08e663e982c9916f1f059e3104d3221e924711 100644 --- a/GUI/coregui/Views/MaskWidgets/PolygonPointView.h +++ b/GUI/coregui/Views/MaskWidgets/PolygonPointView.h @@ -19,8 +19,7 @@ //! This is a View of polygon point for PolygonMaskItem -class PolygonPointView : public IShape2DView -{ +class PolygonPointView : public IShape2DView { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/PolygonView.cpp b/GUI/coregui/Views/MaskWidgets/PolygonView.cpp index 2e2284d1e73567d784380d86370ea1e8d7dafb23..feeb5ab74358bc9d575b8fd8fb5c836caaa0df4d 100644 --- a/GUI/coregui/Views/MaskWidgets/PolygonView.cpp +++ b/GUI/coregui/Views/MaskWidgets/PolygonView.cpp @@ -18,20 +18,17 @@ #include <QCursor> #include <QPainter> -namespace -{ +namespace { const double bbox_margins = 5; // additional margins around points to form bounding box } -PolygonView::PolygonView() : m_block_on_point_update(false), m_close_polygon_request(false) -{ +PolygonView::PolygonView() : m_block_on_point_update(false), m_close_polygon_request(false) { setFlag(QGraphicsItem::ItemIsSelectable); setFlag(QGraphicsItem::ItemIsMovable); setFlag(QGraphicsItem::ItemSendsGeometryChanges); } -void PolygonView::addView(IShape2DView* childView, int row) -{ +void PolygonView::addView(IShape2DView* childView, int row) { Q_UNUSED(row); if (childItems().contains(childView)) @@ -54,15 +51,13 @@ void PolygonView::addView(IShape2DView* childView, int row) } //! returns last added poligon point in scene coordinates -QPointF PolygonView::lastAddedPoint() const -{ +QPointF PolygonView::lastAddedPoint() const { return childItems().size() ? childItems().back()->scenePos() : QPointF(); } //! Returns true if there was a request to close polygon (emitted by its start point), //! and then closes a polygon. Returns true if polygon was closed. -bool PolygonView::closePolygonIfNecessary() -{ +bool PolygonView::closePolygonIfNecessary() { if (m_close_polygon_request) { for (QGraphicsItem* childItem : childItems()) { childItem->setFlag(QGraphicsItem::ItemIsMovable); @@ -76,18 +71,15 @@ bool PolygonView::closePolygonIfNecessary() return isClosedPolygon(); } -void PolygonView::onClosePolygonRequest(bool value) -{ +void PolygonView::onClosePolygonRequest(bool value) { m_close_polygon_request = value; } -bool PolygonView::isClosedPolygon() -{ +bool PolygonView::isClosedPolygon() { return m_item->getItemValue(PolygonItem::P_ISCLOSED).toBool(); } -void PolygonView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void PolygonView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { ASSERT(m_item); painter->setRenderHints(QPainter::Antialiasing); @@ -103,22 +95,19 @@ void PolygonView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWid painter->drawPolygon(m_polygon.toPolygon()); } -QVariant PolygonView::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) -{ +QVariant PolygonView::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) { if (change == QGraphicsItem::ItemSelectedHasChanged) setChildrenVisible(this->isSelected()); return value; } -void PolygonView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) -{ +void PolygonView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { IShape2DView::mouseMoveEvent(event); update_points(); } -void PolygonView::update_view() -{ +void PolygonView::update_view() { update_polygon(); update(); } @@ -126,8 +115,7 @@ void PolygonView::update_view() //! Runs through all PolygonPointItem and calculate bounding rectangle. //! Determines position of the rectangle in scene. //! Calculates position of PolygonPointView in local polygon coordinates -void PolygonView::update_polygon() -{ +void PolygonView::update_polygon() { if (m_block_on_point_update) return; @@ -167,8 +155,7 @@ void PolygonView::update_polygon() //! When polygon moves as a whole thing across the scene, given method updates coordinates //! of PolygonPointItem's -void PolygonView::update_points() -{ +void PolygonView::update_points() { if (m_block_on_point_update) return; @@ -181,8 +168,7 @@ void PolygonView::update_points() } } -void PolygonView::setChildrenVisible(bool value) -{ +void PolygonView::setChildrenVisible(bool value) { for (QGraphicsItem* childItem : childItems()) childItem->setVisible(value); } diff --git a/GUI/coregui/Views/MaskWidgets/PolygonView.h b/GUI/coregui/Views/MaskWidgets/PolygonView.h index 0b8c9c96cc2ec4b15f4f4d1b6e322328f3034e95..1924fb3035fc835d2dca621006e59c4f152e96dc 100644 --- a/GUI/coregui/Views/MaskWidgets/PolygonView.h +++ b/GUI/coregui/Views/MaskWidgets/PolygonView.h @@ -20,8 +20,7 @@ //! This is a View of polygon mask (represented by PolygonItem) on GraphicsScene. -class PolygonView : public IShape2DView -{ +class PolygonView : public IShape2DView { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/RectangleBaseView.cpp b/GUI/coregui/Views/MaskWidgets/RectangleBaseView.cpp index be03bb8cac658ff1c495775ae60355eb2f0bff96..223c29a0e61db7df704275234716dca1594abefe 100644 --- a/GUI/coregui/Views/MaskWidgets/RectangleBaseView.cpp +++ b/GUI/coregui/Views/MaskWidgets/RectangleBaseView.cpp @@ -15,13 +15,11 @@ #include "GUI/coregui/Views/MaskWidgets/RectangleBaseView.h" #include "Base/Utils/Assert.h" -namespace -{ +namespace { const double bbox_margins = 5; // additional margins around rectangle to form bounding box } -RectangleBaseView::RectangleBaseView() : m_activeHandleElement(0) -{ +RectangleBaseView::RectangleBaseView() : m_activeHandleElement(0) { setFlag(QGraphicsItem::ItemIsSelectable); setFlag(QGraphicsItem::ItemIsMovable); setFlag(QGraphicsItem::ItemSendsGeometryChanges); @@ -30,8 +28,7 @@ RectangleBaseView::RectangleBaseView() : m_activeHandleElement(0) } //! triggered by SizeHandleElement -void RectangleBaseView::onSizeHandleElementRequest(bool going_to_resize) -{ +void RectangleBaseView::onSizeHandleElementRequest(bool going_to_resize) { if (going_to_resize) { setFlag(QGraphicsItem::ItemIsMovable, false); m_activeHandleElement = qobject_cast<SizeHandleElement*>(sender()); @@ -47,8 +44,7 @@ void RectangleBaseView::onSizeHandleElementRequest(bool going_to_resize) //! Track if item selected/deselected and show/hide size handles QVariant RectangleBaseView::itemChange(QGraphicsItem::GraphicsItemChange change, - const QVariant& value) -{ + const QVariant& value) { if (change == QGraphicsItem::ItemSelectedChange) { for (auto it = m_resize_handles.begin(); it != m_resize_handles.end(); ++it) { it.value()->setVisible(!this->isSelected()); @@ -57,14 +53,12 @@ QVariant RectangleBaseView::itemChange(QGraphicsItem::GraphicsItemChange change, return value; } -void RectangleBaseView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) -{ +void RectangleBaseView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { onSizeHandleElementRequest(false); IShape2DView::mouseReleaseEvent(event); } -void RectangleBaseView::update_view() -{ +void RectangleBaseView::update_view() { prepareGeometryChange(); update_bounding_rect(); update_position(); @@ -72,8 +66,7 @@ void RectangleBaseView::update_view() //! updates view's bounding rectangle using item properties -void RectangleBaseView::update_bounding_rect() -{ +void RectangleBaseView::update_bounding_rect() { if (m_item) { m_mask_rect = mask_rectangle(); m_bounding_rect = m_mask_rect.marginsAdded( @@ -88,18 +81,15 @@ void RectangleBaseView::update_bounding_rect() //! returns width of the rectangle -qreal RectangleBaseView::width() const -{ +qreal RectangleBaseView::width() const { return right() - left(); } -qreal RectangleBaseView::height() const -{ +qreal RectangleBaseView::height() const { return bottom() - top(); } -void RectangleBaseView::create_size_handle_elements() -{ +void RectangleBaseView::create_size_handle_elements() { QList<SizeHandleElement::EHandleLocation> points; points << SizeHandleElement::TOPLEFT << SizeHandleElement::TOPMIDDLE << SizeHandleElement::TOPRIGHT << SizeHandleElement::MIDDLERIGHT diff --git a/GUI/coregui/Views/MaskWidgets/RectangleBaseView.h b/GUI/coregui/Views/MaskWidgets/RectangleBaseView.h index cd5629ed244d33e4ddef81079ccf5bb2ae3a2b68..e9a35adec1eaa8eb939a8c7f3b4b380d65ada4c3 100644 --- a/GUI/coregui/Views/MaskWidgets/RectangleBaseView.h +++ b/GUI/coregui/Views/MaskWidgets/RectangleBaseView.h @@ -21,8 +21,7 @@ //! Base view for all rectangular-like masks. -class RectangleBaseView : public IShape2DView -{ +class RectangleBaseView : public IShape2DView { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/RectangleView.cpp b/GUI/coregui/Views/MaskWidgets/RectangleView.cpp index 000043549c43a6415d73998651fab58dd6ba589c..a595549d9ce43a60db35652943ebd0612dbd5733 100644 --- a/GUI/coregui/Views/MaskWidgets/RectangleView.cpp +++ b/GUI/coregui/Views/MaskWidgets/RectangleView.cpp @@ -19,38 +19,33 @@ RectangleView::RectangleView() = default; -void RectangleView::onChangedX() -{ +void RectangleView::onChangedX() { setBlockOnProperty(true); m_item->setItemValue(RectangleItem::P_XLOW, fromSceneX(this->x())); m_item->setItemValue(RectangleItem::P_XUP, fromSceneX(this->x() + m_mask_rect.width())); setBlockOnProperty(false); } -void RectangleView::onChangedY() -{ +void RectangleView::onChangedY() { setBlockOnProperty(true); m_item->setItemValue(RectangleItem::P_YLOW, fromSceneY(this->y() + m_mask_rect.height())); m_item->setItemValue(RectangleItem::P_YUP, fromSceneY(this->y())); setBlockOnProperty(false); } -void RectangleView::onPropertyChange(const QString& propertyName) -{ +void RectangleView::onPropertyChange(const QString& propertyName) { if (propertyName != MaskItem::P_MASK_VALUE) update_view(); } -void RectangleView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void RectangleView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { bool mask_value = m_item->getItemValue(MaskItem::P_MASK_VALUE).toBool(); painter->setBrush(MaskEditorHelper::getMaskBrush(mask_value)); painter->setPen(MaskEditorHelper::getMaskPen(mask_value)); painter->drawRect(m_mask_rect); } -void RectangleView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) -{ +void RectangleView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (m_activeHandleElement) { qreal xmin = std::min(event->scenePos().x(), m_resize_opposite_origin.x()); @@ -81,41 +76,35 @@ void RectangleView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) } //! updates position of view using item properties -void RectangleView::update_position() -{ +void RectangleView::update_position() { setX(toSceneX(RectangleItem::P_XLOW)); setY(toSceneY(RectangleItem::P_YUP)); } -QRectF RectangleView::mask_rectangle() -{ +QRectF RectangleView::mask_rectangle() { return QRectF(0.0, 0.0, width(), height()); } //! returns the x-coordinate of the rectangle's left edge -qreal RectangleView::left() const -{ +qreal RectangleView::left() const { return toSceneX(par(RectangleItem::P_XLOW)); } //! returns the x-coordinate of the rectangle's right edge -qreal RectangleView::right() const -{ +qreal RectangleView::right() const { return toSceneX(par(RectangleItem::P_XUP)); } //! Returns the y-coordinate of the rectangle's top edge. -qreal RectangleView::top() const -{ +qreal RectangleView::top() const { return toSceneY(par(RectangleItem::P_YUP)); } //! Returns the y-coordinate of the rectangle's bottom edge. -qreal RectangleView::bottom() const -{ +qreal RectangleView::bottom() const { return toSceneY(par(RectangleItem::P_YLOW)); } diff --git a/GUI/coregui/Views/MaskWidgets/RectangleView.h b/GUI/coregui/Views/MaskWidgets/RectangleView.h index 38b3dc6262ac704ff134f6db4d24fa6c80e0a949..cd56980044ec8abe40e5ec8b479a1e96b0fa5c9e 100644 --- a/GUI/coregui/Views/MaskWidgets/RectangleView.h +++ b/GUI/coregui/Views/MaskWidgets/RectangleView.h @@ -20,8 +20,7 @@ //! This is a View of rectangular mask (represented by RectangleItem) on GraphicsScene. //! Given view follows standard QGraphicsScene notations: (x,y) is top left corner. -class RectangleView : public RectangleBaseView -{ +class RectangleView : public RectangleBaseView { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/RegionOfInterestView.cpp b/GUI/coregui/Views/MaskWidgets/RegionOfInterestView.cpp index 5f6fb49f1957699c385f803928abae955f3f092e..d453af42cf11ff4c30e7af9fe255d0413d29d160 100644 --- a/GUI/coregui/Views/MaskWidgets/RegionOfInterestView.cpp +++ b/GUI/coregui/Views/MaskWidgets/RegionOfInterestView.cpp @@ -17,8 +17,7 @@ //! Paints two-color tiny frame without filling. -void RegionOfInterestView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void RegionOfInterestView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { painter->setPen(QPen(QColor(34, 67, 255))); painter->drawRect(m_mask_rect); diff --git a/GUI/coregui/Views/MaskWidgets/RegionOfInterestView.h b/GUI/coregui/Views/MaskWidgets/RegionOfInterestView.h index 17108019d83e2a5e8107b6e1921c3f7f33489543..8443f15e43a9ef9a84027d0e50a62e223d5d7ead 100644 --- a/GUI/coregui/Views/MaskWidgets/RegionOfInterestView.h +++ b/GUI/coregui/Views/MaskWidgets/RegionOfInterestView.h @@ -19,8 +19,7 @@ //! The RegionOfInterest class represent view of RegionOfInterestItem on graphics scene. -class RegionOfInterestView : public RectangleView -{ +class RegionOfInterestView : public RectangleView { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaskWidgets/SizeHandleElement.cpp b/GUI/coregui/Views/MaskWidgets/SizeHandleElement.cpp index 18ce0d12fd9eea9756a0a15b757a48f81b0142cf..3fab7cfc1777420a9f1a7e3075e8f2ddc45f6b88 100644 --- a/GUI/coregui/Views/MaskWidgets/SizeHandleElement.cpp +++ b/GUI/coregui/Views/MaskWidgets/SizeHandleElement.cpp @@ -17,10 +17,8 @@ #include <QGraphicsSceneHoverEvent> #include <QPainter> -namespace -{ -QMap<SizeHandleElement::EHandleLocation, Qt::CursorShape> create_cursors_map() -{ +namespace { +QMap<SizeHandleElement::EHandleLocation, Qt::CursorShape> create_cursors_map() { QMap<SizeHandleElement::EHandleLocation, Qt::CursorShape> result; result[SizeHandleElement::NONE] = Qt::ArrowCursor; result[SizeHandleElement::TOPLEFT] = Qt::SizeFDiagCursor; @@ -35,8 +33,7 @@ QMap<SizeHandleElement::EHandleLocation, Qt::CursorShape> create_cursors_map() } QMap<SizeHandleElement::EHandleLocation, SizeHandleElement::EHandleType> -create_location_to_type_map() -{ +create_location_to_type_map() { QMap<SizeHandleElement::EHandleLocation, SizeHandleElement::EHandleType> result; result[SizeHandleElement::NONE] = SizeHandleElement::RESIZE; result[SizeHandleElement::TOPLEFT] = SizeHandleElement::RESIZE; @@ -51,8 +48,7 @@ create_location_to_type_map() } QMap<SizeHandleElement::EHandleLocation, SizeHandleElement::EHandleLocation> -getMapOfOppositeCorners() -{ +getMapOfOppositeCorners() { QMap<SizeHandleElement::EHandleLocation, SizeHandleElement::EHandleLocation> result; result[SizeHandleElement::TOPLEFT] = SizeHandleElement::BOTTOMRIGHT; result[SizeHandleElement::TOPMIDDLE] = SizeHandleElement::BOTTOMMIDLE; @@ -81,19 +77,16 @@ QMap<SizeHandleElement::EHandleLocation, SizeHandleElement::EHandleLocation> SizeHandleElement::SizeHandleElement(EHandleLocation pointType, QGraphicsObject* parent) : QGraphicsObject(parent) , m_handleLocation(pointType) - , m_handleType(m_location_to_type[pointType]) -{ + , m_handleType(m_location_to_type[pointType]) { setCursor(m_cursors[m_handleLocation]); setParentItem(parent); } -QRectF SizeHandleElement::boundingRect() const -{ +QRectF SizeHandleElement::boundingRect() const { return QRectF(-4, -4, 8, 8); } -void SizeHandleElement::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) -{ +void SizeHandleElement::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { painter->setRenderHints(QPainter::Antialiasing); painter->setBrush(MaskEditorHelper::getSelectionMarkerBrush()); @@ -105,21 +98,18 @@ void SizeHandleElement::paint(QPainter* painter, const QStyleOptionGraphicsItem* } } -void SizeHandleElement::mousePressEvent(QGraphicsSceneMouseEvent* event) -{ +void SizeHandleElement::mousePressEvent(QGraphicsSceneMouseEvent* event) { emit resize_request(true); QGraphicsObject::mousePressEvent(event); } -void SizeHandleElement::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) -{ +void SizeHandleElement::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { emit resize_request(false); QGraphicsObject::mouseReleaseEvent(event); } //! set position from location type using coordinates of external rectangle -void SizeHandleElement::updateHandleElementPosition(const QRectF& rect) -{ +void SizeHandleElement::updateHandleElementPosition(const QRectF& rect) { if (m_handleLocation == TOPLEFT) { setPos(rect.topLeft()); } @@ -153,22 +143,18 @@ void SizeHandleElement::updateHandleElementPosition(const QRectF& rect) } } -SizeHandleElement::EHandleLocation SizeHandleElement::getHandleLocation() const -{ +SizeHandleElement::EHandleLocation SizeHandleElement::getHandleLocation() const { return m_handleLocation; } -SizeHandleElement::EHandleLocation SizeHandleElement::getOppositeHandleLocation() const -{ +SizeHandleElement::EHandleLocation SizeHandleElement::getOppositeHandleLocation() const { return m_opposite_handle_location[m_handleLocation]; } -SizeHandleElement::EHandleType SizeHandleElement::getHandleType() const -{ +SizeHandleElement::EHandleType SizeHandleElement::getHandleType() const { return m_handleType; } -void SizeHandleElement::update_view() -{ +void SizeHandleElement::update_view() { update(); } diff --git a/GUI/coregui/Views/MaskWidgets/SizeHandleElement.h b/GUI/coregui/Views/MaskWidgets/SizeHandleElement.h index 90d08dacfc2de1e1f7d9981a39fd7c87e359b313..d04caccda19bc52f4d9cbc30cc0b46f8f9009807 100644 --- a/GUI/coregui/Views/MaskWidgets/SizeHandleElement.h +++ b/GUI/coregui/Views/MaskWidgets/SizeHandleElement.h @@ -23,8 +23,7 @@ //! Size handle on top of RectangleView represented as small circle or small rectangle. //! Placed either in corners on in the middle of the edge. -class SizeHandleElement : public QGraphicsObject -{ +class SizeHandleElement : public QGraphicsObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaterialEditor/ExternalProperty.cpp b/GUI/coregui/Views/MaterialEditor/ExternalProperty.cpp index 51960f3948708ecb7bf83a16aa304f11fbffc8da..ad9667f027f98c6f96d273cf24d5277252613e00 100644 --- a/GUI/coregui/Views/MaterialEditor/ExternalProperty.cpp +++ b/GUI/coregui/Views/MaterialEditor/ExternalProperty.cpp @@ -18,38 +18,31 @@ ExternalProperty::ExternalProperty() = default; -QString ExternalProperty::text() const -{ +QString ExternalProperty::text() const { return m_text; } -void ExternalProperty::setText(const QString& name) -{ +void ExternalProperty::setText(const QString& name) { m_text = name; } -QColor ExternalProperty::color() const -{ +QColor ExternalProperty::color() const { return m_color; } -void ExternalProperty::setColor(const QColor& color) -{ +void ExternalProperty::setColor(const QColor& color) { m_color = color; } -QString ExternalProperty::identifier() const -{ +QString ExternalProperty::identifier() const { return m_identifier; } -void ExternalProperty::setIdentifier(const QString& identifier) -{ +void ExternalProperty::setIdentifier(const QString& identifier) { m_identifier = identifier; } -QPixmap ExternalProperty::pixmap() const -{ +QPixmap ExternalProperty::pixmap() const { QPixmap pixmap(10, 10); pixmap.fill(color()); return pixmap; @@ -57,23 +50,20 @@ QPixmap ExternalProperty::pixmap() const //! Returns true if property is in valid state (i.e. have at least one member defined). -bool ExternalProperty::isValid() const -{ +bool ExternalProperty::isValid() const { if (m_identifier.isEmpty() && m_text.isEmpty() && !m_color.isValid()) return false; return true; } -QVariant ExternalProperty::variant() const -{ +QVariant ExternalProperty::variant() const { QVariant variant; variant.setValue(*this); return variant; } -bool ExternalProperty::operator==(const ExternalProperty& other) const -{ +bool ExternalProperty::operator==(const ExternalProperty& other) const { if (m_identifier != other.m_identifier) return false; if (m_text != other.m_text) @@ -84,12 +74,10 @@ bool ExternalProperty::operator==(const ExternalProperty& other) const return true; } -bool ExternalProperty::operator!=(const ExternalProperty& other) const -{ +bool ExternalProperty::operator!=(const ExternalProperty& other) const { return !(*this == other); } -bool ExternalProperty::operator<(const ExternalProperty& other) const -{ +bool ExternalProperty::operator<(const ExternalProperty& other) const { return m_identifier < other.m_identifier && m_text < other.m_text; } diff --git a/GUI/coregui/Views/MaterialEditor/ExternalProperty.h b/GUI/coregui/Views/MaterialEditor/ExternalProperty.h index ab9624d26f55f1a514d1c1f662d1fde411240770..f8bc58032e259ca99b4961745a8dcde94c2978e2 100644 --- a/GUI/coregui/Views/MaterialEditor/ExternalProperty.h +++ b/GUI/coregui/Views/MaterialEditor/ExternalProperty.h @@ -24,8 +24,7 @@ //! The ExternalProperty class defines custom QVariant property to carry the text, color and //! an identifier. -class ExternalProperty -{ +class ExternalProperty { public: explicit ExternalProperty(); diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp b/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp index 111a71026c6776a4dd8d7c6bcd376bc51e09e90a..9aa1250bddc38b1ca3a847681a57d626bfeb7118 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp @@ -30,8 +30,7 @@ MaterialEditor::MaterialEditor(MaterialModel* materialModel, QWidget* parent) , m_splitter(new QSplitter) , m_listView(new QListView) , m_componentEditor(new ComponentEditor) - , m_model_was_modified(false) -{ + , m_model_was_modified(false) { setWindowTitle("MaterialEditorWidget"); setMinimumSize(128, 128); resize(512, 400); @@ -53,21 +52,18 @@ MaterialEditor::MaterialEditor(MaterialModel* materialModel, QWidget* parent) init_views(); } -QItemSelectionModel* MaterialEditor::selectionModel() -{ +QItemSelectionModel* MaterialEditor::selectionModel() { ASSERT(m_listView); return m_listView->selectionModel(); } -MaterialItem* MaterialEditor::selectedMaterial() -{ +MaterialItem* MaterialEditor::selectedMaterial() { auto selected = selectionModel()->currentIndex(); return selected.isValid() ? m_materialModel->materialFromIndex(selected) : nullptr; } //! Sets selection corresponding to initial material property -void MaterialEditor::setInitialMaterialProperty(const ExternalProperty& matProperty) -{ +void MaterialEditor::setInitialMaterialProperty(const ExternalProperty& matProperty) { if (MaterialItem* mat = m_materialModel->materialFromIdentifier(matProperty.identifier())) { selectionModel()->clearSelection(); selectionModel()->setCurrentIndex(m_materialModel->indexOfItem(mat), @@ -77,13 +73,11 @@ void MaterialEditor::setInitialMaterialProperty(const ExternalProperty& matPrope } } -bool MaterialEditor::modelWasChanged() const -{ +bool MaterialEditor::modelWasChanged() const { return m_model_was_modified; } -void MaterialEditor::onSelectionChanged(const QItemSelection& selected, const QItemSelection&) -{ +void MaterialEditor::onSelectionChanged(const QItemSelection& selected, const QItemSelection&) { QModelIndexList indices = selected.indexes(); if (indices.isEmpty()) { @@ -94,29 +88,24 @@ void MaterialEditor::onSelectionChanged(const QItemSelection& selected, const QI } } -void MaterialEditor::onDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&) -{ +void MaterialEditor::onDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&) { m_model_was_modified = true; } -void MaterialEditor::onRowsInserted(const QModelIndex&, int, int) -{ +void MaterialEditor::onRowsInserted(const QModelIndex&, int, int) { m_model_was_modified = true; } -void MaterialEditor::onRowsRemoved(const QModelIndex&, int, int) -{ +void MaterialEditor::onRowsRemoved(const QModelIndex&, int, int) { m_model_was_modified = true; } //! Context menu reimplemented to supress default menu -void MaterialEditor::contextMenuEvent(QContextMenuEvent* event) -{ +void MaterialEditor::contextMenuEvent(QContextMenuEvent* event) { Q_UNUSED(event); } -void MaterialEditor::init_views() -{ +void MaterialEditor::init_views() { connect(m_materialModel, &MaterialModel::dataChanged, this, &MaterialEditor::onDataChanged); connect(m_materialModel, &MaterialModel::rowsInserted, this, &MaterialEditor::onRowsInserted); connect(m_materialModel, &MaterialModel::rowsRemoved, this, &MaterialEditor::onRowsRemoved); diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditor.h b/GUI/coregui/Views/MaterialEditor/MaterialEditor.h index 6db44820b2b101a58faebbcb643abe3695a6826c..904d7d066d413b0e9e7c40fe39039baf1313d0ac 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditor.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditor.h @@ -29,8 +29,7 @@ class ExternalProperty; //! Main widget of MaterialEditor -class MaterialEditor : public QWidget -{ +class MaterialEditor : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp index 50c42f77c9a4d3c27f05c5ebe6586cd15b4354dd..4b55c704fa83dd69046d326c9c7a4d182d99f458 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp @@ -23,14 +23,12 @@ #include <QSettings> #include <QVBoxLayout> -namespace -{ +namespace { const QSize default_dialog_size(512, 400); } MaterialEditorDialog::MaterialEditorDialog(MaterialModel* materialModel, QWidget* parent) - : QDialog(parent), m_origMaterialModel(materialModel), m_materialEditor(nullptr) -{ + : QDialog(parent), m_origMaterialModel(materialModel), m_materialEditor(nullptr) { setWindowTitle("Material Editor"); setMinimumSize(128, 128); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -48,8 +46,7 @@ MaterialEditorDialog::MaterialEditorDialog(MaterialModel* materialModel, QWidget } //! replaces original material model with the model modified by MaterialEditor -void MaterialEditorDialog::onOKButton() -{ +void MaterialEditorDialog::onOKButton() { if (m_materialEditor->modelWasChanged()) { m_origMaterialModel->clear(); m_origMaterialModel->initFrom(m_tmpMaterialModel.get(), 0); @@ -58,14 +55,12 @@ void MaterialEditorDialog::onOKButton() accept(); } -void MaterialEditorDialog::onCancelButton() -{ +void MaterialEditorDialog::onCancelButton() { writeSettings(); reject(); } -QBoxLayout* MaterialEditorDialog::createButtonLayout() -{ +QBoxLayout* MaterialEditorDialog::createButtonLayout() { auto result = new QHBoxLayout; auto okButton = new QPushButton("OK"); @@ -82,16 +77,14 @@ QBoxLayout* MaterialEditorDialog::createButtonLayout() return result; } -void MaterialEditorDialog::init_material_editor() -{ +void MaterialEditorDialog::init_material_editor() { ASSERT(m_origMaterialModel); m_tmpMaterialModel.reset(m_origMaterialModel->createCopy()); m_materialEditor = new MaterialEditor(m_tmpMaterialModel.get(), this); readSettings(); } -void MaterialEditorDialog::readSettings() -{ +void MaterialEditorDialog::readSettings() { QSettings settings; if (settings.childGroups().contains(Constants::S_MATERIALEDITOR)) { settings.beginGroup(Constants::S_MATERIALEDITOR); @@ -104,8 +97,7 @@ void MaterialEditorDialog::readSettings() } } -void MaterialEditorDialog::writeSettings() -{ +void MaterialEditorDialog::writeSettings() { QSettings settings; settings.beginGroup(Constants::S_MATERIALEDITOR); settings.setValue(Constants::S_WINDOWSIZE, this->size()); @@ -113,8 +105,7 @@ void MaterialEditorDialog::writeSettings() settings.endGroup(); } -ExternalProperty MaterialEditorDialog::selectedMaterialProperty() -{ +ExternalProperty MaterialEditorDialog::selectedMaterialProperty() { if (MaterialItem* material = m_materialEditor->selectedMaterial()) return MaterialItemUtils::materialProperty(*material); @@ -122,8 +113,7 @@ ExternalProperty MaterialEditorDialog::selectedMaterialProperty() } //! -void MaterialEditorDialog::setMaterialProperty(const ExternalProperty& matProperty) -{ +void MaterialEditorDialog::setMaterialProperty(const ExternalProperty& matProperty) { ASSERT(m_materialEditor); m_materialEditor->setInitialMaterialProperty(matProperty); diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h index 68afaba18f557c016b19741b6ac15b677cc99ad2..20db5858b3d3f6301b4953b6e9153d672d481916 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h @@ -27,8 +27,7 @@ class QBoxLayout; //! It's main function is to return MaterialModel to original state, if user decided to cancel //! changes. -class MaterialEditorDialog : public QDialog -{ +class MaterialEditorDialog : public QDialog { Q_OBJECT public: diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.cpp b/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.cpp index 81c3606ea16153576719bd652f9907405b03695c..b57ec7362083c8bad554857244ead30a55d7a892 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.cpp @@ -21,8 +21,7 @@ #include <QMenu> #include <QVariant> -namespace -{ +namespace { const int toolbar_icon_size = 32; } @@ -32,8 +31,7 @@ MaterialEditorToolBar::MaterialEditorToolBar(MaterialModel* materialModel, QWidg , m_selectionModel(nullptr) , m_newMaterialAction(nullptr) , m_cloneMaterialAction(nullptr) - , m_removeMaterialAction(nullptr) -{ + , m_removeMaterialAction(nullptr) { setIconSize(QSize(toolbar_icon_size, toolbar_icon_size)); setToolButtonStyle(Qt::ToolButtonTextBesideIcon); @@ -59,13 +57,11 @@ MaterialEditorToolBar::MaterialEditorToolBar(MaterialModel* materialModel, QWidg addAction(m_removeMaterialAction); } -void MaterialEditorToolBar::setSelectionModel(QItemSelectionModel* selectionModel) -{ +void MaterialEditorToolBar::setSelectionModel(QItemSelectionModel* selectionModel) { m_selectionModel = selectionModel; } -void MaterialEditorToolBar::onCustomContextMenuRequested(const QPoint& point) -{ +void MaterialEditorToolBar::onCustomContextMenuRequested(const QPoint& point) { QListView* listView = qobject_cast<QListView*>(sender()); ASSERT(listView); QMenu menu; @@ -73,21 +69,18 @@ void MaterialEditorToolBar::onCustomContextMenuRequested(const QPoint& point) menu.exec(listView->mapToGlobal(point)); } -void MaterialEditorToolBar::onNewMaterialAction() -{ +void MaterialEditorToolBar::onNewMaterialAction() { m_materialModel->addRefractiveMaterial("unnamed", 0.0, 0.0); // vacuum } -void MaterialEditorToolBar::onCloneMaterialAction() -{ +void MaterialEditorToolBar::onCloneMaterialAction() { auto selected = m_selectionModel->currentIndex(); if (selected.isValid()) m_materialModel->cloneMaterial(selected); } -void MaterialEditorToolBar::onRemoveMaterialAction() -{ +void MaterialEditorToolBar::onRemoveMaterialAction() { ASSERT(m_materialModel); ASSERT(m_selectionModel); @@ -97,8 +90,7 @@ void MaterialEditorToolBar::onRemoveMaterialAction() m_materialModel->removeRows(selected.row(), 1, selected.parent()); } -void MaterialEditorToolBar::initItemContextMenu(QMenu& menu) -{ +void MaterialEditorToolBar::initItemContextMenu(QMenu& menu) { menu.addAction(m_newMaterialAction); menu.addAction(m_cloneMaterialAction); menu.addSeparator(); diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.h b/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.h index 2e591f3ee89d18eb1d1d667783fbd66d431f0709..c1bd5e2312f402898b34eb8545e9fc56dd9e9bd8 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.h @@ -25,8 +25,7 @@ class QMenu; //! Toolbar for MaterialEditor. -class MaterialEditorToolBar : public QToolBar -{ +class MaterialEditorToolBar : public QToolBar { Q_OBJECT public: MaterialEditorToolBar(MaterialModel* materialModel, QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp index 87211fa48752ca2293a830a0d99b383eea4ce57c..6f99121d5f5a7aa2019be64a378ba0d29e466b30 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp @@ -31,11 +31,9 @@ #include "Sample/Material/Material.h" #include <QColorDialog> -namespace -{ +namespace { -std::map<QString, QString> get_tag_map() -{ +std::map<QString, QString> get_tag_map() { std::map<QString, QString> result = { {"ParticleComposition", ParticleCompositionItem::T_PARTICLES}, {"ParticleDistribution", ParticleDistributionItem::T_PARTICLES}, @@ -45,8 +43,7 @@ std::map<QString, QString> get_tag_map() } } // namespace -QColor MaterialItemUtils::suggestMaterialColor(const QString& name) -{ +QColor MaterialItemUtils::suggestMaterialColor(const QString& name) { if (name.contains("Vacuum")) { return QColor(179, 242, 255); } else if (name.contains("Substrate")) { @@ -60,8 +57,7 @@ QColor MaterialItemUtils::suggestMaterialColor(const QString& name) } } -ExternalProperty MaterialItemUtils::defaultMaterialProperty() -{ +ExternalProperty MaterialItemUtils::defaultMaterialProperty() { if (!AppSvc::materialModel()) return ExternalProperty(); @@ -71,16 +67,14 @@ ExternalProperty MaterialItemUtils::defaultMaterialProperty() } std::unique_ptr<Material> -MaterialItemUtils::createDomainMaterial(const ExternalProperty& material_property) -{ +MaterialItemUtils::createDomainMaterial(const ExternalProperty& material_property) { MaterialItem* materialItem = findMaterial(material_property); return materialItem->createMaterial(); } std::unique_ptr<Material> MaterialItemUtils::createDomainMaterial(const ExternalProperty& material_property, - const MaterialItemContainer& container) -{ + const MaterialItemContainer& container) { const MaterialItem* material_item = container.findMaterialById(material_property.identifier()); if (!material_item) throw GUIHelpers::Error("MaterialUtils::createDomainMaterial() -> Error. Can't find " @@ -89,8 +83,7 @@ MaterialItemUtils::createDomainMaterial(const ExternalProperty& material_propert return material_item->createMaterial(); } -MaterialItem* MaterialItemUtils::findMaterial(const ExternalProperty& material_property) -{ +MaterialItem* MaterialItemUtils::findMaterial(const ExternalProperty& material_property) { if (!AppSvc::materialModel()) throw GUIHelpers::Error("MaterialItemUtils::findMaterial() -> Error. " "Attempt to access non-existing material model"); @@ -106,8 +99,7 @@ MaterialItem* MaterialItemUtils::findMaterial(const ExternalProperty& material_p //! Returns material tag for given item. Returns empty string, if item doesn't have materials. -QString MaterialItemUtils::materialTag(const SessionItem& item) -{ +QString MaterialItemUtils::materialTag(const SessionItem& item) { QString result; if (item.modelType() == "Particle") { result = ParticleItem::P_MATERIAL; @@ -119,15 +111,13 @@ QString MaterialItemUtils::materialTag(const SessionItem& item) //! Returns list of model types which contains registered MaterialProperty. -QStringList MaterialItemUtils::materialRelatedModelTypes() -{ +QStringList MaterialItemUtils::materialRelatedModelTypes() { return {"Particle", "Layer"}; } //! Constructs material property for given material. -ExternalProperty MaterialItemUtils::materialProperty(const SessionItem& materialItem) -{ +ExternalProperty MaterialItemUtils::materialProperty(const SessionItem& materialItem) { ExternalProperty result; ExternalProperty colorProperty = @@ -139,8 +129,7 @@ ExternalProperty MaterialItemUtils::materialProperty(const SessionItem& material return result; } -ExternalProperty MaterialItemUtils::colorProperty(const QColor& color) -{ +ExternalProperty MaterialItemUtils::colorProperty(const QColor& color) { ExternalProperty result; result.setColor(color); result.setText(QString("[%1, %2, %3] (%4)") @@ -151,8 +140,7 @@ ExternalProperty MaterialItemUtils::colorProperty(const QColor& color) return result; } -ExternalProperty MaterialItemUtils::selectMaterialProperty(const ExternalProperty& previous) -{ +ExternalProperty MaterialItemUtils::selectMaterialProperty(const ExternalProperty& previous) { MaterialEditorDialog dialog(AppSvc::materialModel()); dialog.setMaterialProperty(previous); if (dialog.exec() == QDialog::Accepted) { @@ -162,8 +150,7 @@ ExternalProperty MaterialItemUtils::selectMaterialProperty(const ExternalPropert return ExternalProperty(); } -ExternalProperty MaterialItemUtils::selectColorProperty(const ExternalProperty& previous) -{ +ExternalProperty MaterialItemUtils::selectColorProperty(const ExternalProperty& previous) { ExternalProperty result; #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) @@ -182,8 +169,7 @@ ExternalProperty MaterialItemUtils::selectColorProperty(const ExternalProperty& return result; } -QVector<SessionItem*> MaterialItemUtils::materialPropertyItems(SessionItem* item) -{ +QVector<SessionItem*> MaterialItemUtils::materialPropertyItems(SessionItem* item) { static const std::map<QString, QString> tag_map = get_tag_map(); QVector<SessionItem*> materials; QList<SessionItem*> particle_holders{item}; diff --git a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h index e916080c110860bf6d312bc229ecb3056428a870..35dff56f88cc21331ce407ff4f1e445996e1a6b4 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h @@ -24,8 +24,7 @@ class Material; class MaterialItemContainer; -namespace MaterialItemUtils -{ +namespace MaterialItemUtils { QColor suggestMaterialColor(const QString& name); ExternalProperty defaultMaterialProperty(); diff --git a/GUI/coregui/Views/PropertyEditor/ComponentEditor.cpp b/GUI/coregui/Views/PropertyEditor/ComponentEditor.cpp index 886d4f3f6581c36b0695600c17f981df4528f8da..a3f476930a6e70859822abe2c1c73efd1c628689 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentEditor.cpp +++ b/GUI/coregui/Views/PropertyEditor/ComponentEditor.cpp @@ -19,11 +19,9 @@ #include <QBoxLayout> #include <QGroupBox> -namespace -{ +namespace { -template <typename T> T* createGroupBox(ComponentView* componentView, QString title) -{ +template <typename T> T* createGroupBox(ComponentView* componentView, QString title) { auto box = new T(title); auto boxlayout = new QVBoxLayout; boxlayout->setContentsMargins(0, 0, 0, 0); @@ -34,8 +32,7 @@ template <typename T> T* createGroupBox(ComponentView* componentView, QString ti } // namespace ComponentEditor::ComponentEditor(EditorType editorType, const QString& title) - : m_type(editorType), m_componentView(nullptr), m_item(nullptr), m_title(title) -{ + : m_type(editorType), m_componentView(nullptr), m_item(nullptr), m_title(title) { m_componentView = createComponentView(); auto mainLayout = new QVBoxLayout; @@ -62,32 +59,27 @@ ComponentEditor::ComponentEditor(EditorType editorType, const QString& title) setLayout(mainLayout); } -void ComponentEditor::setItem(SessionItem* item) -{ +void ComponentEditor::setItem(SessionItem* item) { m_item = item; m_componentView->setItem(item); } -void ComponentEditor::clearEditor() -{ +void ComponentEditor::clearEditor() { m_item = nullptr; m_componentView->clearEditor(); } -void ComponentEditor::addItem(SessionItem* item) -{ +void ComponentEditor::addItem(SessionItem* item) { if (!m_item) m_item = item; m_componentView->addItem(item); } -void ComponentEditor::onDialogRequest() -{ +void ComponentEditor::onDialogRequest() { emit dialogRequest(m_item, m_title); } -ComponentView* ComponentEditor::createComponentView() -{ +ComponentView* ComponentEditor::createComponentView() { ComponentView* result(nullptr); if (m_type.testFlag(Tree)) { diff --git a/GUI/coregui/Views/PropertyEditor/ComponentEditor.h b/GUI/coregui/Views/PropertyEditor/ComponentEditor.h index bd57a6f4d50e464e1fbc9cfc5ea1067dea6a4e29..7af2544f0522b6c903b8310eda1358bd243ef176 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentEditor.h +++ b/GUI/coregui/Views/PropertyEditor/ComponentEditor.h @@ -24,8 +24,7 @@ class QBoxLayout; //! Component editor for SessionItem. Can have various appearance depending //! on EditorFlags -class ComponentEditor : public QWidget -{ +class ComponentEditor : public QWidget { Q_OBJECT public: enum EditorFlags { diff --git a/GUI/coregui/Views/PropertyEditor/ComponentFlatView.cpp b/GUI/coregui/Views/PropertyEditor/ComponentFlatView.cpp index 5e8f45a888d89bdf9930daed393472fdc3042de0..b43f28d153a33bb2b6635cf98d3a394f55b077e4 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentFlatView.cpp +++ b/GUI/coregui/Views/PropertyEditor/ComponentFlatView.cpp @@ -30,8 +30,7 @@ ComponentFlatView::ComponentFlatView(QWidget* parent) , m_mainLayout(new QVBoxLayout) , m_gridLayout(nullptr) , m_model(nullptr) - , m_show_children(true) -{ + , m_show_children(true) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_mainLayout->setMargin(10); @@ -44,8 +43,7 @@ ComponentFlatView::ComponentFlatView(QWidget* parent) ComponentFlatView::~ComponentFlatView() = default; -void ComponentFlatView::setItem(SessionItem* item) -{ +void ComponentFlatView::setItem(SessionItem* item) { clearEditor(); m_topItems.push_back(item); @@ -53,8 +51,7 @@ void ComponentFlatView::setItem(SessionItem* item) updateItemProperties(); } -void ComponentFlatView::addItem(SessionItem* item) -{ +void ComponentFlatView::addItem(SessionItem* item) { if (m_topItems.isEmpty()) { setItem(item); return; @@ -63,8 +60,7 @@ void ComponentFlatView::addItem(SessionItem* item) updateItemProperties(); } -void ComponentFlatView::setModel(SessionModel* model) -{ +void ComponentFlatView::setModel(SessionModel* model) { if (m_model) { disconnect(m_model, &SessionModel::dataChanged, this, &ComponentFlatView::onDataChanged); } @@ -74,8 +70,7 @@ void ComponentFlatView::setModel(SessionModel* model) } } -void ComponentFlatView::clearLayout() -{ +void ComponentFlatView::clearLayout() { ASSERT(m_gridLayout); LayoutUtils::clearGridLayout(m_gridLayout, false); @@ -84,14 +79,12 @@ void ComponentFlatView::clearLayout() m_widgetItems.clear(); } -void ComponentFlatView::setShowChildren(bool show) -{ +void ComponentFlatView::setShowChildren(bool show) { m_show_children = show; } void ComponentFlatView::onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, - const QVector<int>& roles) -{ + const QVector<int>& roles) { Q_UNUSED(bottomRight); SessionItem* item = m_model->itemForIndex(topLeft); ASSERT(item); @@ -102,14 +95,12 @@ void ComponentFlatView::onDataChanged(const QModelIndex& topLeft, const QModelIn updateItemRoles(item); } -void ComponentFlatView::clearEditor() -{ +void ComponentFlatView::clearEditor() { m_topItems.clear(); clearLayout(); } -void ComponentFlatView::updateItemProperties() -{ +void ComponentFlatView::updateItemProperties() { clearLayout(); QList<const SessionItem*> allitems; @@ -128,15 +119,13 @@ void ComponentFlatView::updateItemProperties() } } -void ComponentFlatView::updateItemRoles(SessionItem* item) -{ +void ComponentFlatView::updateItemRoles(SessionItem* item) { for (auto widget : m_widgetItems) if (widget->item() == item) widget->updateItemRoles(); } -void ComponentFlatView::initGridLayout() -{ +void ComponentFlatView::initGridLayout() { delete m_gridLayout; m_gridLayout = new QGridLayout; m_gridLayout->setSpacing(6); @@ -144,8 +133,7 @@ void ComponentFlatView::initGridLayout() m_mainLayout->addStretch(1); } -PropertyWidgetItem* ComponentFlatView::createWidget(const SessionItem* item) -{ +PropertyWidgetItem* ComponentFlatView::createWidget(const SessionItem* item) { auto editor = PropertyEditorFactory::CreateEditor(*item); if (!editor) return nullptr; diff --git a/GUI/coregui/Views/PropertyEditor/ComponentFlatView.h b/GUI/coregui/Views/PropertyEditor/ComponentFlatView.h index f31b7d740f45a20b0faf78be52f68686a91b62f2..4071a9af805d4e41a4481af0fd52e0a1b9dc5320 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentFlatView.h +++ b/GUI/coregui/Views/PropertyEditor/ComponentFlatView.h @@ -28,8 +28,7 @@ class PropertyWidgetItem; //! properties are presented as widgets in grid layout. //! Shows only PropertyItems and current items of GroupProperties. -class ComponentFlatView : public ComponentView -{ +class ComponentFlatView : public ComponentView { Q_OBJECT public: ComponentFlatView(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/PropertyEditor/ComponentTreeActions.cpp b/GUI/coregui/Views/PropertyEditor/ComponentTreeActions.cpp index 8da6b3f4adc517889778cd1e0ff3016f3d1194ec..4b390b83523ceebe6aa2a8392f41c6aea785a508 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentTreeActions.cpp +++ b/GUI/coregui/Views/PropertyEditor/ComponentTreeActions.cpp @@ -23,8 +23,7 @@ ComponentTreeActions::ComponentTreeActions(QObject* parent) : QObject(parent) {} //! which will allow user to switch between scientific notation and the notation //! with a specified number of decimals. -void ComponentTreeActions::onCustomContextMenuRequested(const QPoint& point, SessionItem& item) -{ +void ComponentTreeActions::onCustomContextMenuRequested(const QPoint& point, SessionItem& item) { bool sc_editor = item.editorType() == "ScientificDouble"; QMenu menu; diff --git a/GUI/coregui/Views/PropertyEditor/ComponentTreeActions.h b/GUI/coregui/Views/PropertyEditor/ComponentTreeActions.h index 40953b3dad2230f80a30d1bae3bdce158fc0d231..8eba50f71dcf21938e5f783fcd2c0c2933310a96 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentTreeActions.h +++ b/GUI/coregui/Views/PropertyEditor/ComponentTreeActions.h @@ -21,8 +21,7 @@ class SessionItem; //! Additional action for ComponentTreeView. -class ComponentTreeActions : public QObject -{ +class ComponentTreeActions : public QObject { Q_OBJECT public: ComponentTreeActions(QObject* parent = nullptr); diff --git a/GUI/coregui/Views/PropertyEditor/ComponentTreeView.cpp b/GUI/coregui/Views/PropertyEditor/ComponentTreeView.cpp index dac6f6b2d3daad84c9ed491b5266c470032a8fa2..c3c470774fa0762313235820f1c6b5b0607e0043 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentTreeView.cpp +++ b/GUI/coregui/Views/PropertyEditor/ComponentTreeView.cpp @@ -31,8 +31,7 @@ ComponentTreeView::ComponentTreeView(QWidget* parent) , m_placeHolderModel(new QStandardItemModel(this)) , m_eventFilter(new RightMouseButtonEater) , m_actions(new ComponentTreeActions(this)) - , m_show_root_item(false) -{ + , m_show_root_item(false) { auto layout = new QVBoxLayout; layout->setMargin(0); @@ -61,8 +60,7 @@ ComponentTreeView::ComponentTreeView(QWidget* parent) ComponentTreeView::~ComponentTreeView() = default; -void ComponentTreeView::setItem(SessionItem* item) -{ +void ComponentTreeView::setItem(SessionItem* item) { if (!item) { setModel(nullptr); return; @@ -72,13 +70,11 @@ void ComponentTreeView::setItem(SessionItem* item) m_tree->expandAll(); } -void ComponentTreeView::clearEditor() -{ +void ComponentTreeView::clearEditor() { m_tree->setModel(m_placeHolderModel); } -void ComponentTreeView::setModel(SessionModel* model) -{ +void ComponentTreeView::setModel(SessionModel* model) { m_proxyModel->setSessionModel(model); if (model) m_tree->setModel(m_proxyModel); @@ -86,8 +82,7 @@ void ComponentTreeView::setModel(SessionModel* model) m_tree->setModel(m_placeHolderModel); } -void ComponentTreeView::setRootIndex(const QModelIndex& index, bool show_root_item) -{ +void ComponentTreeView::setRootIndex(const QModelIndex& index, bool show_root_item) { if (QWidget* editor = m_tree->indexWidget(m_tree->currentIndex())) m_delegate->closeEditor(editor, QAbstractItemDelegate::NoHint); ASSERT(m_proxyModel); @@ -96,18 +91,15 @@ void ComponentTreeView::setRootIndex(const QModelIndex& index, bool show_root_it m_tree->setRootIndex(m_proxyModel->mapFromSource(index)); } -void ComponentTreeView::setShowHeader(bool show) -{ +void ComponentTreeView::setShowHeader(bool show) { m_tree->setHeaderHidden(!show); } -void ComponentTreeView::setShowRootItem(bool show) -{ +void ComponentTreeView::setShowRootItem(bool show) { m_show_root_item = show; } -void ComponentTreeView::onCustomContextMenuRequested(const QPoint& pos) -{ +void ComponentTreeView::onCustomContextMenuRequested(const QPoint& pos) { auto point = m_tree->mapToGlobal(pos); auto treeIndex = m_tree->indexAt(pos); if (!treeIndex.isValid()) diff --git a/GUI/coregui/Views/PropertyEditor/ComponentTreeView.h b/GUI/coregui/Views/PropertyEditor/ComponentTreeView.h index 56d965bfb8e6cb010a030af31e92b74e24f668fb..8f7e7dcd0a2ce703183ef8e20a06bfe28ce53267 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentTreeView.h +++ b/GUI/coregui/Views/PropertyEditor/ComponentTreeView.h @@ -31,8 +31,7 @@ class ComponentTreeActions; //! Component property tree for SessionItems. //! Shows only PropertyItems and current items of GroupProperties. -class ComponentTreeView : public ComponentView -{ +class ComponentTreeView : public ComponentView { Q_OBJECT public: ComponentTreeView(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/PropertyEditor/ComponentUtils.cpp b/GUI/coregui/Views/PropertyEditor/ComponentUtils.cpp index b29fdc10853f526985841312cb71f6400aa0ce94..244f5b94f3e19b584a42dffe538e03d4a4b4541a 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentUtils.cpp +++ b/GUI/coregui/Views/PropertyEditor/ComponentUtils.cpp @@ -15,13 +15,11 @@ #include "GUI/coregui/Views/PropertyEditor/ComponentUtils.h" #include "GUI/coregui/Models/SessionItem.h" -namespace -{ +namespace { QList<const SessionItem*> groupItems(const SessionItem& item); } -QStringList ComponentUtils::propertyRelatedTypes() -{ +QStringList ComponentUtils::propertyRelatedTypes() { QStringList result = QStringList() << "Property" << "GroupProperty" << "Vector" @@ -31,8 +29,7 @@ QStringList ComponentUtils::propertyRelatedTypes() return result; } -QList<const SessionItem*> ComponentUtils::componentItems(const SessionItem& item) -{ +QList<const SessionItem*> ComponentUtils::componentItems(const SessionItem& item) { static QStringList propertyRelated = ComponentUtils::propertyRelatedTypes(); QList<const SessionItem*> result; @@ -61,10 +58,8 @@ QList<const SessionItem*> ComponentUtils::componentItems(const SessionItem& item return result; } -namespace -{ -QList<const SessionItem*> groupItems(const SessionItem& item) -{ +namespace { +QList<const SessionItem*> groupItems(const SessionItem& item) { ASSERT(item.modelType() == "GroupProperty"); QList<const SessionItem*> result; diff --git a/GUI/coregui/Views/PropertyEditor/ComponentUtils.h b/GUI/coregui/Views/PropertyEditor/ComponentUtils.h index 67a1ff4102a249a4e2b5e4d56c61fc2bddbefa8b..23614816e3caba3c4cd9d841ff08be2db262ba0e 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentUtils.h +++ b/GUI/coregui/Views/PropertyEditor/ComponentUtils.h @@ -22,8 +22,7 @@ class SessionItem; //! Contains collection of utility functions to support editing of SessionItem's components. -namespace ComponentUtils -{ +namespace ComponentUtils { //! Returns list of strings representing modelTypes suitable for editing in component editors. QStringList propertyRelatedTypes(); diff --git a/GUI/coregui/Views/PropertyEditor/ComponentView.h b/GUI/coregui/Views/PropertyEditor/ComponentView.h index 1c43c8e5a44e171b7f8d2ee0b25080ac7bb507a7..2b05c5ad8c88d41e85fd11a57b78e19929cac475 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentView.h +++ b/GUI/coregui/Views/PropertyEditor/ComponentView.h @@ -21,8 +21,7 @@ class SessionItem; //! Base class for ComponentTreeView and ComponentFlatView. -class ComponentView : public QWidget -{ +class ComponentView : public QWidget { Q_OBJECT public: ComponentView(QWidget* parent = nullptr) : QWidget(parent) {} diff --git a/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp b/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp index 978ecf7566acf0043b647dc1401f8b49489833d4..b83db3e2cf4f23df472a565ccf65398ecd917394 100644 --- a/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp +++ b/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp @@ -32,12 +32,10 @@ #include <QToolButton> #include <cmath> -namespace -{ +namespace { //! Single step for QDoubleSpinBox. -double singleStep(int decimals) -{ +double singleStep(int decimals) { // For item with decimals=3 (i.e. 0.001) single step will be 0.1 return 1. / std::pow(10., decimals - 1); } @@ -46,8 +44,7 @@ double singleStep(int decimals) //! Sets the data from the model to editor. -void CustomEditor::setData(const QVariant& data) -{ +void CustomEditor::setData(const QVariant& data) { m_data = data; initEditor(); } @@ -58,8 +55,7 @@ void CustomEditor::initEditor() {} //! Saves the data from the editor and informs external delegates. -void CustomEditor::setDataIntern(const QVariant& data) -{ +void CustomEditor::setDataIntern(const QVariant& data) { m_data = data; dataChanged(m_data); } @@ -71,8 +67,7 @@ ExternalPropertyEditor::ExternalPropertyEditor(QWidget* parent) , m_textLabel(new QLabel) , m_pixmapLabel(new QLabel) , m_focusFilter(new LostFocusFilter(this)) - , m_extDialogType("ExtMaterialEditor") -{ + , m_extDialogType("ExtMaterialEditor") { setMouseTracking(true); setAutoFillBackground(true); @@ -98,13 +93,11 @@ ExternalPropertyEditor::ExternalPropertyEditor(QWidget* parent) setLayout(layout); } -void ExternalPropertyEditor::setExternalDialogType(const QString& editorType) -{ +void ExternalPropertyEditor::setExternalDialogType(const QString& editorType) { m_extDialogType = editorType; } -void ExternalPropertyEditor::buttonClicked() -{ +void ExternalPropertyEditor::buttonClicked() { // temporarily installing filter to prevent loss of focus caused by too insistent dialog installEventFilter(m_focusFilter); ExternalProperty property = m_data.value<ExternalProperty>(); @@ -124,8 +117,7 @@ void ExternalPropertyEditor::buttonClicked() setDataIntern(newProperty.variant()); } -void ExternalPropertyEditor::initEditor() -{ +void ExternalPropertyEditor::initEditor() { ASSERT(m_data.canConvert<ExternalProperty>()); ExternalProperty materialProperty = m_data.value<ExternalProperty>(); m_textLabel->setText(materialProperty.text()); @@ -135,8 +127,7 @@ void ExternalPropertyEditor::initEditor() // --- CustomComboEditor --- ComboPropertyEditor::ComboPropertyEditor(QWidget* parent) - : CustomEditor(parent), m_box(new QComboBox), m_wheel_event_filter(new WheelEventEater(this)) -{ + : CustomEditor(parent), m_box(new QComboBox), m_wheel_event_filter(new WheelEventEater(this)) { setAutoFillBackground(true); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); @@ -151,18 +142,15 @@ ComboPropertyEditor::ComboPropertyEditor(QWidget* parent) setConnected(true); } -QSize ComboPropertyEditor::sizeHint() const -{ +QSize ComboPropertyEditor::sizeHint() const { return m_box->sizeHint(); } -QSize ComboPropertyEditor::minimumSizeHint() const -{ +QSize ComboPropertyEditor::minimumSizeHint() const { return m_box->minimumSizeHint(); } -void ComboPropertyEditor::onIndexChanged(int index) -{ +void ComboPropertyEditor::onIndexChanged(int index) { ComboProperty comboProperty = m_data.value<ComboProperty>(); if (comboProperty.currentIndex() != index) { @@ -171,8 +159,7 @@ void ComboPropertyEditor::onIndexChanged(int index) } } -void ComboPropertyEditor::initEditor() -{ +void ComboPropertyEditor::initEditor() { setConnected(false); m_box->clear(); @@ -184,8 +171,7 @@ void ComboPropertyEditor::initEditor() //! Returns list of labels for QComboBox -QStringList ComboPropertyEditor::internLabels() -{ +QStringList ComboPropertyEditor::internLabels() { if (!m_data.canConvert<ComboProperty>()) return {}; ComboProperty comboProperty = m_data.value<ComboProperty>(); @@ -194,16 +180,14 @@ QStringList ComboPropertyEditor::internLabels() //! Returns index for QComboBox. -int ComboPropertyEditor::internIndex() -{ +int ComboPropertyEditor::internIndex() { if (!m_data.canConvert<ComboProperty>()) return 0; ComboProperty comboProperty = m_data.value<ComboProperty>(); return comboProperty.currentIndex(); } -void ComboPropertyEditor::setConnected(bool isConnected) -{ +void ComboPropertyEditor::setConnected(bool isConnected) { if (isConnected) connect(m_box, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ComboPropertyEditor::onIndexChanged, Qt::UniqueConnection); @@ -215,8 +199,7 @@ void ComboPropertyEditor::setConnected(bool isConnected) // --- ScientificDoublePropertyEditor --- ScientificDoublePropertyEditor::ScientificDoublePropertyEditor(QWidget* parent) - : CustomEditor(parent), m_lineEdit(new QLineEdit), m_validator(nullptr) -{ + : CustomEditor(parent), m_lineEdit(new QLineEdit), m_validator(nullptr) { setAutoFillBackground(true); auto layout = new QVBoxLayout; @@ -235,23 +218,20 @@ ScientificDoublePropertyEditor::ScientificDoublePropertyEditor(QWidget* parent) setLayout(layout); } -void ScientificDoublePropertyEditor::setLimits(const RealLimits& limits) -{ +void ScientificDoublePropertyEditor::setLimits(const RealLimits& limits) { double minimum = limits.hasLowerLimit() ? std::max(limits.lowerLimit(), -1e+200) : -1e+200; double maximum = limits.hasUpperLimit() ? std::min(limits.upperLimit(), +1e+200) : +1e+200; m_validator->setRange(minimum, maximum, 1000); } -void ScientificDoublePropertyEditor::onEditingFinished() -{ +void ScientificDoublePropertyEditor::onEditingFinished() { double new_value = m_lineEdit->text().toDouble(); if (new_value != m_data.toDouble()) setDataIntern(QVariant::fromValue(new_value)); } -void ScientificDoublePropertyEditor::initEditor() -{ +void ScientificDoublePropertyEditor::initEditor() { ASSERT(m_data.type() == QVariant::Double); m_lineEdit->setText(QString::number(m_data.toDouble(), 'g')); } @@ -259,8 +239,7 @@ void ScientificDoublePropertyEditor::initEditor() // --- DoubleEditor --- DoubleEditor::DoubleEditor(QWidget* parent) - : CustomEditor(parent), m_doubleEditor(new QDoubleSpinBox) -{ + : CustomEditor(parent), m_doubleEditor(new QDoubleSpinBox) { setAutoFillBackground(true); setFocusPolicy(Qt::StrongFocus); m_doubleEditor->setFocusPolicy(Qt::StrongFocus); @@ -281,8 +260,7 @@ DoubleEditor::DoubleEditor(QWidget* parent) setFocusProxy(m_doubleEditor); } -void DoubleEditor::setLimits(const RealLimits& limits) -{ +void DoubleEditor::setLimits(const RealLimits& limits) { m_doubleEditor->setMaximum(std::numeric_limits<double>::max()); m_doubleEditor->setMinimum(std::numeric_limits<double>::lowest()); @@ -292,22 +270,19 @@ void DoubleEditor::setLimits(const RealLimits& limits) m_doubleEditor->setMaximum(static_cast<int>(limits.upperLimit())); } -void DoubleEditor::setDecimals(int decimals) -{ +void DoubleEditor::setDecimals(int decimals) { m_doubleEditor->setDecimals(decimals); m_doubleEditor->setSingleStep(singleStep(decimals)); } -void DoubleEditor::onEditingFinished() -{ +void DoubleEditor::onEditingFinished() { double new_value = m_doubleEditor->value(); if (new_value != m_data.toDouble()) setDataIntern(QVariant::fromValue(new_value)); } -void DoubleEditor::initEditor() -{ +void DoubleEditor::initEditor() { ASSERT(m_data.type() == QVariant::Double); m_doubleEditor->setValue(m_data.toDouble()); } @@ -315,8 +290,7 @@ void DoubleEditor::initEditor() // --- DoubleEditor --- ScientificSpinBoxEditor::ScientificSpinBoxEditor(QWidget* parent) - : CustomEditor(parent), m_doubleEditor(new ScientificSpinBox) -{ + : CustomEditor(parent), m_doubleEditor(new ScientificSpinBox) { setAutoFillBackground(true); setFocusPolicy(Qt::StrongFocus); m_doubleEditor->setFocusPolicy(Qt::StrongFocus); @@ -335,43 +309,37 @@ ScientificSpinBoxEditor::ScientificSpinBoxEditor(QWidget* parent) setFocusProxy(m_doubleEditor); } -void ScientificSpinBoxEditor::setLimits(const RealLimits& limits) -{ +void ScientificSpinBoxEditor::setLimits(const RealLimits& limits) { m_doubleEditor->setMinimum(limits.hasLowerLimit() ? limits.lowerLimit() : std::numeric_limits<double>::lowest()); m_doubleEditor->setMaximum(limits.hasUpperLimit() ? limits.upperLimit() : std::numeric_limits<double>::max()); } -void ScientificSpinBoxEditor::setDecimals(int decimals) -{ +void ScientificSpinBoxEditor::setDecimals(int decimals) { m_doubleEditor->setDecimals(decimals); m_doubleEditor->setSingleStep(singleStep(decimals)); } -void ScientificSpinBoxEditor::setSingleStep(double step) -{ +void ScientificSpinBoxEditor::setSingleStep(double step) { m_doubleEditor->setSingleStep(step); } -void ScientificSpinBoxEditor::onEditingFinished() -{ +void ScientificSpinBoxEditor::onEditingFinished() { double new_value = m_doubleEditor->value(); if (new_value != m_data.toDouble()) setDataIntern(QVariant::fromValue(new_value)); } -void ScientificSpinBoxEditor::initEditor() -{ +void ScientificSpinBoxEditor::initEditor() { ASSERT(m_data.type() == QVariant::Double); m_doubleEditor->setValue(m_data.toDouble()); } // --- IntEditor --- -IntEditor::IntEditor(QWidget* parent) : CustomEditor(parent), m_intEditor(new QSpinBox) -{ +IntEditor::IntEditor(QWidget* parent) : CustomEditor(parent), m_intEditor(new QSpinBox) { setAutoFillBackground(true); m_intEditor->setFocusPolicy(Qt::StrongFocus); m_intEditor->setKeyboardTracking(false); @@ -390,8 +358,7 @@ IntEditor::IntEditor(QWidget* parent) : CustomEditor(parent), m_intEditor(new QS setFocusProxy(m_intEditor); } -void IntEditor::setLimits(const RealLimits& limits) -{ +void IntEditor::setLimits(const RealLimits& limits) { m_intEditor->setMaximum(std::numeric_limits<int>::max()); if (limits.hasLowerLimit()) @@ -400,16 +367,14 @@ void IntEditor::setLimits(const RealLimits& limits) m_intEditor->setMaximum(static_cast<int>(limits.upperLimit())); } -void IntEditor::onEditingFinished() -{ +void IntEditor::onEditingFinished() { int new_value = m_intEditor->value(); if (new_value != m_data.toInt()) setDataIntern(QVariant::fromValue(new_value)); } -void IntEditor::initEditor() -{ +void IntEditor::initEditor() { if (!m_data.isValid() || m_data.type() != QVariant::Int) return; m_intEditor->setValue(m_data.toInt()); @@ -417,8 +382,7 @@ void IntEditor::initEditor() // --- BoolEditor --- -BoolEditor::BoolEditor(QWidget* parent) : CustomEditor(parent), m_checkBox(new QCheckBox) -{ +BoolEditor::BoolEditor(QWidget* parent) : CustomEditor(parent), m_checkBox(new QCheckBox) { setAutoFillBackground(true); auto layout = new QHBoxLayout; layout->setContentsMargins(4, 0, 0, 0); @@ -430,14 +394,12 @@ BoolEditor::BoolEditor(QWidget* parent) : CustomEditor(parent), m_checkBox(new Q m_checkBox->setText(tr("True")); } -void BoolEditor::onCheckBoxChange(bool value) -{ +void BoolEditor::onCheckBoxChange(bool value) { if (value != m_data.toBool()) setDataIntern(QVariant(value)); } -void BoolEditor::initEditor() -{ +void BoolEditor::initEditor() { ASSERT(m_data.type() == QVariant::Bool); bool value = m_data.toBool(); diff --git a/GUI/coregui/Views/PropertyEditor/CustomEditors.h b/GUI/coregui/Views/PropertyEditor/CustomEditors.h index 4255a1bff58f34d2bef4f7d18536be0be3929057..ce17e81b98d2d716ebd638df932af1f078f485ce 100644 --- a/GUI/coregui/Views/PropertyEditor/CustomEditors.h +++ b/GUI/coregui/Views/PropertyEditor/CustomEditors.h @@ -25,8 +25,7 @@ class RealLimits; //! Base class for all custom variants editors. -class CustomEditor : public QWidget -{ +class CustomEditor : public QWidget { Q_OBJECT public: explicit CustomEditor(QWidget* parent = nullptr) : QWidget(parent) {} @@ -48,8 +47,7 @@ protected: //! Editor for ExternalProperty variant. -class ExternalPropertyEditor : public CustomEditor -{ +class ExternalPropertyEditor : public CustomEditor { Q_OBJECT public: explicit ExternalPropertyEditor(QWidget* parent = nullptr); @@ -71,8 +69,7 @@ private: //! Editor for ComboProperty variant. -class ComboPropertyEditor : public CustomEditor -{ +class ComboPropertyEditor : public CustomEditor { Q_OBJECT public: explicit ComboPropertyEditor(QWidget* parent = nullptr); @@ -95,8 +92,7 @@ protected: //! Editor for ScientificDoubleProperty variant. -class ScientificDoublePropertyEditor : public CustomEditor -{ +class ScientificDoublePropertyEditor : public CustomEditor { Q_OBJECT public: ScientificDoublePropertyEditor(QWidget* parent = nullptr); @@ -116,8 +112,7 @@ private: //! Editor for Double variant. -class DoubleEditor : public CustomEditor -{ +class DoubleEditor : public CustomEditor { Q_OBJECT public: DoubleEditor(QWidget* parent = nullptr); @@ -137,8 +132,7 @@ private: //! Editor for Double variant using ScientificSpinBox. -class ScientificSpinBoxEditor : public CustomEditor -{ +class ScientificSpinBoxEditor : public CustomEditor { Q_OBJECT public: ScientificSpinBoxEditor(QWidget* parent = nullptr); @@ -159,8 +153,7 @@ private: //! Editor for Int variant. -class IntEditor : public CustomEditor -{ +class IntEditor : public CustomEditor { Q_OBJECT public: IntEditor(QWidget* parent = nullptr); @@ -181,8 +174,7 @@ private: class QCheckBox; -class BoolEditor : public CustomEditor -{ +class BoolEditor : public CustomEditor { Q_OBJECT public: BoolEditor(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/PropertyEditor/MultiComboPropertyEditor.cpp b/GUI/coregui/Views/PropertyEditor/MultiComboPropertyEditor.cpp index 5efead41da9dcd63d4c6b2fa2ea07521186c9a1e..1d2b6c595aaf9a9dc78ffb2fc0cd5e0caf555c6a 100644 --- a/GUI/coregui/Views/PropertyEditor/MultiComboPropertyEditor.cpp +++ b/GUI/coregui/Views/PropertyEditor/MultiComboPropertyEditor.cpp @@ -25,13 +25,10 @@ #include <QVBoxLayout> QCheckListStyledItemDelegate::QCheckListStyledItemDelegate(QObject* parent) - : QStyledItemDelegate(parent) -{ -} + : QStyledItemDelegate(parent) {} void QCheckListStyledItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ + const QModelIndex& index) const { QStyleOptionViewItem& styleOption = const_cast<QStyleOptionViewItem&>(option); styleOption.showDecorationSelected = false; QStyledItemDelegate::paint(painter, styleOption, index); @@ -47,8 +44,7 @@ MultiComboPropertyEditor::MultiComboPropertyEditor(QWidget* parent) : CustomEditor(parent) , m_box(new QComboBox) , m_wheel_event_filter(new WheelEventEater(this)) - , m_model(new QStandardItemModel(this)) -{ + , m_model(new QStandardItemModel(this)) { setAutoFillBackground(true); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); @@ -74,21 +70,18 @@ MultiComboPropertyEditor::MultiComboPropertyEditor(QWidget* parent) setConnected(true); } -QSize MultiComboPropertyEditor::sizeHint() const -{ +QSize MultiComboPropertyEditor::sizeHint() const { return m_box->sizeHint(); } -QSize MultiComboPropertyEditor::minimumSizeHint() const -{ +QSize MultiComboPropertyEditor::minimumSizeHint() const { return m_box->minimumSizeHint(); } //! Propagate check state from the model to ComboProperty. void MultiComboPropertyEditor::onModelDataChanged(const QModelIndex& topLeft, const QModelIndex&, - const QVector<int>&) -{ + const QVector<int>&) { // on Qt 5.9 roles remains empty for checked state. It will stop working if uncomment. // if (!roles.contains(Qt::CheckStateRole)) // return; @@ -107,8 +100,7 @@ void MultiComboPropertyEditor::onModelDataChanged(const QModelIndex& topLeft, co //! Processes press event in QComboBox's underlying list view. -void MultiComboPropertyEditor::onClickedList(const QModelIndex& index) -{ +void MultiComboPropertyEditor::onClickedList(const QModelIndex& index) { if (auto item = m_model->itemFromIndex(index)) { auto state = item->checkState() == Qt::Checked ? Qt::Unchecked : Qt::Checked; item->setCheckState(state); @@ -117,8 +109,7 @@ void MultiComboPropertyEditor::onClickedList(const QModelIndex& index) //! Handles mouse clicks on QComboBox elements. -bool MultiComboPropertyEditor::eventFilter(QObject* obj, QEvent* event) -{ +bool MultiComboPropertyEditor::eventFilter(QObject* obj, QEvent* event) { if (isClickToSelect(obj, event)) { // Handles mouse clicks on QListView when it is expanded from QComboBox // 1) Prevents list from closing while selecting items. @@ -140,8 +131,7 @@ bool MultiComboPropertyEditor::eventFilter(QObject* obj, QEvent* event) } } -void MultiComboPropertyEditor::initEditor() -{ +void MultiComboPropertyEditor::initEditor() { if (!m_data.canConvert<ComboProperty>()) return; @@ -167,8 +157,7 @@ void MultiComboPropertyEditor::initEditor() updateBoxLabel(); } -void MultiComboPropertyEditor::setConnected(bool isConnected) -{ +void MultiComboPropertyEditor::setConnected(bool isConnected) { if (isConnected) { connect(m_model, &QStandardItemModel::dataChanged, this, &MultiComboPropertyEditor::onModelDataChanged); @@ -180,18 +169,15 @@ void MultiComboPropertyEditor::setConnected(bool isConnected) //! Update text on QComboBox with the label provided by combo property. -void MultiComboPropertyEditor::updateBoxLabel() -{ +void MultiComboPropertyEditor::updateBoxLabel() { ComboProperty combo = m_data.value<ComboProperty>(); m_box->setCurrentText(combo.label()); } -bool MultiComboPropertyEditor::isClickToSelect(QObject* obj, QEvent* event) const -{ +bool MultiComboPropertyEditor::isClickToSelect(QObject* obj, QEvent* event) const { return obj == m_box->view()->viewport() && event->type() == QEvent::MouseButtonRelease; } -bool MultiComboPropertyEditor::isClickToExpand(QObject* obj, QEvent* event) const -{ +bool MultiComboPropertyEditor::isClickToExpand(QObject* obj, QEvent* event) const { return obj == m_box->lineEdit() && event->type() == QEvent::MouseButtonRelease; } diff --git a/GUI/coregui/Views/PropertyEditor/MultiComboPropertyEditor.h b/GUI/coregui/Views/PropertyEditor/MultiComboPropertyEditor.h index 46782ed991331f85729ceb90f1372c0980c62e8d..933f68a9e5a81f21eedbfaf992972b6ae317c4e9 100644 --- a/GUI/coregui/Views/PropertyEditor/MultiComboPropertyEditor.h +++ b/GUI/coregui/Views/PropertyEditor/MultiComboPropertyEditor.h @@ -25,8 +25,7 @@ class QStyleOptionViewItem; //! Provides custom editor for ComboProperty with multi-select option. -class MultiComboPropertyEditor : public CustomEditor -{ +class MultiComboPropertyEditor : public CustomEditor { Q_OBJECT public: explicit MultiComboPropertyEditor(QWidget* parent = nullptr); @@ -57,8 +56,7 @@ private: //! Provides custom style delegate for QComboBox to allow checkboxes. -class QCheckListStyledItemDelegate : public QStyledItemDelegate -{ +class QCheckListStyledItemDelegate : public QStyledItemDelegate { public: QCheckListStyledItemDelegate(QObject* parent = nullptr); diff --git a/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.cpp b/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.cpp index fcb6ebfe287a6172d61fba80e1045fd11bfaa8fc..d32ee45e46cc6dda1a665d2c4e0ee0c972df7a94 100644 --- a/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.cpp +++ b/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.cpp @@ -25,45 +25,37 @@ #include <QSpinBox> #include <limits> -namespace -{ +namespace { QWidget* createCustomStringEditor(const SessionItem& item); double getStep(double val); -bool isDoubleProperty(const QVariant& variant) -{ +bool isDoubleProperty(const QVariant& variant) { return variant.type() == QVariant::Double; } -bool isIntProperty(const QVariant& variant) -{ +bool isIntProperty(const QVariant& variant) { return variant.type() == QVariant::Int; } -bool isExternalProperty(const QVariant& variant) -{ +bool isExternalProperty(const QVariant& variant) { return variant.canConvert<ExternalProperty>(); } -bool isComboProperty(const QVariant& variant) -{ +bool isComboProperty(const QVariant& variant) { return variant.canConvert<ComboProperty>(); } -bool isStringProperty(const QVariant& variant) -{ +bool isStringProperty(const QVariant& variant) { return variant.type() == QVariant::String; } -bool isBoolProperty(const QVariant& variant) -{ +bool isBoolProperty(const QVariant& variant) { return variant.type() == QVariant::Bool; } } // namespace -bool PropertyEditorFactory::hasStringRepresentation(const QModelIndex& index) -{ +bool PropertyEditorFactory::hasStringRepresentation(const QModelIndex& index) { auto variant = index.data(); if (isExternalProperty(variant)) return true; @@ -77,8 +69,7 @@ bool PropertyEditorFactory::hasStringRepresentation(const QModelIndex& index) return false; } -QString PropertyEditorFactory::toString(const QModelIndex& index) -{ +QString PropertyEditorFactory::toString(const QModelIndex& index) { auto variant = index.data(); if (isExternalProperty(variant)) return variant.value<ExternalProperty>().text(); @@ -99,8 +90,7 @@ QString PropertyEditorFactory::toString(const QModelIndex& index) return ""; } -QWidget* PropertyEditorFactory::CreateEditor(const SessionItem& item, QWidget* parent) -{ +QWidget* PropertyEditorFactory::CreateEditor(const SessionItem& item, QWidget* parent) { QWidget* result(nullptr); if (isDoubleProperty(item.value())) { @@ -151,11 +141,9 @@ QWidget* PropertyEditorFactory::CreateEditor(const SessionItem& item, QWidget* p return result; } -namespace -{ +namespace { -QWidget* createCustomStringEditor(const SessionItem& item) -{ +QWidget* createCustomStringEditor(const SessionItem& item) { QWidget* result(nullptr); if (item.isEditable()) { @@ -171,8 +159,7 @@ QWidget* createCustomStringEditor(const SessionItem& item) return result; } -double getStep(double val) -{ +double getStep(double val) { return val == 0.0 ? 1.0 : val / 100.; } diff --git a/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.h b/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.h index 5aef56411d942ae48dc56ab22c57cfd9413540fb..5e9d4b700ec52ea35b38170d41807eda0351c35d 100644 --- a/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.h +++ b/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.h @@ -24,8 +24,7 @@ class QVariant; //! Creates editors for SessionItem's values. -namespace PropertyEditorFactory -{ +namespace PropertyEditorFactory { //! Returns true if the index data has known (custom) convertion to string. bool hasStringRepresentation(const QModelIndex& index); diff --git a/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.cpp b/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.cpp index 33704e9f3dfce7dfaf496a0850cec2b34abb5160..e1e35b58e71585ccdc488387baaf73a569c34c7a 100644 --- a/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.cpp +++ b/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.cpp @@ -32,21 +32,18 @@ PropertyWidgetItem::PropertyWidgetItem(QWidget* parent) , m_editor(nullptr) , m_dataMapper(new QDataWidgetMapper(this)) , m_delegate(new SessionModelDelegate(nullptr)) - , m_item(nullptr) -{ + , m_item(nullptr) { m_label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed)); } -PropertyWidgetItem::~PropertyWidgetItem() -{ +PropertyWidgetItem::~PropertyWidgetItem() { m_editor->clearFocus(); delete m_label; delete m_editor; delete m_delegate; } -void PropertyWidgetItem::setItemEditor(const SessionItem* item, QWidget* editor) -{ +void PropertyWidgetItem::setItemEditor(const SessionItem* item, QWidget* editor) { ASSERT(m_item == nullptr); m_item = item; m_editor = editor; @@ -71,8 +68,7 @@ void PropertyWidgetItem::setItemEditor(const SessionItem* item, QWidget* editor) updateItemRoles(); } -void PropertyWidgetItem::addToGrid(QGridLayout* gridLayout, int nrow) -{ +void PropertyWidgetItem::addToGrid(QGridLayout* gridLayout, int nrow) { ASSERT(m_label); ASSERT(m_editor); @@ -80,8 +76,7 @@ void PropertyWidgetItem::addToGrid(QGridLayout* gridLayout, int nrow) gridLayout->addWidget(m_editor, nrow, 1); } -void PropertyWidgetItem::updateItemRoles() -{ +void PropertyWidgetItem::updateItemRoles() { ASSERT(m_item); m_label->setEnabled(m_item->isEnabled()); m_editor->setEnabled(m_item->isEnabled()); @@ -89,15 +84,13 @@ void PropertyWidgetItem::updateItemRoles() m_editor->setToolTip(SessionItemUtils::ToolTipRole(*m_item).toString()); } -const SessionItem* PropertyWidgetItem::item() -{ +const SessionItem* PropertyWidgetItem::item() { return m_item; } //! Provide additional connections of editor to model mapper. -void PropertyWidgetItem::connectEditor(QWidget* editor) -{ +void PropertyWidgetItem::connectEditor(QWidget* editor) { if (auto customEditor = dynamic_cast<CustomEditor*>(editor)) { connect(customEditor, &CustomEditor::dataChanged, m_delegate, &SessionModelDelegate::onCustomEditorDataChanged); diff --git a/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.h b/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.h index 90cb2be3a93c1fbc33d787271fa26aa5cc8d6c27..c0e6b407ec329eeac9f3c6d268055e2a7d1593fe 100644 --- a/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.h +++ b/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.h @@ -27,8 +27,7 @@ class SessionModelDelegate; //! Container to hold label and editor for PropertyItem. //! Contains also logic to map editor to SessionModel. -class PropertyWidgetItem : public QObject -{ +class PropertyWidgetItem : public QObject { Q_OBJECT public: explicit PropertyWidgetItem(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp b/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp index 270a2b8d48c9ec1b28a473a288d95b029939be8e..56e11292b57f7dd5d23f36d069f1b939f301d64f 100644 --- a/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp +++ b/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp @@ -46,8 +46,7 @@ TestComponentView::TestComponentView(MainWindow* mainWindow) , m_expandButton(new QPushButton("Expand tree")) , m_splitter(new Manhattan::MiniSplitter) , m_delegate(new SessionModelDelegate(this)) - , m_isExpaned(false) -{ + , m_isExpaned(false) { auto buttonLayout = new QHBoxLayout; buttonLayout->addWidget(m_updateButton); buttonLayout->addWidget(m_addItemButton); @@ -81,18 +80,15 @@ TestComponentView::TestComponentView(MainWindow* mainWindow) &TestComponentView::onSelectionChanged); } -void TestComponentView::onUpdateRequest() -{ +void TestComponentView::onUpdateRequest() { // m_componentTree->setModel(m_sourceModel); } -void TestComponentView::onAddItemRequest() -{ +void TestComponentView::onAddItemRequest() { m_sampleModel->insertNewItem("Particle"); } -void TestComponentView::onExpandRequest() -{ +void TestComponentView::onExpandRequest() { if (!m_isExpaned) { m_sourceTree->expandAll(); m_sourceTree->resizeColumnToContents(0); @@ -115,8 +111,7 @@ void TestComponentView::onExpandRequest() //! Inserts test items into source model. -void TestComponentView::init_source() -{ +void TestComponentView::init_source() { SampleBuilderFactory factory; const std::unique_ptr<MultiLayer> sample( factory.createSampleByName("CylindersWithSizeDistributionBuilder")); @@ -128,8 +123,7 @@ void TestComponentView::init_source() m_sampleModel->insertNewItem("IntensityData"); } -void TestComponentView::onSelectionChanged(const QItemSelection& selected, const QItemSelection&) -{ +void TestComponentView::onSelectionChanged(const QItemSelection& selected, const QItemSelection&) { QModelIndexList indices = selected.indexes(); if (!indices.empty()) { @@ -143,8 +137,7 @@ void TestComponentView::onSelectionChanged(const QItemSelection& selected, const } } -QWidget* TestComponentView::componentTreePanel() -{ +QWidget* TestComponentView::componentTreePanel() { Manhattan::MiniSplitter* result = new Manhattan::MiniSplitter(Qt::Vertical); result->addWidget(m_componentTree); @@ -152,8 +145,7 @@ QWidget* TestComponentView::componentTreePanel() return result; } -QWidget* TestComponentView::componentBoxPanel() -{ +QWidget* TestComponentView::componentBoxPanel() { Manhattan::MiniSplitter* result = new Manhattan::MiniSplitter(Qt::Vertical); result->addWidget(m_componentFlat); diff --git a/GUI/coregui/Views/PropertyEditor/TestComponentView.h b/GUI/coregui/Views/PropertyEditor/TestComponentView.h index 99dbf6f2a0bb81fc3071f318a8bdf75be27eed4a..92031b7f7bc12abc737fe93ba23eeef3e2b7f2ed 100644 --- a/GUI/coregui/Views/PropertyEditor/TestComponentView.h +++ b/GUI/coregui/Views/PropertyEditor/TestComponentView.h @@ -25,8 +25,7 @@ class SessionModelDelegate; class QItemSelection; class ComponentEditor; class ComponentTreeView; -namespace Manhattan -{ +namespace Manhattan { class MiniSplitter; } class QBoxLayout; @@ -35,8 +34,7 @@ class MaterialModel; //! View to tests QListView working with ComponentProxyModel. -class TestComponentView : public QWidget -{ +class TestComponentView : public QWidget { Q_OBJECT public: TestComponentView(MainWindow* mainWindow = nullptr); diff --git a/GUI/coregui/Views/RealSpaceWidgets/IPositionBuilder.cpp b/GUI/coregui/Views/RealSpaceWidgets/IPositionBuilder.cpp index cc63ab98e7ac78725b48b3c46c3d97b2fd3896c0..964fac328ea31ef56649b79c81adae905ddf655c 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/IPositionBuilder.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/IPositionBuilder.cpp @@ -18,8 +18,7 @@ #include <cmath> #include <random> -namespace -{ +namespace { std::vector<std::vector<double>> Generate2DLatticePoints(double l1, double l2, double alpha, double xi, unsigned n1, unsigned n2); } @@ -27,8 +26,7 @@ std::vector<std::vector<double>> Generate2DLatticePoints(double l1, double l2, d IPositionBuilder::~IPositionBuilder() = default; std::vector<std::vector<double>> IPositionBuilder::generatePositions(double layer_size, - double density) const -{ + double density) const { std::vector<std::vector<double>> positions = generatePositionsImpl(layer_size, density); double pos_var = positionVariance(); if (pos_var > 0.0) { @@ -48,14 +46,13 @@ DefaultPositionBuilder::DefaultPositionBuilder() = default; DefaultPositionBuilder::~DefaultPositionBuilder() = default; -std::vector<std::vector<double>> DefaultPositionBuilder::generatePositionsImpl(double, double) const -{ +std::vector<std::vector<double>> DefaultPositionBuilder::generatePositionsImpl(double, + double) const { std::vector<double> origin = {0.0, 0.0}; return {origin}; } -double DefaultPositionBuilder::positionVariance() const -{ +double DefaultPositionBuilder::positionVariance() const { return 0.0; } @@ -63,9 +60,8 @@ RandomPositionBuilder::RandomPositionBuilder() = default; RandomPositionBuilder::~RandomPositionBuilder() = default; -std::vector<std::vector<double>> RandomPositionBuilder::generatePositionsImpl(double layer_size, - double density) const -{ +std::vector<std::vector<double>> +RandomPositionBuilder::generatePositionsImpl(double layer_size, double density) const { std::vector<std::vector<double>> lattice_positions; std::vector<double> position; @@ -89,21 +85,17 @@ std::vector<std::vector<double>> RandomPositionBuilder::generatePositionsImpl(do return lattice_positions; } -double RandomPositionBuilder::positionVariance() const -{ +double RandomPositionBuilder::positionVariance() const { return 0.0; // no need for extra randomness here } Lattice1DPositionBuilder::Lattice1DPositionBuilder(const InterferenceFunction1DLattice* p_iff) - : m_iff(p_iff->clone()) -{ -} + : m_iff(p_iff->clone()) {} Lattice1DPositionBuilder::~Lattice1DPositionBuilder() = default; std::vector<std::vector<double>> Lattice1DPositionBuilder::generatePositionsImpl(double layer_size, - double) const -{ + double) const { const double length = m_iff->getLength(); const double xi = m_iff->getXi(); @@ -115,21 +107,17 @@ std::vector<std::vector<double>> Lattice1DPositionBuilder::generatePositionsImpl return Generate2DLatticePoints(length, 0.0, 0.0, xi, n1, 1u); } -double Lattice1DPositionBuilder::positionVariance() const -{ +double Lattice1DPositionBuilder::positionVariance() const { return m_iff->positionVariance(); } Lattice2DPositionBuilder::Lattice2DPositionBuilder(const InterferenceFunction2DLattice* p_iff) - : m_iff(p_iff->clone()) -{ -} + : m_iff(p_iff->clone()) {} Lattice2DPositionBuilder::~Lattice2DPositionBuilder() = default; std::vector<std::vector<double>> Lattice2DPositionBuilder::generatePositionsImpl(double layer_size, - double) const -{ + double) const { auto& lattice = m_iff->lattice(); double l1 = lattice.length1(); double l2 = lattice.length2(); @@ -150,42 +138,34 @@ std::vector<std::vector<double>> Lattice2DPositionBuilder::generatePositionsImpl return Generate2DLatticePoints(l1, l2, alpha, xi, n1, n2); } -double Lattice2DPositionBuilder::positionVariance() const -{ +double Lattice2DPositionBuilder::positionVariance() const { return m_iff->positionVariance(); } ParaCrystal2DPositionBuilder::ParaCrystal2DPositionBuilder( const InterferenceFunction2DParaCrystal* p_iff) - : m_iff(p_iff->clone()) -{ -} + : m_iff(p_iff->clone()) {} ParaCrystal2DPositionBuilder::~ParaCrystal2DPositionBuilder() = default; std::vector<std::vector<double>> -ParaCrystal2DPositionBuilder::generatePositionsImpl(double layer_size, double) const -{ +ParaCrystal2DPositionBuilder::generatePositionsImpl(double layer_size, double) const { return RealSpace2DParacrystalUtils::Compute2DParacrystalLatticePositions(m_iff.get(), layer_size); } -double ParaCrystal2DPositionBuilder::positionVariance() const -{ +double ParaCrystal2DPositionBuilder::positionVariance() const { return m_iff->positionVariance(); } Finite2DLatticePositionBuilder::Finite2DLatticePositionBuilder( const InterferenceFunctionFinite2DLattice* p_iff) - : m_iff(p_iff->clone()) -{ -} + : m_iff(p_iff->clone()) {} Finite2DLatticePositionBuilder::~Finite2DLatticePositionBuilder() = default; std::vector<std::vector<double>> -Finite2DLatticePositionBuilder::generatePositionsImpl(double layer_size, double) const -{ +Finite2DLatticePositionBuilder::generatePositionsImpl(double layer_size, double) const { auto& lattice = m_iff->lattice(); double l1 = lattice.length1(); double l2 = lattice.length2(); @@ -207,22 +187,18 @@ Finite2DLatticePositionBuilder::generatePositionsImpl(double layer_size, double) return Generate2DLatticePoints(l1, l2, alpha, xi, n1, n2); } -double Finite2DLatticePositionBuilder::positionVariance() const -{ +double Finite2DLatticePositionBuilder::positionVariance() const { return m_iff->positionVariance(); } RadialParacrystalPositionBuilder::RadialParacrystalPositionBuilder( const InterferenceFunctionRadialParaCrystal* p_iff) - : m_iff(p_iff->clone()) -{ -} + : m_iff(p_iff->clone()) {} RadialParacrystalPositionBuilder::~RadialParacrystalPositionBuilder() = default; std::vector<std::vector<double>> -RadialParacrystalPositionBuilder::generatePositionsImpl(double layer_size, double) const -{ +RadialParacrystalPositionBuilder::generatePositionsImpl(double layer_size, double) const { std::vector<std::vector<double>> lattice_positions; double distance = m_iff->peakDistance(); @@ -259,16 +235,13 @@ RadialParacrystalPositionBuilder::generatePositionsImpl(double layer_size, doubl return lattice_positions; } -double RadialParacrystalPositionBuilder::positionVariance() const -{ +double RadialParacrystalPositionBuilder::positionVariance() const { return m_iff->positionVariance(); } -namespace -{ +namespace { std::vector<std::vector<double>> Generate2DLatticePoints(double l1, double l2, double alpha, - double xi, unsigned n1, unsigned n2) -{ + double xi, unsigned n1, unsigned n2) { std::vector<std::vector<double>> lattice_positions; std::vector<double> position; diff --git a/GUI/coregui/Views/RealSpaceWidgets/IPositionBuilder.h b/GUI/coregui/Views/RealSpaceWidgets/IPositionBuilder.h index 0fc1efc78704dd2dc062984d8bfcf21493fed976..0bba04138fb39f320e4c4c0ea8033c463d486fdd 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/IPositionBuilder.h +++ b/GUI/coregui/Views/RealSpaceWidgets/IPositionBuilder.h @@ -24,8 +24,7 @@ class InterferenceFunction2DParaCrystal; class InterferenceFunctionFinite2DLattice; class InterferenceFunctionRadialParaCrystal; -class IPositionBuilder -{ +class IPositionBuilder { public: virtual ~IPositionBuilder(); @@ -42,8 +41,7 @@ private: //! the positions based on the interference function //! //! It always generates a single point at the origin -class DefaultPositionBuilder : public IPositionBuilder -{ +class DefaultPositionBuilder : public IPositionBuilder { public: DefaultPositionBuilder(); ~DefaultPositionBuilder() override; @@ -54,8 +52,7 @@ private: double positionVariance() const override; }; -class RandomPositionBuilder : public IPositionBuilder -{ +class RandomPositionBuilder : public IPositionBuilder { public: RandomPositionBuilder(); ~RandomPositionBuilder() override; @@ -66,8 +63,7 @@ private: double positionVariance() const override; }; -class Lattice1DPositionBuilder : public IPositionBuilder -{ +class Lattice1DPositionBuilder : public IPositionBuilder { public: Lattice1DPositionBuilder(const InterferenceFunction1DLattice* p_iff); ~Lattice1DPositionBuilder() override; @@ -79,8 +75,7 @@ private: std::unique_ptr<InterferenceFunction1DLattice> m_iff; }; -class Lattice2DPositionBuilder : public IPositionBuilder -{ +class Lattice2DPositionBuilder : public IPositionBuilder { public: Lattice2DPositionBuilder(const InterferenceFunction2DLattice* p_iff); ~Lattice2DPositionBuilder() override; @@ -92,8 +87,7 @@ private: std::unique_ptr<InterferenceFunction2DLattice> m_iff; }; -class ParaCrystal2DPositionBuilder : public IPositionBuilder -{ +class ParaCrystal2DPositionBuilder : public IPositionBuilder { public: ParaCrystal2DPositionBuilder(const InterferenceFunction2DParaCrystal* p_iff); ~ParaCrystal2DPositionBuilder() override; @@ -105,8 +99,7 @@ private: std::unique_ptr<InterferenceFunction2DParaCrystal> m_iff; }; -class Finite2DLatticePositionBuilder : public IPositionBuilder -{ +class Finite2DLatticePositionBuilder : public IPositionBuilder { public: Finite2DLatticePositionBuilder(const InterferenceFunctionFinite2DLattice* p_iff); ~Finite2DLatticePositionBuilder() override; @@ -118,8 +111,7 @@ private: std::unique_ptr<InterferenceFunctionFinite2DLattice> m_iff; }; -class RadialParacrystalPositionBuilder : public IPositionBuilder -{ +class RadialParacrystalPositionBuilder : public IPositionBuilder { public: RadialParacrystalPositionBuilder(const InterferenceFunctionRadialParaCrystal* p_iff); ~RadialParacrystalPositionBuilder() override; diff --git a/GUI/coregui/Views/RealSpaceWidgets/Particle3DContainer.cpp b/GUI/coregui/Views/RealSpaceWidgets/Particle3DContainer.cpp index ee935bd45592bbd268928643f6b240a504f3823d..2cd2c2e06e255ad2414a914a009146def6d4aa86 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/Particle3DContainer.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/Particle3DContainer.cpp @@ -17,8 +17,7 @@ // copy constructor Particle3DContainer::Particle3DContainer(const Particle3DContainer& other) - : m_cumulativeAbundance(other.m_cumulativeAbundance), m_containerType(other.m_containerType) -{ + : m_cumulativeAbundance(other.m_cumulativeAbundance), m_containerType(other.m_containerType) { m_containerParticles.resize(other.m_containerParticles.size()); for (size_t i = 0; i < m_containerParticles.size(); ++i) m_containerParticles[i] = @@ -30,8 +29,7 @@ Particle3DContainer::Particle3DContainer(const Particle3DContainer& other) } // copy assignment -Particle3DContainer& Particle3DContainer::operator=(const Particle3DContainer& rhs) -{ +Particle3DContainer& Particle3DContainer::operator=(const Particle3DContainer& rhs) { if (this != &rhs) { clearContainer(); m_containerParticles.resize(rhs.containerSize()); @@ -50,8 +48,7 @@ Particle3DContainer& Particle3DContainer::operator=(const Particle3DContainer& r } // destructor -Particle3DContainer::~Particle3DContainer() noexcept -{ +Particle3DContainer::~Particle3DContainer() noexcept { clearContainer(); } @@ -60,13 +57,10 @@ Particle3DContainer::Particle3DContainer(Particle3DContainer&& other) noexcept : m_containerParticles(std::move(other.m_containerParticles)) , m_cumulativeAbundance(std::move(other.m_cumulativeAbundance)) , m_containerType(std::move(other.m_containerType)) - , m_containerParticlesBlend(std::move(other.m_containerParticlesBlend)) -{ -} + , m_containerParticlesBlend(std::move(other.m_containerParticlesBlend)) {} // move assignment -Particle3DContainer& Particle3DContainer::operator=(Particle3DContainer&& rhs) noexcept -{ +Particle3DContainer& Particle3DContainer::operator=(Particle3DContainer&& rhs) noexcept { if (this != &rhs) { clearContainer(); m_containerParticles = std::move(rhs.m_containerParticles); @@ -77,8 +71,7 @@ Particle3DContainer& Particle3DContainer::operator=(Particle3DContainer&& rhs) n return *this; } -void Particle3DContainer::clearContainer() -{ +void Particle3DContainer::clearContainer() { for (auto it = m_containerParticles.begin(); it != m_containerParticles.end(); ++it) delete (*it); @@ -86,25 +79,21 @@ void Particle3DContainer::clearContainer() m_containerParticlesBlend.clear(); } -void Particle3DContainer::addParticle(RealSpace::Particles::Particle* particle3D, bool blend) -{ +void Particle3DContainer::addParticle(RealSpace::Particles::Particle* particle3D, bool blend) { m_containerParticles.emplace_back(particle3D); m_containerParticlesBlend.emplace_back(blend); } -void Particle3DContainer::setCumulativeAbundance(double cumulativeAbundance) -{ +void Particle3DContainer::setCumulativeAbundance(double cumulativeAbundance) { m_cumulativeAbundance = cumulativeAbundance; } -void Particle3DContainer::setParticleType(QString particleType) -{ +void Particle3DContainer::setParticleType(QString particleType) { m_containerType = particleType; } std::unique_ptr<RealSpace::Particles::Particle> -Particle3DContainer::createParticle(const size_t& index) const -{ +Particle3DContainer::createParticle(const size_t& index) const { auto particle = new RealSpace::Particles::Particle(*m_containerParticles.at(index)); return std::unique_ptr<RealSpace::Particles::Particle>(particle); } diff --git a/GUI/coregui/Views/RealSpaceWidgets/Particle3DContainer.h b/GUI/coregui/Views/RealSpaceWidgets/Particle3DContainer.h index 733f68b51935571dafb9cc3407f0e1402ee67771..c016bcad563a01abbbba69b75cd808ee6da31cca 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/Particle3DContainer.h +++ b/GUI/coregui/Views/RealSpaceWidgets/Particle3DContainer.h @@ -19,16 +19,13 @@ #include <memory> #include <vector> -namespace RealSpace -{ -namespace Particles -{ +namespace RealSpace { +namespace Particles { class Particle; } } // namespace RealSpace -class Particle3DContainer -{ +class Particle3DContainer { public: Particle3DContainer() : m_cumulativeAbundance(0) {} Particle3DContainer(const Particle3DContainer& other); // copy constructor diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpace2DParacrystalUtils.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpace2DParacrystalUtils.cpp index 6c16bfcd1bd0e3ee80914eebbb0337fba1eb3330..c1eeaf2326fef42081313104116ed537cd7df4e0 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpace2DParacrystalUtils.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpace2DParacrystalUtils.cpp @@ -16,8 +16,7 @@ #include "GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.h" #include "Sample/Aggregate/InterferenceFunction2DParaCrystal.h" -namespace -{ +namespace { void ResizeLatticePositions(std::vector<std::vector<double>>& lattice_positions, double l1, double l2, double layer_size); void FindLatticePositionsIndex(size_t& index, size_t& index_prev, int i, int j, int size, @@ -42,8 +41,7 @@ void ComputePositionsInsideLatticeQuadrants(std::vector<std::vector<double>>& la } // namespace std::vector<std::vector<double>> RealSpace2DParacrystalUtils::Compute2DParacrystalLatticePositions( - const InterferenceFunction2DParaCrystal* p_iff, double layer_size) -{ + const InterferenceFunction2DParaCrystal* p_iff, double layer_size) { auto& lattice = p_iff->lattice(); double l1 = lattice.length1(); double l2 = lattice.length2(); @@ -63,11 +61,9 @@ std::vector<std::vector<double>> RealSpace2DParacrystalUtils::Compute2DParacryst return lattice_positions; } -namespace -{ +namespace { void ResizeLatticePositions(std::vector<std::vector<double>>& lattice_positions, double l1, - double l2, double layer_size) -{ + double l2, double layer_size) { // Estimate the limit n1 and n2 of the integer multiple j and i of the lattice vectors l1 and l2 // required for populating particles correctly within the 3D model's boundaries int n1 = 0, n2 = 0; @@ -86,8 +82,7 @@ void ResizeLatticePositions(std::vector<std::vector<double>>& lattice_positions, } void FindLatticePositionsIndex(size_t& index, size_t& index_prev, int i, int j, int size, - double l_alpha) -{ + double l_alpha) { index = static_cast<size_t>(i * (2 * size + 1) + j); if (std::sin(l_alpha) == 0) // along l1 @@ -108,8 +103,7 @@ void FindLatticePositionsIndex(size_t& index, size_t& index_prev, int i, int j, std::pair<double, double> ComputePositionAlongPositiveLatticeVector( const size_t index_prev, std::vector<std::vector<double>>& lattice_positions, - const IFTDistribution2D* pdf, double l, double l_xi, double l_alpha) -{ + const IFTDistribution2D* pdf, double l, double l_xi, double l_alpha) { double gamma_pdf = pdf->gamma(); std::pair<double, double> sampleXYpdf = pdf->createSampler()->randomSample(); @@ -128,8 +122,7 @@ std::pair<double, double> ComputePositionAlongPositiveLatticeVector( std::pair<double, double> ComputePositionAlongNegativeLatticeVector( const size_t index_prev, std::vector<std::vector<double>>& lattice_positions, - const IFTDistribution2D* pdf, double l, double l_xi, double l_alpha) -{ + const IFTDistribution2D* pdf, double l, double l_xi, double l_alpha) { double gamma_pdf = pdf->gamma(); std::pair<double, double> sampleXYpdf = pdf->createSampler()->randomSample(); @@ -149,8 +142,7 @@ std::pair<double, double> ComputePositionAlongNegativeLatticeVector( std::pair<double, double> ComputeLatticePosition(const size_t index_prev, int i, int j, std::vector<std::vector<double>>& lattice_positions, - const IFTDistribution2D* pdf, double l, double l_xi, double l_alpha) -{ + const IFTDistribution2D* pdf, double l, double l_xi, double l_alpha) { if (std::sin(l_alpha) == 0) { if (!(j % 2 == 0)) // along +l1 return ComputePositionAlongPositiveLatticeVector(index_prev, lattice_positions, pdf, l, @@ -170,8 +162,7 @@ ComputeLatticePosition(const size_t index_prev, int i, int j, void ComputePositionsAlongLatticeVectorAxes(std::vector<std::vector<double>>& lattice_positions, const IFTDistribution2D* pdf, double l, double l_xi, - double l_alpha) -{ + double l_alpha) { int n = static_cast<int>((std::sqrt(lattice_positions.size()) - 1) / 2); size_t index = 0; // lattice_positions index for current particle @@ -209,8 +200,7 @@ void ComputePositionsAlongLatticeVectorAxes(std::vector<std::vector<double>>& la void ComputePositionsInsideLatticeQuadrants(std::vector<std::vector<double>>& lattice_positions, const IFTDistribution2D* pdf1, const IFTDistribution2D* pdf2, double l1, double l2, - double l_xi, double l_alpha) -{ + double l_xi, double l_alpha) { int n = static_cast<int>((std::sqrt(lattice_positions.size()) - 1) / 2); size_t index = 0; // lattice_positions index for current particle diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpace2DParacrystalUtils.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpace2DParacrystalUtils.h index e629a4238be770a8fcb29eef95b605c59ca3da47..a5a4ce6253f048b018837456261545ff2642e647 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpace2DParacrystalUtils.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpace2DParacrystalUtils.h @@ -19,8 +19,7 @@ class InterferenceFunction2DParaCrystal; -namespace RealSpace2DParacrystalUtils -{ +namespace RealSpace2DParacrystalUtils { std::vector<std::vector<double>> Compute2DParacrystalLatticePositions(const InterferenceFunction2DParaCrystal*, double layer_size); }; diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.h index ca922c8ab0a429e74f66d7118e8b195bb64554d9..f8e78cbcfa941982e793ab6fb481a00321748dbc 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceActions.h @@ -19,8 +19,7 @@ //! Collection of actions for RealSpaceWidget. -class RealSpaceActions : public QObject -{ +class RealSpaceActions : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.cpp index 14c3549f6bc3088f60ac05d54af4d8a11cfd9a3f..091f59ad315e4d2fb567df7d36b6731ff178a6e6 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.cpp @@ -37,8 +37,7 @@ #include "Sample/Particle/ParticleCoreShell.h" #include <QDebug> -namespace -{ +namespace { std::unique_ptr<IInterferenceFunction> GetInterferenceFunction(const SessionItem& layoutItem); } @@ -48,8 +47,7 @@ RealSpaceBuilder::~RealSpaceBuilder() = default; void RealSpaceBuilder::populate(RealSpaceModel* model, const SessionItem& item, const SceneGeometry& sceneGeometry, - const RealSpace::Camera::Position& cameraPosition) -{ + const RealSpace::Camera::Position& cameraPosition) { // default value of cameraPosition is in RealSpaceBuilder.h model->defCamPos = cameraPosition; @@ -80,8 +78,7 @@ void RealSpaceBuilder::populate(RealSpaceModel* model, const SessionItem& item, } void RealSpaceBuilder::populateMultiLayer(RealSpaceModel* model, const SessionItem& item, - const SceneGeometry& sceneGeometry, const QVector3D&) -{ + const SceneGeometry& sceneGeometry, const QVector3D&) { double total_height(0.0); int index(0); for (auto layer : item.getItems(MultiLayerItem::T_LAYERS)) { @@ -99,8 +96,7 @@ void RealSpaceBuilder::populateMultiLayer(RealSpaceModel* model, const SessionIt void RealSpaceBuilder::populateLayer(RealSpaceModel* model, const SessionItem& layerItem, const SceneGeometry& sceneGeometry, const QVector3D& origin, - const bool isTopLayer) -{ + const bool isTopLayer) { auto layer = TransformTo3D::createLayer(layerItem, sceneGeometry, origin); if (layer && !isTopLayer) model->addBlend(layer.release()); @@ -110,8 +106,7 @@ void RealSpaceBuilder::populateLayer(RealSpaceModel* model, const SessionItem& l } void RealSpaceBuilder::populateLayout(RealSpaceModel* model, const SessionItem& layoutItem, - const SceneGeometry& sceneGeometry, const QVector3D& origin) -{ + const SceneGeometry& sceneGeometry, const QVector3D& origin) { ASSERT(layoutItem.modelType() == "ParticleLayout"); // If there is no particle to populate @@ -135,8 +130,7 @@ void RealSpaceBuilder::populateLayout(RealSpaceModel* model, const SessionItem& } void RealSpaceBuilder::populateParticleFromParticleItem(RealSpaceModel* model, - const SessionItem& particleItem) const -{ + const SessionItem& particleItem) const { Particle3DContainer particle3DContainer; if (particleItem.modelType() == "Particle") { auto pItem = dynamic_cast<const ParticleItem*>(&particleItem); @@ -179,8 +173,7 @@ void RealSpaceBuilder::populateParticleFromParticleItem(RealSpaceModel* model, void RealSpaceBuilder::populateParticleFromParticle3DContainer( RealSpaceModel* model, const Particle3DContainer& particle3DContainer, - const QVector3D& lattice_position) const -{ + const QVector3D& lattice_position) const { if (particle3DContainer.containerSize()) { for (size_t i = 0; i < particle3DContainer.containerSize(); ++i) { auto particle3D = particle3DContainer.createParticle(i); @@ -195,10 +188,8 @@ void RealSpaceBuilder::populateParticleFromParticle3DContainer( } } -namespace -{ -std::unique_ptr<IInterferenceFunction> GetInterferenceFunction(const SessionItem& layoutItem) -{ +namespace { +std::unique_ptr<IInterferenceFunction> GetInterferenceFunction(const SessionItem& layoutItem) { auto interferenceLattice = layoutItem.getItem(ParticleLayoutItem::T_INTERFERENCE); if (interferenceLattice) { auto interferenceItem = static_cast<const InterferenceFunctionItem*>(interferenceLattice); diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.h index a35f704e1e043c5d429a4c0e924e7fb6fb26dc2b..7f99c5322e2cfdacff1c0b565e5f592dd36551bc 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.h @@ -25,8 +25,7 @@ class Shape3D; class SceneGeometry; class Particle3DContainer; -class RealSpaceBuilder : public QWidget -{ +class RealSpaceBuilder : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.cpp index f1b1a98a2ac654f6a4f83b9282bb92f2e65a3ee1..72b56b88098b0cf048c63dd21c406ae05f722cc3 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.cpp @@ -44,12 +44,10 @@ #include "Sample/Particle/ParticleCoreShell.h" #include "Sample/Scattering/IFormFactorDecorator.h" -namespace -{ +namespace { const double layerBorderWidth = 10.0; -const IFormFactor* getUnderlyingFormFactor(const IFormFactor* ff) -{ +const IFormFactor* getUnderlyingFormFactor(const IFormFactor* ff) { // TRUE as long as ff is of IFormFactorDecorator (or its derived) type while (dynamic_cast<const IFormFactorDecorator*>(ff)) ff = dynamic_cast<const IFormFactorDecorator*>(ff)->getFormFactor(); @@ -57,8 +55,7 @@ const IFormFactor* getUnderlyingFormFactor(const IFormFactor* ff) return ff; } -kvector_t to_kvector(const QVector3D& origin) -{ +kvector_t to_kvector(const QVector3D& origin) { return kvector_t(static_cast<double>(origin.x()), static_cast<double>(origin.y()), static_cast<double>(origin.z())); } @@ -66,8 +63,7 @@ kvector_t to_kvector(const QVector3D& origin) } // namespace // compute cumulative abundances of particles -QVector<double> RealSpaceBuilderUtils::computeCumulativeAbundances(const SessionItem& layoutItem) -{ +QVector<double> RealSpaceBuilderUtils::computeCumulativeAbundances(const SessionItem& layoutItem) { // Retrieving abundances of particles double total_abundance = 0.0; QVector<double> cumulative_abundances; @@ -85,8 +81,7 @@ QVector<double> RealSpaceBuilderUtils::computeCumulativeAbundances(const Session void RealSpaceBuilderUtils::populateParticlesAtLatticePositions( const std::vector<std::vector<double>>& lattice_positions, const std::vector<Particle3DContainer>& particle3DContainer_vector, RealSpaceModel* model, - const SceneGeometry& sceneGeometry, const RealSpaceBuilder* builder3D) -{ + const SceneGeometry& sceneGeometry, const RealSpaceBuilder* builder3D) { double layer_size = sceneGeometry.layer_size(); double layer_thickness = std::max(sceneGeometry.layer_top_thickness(), sceneGeometry.layer_bottom_thickness()); @@ -121,8 +116,7 @@ void RealSpaceBuilderUtils::populateParticlesAtLatticePositions( // Implement Rotation of a 3D particle using parameters from IRotation Object RealSpace::Vector3D -RealSpaceBuilderUtils::implementParticleRotationfromIRotation(const IRotation*& rotation) -{ +RealSpaceBuilderUtils::implementParticleRotationfromIRotation(const IRotation*& rotation) { double alpha = 0.0; double beta = 0.0; double gamma = 0.0; @@ -146,8 +140,7 @@ RealSpaceBuilderUtils::implementParticleRotationfromIRotation(const IRotation*& void RealSpaceBuilderUtils::applyParticleTransformations(const Particle& particle, RealSpace::Particles::Particle& particle3D, - const kvector_t& origin) -{ + const kvector_t& origin) { // rotation RealSpace::Vector3D particle_rotate; const IRotation* rotation = particle.rotation(); @@ -173,8 +166,7 @@ void RealSpaceBuilderUtils::applyParticleTransformations(const Particle& particl void RealSpaceBuilderUtils::applyParticleCoreShellTransformations( const Particle& particle, RealSpace::Particles::Particle& particle3D, - const ParticleCoreShell& particleCoreShell, const kvector_t& origin) -{ + const ParticleCoreShell& particleCoreShell, const kvector_t& origin) { std::unique_ptr<Particle> P_clone(particle.clone()); // clone of the current particle // rotation @@ -203,8 +195,7 @@ void RealSpaceBuilderUtils::applyParticleCoreShellTransformations( void RealSpaceBuilderUtils::applyParticleColor(const Particle& particle, RealSpace::Particles::Particle& particle3D, - double alpha) -{ + double alpha) { // assign correct color to the particle from the knowledge of its material const Material* particle_material = particle.material(); QString material_name = QString::fromStdString(particle_material->getName()); @@ -216,8 +207,7 @@ void RealSpaceBuilderUtils::applyParticleColor(const Particle& particle, std::vector<Particle3DContainer> RealSpaceBuilderUtils::particle3DContainerVector(const SessionItem& layoutItem, - const QVector3D& origin) -{ + const QVector3D& origin) { std::vector<Particle3DContainer> particle3DContainer_vector; double total_abundance = computeCumulativeAbundances(layoutItem).last(); @@ -284,8 +274,7 @@ RealSpaceBuilderUtils::particle3DContainerVector(const SessionItem& layoutItem, Particle3DContainer RealSpaceBuilderUtils::singleParticle3DContainer(const Particle& particle, double total_abundance, - const QVector3D& origin) -{ + const QVector3D& origin) { std::unique_ptr<Particle> P_clone(particle.clone()); // clone of the particle std::unique_ptr<const IFormFactor> particleff(P_clone->createFormFactor()); @@ -303,10 +292,8 @@ Particle3DContainer RealSpaceBuilderUtils::singleParticle3DContainer(const Parti return singleParticle3DContainer; } -Particle3DContainer -RealSpaceBuilderUtils::particleCoreShell3DContainer(const ParticleCoreShell& particleCoreShell, - double total_abundance, const QVector3D& origin) -{ +Particle3DContainer RealSpaceBuilderUtils::particleCoreShell3DContainer( + const ParticleCoreShell& particleCoreShell, double total_abundance, const QVector3D& origin) { // clone of the particleCoreShell std::unique_ptr<ParticleCoreShell> PCS_clone(particleCoreShell.clone()); @@ -342,8 +329,8 @@ RealSpaceBuilderUtils::particleCoreShell3DContainer(const ParticleCoreShell& par } Particle3DContainer RealSpaceBuilderUtils::particleComposition3DContainer( - const ParticleComposition& particleComposition, double total_abundance, const QVector3D& origin) -{ + const ParticleComposition& particleComposition, double total_abundance, + const QVector3D& origin) { // clone of the particleComposition std::unique_ptr<ParticleComposition> PC_clone(particleComposition.clone()); @@ -383,8 +370,7 @@ Particle3DContainer RealSpaceBuilderUtils::particleComposition3DContainer( std::vector<Particle3DContainer> RealSpaceBuilderUtils::particleDistribution3DContainer( const ParticleDistribution& particleDistribution, double total_abundance, - const QVector3D& origin) -{ + const QVector3D& origin) { auto pd_vector = particleDistribution.generateParticles(); std::vector<Particle3DContainer> particleDistribution3DContainer_vector; @@ -417,8 +403,7 @@ std::vector<Particle3DContainer> RealSpaceBuilderUtils::particleDistribution3DCo Particle3DContainer RealSpaceBuilderUtils::mesoCrystal3DContainer(const MesoCrystalItem& mesoCrystalItem, - double total_abundance, const QVector3D& origin) -{ + double total_abundance, const QVector3D& origin) { RealSpaceMesoCrystal mesoCrystalUtils(&mesoCrystalItem, total_abundance, origin); Particle3DContainer mesoCrystal3DContainer = mesoCrystalUtils.populateMesoCrystal(); diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.h index c1268547d681965877c0417a191136f5165d881a..5ef82a028c5f4981ca04d09a9b12be8946a30b52 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.h @@ -33,17 +33,14 @@ class ParticleDistribution; class IInterferenceFunction; class Particle3DContainer; class InterferenceFunction2DParaCrystal; -namespace RealSpace -{ +namespace RealSpace { struct Vector3D; -namespace Particles -{ +namespace Particles { class Particle; } } // namespace RealSpace -namespace RealSpaceBuilderUtils -{ +namespace RealSpaceBuilderUtils { // compute cumulative abundances of particles QVector<double> computeCumulativeAbundances(const SessionItem& layoutItem); diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.cpp index 5aea8b94d52a604d25b5b690ea4c6763626ea7bb..49d49034bbb0759551782502e5b74863fefe8469 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.cpp @@ -34,8 +34,7 @@ RealSpaceCanvas::RealSpaceCanvas(QWidget* parent) , m_selectionModel(nullptr) , m_view_locked(false) , m_sceneGeometry(new SceneGeometry) - , m_warningSign(new WarningSign(this)) -{ + , m_warningSign(new WarningSign(this)) { auto layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); @@ -45,8 +44,7 @@ RealSpaceCanvas::RealSpaceCanvas(QWidget* parent) RealSpaceCanvas::~RealSpaceCanvas() = default; -void RealSpaceCanvas::setModel(SampleModel* sampleModel, QItemSelectionModel* selectionModel) -{ +void RealSpaceCanvas::setModel(SampleModel* sampleModel, QItemSelectionModel* selectionModel) { if (sampleModel != m_sampleModel) { if (m_sampleModel) @@ -73,13 +71,11 @@ void RealSpaceCanvas::setModel(SampleModel* sampleModel, QItemSelectionModel* se updateToSelection(); } -void RealSpaceCanvas::onSelectionChanged(const QItemSelection&, const QItemSelection&) -{ +void RealSpaceCanvas::onSelectionChanged(const QItemSelection&, const QItemSelection&) { updateToSelection(); } -void RealSpaceCanvas::updateToSelection() -{ +void RealSpaceCanvas::updateToSelection() { if (!m_selectionModel) return; @@ -96,31 +92,26 @@ void RealSpaceCanvas::updateToSelection() } } -void RealSpaceCanvas::onDefaultViewAction() -{ +void RealSpaceCanvas::onDefaultViewAction() { defaultView(); } -void RealSpaceCanvas::onSideViewAction() -{ +void RealSpaceCanvas::onSideViewAction() { sideView(); } -void RealSpaceCanvas::onTopViewAction() -{ +void RealSpaceCanvas::onTopViewAction() { topView(); } -void RealSpaceCanvas::onLockViewAction(bool view_locked) -{ +void RealSpaceCanvas::onLockViewAction(bool view_locked) { if (m_view_locked != view_locked) { m_view_locked = view_locked; updateToSelection(); } } -void RealSpaceCanvas::onChangeLayerSizeAction(double layerSizeChangeScale) -{ +void RealSpaceCanvas::onChangeLayerSizeAction(double layerSizeChangeScale) { // when no object is selected --> take no action if (m_currentSelection == QModelIndex()) return; @@ -129,22 +120,19 @@ void RealSpaceCanvas::onChangeLayerSizeAction(double layerSizeChangeScale) updateScene(); } -void RealSpaceCanvas::onSavePictureAction() -{ +void RealSpaceCanvas::onSavePictureAction() { QPixmap pixmap(this->size()); render(&pixmap, QPoint(), childrenRegion()); savePicture(pixmap); } -void RealSpaceCanvas::onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int) -{ +void RealSpaceCanvas::onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int) { // clear scene if current selection will be removed if (m_currentSelection == m_sampleModel->index(first, 0, parent)) resetScene(); } -void RealSpaceCanvas::savePicture(const QPixmap& pixmap) -{ +void RealSpaceCanvas::savePicture(const QPixmap& pixmap) { QString dirname = AppSvc::projectManager()->userExportDir(); QString defaultExtension = ".png"; QString selectedFilter("*" + defaultExtension); @@ -167,8 +155,7 @@ void RealSpaceCanvas::savePicture(const QPixmap& pixmap) } } -void RealSpaceCanvas::onDataChanged(const QModelIndex& index) -{ +void RealSpaceCanvas::onDataChanged(const QModelIndex& index) { auto item = m_sampleModel->itemForIndex(index); if (!item) return; @@ -177,8 +164,7 @@ void RealSpaceCanvas::onDataChanged(const QModelIndex& index) updateScene(); } -void RealSpaceCanvas::updateScene() -{ +void RealSpaceCanvas::updateScene() { QApplication::setOverrideCursor(Qt::WaitCursor); m_realSpaceModel.reset(new RealSpaceModel); @@ -209,30 +195,25 @@ void RealSpaceCanvas::updateScene() QApplication::restoreOverrideCursor(); } -void RealSpaceCanvas::resetScene() -{ +void RealSpaceCanvas::resetScene() { m_realSpaceModel.reset(); m_view->setModel(nullptr); m_currentSelection = {}; } -void RealSpaceCanvas::defaultView() -{ +void RealSpaceCanvas::defaultView() { m_view->defaultView(); } -void RealSpaceCanvas::sideView() -{ +void RealSpaceCanvas::sideView() { m_view->sideView(); } -void RealSpaceCanvas::topView() -{ +void RealSpaceCanvas::topView() { m_view->topView(); } -void RealSpaceCanvas::setConnected(SampleModel* model, bool makeConnected) -{ +void RealSpaceCanvas::setConnected(SampleModel* model, bool makeConnected) { if (!model) return; diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.h index 667aa6fce18ab435b127fab76bac28ce5c8281ed..cc9a9d1edb99b0eae64172b061c513dee2bac780 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.h @@ -26,12 +26,10 @@ class RealSpaceModel; class WarningSign; // Class for holding size and thickness information of layers -class SceneGeometry -{ +class SceneGeometry { public: SceneGeometry(double size = 100.0, double top_thickness = 25.0, double bottom_thickness = 25.0, - double min_thickness = 2.0) - { + double min_thickness = 2.0) { l_size = size; // layer size l_top_thickness = top_thickness; // top layer thickness l_bottom_thickness = bottom_thickness; // bottom layer thickness @@ -55,8 +53,7 @@ private: }; //! Provides 3D object generation for RealSpaceWidget. -class RealSpaceCanvas : public QWidget -{ +class RealSpaceCanvas : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.cpp index 19689f9c854f672cfc8f56f3d20bef6a1a349db5..05b00758dad5b57cf6864ba1dc127569bd2f2b7e 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.cpp @@ -28,12 +28,10 @@ #include "Sample/Particle/Particle.h" #include "Sample/Particle/ParticleCoreShell.h" -namespace -{ +namespace { const int n = 10; // TODO: Adjust this parameter based on the size of the mesocrystal -bool isPositionInsideMesoCrystal(const IFormFactor* outerShape, kvector_t positionInside) -{ +bool isPositionInsideMesoCrystal(const IFormFactor* outerShape, kvector_t positionInside) { bool check(false); if (auto ff_AnisoPyramid = dynamic_cast<const FormFactorAnisoPyramid*>(outerShape)) { double L = ff_AnisoPyramid->getLength(); @@ -347,15 +345,13 @@ bool isPositionInsideMesoCrystal(const IFormFactor* outerShape, kvector_t positi RealSpaceMesoCrystal::~RealSpaceMesoCrystal() = default; RealSpaceMesoCrystal::RealSpaceMesoCrystal(const MesoCrystalItem* mesoCrystalItem, - double total_abundance, const QVector3D& origin) -{ + double total_abundance, const QVector3D& origin) { m_mesoCrystalItem = mesoCrystalItem; m_total_abundance = total_abundance; m_origin = origin; } -Particle3DContainer RealSpaceMesoCrystal::populateMesoCrystal() -{ +Particle3DContainer RealSpaceMesoCrystal::populateMesoCrystal() { auto mesoCrystal = m_mesoCrystalItem->createMesoCrystal(); std::unique_ptr<MesoCrystal> M_clone(mesoCrystal->clone()); // clone of the mesoCrystal diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.h index 65fc9870c65969285692c901f132b3d96fd92dc0..3dc4f5796be42402d76aeb77d6212147cb790593 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.h @@ -23,8 +23,7 @@ class MesoCrystal; class MesoCrystalItem; class Particle3DContainer; -class RealSpaceMesoCrystal -{ +class RealSpaceMesoCrystal { public: ~RealSpaceMesoCrystal(); diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceModel.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceModel.h index 026cecec1e96cd1988a05cd99dfaf2b4e183d17b..e803ed2d5a7974eb802aaec85b3bc4ce608b3cae 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceModel.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceModel.h @@ -17,8 +17,6 @@ #include "GUI/ba3d/model/model.h" -class RealSpaceModel : public RealSpace::Model -{ -}; +class RealSpaceModel : public RealSpace::Model {}; #endif // BORNAGAIN_GUI_COREGUI_VIEWS_REALSPACEWIDGETS_REALSPACEMODEL_H diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpacePositionBuilder.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpacePositionBuilder.cpp index 7e07ccb75955c6c56608a182b9576a444fc90b86..9be1293a1b2703d2d4602609717cec5d2a7ffd58 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpacePositionBuilder.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpacePositionBuilder.cpp @@ -15,44 +15,36 @@ #include "GUI/coregui/Views/RealSpaceWidgets/RealSpacePositionBuilder.h" #include "GUI/coregui/Views/RealSpaceWidgets/IPositionBuilder.h" -RealSpacePositionBuilder::RealSpacePositionBuilder() : m_pos_builder{new DefaultPositionBuilder()} -{ -} +RealSpacePositionBuilder::RealSpacePositionBuilder() + : m_pos_builder{new DefaultPositionBuilder()} {} RealSpacePositionBuilder::~RealSpacePositionBuilder() = default; -void RealSpacePositionBuilder::visit(const InterferenceFunction1DLattice* p_iff) -{ +void RealSpacePositionBuilder::visit(const InterferenceFunction1DLattice* p_iff) { m_pos_builder = std::make_unique<Lattice1DPositionBuilder>(p_iff); } -void RealSpacePositionBuilder::visit(const InterferenceFunction2DLattice* p_iff) -{ +void RealSpacePositionBuilder::visit(const InterferenceFunction2DLattice* p_iff) { m_pos_builder = std::make_unique<Lattice2DPositionBuilder>(p_iff); } -void RealSpacePositionBuilder::visit(const InterferenceFunction2DParaCrystal* p_iff) -{ +void RealSpacePositionBuilder::visit(const InterferenceFunction2DParaCrystal* p_iff) { m_pos_builder = std::make_unique<ParaCrystal2DPositionBuilder>(p_iff); } -void RealSpacePositionBuilder::visit(const InterferenceFunctionFinite2DLattice* p_iff) -{ +void RealSpacePositionBuilder::visit(const InterferenceFunctionFinite2DLattice* p_iff) { m_pos_builder = std::make_unique<Finite2DLatticePositionBuilder>(p_iff); } -void RealSpacePositionBuilder::visit(const InterferenceFunctionRadialParaCrystal* p_iff) -{ +void RealSpacePositionBuilder::visit(const InterferenceFunctionRadialParaCrystal* p_iff) { m_pos_builder = std::make_unique<RadialParacrystalPositionBuilder>(p_iff); } -void RealSpacePositionBuilder::visit(const InterferenceFunctionNone*) -{ +void RealSpacePositionBuilder::visit(const InterferenceFunctionNone*) { m_pos_builder.reset(new RandomPositionBuilder()); } std::vector<std::vector<double>> RealSpacePositionBuilder::generatePositions(double layer_size, - double density) const -{ + double density) const { return m_pos_builder->generatePositions(layer_size, density); } diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpacePositionBuilder.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpacePositionBuilder.h index 9e96d1f94785488e4ddaaafba21175d2080d3228..64b519c333589df2e9898cc798e4d31e993c49dd 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpacePositionBuilder.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpacePositionBuilder.h @@ -21,8 +21,7 @@ class IPositionBuilder; -class RealSpacePositionBuilder : public INodeVisitor -{ +class RealSpacePositionBuilder : public INodeVisitor { public: RealSpacePositionBuilder(); ~RealSpacePositionBuilder() override; diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.cpp index 7948adca32a8d102fc384b0d7d238d1652b7ed84..a4fb04371a4b76559fe4b153bb38955864c2dd6f 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.cpp @@ -18,8 +18,7 @@ #include <QCheckBox> #include <QToolButton> -namespace -{ +namespace { const double increaseLayerSizeScale = 1.25; const double decreaseLayerSizeScale = 0.8; } // namespace @@ -32,8 +31,7 @@ RealSpaceToolBar::RealSpaceToolBar(QWidget* parent) , m_lockViewCheckBox(new QCheckBox) , m_increaseLayerSizeButton(new QToolButton) , m_decreaseLayerSizeButton(new QToolButton) - , m_savePictureButton(new QToolButton) -{ + , m_savePictureButton(new QToolButton) { setMinimumSize(Constants::styled_toolbar_height, Constants::styled_toolbar_height); // Save image -- this first so it is available for smaller widget sizes diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.h index 29a367b10c0fb44773ef7ed24ad8e5efb5980cb3..b9e823047001a2d2169249ea71a0b8b6f36fdeab 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceToolBar.h @@ -22,8 +22,7 @@ class QCheckBox; //! Thin toolbar on top of RealSpaceWidget. -class RealSpaceToolBar : public StyledToolBar -{ +class RealSpaceToolBar : public StyledToolBar { Q_OBJECT public: diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.cpp index 2c4f953f886d4cb87eb3ef64dd190718174bfa79..fa50d5418aca0d6c3538438ee5ee3c28ae1e2832 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.cpp @@ -17,8 +17,7 @@ #include "GUI/coregui/Views/RealSpaceWidgets/RealSpaceModel.h" #include <QVBoxLayout> -RealSpaceView::RealSpaceView(QWidget* parent) : QWidget(parent), m_3dview(new RealSpace::Widget3D) -{ +RealSpaceView::RealSpaceView(QWidget* parent) : QWidget(parent), m_3dview(new RealSpace::Widget3D) { QVBoxLayout* layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); @@ -27,27 +26,22 @@ RealSpaceView::RealSpaceView(QWidget* parent) : QWidget(parent), m_3dview(new Re setLayout(layout); } -void RealSpaceView::setModel(RealSpaceModel* model) -{ +void RealSpaceView::setModel(RealSpaceModel* model) { m_3dview->setModel(model); } -void RealSpaceView::defaultView() -{ +void RealSpaceView::defaultView() { m_3dview->defaultView(); } -void RealSpaceView::sideView() -{ +void RealSpaceView::sideView() { m_3dview->sideView(); } -void RealSpaceView::topView() -{ +void RealSpaceView::topView() { m_3dview->topView(); } -RealSpace::Camera& RealSpaceView::getCamera() -{ +RealSpace::Camera& RealSpaceView::getCamera() { return m_3dview->cam(); } diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.h index cec5a126f2d377abcd84960a349a91d8a288946c..552b5f6e729637343bcaac4894725caa6b6fe8c2 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceView.h @@ -19,16 +19,14 @@ class RealSpaceModel; -namespace RealSpace -{ +namespace RealSpace { class Widget3D; class Camera; } // namespace RealSpace //! Contains 3D view. -class RealSpaceView : public QWidget -{ +class RealSpaceView : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.cpp index 687ae71ca9334887830bbd38fdbc5c1e350bc19a..c466bde3257c3e5ad57c33c7b4ef46a8f05ed5e5 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.cpp @@ -26,8 +26,7 @@ RealSpaceWidget::RealSpaceWidget(SampleModel* sampleModel, QItemSelectionModel* , m_toolBar(new RealSpaceToolBar) , m_canvas(new RealSpaceCanvas) , m_sampleModel(sampleModel) - , m_selectionModel(selectionModel) -{ + , m_selectionModel(selectionModel) { auto hlayout = new QHBoxLayout; hlayout->setMargin(0); hlayout->setSpacing(0); @@ -62,12 +61,10 @@ RealSpaceWidget::RealSpaceWidget(SampleModel* sampleModel, QItemSelectionModel* &RealSpaceCanvas::onSavePictureAction); } -void RealSpaceWidget::showEvent(QShowEvent*) -{ +void RealSpaceWidget::showEvent(QShowEvent*) { m_canvas->setModel(m_sampleModel, m_selectionModel); } -void RealSpaceWidget::hideEvent(QHideEvent*) -{ +void RealSpaceWidget::hideEvent(QHideEvent*) { m_canvas->setModel(nullptr, nullptr); } diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.h b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.h index 4dbab286f94acfbd826d525ab9a317286904db1b..3c68421d296ff1f26cbe00b6efe4775440e59a21 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.h +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceWidget.h @@ -26,8 +26,7 @@ class SampleModel; //! Prototype of real space widget to present sample structure in 3D view. -class RealSpaceWidget : public QWidget -{ +class RealSpaceWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp b/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp index fa5b123b103c59a343581e3f8af115cf822fd3c1..40619d8835fa8790ebfa727e6feee79cfeb8878c 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp @@ -25,23 +25,19 @@ #include "GUI/coregui/Views/RealSpaceWidgets/RealSpaceCanvas.h" #include "Sample/HardParticle/HardParticles.h" -namespace -{ -bool isTopLayer(const SessionItem& layerItem) -{ +namespace { +bool isTopLayer(const SessionItem& layerItem) { auto layers = layerItem.parent()->getItems(MultiLayerItem::T_LAYERS); return layers.indexOf(const_cast<SessionItem*>(&layerItem)) == 0; } -bool isBottomLayer(const SessionItem& layerItem) -{ +bool isBottomLayer(const SessionItem& layerItem) { auto layers = layerItem.parent()->getItems(MultiLayerItem::T_LAYERS); return layers.indexOf(const_cast<SessionItem*>(&layerItem)) == layers.size() - 1; } } // namespace double TransformTo3D::visualLayerThickness(const SessionItem& layerItem, - const SceneGeometry& sceneGeometry) -{ + const SceneGeometry& sceneGeometry) { ASSERT(layerItem.modelType() == "Layer"); double thickness(0.0); @@ -57,8 +53,7 @@ double TransformTo3D::visualLayerThickness(const SessionItem& layerItem, std::unique_ptr<RealSpace::Layer> TransformTo3D::createLayer(const SessionItem& layerItem, const SceneGeometry& sceneGeometry, - const QVector3D& origin) -{ + const QVector3D& origin) { ASSERT(layerItem.modelType() == "Layer"); double thickness = TransformTo3D::visualLayerThickness(layerItem, sceneGeometry); @@ -82,8 +77,7 @@ std::unique_ptr<RealSpace::Layer> TransformTo3D::createLayer(const SessionItem& } std::unique_ptr<RealSpace::Particles::Particle> -TransformTo3D::createParticle3D(const SessionItem& particleItem) -{ +TransformTo3D::createParticle3D(const SessionItem& particleItem) { ASSERT(particleItem.modelType() == "Particle"); std::unique_ptr<RealSpace::Particles::Particle> result; @@ -99,8 +93,7 @@ TransformTo3D::createParticle3D(const SessionItem& particleItem) } std::unique_ptr<RealSpace::Particles::Particle> -TransformTo3D::createParticlefromIFormFactor(const IFormFactor* ff) -{ +TransformTo3D::createParticlefromIFormFactor(const IFormFactor* ff) { std::unique_ptr<RealSpace::Particles::Particle> result; if (auto ff_AnisoPyramid = dynamic_cast<const FormFactorAnisoPyramid*>(ff)) { diff --git a/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.h b/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.h index 3e41d5af2f75555c2cab6bd055c29e4aee5d998f..1c948bfdbb9fd484754b7e2b56b1b2036b1dfcfc 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.h +++ b/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.h @@ -26,8 +26,7 @@ class IFormFactor; //! Collection of utility functions to build 3D objects from session items. -namespace TransformTo3D -{ +namespace TransformTo3D { double visualLayerThickness(const SessionItem& layerItem, const SceneGeometry& sceneGeometry); diff --git a/GUI/coregui/Views/SampleDesigner/ConnectableView.cpp b/GUI/coregui/Views/SampleDesigner/ConnectableView.cpp index 63888cea63759f662e80641d7a7bb345cd4f8011..0967006d03a801fd76ccbf7b054a1d23992a7802 100644 --- a/GUI/coregui/Views/SampleDesigner/ConnectableView.cpp +++ b/GUI/coregui/Views/SampleDesigner/ConnectableView.cpp @@ -29,8 +29,7 @@ ConnectableView::ConnectableView(QGraphicsItem* parent, QRectF rect) , m_color(Qt::gray) , m_rect(rect) , m_roundpar(0) - , m_label_vspace(0) -{ + , m_label_vspace(0) { setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges); @@ -39,8 +38,7 @@ ConnectableView::ConnectableView(QGraphicsItem* parent, QRectF rect) } void ConnectableView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, - QWidget* widget) -{ + QWidget* widget) { Q_UNUSED(widget); painter->setPen(Qt::gray); @@ -67,8 +65,7 @@ void ConnectableView::paint(QPainter* painter, const QStyleOptionGraphicsItem* o NodeEditorPort* ConnectableView::addPort(const QString& name, NodeEditorPort::EPortDirection direction, - NodeEditorPort::EPortType port_type) -{ + NodeEditorPort::EPortType port_type) { NodeEditorPort* port = new NodeEditorPort(this, name, direction, port_type); if (direction == NodeEditorPort::INPUT) { m_input_ports.append(port); @@ -81,14 +78,12 @@ NodeEditorPort* ConnectableView::addPort(const QString& name, return port; } -void ConnectableView::setLabel(const QString& name) -{ +void ConnectableView::setLabel(const QString& name) { m_label = name; setPortCoordinates(); } -void ConnectableView::connectInputPort(ConnectableView* other, int port_number) -{ +void ConnectableView::connectInputPort(ConnectableView* other, int port_number) { ASSERT(other); if (port_number >= m_input_ports.size()) @@ -111,14 +106,12 @@ void ConnectableView::connectInputPort(ConnectableView* other, int port_number) } } -int ConnectableView::getInputPortIndex(NodeEditorPort* port) -{ +int ConnectableView::getInputPortIndex(NodeEditorPort* port) { return m_input_ports.indexOf(port); } // calculation of y-pos for ports -void ConnectableView::setPortCoordinates() -{ +void ConnectableView::setPortCoordinates() { if (!getNumberOfPorts()) return; @@ -155,29 +148,24 @@ void ConnectableView::setPortCoordinates() } } -int ConnectableView::getNumberOfPorts() -{ +int ConnectableView::getNumberOfPorts() { return m_input_ports.size() + m_output_ports.size(); } -int ConnectableView::getNumberOfOutputPorts() -{ +int ConnectableView::getNumberOfOutputPorts() { return m_output_ports.size(); } -int ConnectableView::getNumberOfInputPorts() -{ +int ConnectableView::getNumberOfInputPorts() { return m_input_ports.size(); } -void ConnectableView::update_appearance() -{ +void ConnectableView::update_appearance() { setLabel(hyphenate(m_item->displayName())); IView::update_appearance(); } -QString ConnectableView::hyphenate(const QString& name) const -{ +QString ConnectableView::hyphenate(const QString& name) const { QRegExp capital_letter("[A-Z]"); QRegExp number("[0-9]"); int next_capital = capital_letter.indexIn(name, 1); diff --git a/GUI/coregui/Views/SampleDesigner/ConnectableView.h b/GUI/coregui/Views/SampleDesigner/ConnectableView.h index 7e1ed716f23e349e8af6a970dc1bfa0d8b0ccdd6..ef6352cfb43fa26e9bb88b974d5219864da7e31b 100644 --- a/GUI/coregui/Views/SampleDesigner/ConnectableView.h +++ b/GUI/coregui/Views/SampleDesigner/ConnectableView.h @@ -24,8 +24,7 @@ class QWidget; class NodeEditorPort; //! view of ISample's with rectangular shape and node functionality -class ConnectableView : public IView -{ +class ConnectableView : public IView { Q_OBJECT public: ConnectableView(QGraphicsItem* parent = 0, QRectF rect = {0, 0, 50, 50}); diff --git a/GUI/coregui/Views/SampleDesigner/DesignerHelper.cpp b/GUI/coregui/Views/SampleDesigner/DesignerHelper.cpp index f0d23adbafed986409c22a9326b7616128c3f0dd..024ee9762f163fa33d34df54906be500b70f57db 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerHelper.cpp +++ b/GUI/coregui/Views/SampleDesigner/DesignerHelper.cpp @@ -19,13 +19,11 @@ #include <iostream> #include <random> -namespace -{ +namespace { double m_current_zoom_level = 1.0; } -QGradient DesignerHelper::getLayerGradient(const QColor& color, const QRectF& rect) -{ +QGradient DesignerHelper::getLayerGradient(const QColor& color, const QRectF& rect) { QColor c = color; c.setAlpha(160); QLinearGradient result(rect.topLeft(), rect.bottomRight()); @@ -41,8 +39,7 @@ QGradient DesignerHelper::getLayerGradient(const QColor& color, const QRectF& re return std::move(result); } -QGradient DesignerHelper::getDecorationGradient(const QColor& color, const QRectF& rect) -{ +QGradient DesignerHelper::getDecorationGradient(const QColor& color, const QRectF& rect) { QColor c = color; // c.setAlpha(200); QLinearGradient result(rect.x() + rect.width() / 2, rect.y(), rect.x() + rect.width() / 2, @@ -53,8 +50,7 @@ QGradient DesignerHelper::getDecorationGradient(const QColor& color, const QRect return std::move(result); } -QPixmap DesignerHelper::getSceneBackground() -{ +QPixmap DesignerHelper::getSceneBackground() { const int size = 10; QPixmap result(size, size); result.fill(QColor(250, 250, 250)); @@ -66,8 +62,7 @@ QPixmap DesignerHelper::getSceneBackground() return result; } -QPixmap DesignerHelper::getPixmapLayer() -{ +QPixmap DesignerHelper::getPixmapLayer() { QRect rect(0, 0, layerWidth(), layerHeight()); QPixmap pixmap(rect.width() + 1, rect.height() + 1); pixmap.fill(Qt::transparent); @@ -78,8 +73,7 @@ QPixmap DesignerHelper::getPixmapLayer() return pixmap; } -QPixmap DesignerHelper::getPixmapMultiLayer() -{ +QPixmap DesignerHelper::getPixmapMultiLayer() { auto rect = getDefaultMultiLayerRect(); QPixmap pixmap(rect.width() + 1, rect.height() + 1); pixmap.fill(Qt::transparent); @@ -93,8 +87,7 @@ QPixmap DesignerHelper::getPixmapMultiLayer() return pixmap; } -QPixmap DesignerHelper::getPixmapParticleLayout() -{ +QPixmap DesignerHelper::getPixmapParticleLayout() { auto rect = getParticleLayoutBoundingRect(); QPixmap pixmap(rect.width() + 1, rect.height() + 1); pixmap.fill(Qt::transparent); @@ -105,8 +98,7 @@ QPixmap DesignerHelper::getPixmapParticleLayout() return pixmap; } -QPixmap DesignerHelper::getPixmapInterferenceFunction() -{ +QPixmap DesignerHelper::getPixmapInterferenceFunction() { auto rect = getInterferenceFunctionBoundingRect(); QPixmap pixmap(rect.width() + 1, rect.height() + 1); pixmap.fill(Qt::transparent); @@ -117,8 +109,7 @@ QPixmap DesignerHelper::getPixmapInterferenceFunction() return pixmap; } -QPixmap DesignerHelper::getPixmapParticle() -{ +QPixmap DesignerHelper::getPixmapParticle() { auto rect = getParticleBoundingRect(); QPixmap pixmap(rect.width() + 1, rect.height() + 1); pixmap.fill(Qt::transparent); @@ -129,8 +120,7 @@ QPixmap DesignerHelper::getPixmapParticle() return pixmap; } -QColor DesignerHelper::getRandomColor() -{ +QColor DesignerHelper::getRandomColor() { static std::random_device r; std::default_random_engine re(r()); std::uniform_int_distribution<int> ru(0, 255); @@ -138,15 +128,13 @@ QColor DesignerHelper::getRandomColor() return QColor(ru(re), ru(re), ru(re)); } -bool DesignerHelper::sort_layers(QGraphicsItem* left, QGraphicsItem* right) -{ +bool DesignerHelper::sort_layers(QGraphicsItem* left, QGraphicsItem* right) { return left->y() < right->y(); } // non-linear conversion of layer's thickness in nanometers to screen size to have reasonable // graphics representation -int DesignerHelper::nanometerToScreen(double nanometer) -{ +int DesignerHelper::nanometerToScreen(double nanometer) { const int ymin(layerHeight()); const int ymax(500); int result(ymin); @@ -155,8 +143,7 @@ int DesignerHelper::nanometerToScreen(double nanometer) return result; } -QRectF DesignerHelper::getDefaultBoundingRect(const QString& name) -{ +QRectF DesignerHelper::getDefaultBoundingRect(const QString& name) { if (name == "MultiLayer") { return getDefaultMultiLayerRect(); } else if (name == "Layer") { @@ -175,8 +162,7 @@ QRectF DesignerHelper::getDefaultBoundingRect(const QString& name) } } -QColor DesignerHelper::getDefaultColor(const QString& name) -{ +QColor DesignerHelper::getDefaultColor(const QString& name) { if (name == "MultiLayer") { // return QColor(Qt::blue); return QColor(51, 116, 255); @@ -198,8 +184,7 @@ QColor DesignerHelper::getDefaultColor(const QString& name) } } -QPixmap DesignerHelper::getMimePixmap(const QString& name) -{ +QPixmap DesignerHelper::getMimePixmap(const QString& name) { QRectF default_rect = getDefaultBoundingRect(name); QRectF mime_rect(0, 0, default_rect.width() * m_current_zoom_level, default_rect.height() * m_current_zoom_level); @@ -213,82 +198,66 @@ QPixmap DesignerHelper::getMimePixmap(const QString& name) return pixmap; } -int DesignerHelper::getHeaderFontSize() -{ +int DesignerHelper::getHeaderFontSize() { return StyleUtils::SystemPointSize() * 1.5; } -int DesignerHelper::layerWidth() -{ +int DesignerHelper::layerWidth() { return StyleUtils::SizeOfLetterM().width() * 18; } -int DesignerHelper::layerHeight() -{ +int DesignerHelper::layerHeight() { return StyleUtils::SizeOfLetterM().height() * 2; } -QColor DesignerHelper::getDefaultLayerColor() -{ +QColor DesignerHelper::getDefaultLayerColor() { return QColor(Qt::lightGray); } -QRectF DesignerHelper::getDefaultMultiLayerRect() -{ +QRectF DesignerHelper::getDefaultMultiLayerRect() { return QRectF(0, 0, layerWidth() * 1.15, layerHeight()); } -QRectF DesignerHelper::getParticleLayoutBoundingRect() -{ +QRectF DesignerHelper::getParticleLayoutBoundingRect() { return QRectF(0, 0, layerHeight() * 3.5, layerHeight() * 4.5); } -QRectF DesignerHelper::getInterferenceFunctionBoundingRect() -{ +QRectF DesignerHelper::getInterferenceFunctionBoundingRect() { return QRectF(0, 0, layerHeight() * 4.5, layerHeight() * 4); } -QColor DesignerHelper::getDefaultParticleColor() -{ +QColor DesignerHelper::getDefaultParticleColor() { return QColor(210, 223, 237); } -QRectF DesignerHelper::getParticleBoundingRect() -{ +QRectF DesignerHelper::getParticleBoundingRect() { return QRectF(0, 0, layerHeight() * 3.5, layerHeight() * 4); } -QColor DesignerHelper::getDefaultTransformationColor() -{ +QColor DesignerHelper::getDefaultTransformationColor() { return QColor(145, 50, 220); } -QRectF DesignerHelper::getTransformationBoundingRect() -{ +QRectF DesignerHelper::getTransformationBoundingRect() { return QRectF(0, 0, layerHeight() * 4, layerHeight() * 2); } -QColor DesignerHelper::getDefaultMaterialColor() -{ +QColor DesignerHelper::getDefaultMaterialColor() { return getRandomColor(); } -int DesignerHelper::getSectionFontSize() -{ +int DesignerHelper::getSectionFontSize() { return StyleUtils::SystemPointSize() * 1.2; } -int DesignerHelper::getLabelFontSize() -{ +int DesignerHelper::getLabelFontSize() { return StyleUtils::SystemPointSize() * 0.9; } -int DesignerHelper::getPortFontSize() -{ +int DesignerHelper::getPortFontSize() { return StyleUtils::SystemPointSize() * 0.7; } -int DesignerHelper::getPythonEditorFontSize() -{ +int DesignerHelper::getPythonEditorFontSize() { return StyleUtils::SystemPointSize(); } diff --git a/GUI/coregui/Views/SampleDesigner/DesignerHelper.h b/GUI/coregui/Views/SampleDesigner/DesignerHelper.h index 5799165f8cfb27f15f6e48ea1581fe5d4ed7da0d..af2816250baba2becb6aa747b4cf00aaeaecf890 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerHelper.h +++ b/GUI/coregui/Views/SampleDesigner/DesignerHelper.h @@ -21,8 +21,7 @@ #include <QRect> //! collection of static methods with SampleDesigner geometry settings -class DesignerHelper -{ +class DesignerHelper { public: static int layerWidth(); static int layerHeight(); diff --git a/GUI/coregui/Views/SampleDesigner/DesignerMimeData.cpp b/GUI/coregui/Views/SampleDesigner/DesignerMimeData.cpp index d79dd9207b94b8307efc6df939d91871df76143e..531ad57b647d7626d4cfd3fab626e66daf8a6a09 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerMimeData.cpp +++ b/GUI/coregui/Views/SampleDesigner/DesignerMimeData.cpp @@ -29,8 +29,7 @@ #endif DesignerMimeData::DesignerMimeData(const QString& entryname, const QString& xmldescr, QDrag* drag) - : m_entryname(entryname), m_xmldescr(xmldescr) -{ + : m_entryname(entryname), m_xmldescr(xmldescr) { drag->setMimeData(this); read_xmldescr(m_xmldescr); @@ -44,8 +43,7 @@ DesignerMimeData::DesignerMimeData(const QString& entryname, const QString& xmld drag->setHotSpot(QPoint(drag->pixmap().width() / 2, drag->pixmap().height() / 2)); } -void DesignerMimeData::read_xmldescr(const QString& xmldescr) -{ +void DesignerMimeData::read_xmldescr(const QString& xmldescr) { QXmlStreamReader reader(xmldescr); bool widget_found = false; @@ -74,8 +72,7 @@ void DesignerMimeData::read_xmldescr(const QString& xmldescr) } // extract class name and skip the rest -void DesignerMimeData::read_widget(QXmlStreamReader& reader) -{ +void DesignerMimeData::read_widget(QXmlStreamReader& reader) { for (const QXmlStreamAttribute& attribute : reader.attributes()) { QStringRef name = attribute.name(); if (name == "class") { @@ -89,8 +86,7 @@ void DesignerMimeData::read_widget(QXmlStreamReader& reader) // Execute a drag and drop operation. Qt::DropAction DesignerMimeData::execDrag(const QString& name, const QString& xmldescr, - QWidget* dragSource) -{ + QWidget* dragSource) { if (xmldescr.size() == 0) return Qt::IgnoreAction; @@ -103,7 +99,6 @@ Qt::DropAction DesignerMimeData::execDrag(const QString& name, const QString& xm return executedAction; } -QPixmap DesignerMimeData::getPixmap(const QString& name) -{ +QPixmap DesignerMimeData::getPixmap(const QString& name) { return DesignerHelper::getMimePixmap(name); } diff --git a/GUI/coregui/Views/SampleDesigner/DesignerMimeData.h b/GUI/coregui/Views/SampleDesigner/DesignerMimeData.h index 9537c81fc9893e0f90cbfc28c80d77d7f2f9d0c6..c48b3e54be9c9aa478088bd5a4dad2f6d798e022 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerMimeData.h +++ b/GUI/coregui/Views/SampleDesigner/DesignerMimeData.h @@ -21,8 +21,7 @@ class QDrag; class QXmlStreamReader; //! Mime data for use with SampleDesigner drag and drop operations -class DesignerMimeData : public QMimeData -{ +class DesignerMimeData : public QMimeData { Q_OBJECT public: DesignerMimeData(const QString& name, const QString& xmldescr, QDrag* drag); diff --git a/GUI/coregui/Views/SampleDesigner/DesignerScene.cpp b/GUI/coregui/Views/SampleDesigner/DesignerScene.cpp index bd8e650108d6f5b02220d337878e97cf20231ad1..72bc1d6fafca52aa894a5f30095c23ebdc104e96 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerScene.cpp +++ b/GUI/coregui/Views/SampleDesigner/DesignerScene.cpp @@ -42,8 +42,7 @@ DesignerScene::DesignerScene(QObject* parent) , m_selectionModel(0) , m_proxy(0) , m_block_selection(false) - , m_aligner(new SampleViewAligner(this)) -{ + , m_aligner(new SampleViewAligner(this)) { setSceneRect(QRectF(-1600, 0, 3200, 3200)); setBackgroundBrush(DesignerHelper::getSceneBackground()); @@ -56,13 +55,11 @@ DesignerScene::DesignerScene(QObject* parent) connect(this, SIGNAL(selectionChanged()), this, SLOT(onSceneSelectionChanged())); } -DesignerScene::~DesignerScene() -{ +DesignerScene::~DesignerScene() { delete m_aligner; } -void DesignerScene::setSampleModel(SampleModel* sampleModel) -{ +void DesignerScene::setSampleModel(SampleModel* sampleModel) { ASSERT(sampleModel); if (sampleModel != m_sampleModel) { @@ -94,18 +91,15 @@ void DesignerScene::setSampleModel(SampleModel* sampleModel) } } -void DesignerScene::setInstrumentModel(InstrumentModel* instrumentModel) -{ +void DesignerScene::setInstrumentModel(InstrumentModel* instrumentModel) { m_instrumentModel = instrumentModel; } -void DesignerScene::setMaterialModel(MaterialModel* materialModel) -{ +void DesignerScene::setMaterialModel(MaterialModel* materialModel) { m_materialModel = materialModel; } -void DesignerScene::setSelectionModel(QItemSelectionModel* model, FilterPropertyProxy* proxy) -{ +void DesignerScene::setSelectionModel(QItemSelectionModel* model, FilterPropertyProxy* proxy) { ASSERT(model); if (model != m_selectionModel) { @@ -123,8 +117,7 @@ void DesignerScene::setSelectionModel(QItemSelectionModel* model, FilterProperty } } -IView* DesignerScene::getViewForItem(SessionItem* item) -{ +IView* DesignerScene::getViewForItem(SessionItem* item) { auto it = m_ItemToView.find(item); if (it != m_ItemToView.end()) { return it.value(); @@ -132,31 +125,28 @@ IView* DesignerScene::getViewForItem(SessionItem* item) return nullptr; } -void DesignerScene::resetScene() -{ +void DesignerScene::resetScene() { clear(); m_ItemToView.clear(); m_layer_interface_line = {}; } -void DesignerScene::updateScene() -{ +void DesignerScene::updateScene() { updateViews(); alignViews(); } -void DesignerScene::onRowsInserted(const QModelIndex& /* parent */, int /* first */, int /* last */) -{ +void DesignerScene::onRowsInserted(const QModelIndex& /* parent */, int /* first */, + int /* last */) { updateScene(); } -void DesignerScene::onRowsRemoved(const QModelIndex& /* parent */, int /* first */, int /* last */) -{ +void DesignerScene::onRowsRemoved(const QModelIndex& /* parent */, int /* first */, + int /* last */) { updateScene(); } -void DesignerScene::onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last) -{ +void DesignerScene::onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last) { m_block_selection = true; for (int irow = first; irow <= last; ++irow) { QModelIndex itemIndex = m_sampleModel->index(irow, 0, parent); @@ -167,8 +157,7 @@ void DesignerScene::onRowsAboutToBeRemoved(const QModelIndex& parent, int first, //! propagate selection from model to scene void DesignerScene::onSessionSelectionChanged(const QItemSelection& /* selected */, - const QItemSelection& /* deselected */) -{ + const QItemSelection& /* deselected */) { if (m_block_selection) return; @@ -190,8 +179,7 @@ void DesignerScene::onSessionSelectionChanged(const QItemSelection& /* selected } //! propagate selection from scene to model -void DesignerScene::onSceneSelectionChanged() -{ +void DesignerScene::onSceneSelectionChanged() { if (m_block_selection) return; @@ -215,8 +203,7 @@ void DesignerScene::onSceneSelectionChanged() } //! runs through all items recursively and updates corresponding views -void DesignerScene::updateViews(const QModelIndex& parentIndex, IView* parentView) -{ +void DesignerScene::updateViews(const QModelIndex& parentIndex, IView* parentView) { ASSERT(m_sampleModel); IView* childView(0); @@ -241,8 +228,7 @@ void DesignerScene::updateViews(const QModelIndex& parentIndex, IView* parentVie } //! adds view for item, if it doesn't exists -IView* DesignerScene::addViewForItem(SessionItem* item) -{ +IView* DesignerScene::addViewForItem(SessionItem* item) { ASSERT(item); IView* view = getViewForItem(item); @@ -262,14 +248,12 @@ IView* DesignerScene::addViewForItem(SessionItem* item) } //! aligns SampleView's on graphical canvas -void DesignerScene::alignViews() -{ +void DesignerScene::alignViews() { m_aligner->alignSample(QModelIndex(), QPointF(200, 800)); } //! runs recursively through model's item and schedules view removal -void DesignerScene::deleteViews(const QModelIndex& viewIndex) -{ +void DesignerScene::deleteViews(const QModelIndex& viewIndex) { for (int i_row = 0; i_row < m_sampleModel->rowCount(viewIndex); ++i_row) { QModelIndex itemIndex = m_sampleModel->index(i_row, 0, viewIndex); @@ -285,8 +269,7 @@ void DesignerScene::deleteViews(const QModelIndex& viewIndex) } //! removes view from scene corresponding to given item -void DesignerScene::removeItemViewFromScene(SessionItem* item) -{ +void DesignerScene::removeItemViewFromScene(SessionItem* item) { ASSERT(item); for (QMap<SessionItem*, IView*>::iterator it = m_ItemToView.begin(); it != m_ItemToView.end(); @@ -305,8 +288,7 @@ void DesignerScene::removeItemViewFromScene(SessionItem* item) } //! propagates deletion of views on the scene to the model -void DesignerScene::deleteSelectedItems() -{ +void DesignerScene::deleteSelectedItems() { QModelIndexList indexes = m_selectionModel->selectedIndexes(); QList<IView*> views_which_will_be_deleted; @@ -335,8 +317,7 @@ void DesignerScene::deleteSelectedItems() } //! shows appropriate layer interface to drop while moving ILayerView -void DesignerScene::drawForeground(QPainter* painter, const QRectF& /* rect */) -{ +void DesignerScene::drawForeground(QPainter* painter, const QRectF& /* rect */) { if (isLayerDragged()) { painter->setPen(QPen(Qt::darkBlue, 2, Qt::DashLine)); painter->drawLine(m_layer_interface_line); @@ -344,8 +325,7 @@ void DesignerScene::drawForeground(QPainter* painter, const QRectF& /* rect */) } //! propagates connection established by NodeEditor to the model -void DesignerScene::onEstablishedConnection(NodeEditorConnection* connection) -{ +void DesignerScene::onEstablishedConnection(NodeEditorConnection* connection) { ConnectableView* parentView = connection->getParentView(); ConnectableView* childView = connection->getChildView(); @@ -374,8 +354,7 @@ void DesignerScene::onEstablishedConnection(NodeEditorConnection* connection) } //! propagates break of connection between views on scene to the model -void DesignerScene::removeConnection(NodeEditorConnection* connection) -{ +void DesignerScene::removeConnection(NodeEditorConnection* connection) { IView* childView = dynamic_cast<IView*>(connection->outputPort()->parentItem()); m_sampleModel->moveItem(childView->getItem(), 0); } @@ -383,8 +362,7 @@ void DesignerScene::removeConnection(NodeEditorConnection* connection) //! handles drag event //! LayerView can be dragged only over MultiLayerView //! MultiLayerView can be dragged both, over the scene and over another MultiLayerView -void DesignerScene::dragMoveEvent(QGraphicsSceneDragDropEvent* event) -{ +void DesignerScene::dragMoveEvent(QGraphicsSceneDragDropEvent* event) { const DesignerMimeData* mimeData = checkDragEvent(event); if (isAcceptedByMultiLayer(mimeData, event)) { QGraphicsScene::dragMoveEvent(event); @@ -394,8 +372,7 @@ void DesignerScene::dragMoveEvent(QGraphicsSceneDragDropEvent* event) //! Hadles drop event //! LayerView can be dropped on MultiLayerView only //! MultiLayerView can be droped on the scene or another MultiLayerView -void DesignerScene::dropEvent(QGraphicsSceneDragDropEvent* event) -{ +void DesignerScene::dropEvent(QGraphicsSceneDragDropEvent* event) { const DesignerMimeData* mimeData = checkDragEvent(event); if (mimeData) { @@ -444,8 +421,7 @@ void DesignerScene::dropEvent(QGraphicsSceneDragDropEvent* event) } //! returns proper MimeData if the object can be hadled by graphics scene -const DesignerMimeData* DesignerScene::checkDragEvent(QGraphicsSceneDragDropEvent* event) -{ +const DesignerMimeData* DesignerScene::checkDragEvent(QGraphicsSceneDragDropEvent* event) { const DesignerMimeData* mimeData = qobject_cast<const DesignerMimeData*>(event->mimeData()); if (!mimeData) { event->ignore(); @@ -455,8 +431,7 @@ const DesignerMimeData* DesignerScene::checkDragEvent(QGraphicsSceneDragDropEven return mimeData; } -void DesignerScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) -{ +void DesignerScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (isLayerDragged()) { invalidate(); // to redraw vertical dashed line which denotes where to drag the layer } @@ -464,8 +439,7 @@ void DesignerScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) } //! Returns true if there is MultiLayerView nearby during drag event. -bool DesignerScene::isMultiLayerNearby(QGraphicsSceneDragDropEvent* event) -{ +bool DesignerScene::isMultiLayerNearby(QGraphicsSceneDragDropEvent* event) { QRectF rect = DesignerHelper::getDefaultMultiLayerRect(); rect.moveCenter(event->scenePos()); for (QGraphicsItem* item : items(rect)) { @@ -475,8 +449,7 @@ bool DesignerScene::isMultiLayerNearby(QGraphicsSceneDragDropEvent* event) return false; } -void DesignerScene::adjustSceneRect() -{ +void DesignerScene::adjustSceneRect() { QRectF boundingRect = itemsBoundingRect(); if (sceneRect().contains(boundingRect)) return; @@ -486,8 +459,7 @@ void DesignerScene::adjustSceneRect() } bool DesignerScene::isAcceptedByMultiLayer(const DesignerMimeData* mimeData, - QGraphicsSceneDragDropEvent* event) -{ + QGraphicsSceneDragDropEvent* event) { if (!mimeData) return false; @@ -503,8 +475,7 @@ bool DesignerScene::isAcceptedByMultiLayer(const DesignerMimeData* mimeData, return false; } -bool DesignerScene::isLayerDragged() const -{ +bool DesignerScene::isLayerDragged() const { ILayerView* layer = dynamic_cast<ILayerView*>(mouseGrabberItem()); if (layer && !m_layer_interface_line.isNull()) { return true; @@ -512,7 +483,6 @@ bool DesignerScene::isLayerDragged() const return false; } -void DesignerScene::onSmartAlign() -{ +void DesignerScene::onSmartAlign() { m_aligner->smartAlign(); } diff --git a/GUI/coregui/Views/SampleDesigner/DesignerScene.h b/GUI/coregui/Views/SampleDesigner/DesignerScene.h index c2918900f3469027f7b751d7abdc192a0eba0e3a..dfc062b7c81493c0f7543fd0eda09b68be7e53bc 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerScene.h +++ b/GUI/coregui/Views/SampleDesigner/DesignerScene.h @@ -34,8 +34,7 @@ class FilterPropertyProxy; class MaterialModel; //! Main class which represents SessionModel on graphics scene -class DesignerScene : public QGraphicsScene -{ +class DesignerScene : public QGraphicsScene { Q_OBJECT public: @@ -66,8 +65,7 @@ public slots: void onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last); void onRowsRemoved(const QModelIndex& parent, int first, int last); - void setLayerInterfaceLine(const QLineF& line = {}) - { + void setLayerInterfaceLine(const QLineF& line = {}) { m_layer_interface_line = line; invalidate(); } diff --git a/GUI/coregui/Views/SampleDesigner/DesignerView.cpp b/GUI/coregui/Views/SampleDesigner/DesignerView.cpp index e9585ec1c7809cd53c0cba325530ea742a03823f..97637360bb2912847882626278f142c9fa1d5266 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerView.cpp +++ b/GUI/coregui/Views/SampleDesigner/DesignerView.cpp @@ -24,16 +24,14 @@ #include <QShortcut> #include <QVBoxLayout> -DesignerView::DesignerView(QGraphicsScene* scene, QWidget* parent) : QGraphicsView(scene, parent) -{ +DesignerView::DesignerView(QGraphicsScene* scene, QWidget* parent) : QGraphicsView(scene, parent) { setAcceptDrops(true); setRenderHint(QPainter::Antialiasing); setMouseTracking(true); setDragMode(QGraphicsView::RubberBandDrag); } -int DesignerView::getSelectionMode() const -{ +int DesignerView::getSelectionMode() const { if (dragMode() == QGraphicsView::NoDrag) { return SIMPLE_SELECTION; } else if (dragMode() == QGraphicsView::RubberBandDrag) { @@ -45,8 +43,7 @@ int DesignerView::getSelectionMode() const } } -void DesignerView::onSelectionMode(int mode) -{ +void DesignerView::onSelectionMode(int mode) { switch (mode) { case SIMPLE_SELECTION: setDragMode(QGraphicsView::NoDrag); @@ -68,29 +65,25 @@ void DesignerView::onSelectionMode(int mode) } } -void DesignerView::onCenterView() -{ +void DesignerView::onCenterView() { // fitInView(scene()->itemsBoundingRect() ,Qt::KeepAspectRatio); centerOn(scene()->itemsBoundingRect().center()); } -void DesignerView::onChangeScale(double new_scale) -{ +void DesignerView::onChangeScale(double new_scale) { QTransform oldMatrix = transform(); resetTransform(); translate(oldMatrix.dx(), oldMatrix.dy()); scale(new_scale, new_scale); } -void DesignerView::deleteSelectedItems() -{ +void DesignerView::deleteSelectedItems() { DesignerScene* designerScene = dynamic_cast<DesignerScene*>(scene()); ASSERT(designerScene); designerScene->deleteSelectedItems(); } -void DesignerView::keyPressEvent(QKeyEvent* event) -{ +void DesignerView::keyPressEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_Left: break; @@ -110,8 +103,7 @@ void DesignerView::keyPressEvent(QKeyEvent* event) } } -void DesignerView::keyReleaseEvent(QKeyEvent* event) -{ +void DesignerView::keyReleaseEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_Space: diff --git a/GUI/coregui/Views/SampleDesigner/DesignerView.h b/GUI/coregui/Views/SampleDesigner/DesignerView.h index e35042bcb02c4bdf03a69f9a016212bbb74a1efa..ab36e532941b7e4be4d121de9b0277dabab7cc02 100644 --- a/GUI/coregui/Views/SampleDesigner/DesignerView.h +++ b/GUI/coregui/Views/SampleDesigner/DesignerView.h @@ -27,8 +27,7 @@ class QKeyEvent; //! //! Belongs to SampleDesigner //! Currently contains logic for zooming, deleting objects -class DesignerView : public QGraphicsView -{ +class DesignerView : public QGraphicsView { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/ILayerView.cpp b/GUI/coregui/Views/SampleDesigner/ILayerView.cpp index fd2a3ae0c4e3300d13510d56bacd51790ca48c3e..c59adb96fdbb89259e39f6c89631e5f0bf8875e1 100644 --- a/GUI/coregui/Views/SampleDesigner/ILayerView.cpp +++ b/GUI/coregui/Views/SampleDesigner/ILayerView.cpp @@ -21,8 +21,7 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include <QGraphicsSceneMouseEvent> -QLineF MultiLayerCandidate::getInterfaceToScene() -{ +QLineF MultiLayerCandidate::getInterfaceToScene() { ASSERT(multilayer); QLineF line = multilayer->getInterfaceLine(row); if (line.length() != 0) { @@ -35,21 +34,18 @@ QLineF MultiLayerCandidate::getInterfaceToScene() return QLineF(); } -bool MultiLayerCandidate::operator<(const MultiLayerCandidate& cmp) const -{ +bool MultiLayerCandidate::operator<(const MultiLayerCandidate& cmp) const { return cmp.distance < distance; } -ILayerView::ILayerView(QGraphicsItem* parent) : ConnectableView(parent) -{ +ILayerView::ILayerView(QGraphicsItem* parent) : ConnectableView(parent) { setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges); } //! Propagates change of 'Thickness' dynamic property to screen thickness of ILayerView. -void ILayerView::onPropertyChange(const QString& propertyName) -{ +void ILayerView::onPropertyChange(const QString& propertyName) { if (propertyName == LayerItem::P_THICKNESS) { updateHeight(); } else if (propertyName == LayerItem::P_MATERIAL) { @@ -60,8 +56,7 @@ void ILayerView::onPropertyChange(const QString& propertyName) IView::onPropertyChange(propertyName); } -void ILayerView::updateHeight() -{ +void ILayerView::updateHeight() { if (m_item->isTag(LayerItem::P_THICKNESS)) { m_rect.setHeight(DesignerHelper::nanometerToScreen( m_item->getItemValue(LayerItem::P_THICKNESS).toDouble())); @@ -71,8 +66,7 @@ void ILayerView::updateHeight() } } -void ILayerView::updateColor() -{ +void ILayerView::updateColor() { if (m_item->isTag(LayerItem::P_MATERIAL)) { QVariant v = m_item->getItemValue(LayerItem::P_MATERIAL); if (v.isValid()) { @@ -85,8 +79,7 @@ void ILayerView::updateColor() } } -void ILayerView::updateLabel() -{ +void ILayerView::updateLabel() { if (getInputPorts().size() < 1) return; @@ -119,8 +112,7 @@ void ILayerView::updateLabel() //! Detects movement of the ILayerView and sends possible drop areas to GraphicsScene //! for visualization. -QVariant ILayerView::itemChange(GraphicsItemChange change, const QVariant& value) -{ +QVariant ILayerView::itemChange(GraphicsItemChange change, const QVariant& value) { if (change == ItemPositionChange && scene()) { MultiLayerCandidate multilayerCandidate = getMultiLayerCandidate(); @@ -132,8 +124,7 @@ QVariant ILayerView::itemChange(GraphicsItemChange change, const QVariant& value return QGraphicsItem::itemChange(change, value); } -void ILayerView::mousePressEvent(QGraphicsSceneMouseEvent* event) -{ +void ILayerView::mousePressEvent(QGraphicsSceneMouseEvent* event) { if (event->button() == Qt::LeftButton) { m_drag_start_position = pos(); } @@ -142,8 +133,7 @@ void ILayerView::mousePressEvent(QGraphicsSceneMouseEvent* event) //! Detects possible MultiLayerView's to drop given ILayerView and propagate //! request to SessionModel. -void ILayerView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) -{ +void ILayerView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { DesignerScene* designerScene = dynamic_cast<DesignerScene*>(scene()); ASSERT(designerScene); designerScene->setLayerInterfaceLine(); // removing drop area hint from the scene @@ -205,8 +195,7 @@ void ILayerView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) throw GUIHelpers::Error("LayerView::mouseReleaseEvent() -> Loggic error."); } -void ILayerView::update_appearance() -{ +void ILayerView::update_appearance() { updateHeight(); updateColor(); updateLabel(); @@ -219,8 +208,7 @@ void ILayerView::update_appearance() //! ILayerView should intersects and ILayerView center should be near appropriate //! drop area. If more than one candidate is found, they will be sorted according //! to the distance between drop area and ILayerVIew center -MultiLayerCandidate ILayerView::getMultiLayerCandidate() -{ +MultiLayerCandidate ILayerView::getMultiLayerCandidate() { QVector<MultiLayerCandidate> candidates; QRectF layerRect = mapRectToScene(boundingRect()); diff --git a/GUI/coregui/Views/SampleDesigner/ILayerView.h b/GUI/coregui/Views/SampleDesigner/ILayerView.h index f178e8770881a08db1b71317148817461a8f0e22..a131891783fc47aef4150d39f2e6af95c73440d3 100644 --- a/GUI/coregui/Views/SampleDesigner/ILayerView.h +++ b/GUI/coregui/Views/SampleDesigner/ILayerView.h @@ -22,8 +22,7 @@ class MultiLayerCandidate; //! Base class for LayerView and MultiLayerView //! Provides functionality for moving view on top of MultiLayer. -class ILayerView : public ConnectableView -{ +class ILayerView : public ConnectableView { Q_OBJECT public: @@ -53,8 +52,7 @@ private: }; //! Class to hold MultiLayer candidate for dropping LayerView. -class MultiLayerCandidate -{ +class MultiLayerCandidate { public: MultiLayerCandidate() : multilayer(0), row(-1), distance(0) {} MultiLayerView* multilayer; //!< pointer to the candidate diff --git a/GUI/coregui/Views/SampleDesigner/IView.cpp b/GUI/coregui/Views/SampleDesigner/IView.cpp index 30268b7662978d18973ccbbaed7ec40fe81e5950..333616127f709a248022fc6cfd523c031605d0c4 100644 --- a/GUI/coregui/Views/SampleDesigner/IView.cpp +++ b/GUI/coregui/Views/SampleDesigner/IView.cpp @@ -16,20 +16,17 @@ #include "GUI/coregui/Models/SessionGraphicsItem.h" #include <QString> -IView::IView(QGraphicsItem* parent) : QGraphicsObject(parent), m_item(0) -{ +IView::IView(QGraphicsItem* parent) : QGraphicsObject(parent), m_item(0) { connect(this, SIGNAL(xChanged()), this, SLOT(onChangedX())); connect(this, SIGNAL(yChanged()), this, SLOT(onChangedY())); } -IView::~IView() -{ +IView::~IView() { if (m_item) m_item->mapper()->unsubscribe(this); } -void IView::setParameterizedItem(SessionItem* item) -{ +void IView::setParameterizedItem(SessionItem* item) { ASSERT(item); ASSERT(m_item == nullptr); @@ -52,28 +49,24 @@ void IView::setParameterizedItem(SessionItem* item) void IView::addView(IView*, int) {} -void IView::onChangedX() -{ +void IView::onChangedX() { if (!m_item) return; m_item->setItemValue(SessionGraphicsItem::P_XPOS, x()); } -void IView::onChangedY() -{ +void IView::onChangedY() { if (!m_item) return; m_item->setItemValue(SessionGraphicsItem::P_YPOS, y()); } //! updates visual appearance of the item (color, icons, size etc) -void IView::update_appearance() -{ +void IView::update_appearance() { update(); } -void IView::onPropertyChange(const QString& propertyName) -{ +void IView::onPropertyChange(const QString& propertyName) { ASSERT(m_item); if (propertyName == SessionGraphicsItem::P_XPOS) { setX(m_item->getItemValue(SessionGraphicsItem::P_XPOS).toReal()); @@ -82,7 +75,6 @@ void IView::onPropertyChange(const QString& propertyName) } } -void IView::onSiblingsChange() -{ +void IView::onSiblingsChange() { update_appearance(); } diff --git a/GUI/coregui/Views/SampleDesigner/IView.h b/GUI/coregui/Views/SampleDesigner/IView.h index e983b77f4d7378a34afc2a0404ae419ce755ea9d..631aa14057b910fcda384299add773c470089009 100644 --- a/GUI/coregui/Views/SampleDesigner/IView.h +++ b/GUI/coregui/Views/SampleDesigner/IView.h @@ -22,8 +22,7 @@ class SessionItem; //! parent class for graphic representation of all ISample's -class IView : public QGraphicsObject -{ +class IView : public QGraphicsObject { Q_OBJECT public: IView(QGraphicsItem* parent = 0); @@ -52,13 +51,11 @@ protected: SessionItem* m_item; }; -inline int IView::type() const -{ +inline int IView::type() const { return ViewTypes::IVIEW; } -inline SessionItem* IView::getItem() -{ +inline SessionItem* IView::getItem() { return m_item; } diff --git a/GUI/coregui/Views/SampleDesigner/InterferenceFunctionViews.cpp b/GUI/coregui/Views/SampleDesigner/InterferenceFunctionViews.cpp index cac5f2e57545dbe3f5d843babce3cd7d086b2e4e..d5d514931bd1d006bb7796911df8f85bccb238e4 100644 --- a/GUI/coregui/Views/SampleDesigner/InterferenceFunctionViews.cpp +++ b/GUI/coregui/Views/SampleDesigner/InterferenceFunctionViews.cpp @@ -16,8 +16,7 @@ #include "GUI/coregui/Views/SampleDesigner/DesignerHelper.h" InterferenceFunction1DLatticeView::InterferenceFunction1DLatticeView(QGraphicsItem* parent) - : ConnectableView(parent) -{ + : ConnectableView(parent) { setName("Interference1DLattice"); setColor(QColor(255, 236, 139)); setRectangle(DesignerHelper::getInterferenceFunctionBoundingRect()); @@ -26,8 +25,7 @@ InterferenceFunction1DLatticeView::InterferenceFunction1DLatticeView(QGraphicsIt } InterferenceFunction2DLatticeView::InterferenceFunction2DLatticeView(QGraphicsItem* parent) - : ConnectableView(parent) -{ + : ConnectableView(parent) { setName("Interference2DLattice"); setColor(QColor(255, 236, 139)); setRectangle(DesignerHelper::getInterferenceFunctionBoundingRect()); @@ -36,8 +34,7 @@ InterferenceFunction2DLatticeView::InterferenceFunction2DLatticeView(QGraphicsIt } InterferenceFunction2DParaCrystalView::InterferenceFunction2DParaCrystalView(QGraphicsItem* parent) - : ConnectableView(parent) -{ + : ConnectableView(parent) { setName("Interference2DParaCrystal"); setColor(QColor(255, 236, 139)); setRectangle(DesignerHelper::getInterferenceFunctionBoundingRect()); @@ -47,8 +44,7 @@ InterferenceFunction2DParaCrystalView::InterferenceFunction2DParaCrystalView(QGr InterferenceFunctionFinite2DLatticeView::InterferenceFunctionFinite2DLatticeView( QGraphicsItem* parent) - : ConnectableView(parent) -{ + : ConnectableView(parent) { setName("InterferenceFinite2DLattice"); setColor(QColor(255, 236, 139)); setRectangle(DesignerHelper::getInterferenceFunctionBoundingRect()); @@ -57,8 +53,7 @@ InterferenceFunctionFinite2DLatticeView::InterferenceFunctionFinite2DLatticeView } InterferenceFunctionHardDiskView::InterferenceFunctionHardDiskView(QGraphicsItem* parent) - : ConnectableView(parent) -{ + : ConnectableView(parent) { setName("InterferenceHardDisk"); setColor(QColor(255, 236, 139)); setRectangle(DesignerHelper::getInterferenceFunctionBoundingRect()); @@ -68,8 +63,7 @@ InterferenceFunctionHardDiskView::InterferenceFunctionHardDiskView(QGraphicsItem InterferenceFunctionRadialParaCrystalView::InterferenceFunctionRadialParaCrystalView( QGraphicsItem* parent) - : ConnectableView(parent) -{ + : ConnectableView(parent) { setName("InterferenceRadialParaCrystal"); setColor(QColor(255, 236, 139)); setRectangle(DesignerHelper::getInterferenceFunctionBoundingRect()); diff --git a/GUI/coregui/Views/SampleDesigner/InterferenceFunctionViews.h b/GUI/coregui/Views/SampleDesigner/InterferenceFunctionViews.h index 04a02bf29c4aa517b7f4084b91557518ddc576f3..512127c93972b4a0a2703b6f104e6d2786c4f605 100644 --- a/GUI/coregui/Views/SampleDesigner/InterferenceFunctionViews.h +++ b/GUI/coregui/Views/SampleDesigner/InterferenceFunctionViews.h @@ -17,48 +17,42 @@ #include "GUI/coregui/Views/SampleDesigner/ConnectableView.h" -class InterferenceFunction1DLatticeView : public ConnectableView -{ +class InterferenceFunction1DLatticeView : public ConnectableView { Q_OBJECT public: InterferenceFunction1DLatticeView(QGraphicsItem* parent = nullptr); int type() const { return ViewTypes::INTERFERENCE_FUNCTION_1D_LATTICE; } }; -class InterferenceFunction2DLatticeView : public ConnectableView -{ +class InterferenceFunction2DLatticeView : public ConnectableView { Q_OBJECT public: InterferenceFunction2DLatticeView(QGraphicsItem* parent = nullptr); int type() const { return ViewTypes::INTERFERENCE_FUNCTION_2D_LATTICE; } }; -class InterferenceFunction2DParaCrystalView : public ConnectableView -{ +class InterferenceFunction2DParaCrystalView : public ConnectableView { Q_OBJECT public: InterferenceFunction2DParaCrystalView(QGraphicsItem* parent = nullptr); int type() const { return ViewTypes::INTERFERENCE_FUNCTION_2D_PARA; } }; -class InterferenceFunctionFinite2DLatticeView : public ConnectableView -{ +class InterferenceFunctionFinite2DLatticeView : public ConnectableView { Q_OBJECT public: InterferenceFunctionFinite2DLatticeView(QGraphicsItem* parent = nullptr); int type() const { return ViewTypes::INTERFERENCE_FUNCTION_FINITE_2D_LATTICE; } }; -class InterferenceFunctionHardDiskView : public ConnectableView -{ +class InterferenceFunctionHardDiskView : public ConnectableView { Q_OBJECT public: InterferenceFunctionHardDiskView(QGraphicsItem* parent = nullptr); int type() const { return ViewTypes::INTERFERENCE_FUNCTION_HARD_DISK; } }; -class InterferenceFunctionRadialParaCrystalView : public ConnectableView -{ +class InterferenceFunctionRadialParaCrystalView : public ConnectableView { Q_OBJECT public: InterferenceFunctionRadialParaCrystalView(QGraphicsItem* parent = nullptr); diff --git a/GUI/coregui/Views/SampleDesigner/ItemTreeView.cpp b/GUI/coregui/Views/SampleDesigner/ItemTreeView.cpp index 11ae2c4780c20430e444ece700963e302b0da65d..136cb6dd8af331c282a26c773772d5c80f921e3c 100644 --- a/GUI/coregui/Views/SampleDesigner/ItemTreeView.cpp +++ b/GUI/coregui/Views/SampleDesigner/ItemTreeView.cpp @@ -18,8 +18,7 @@ #include <QMimeData> #include <QtCore/QXmlStreamWriter> -ItemTreeView::ItemTreeView(QWidget* parent) : QTreeView(parent) -{ +ItemTreeView::ItemTreeView(QWidget* parent) : QTreeView(parent) { setAllColumnsShowFocus(true); setWindowTitle("Sample Tree View"); @@ -30,8 +29,7 @@ ItemTreeView::ItemTreeView(QWidget* parent) : QTreeView(parent) ItemTreeView::~ItemTreeView() = default; -void ItemTreeView::dragMoveEvent(QDragMoveEvent* event) -{ +void ItemTreeView::dragMoveEvent(QDragMoveEvent* event) { QTreeView::dragMoveEvent(event); SessionModel* model = static_cast<SessionModel*>(this->model()); model->setDraggedItemType(QString()); diff --git a/GUI/coregui/Views/SampleDesigner/ItemTreeView.h b/GUI/coregui/Views/SampleDesigner/ItemTreeView.h index 73b850fcdd20eb3f5ce1bff5e0e59127fcda2ec6..710d18625d9ae5cbe309dfd97cb4b2cd7730450d 100644 --- a/GUI/coregui/Views/SampleDesigner/ItemTreeView.h +++ b/GUI/coregui/Views/SampleDesigner/ItemTreeView.h @@ -17,8 +17,7 @@ #include <QTreeView> -class ItemTreeView : public QTreeView -{ +class ItemTreeView : public QTreeView { Q_OBJECT public: explicit ItemTreeView(QWidget* parent = 0); diff --git a/GUI/coregui/Views/SampleDesigner/LayerView.cpp b/GUI/coregui/Views/SampleDesigner/LayerView.cpp index 95e18cff12c400305a5c08b7bed3cbf0424879cf..c49834a8572957d47f8ce725ece10e1c7e83fadc 100644 --- a/GUI/coregui/Views/SampleDesigner/LayerView.cpp +++ b/GUI/coregui/Views/SampleDesigner/LayerView.cpp @@ -21,8 +21,7 @@ #include <QPainter> #include <QStyleOptionGraphicsItem> -LayerView::LayerView(QGraphicsItem* parent) : ILayerView(parent) -{ +LayerView::LayerView(QGraphicsItem* parent) : ILayerView(parent) { setColor(QColor(qrand() % 256, qrand() % 256, qrand() % 256)); setName("Layer"); setRectangle(DesignerHelper::getDefaultBoundingRect("Layer")); @@ -30,8 +29,7 @@ LayerView::LayerView(QGraphicsItem* parent) : ILayerView(parent) addPort(QString(), NodeEditorPort::INPUT, NodeEditorPort::PARTICLE_LAYOUT); } -void LayerView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) -{ +void LayerView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED(widget); painter->setPen(Qt::black); @@ -42,8 +40,7 @@ void LayerView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, painter->drawRect(getRectangle()); } -void LayerView::addView(IView* childView, int /* row */) -{ +void LayerView::addView(IView* childView, int /* row */) { ParticleLayoutView* layout = dynamic_cast<ParticleLayoutView*>(childView); ASSERT(layout); connectInputPort(layout, 0); diff --git a/GUI/coregui/Views/SampleDesigner/LayerView.h b/GUI/coregui/Views/SampleDesigner/LayerView.h index b2d320569133ac32377414a49cd83c141fff456b..0fc74e7063f6f19f655dc02b865da974625b54df 100644 --- a/GUI/coregui/Views/SampleDesigner/LayerView.h +++ b/GUI/coregui/Views/SampleDesigner/LayerView.h @@ -18,8 +18,7 @@ #include "GUI/coregui/Views/SampleDesigner/ILayerView.h" //! Class that represents view of Layer -class LayerView : public ILayerView -{ +class LayerView : public ILayerView { Q_OBJECT public: LayerView(QGraphicsItem* parent = 0); diff --git a/GUI/coregui/Views/SampleDesigner/MesoCrystalView.cpp b/GUI/coregui/Views/SampleDesigner/MesoCrystalView.cpp index 808cd13e6169c59c2acd9f62f461a72874d8b45c..816a2da6a57ec8458150d12644f8443eab481684 100644 --- a/GUI/coregui/Views/SampleDesigner/MesoCrystalView.cpp +++ b/GUI/coregui/Views/SampleDesigner/MesoCrystalView.cpp @@ -18,8 +18,7 @@ #include "GUI/coregui/Views/SampleDesigner/DesignerHelper.h" #include "GUI/coregui/utils/StyleUtils.h" -MesoCrystalView::MesoCrystalView(QGraphicsItem* parent) : ConnectableView(parent) -{ +MesoCrystalView::MesoCrystalView(QGraphicsItem* parent) : ConnectableView(parent) { setName("MesoCrystal"); setColor(DesignerHelper::getDefaultParticleColor()); setRectangle(DesignerHelper::getDefaultBoundingRect("ParticleCoreShell")); @@ -32,8 +31,7 @@ MesoCrystalView::MesoCrystalView(QGraphicsItem* parent) : ConnectableView(parent m_label_vspace = StyleUtils::SizeOfLetterM().height() * 2.5; } -void MesoCrystalView::addView(IView* childView, int /* row */) -{ +void MesoCrystalView::addView(IView* childView, int /* row */) { int index = 0; if (this->getItem()->tagFromItem(childView->getItem()) == ParticleItem::T_TRANSFORMATION) index = 1; diff --git a/GUI/coregui/Views/SampleDesigner/MesoCrystalView.h b/GUI/coregui/Views/SampleDesigner/MesoCrystalView.h index 08b7836fb783362386336ad33022c2a0ec4689a5..c68c9b93d842d63701e545e2dd6fb121a229e549 100644 --- a/GUI/coregui/Views/SampleDesigner/MesoCrystalView.h +++ b/GUI/coregui/Views/SampleDesigner/MesoCrystalView.h @@ -18,8 +18,7 @@ #include "GUI/coregui/Views/SampleDesigner/ConnectableView.h" //! Class representing view of a meso crystal item -class MesoCrystalView : public ConnectableView -{ +class MesoCrystalView : public ConnectableView { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/MultiLayerView.cpp b/GUI/coregui/Views/SampleDesigner/MultiLayerView.cpp index 4e89afc29d80da9e8532400c2b379864d93cd663..8ac4da0b4b18250fbe7f096368503c7d15d649fe 100644 --- a/GUI/coregui/Views/SampleDesigner/MultiLayerView.cpp +++ b/GUI/coregui/Views/SampleDesigner/MultiLayerView.cpp @@ -22,8 +22,7 @@ #include <QPainter> #include <QStyleOptionGraphicsItem> -MultiLayerView::MultiLayerView(QGraphicsItem* parent) : ILayerView(parent) -{ +MultiLayerView::MultiLayerView(QGraphicsItem* parent) : ILayerView(parent) { setColor(QColor(Qt::blue)); setRectangle(DesignerHelper::getDefaultBoundingRect("MultiLayer")); @@ -33,8 +32,7 @@ MultiLayerView::MultiLayerView(QGraphicsItem* parent) : ILayerView(parent) updateGeometry(); } -QRectF MultiLayerView::boundingRect() const -{ +QRectF MultiLayerView::boundingRect() const { QRectF result = m_rect; if (!m_layers.empty()) { qreal toplayer_height = m_layers.front()->boundingRect().height(); @@ -46,8 +44,7 @@ QRectF MultiLayerView::boundingRect() const } void MultiLayerView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, - QWidget* widget) -{ + QWidget* widget) { Q_UNUSED(widget); painter->setPen(m_color); if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus)) { @@ -57,8 +54,7 @@ void MultiLayerView::paint(QPainter* painter, const QStyleOptionGraphicsItem* op painter->drawRect(getRectangle()); } -void MultiLayerView::addView(IView* childView, int row) -{ +void MultiLayerView::addView(IView* childView, int row) { ILayerView* layer = dynamic_cast<ILayerView*>(childView); ASSERT(layer); @@ -77,8 +73,7 @@ void MultiLayerView::addView(IView* childView, int row) updateGeometry(); } -void MultiLayerView::addNewLayer(ILayerView* layer, int row) -{ +void MultiLayerView::addNewLayer(ILayerView* layer, int row) { m_layers.insert(row, layer); connect(layer, SIGNAL(heightChanged()), this, SLOT(updateHeight()), Qt::UniqueConnection); connect(layer, SIGNAL(aboutToBeDeleted()), this, SLOT(onLayerAboutToBeDeleted()), @@ -86,15 +81,13 @@ void MultiLayerView::addNewLayer(ILayerView* layer, int row) layer->setParentItem(this); } -void MultiLayerView::onLayerAboutToBeDeleted() -{ +void MultiLayerView::onLayerAboutToBeDeleted() { ILayerView* layer = qobject_cast<ILayerView*>(sender()); ASSERT(layer); removeLayer(layer); } -void MultiLayerView::removeLayer(ILayerView* layer) -{ +void MultiLayerView::removeLayer(ILayerView* layer) { ASSERT(m_layers.contains(layer)); disconnect(layer, SIGNAL(heightChanged()), this, SLOT(updateHeight())); disconnect(layer, SIGNAL(aboutToBeDeleted()), this, SLOT(onLayerAboutToBeDeleted())); @@ -103,15 +96,13 @@ void MultiLayerView::removeLayer(ILayerView* layer) } //! Updates geometry of MultiLayerView from current childs geometries. -void MultiLayerView::updateGeometry() -{ +void MultiLayerView::updateGeometry() { updateHeight(); updateWidth(); } //! Updates MultiLayer height, sets y-positions of children, defines new drop areas. -void MultiLayerView::updateHeight() -{ +void MultiLayerView::updateHeight() { // drop areas are rectangles covering the area of layer interfaces m_drop_areas.clear(); m_interfaces.clear(); @@ -146,8 +137,7 @@ void MultiLayerView::updateHeight() //! Updates MultiLayerView width, sets x-positions of children. //! If list of children contains another MultiLayer, then width of given MultiLayer //! will be increased by 12% -void MultiLayerView::updateWidth() -{ +void MultiLayerView::updateWidth() { const double wider_than_children(1.15); double max_width(0); for (ILayerView* layer : m_layers) { @@ -170,8 +160,7 @@ void MultiLayerView::updateWidth() } //! Returns index of drop area for given coordinate. -int MultiLayerView::getDropArea(QPointF pos) -{ +int MultiLayerView::getDropArea(QPointF pos) { int area(-1); for (int i = 0; i < m_drop_areas.size(); ++i) { if (m_drop_areas.at(i).contains(pos)) { @@ -183,8 +172,7 @@ int MultiLayerView::getDropArea(QPointF pos) } //! Returns drop area rectangle corresponding to given row -QRectF MultiLayerView::getDropAreaRectangle(int row) -{ +QRectF MultiLayerView::getDropAreaRectangle(int row) { if (row >= 0 && row < m_drop_areas.size()) { return m_drop_areas[row]; } else { @@ -193,8 +181,7 @@ QRectF MultiLayerView::getDropAreaRectangle(int row) } //! Returns line representing interface -QLineF MultiLayerView::getInterfaceLine(int row) -{ +QLineF MultiLayerView::getInterfaceLine(int row) { if (row >= 0 && row < m_interfaces.size()) { return m_interfaces[row]; } else { @@ -202,14 +189,12 @@ QLineF MultiLayerView::getInterfaceLine(int row) } } -void MultiLayerView::dragMoveEvent(QGraphicsSceneDragDropEvent* event) -{ +void MultiLayerView::dragMoveEvent(QGraphicsSceneDragDropEvent* event) { if (!checkDragEvent(event)) QGraphicsItem::dragMoveEvent(event); } -void MultiLayerView::dropEvent(QGraphicsSceneDragDropEvent* event) -{ +void MultiLayerView::dropEvent(QGraphicsSceneDragDropEvent* event) { const DesignerMimeData* mimeData = checkDragEvent(event); if (mimeData) { DesignerScene* designerScene = dynamic_cast<DesignerScene*>(scene()); @@ -223,8 +208,7 @@ void MultiLayerView::dropEvent(QGraphicsSceneDragDropEvent* event) } } -const DesignerMimeData* MultiLayerView::checkDragEvent(QGraphicsSceneDragDropEvent* event) -{ +const DesignerMimeData* MultiLayerView::checkDragEvent(QGraphicsSceneDragDropEvent* event) { const DesignerMimeData* mimeData = qobject_cast<const DesignerMimeData*>(event->mimeData()); if (!mimeData) { event->ignore(); @@ -241,7 +225,7 @@ const DesignerMimeData* MultiLayerView::checkDragEvent(QGraphicsSceneDragDropEve return mimeData; } -QVariant MultiLayerView::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) -{ +QVariant MultiLayerView::itemChange(QGraphicsItem::GraphicsItemChange change, + const QVariant& value) { return QGraphicsItem::itemChange(change, value); } diff --git a/GUI/coregui/Views/SampleDesigner/MultiLayerView.h b/GUI/coregui/Views/SampleDesigner/MultiLayerView.h index 7d4f07863567db1e29b5544a825c77a1b92e3efe..6d7012269941ee8ffec92d217b009870d7faca51 100644 --- a/GUI/coregui/Views/SampleDesigner/MultiLayerView.h +++ b/GUI/coregui/Views/SampleDesigner/MultiLayerView.h @@ -22,8 +22,7 @@ class QGraphicsSceneDragDropEvent; //! Class representing view of MultiLayer. //! Handles drop of other MultiLayer and Layer views on top of it -class MultiLayerView : public ILayerView -{ +class MultiLayerView : public ILayerView { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/NodeEditor.cpp b/GUI/coregui/Views/SampleDesigner/NodeEditor.cpp index 70bc3101043463b3f53f07383165c5c6cfef8671..14012bdfedbe101a8f7a2bd722d31741e82f1d75 100644 --- a/GUI/coregui/Views/SampleDesigner/NodeEditor.cpp +++ b/GUI/coregui/Views/SampleDesigner/NodeEditor.cpp @@ -22,14 +22,12 @@ NodeEditor::NodeEditor(QObject* parent) : QObject(parent), m_scene(0), m_conn(0) {} -void NodeEditor::install(QGraphicsScene* scene) -{ +void NodeEditor::install(QGraphicsScene* scene) { scene->installEventFilter(this); m_scene = scene; } -QGraphicsItem* NodeEditor::itemAt(const QPointF& pos) -{ +QGraphicsItem* NodeEditor::itemAt(const QPointF& pos) { QList<QGraphicsItem*> items = m_scene->items(QRectF(pos - QPointF(1, 1), QSize(3, 3))); for (QGraphicsItem* item : items) @@ -39,8 +37,7 @@ QGraphicsItem* NodeEditor::itemAt(const QPointF& pos) return nullptr; } -bool NodeEditor::eventFilter(QObject* object, QEvent* event) -{ +bool NodeEditor::eventFilter(QObject* object, QEvent* event) { QGraphicsSceneMouseEvent* mouseEvent = dynamic_cast<QGraphicsSceneMouseEvent*>(event); if (!mouseEvent) return QObject::eventFilter(object, event); @@ -57,8 +54,7 @@ bool NodeEditor::eventFilter(QObject* object, QEvent* event) return isProcessedEvent ? isProcessedEvent : QObject::eventFilter(object, event); } -bool NodeEditor::processMousePress(QGraphicsSceneMouseEvent* event) -{ +bool NodeEditor::processMousePress(QGraphicsSceneMouseEvent* event) { bool result(false); if (m_conn == 0 && event->button() == Qt::LeftButton) { @@ -77,8 +73,7 @@ bool NodeEditor::processMousePress(QGraphicsSceneMouseEvent* event) return result; } -bool NodeEditor::processMouseMove(QGraphicsSceneMouseEvent* event) -{ +bool NodeEditor::processMouseMove(QGraphicsSceneMouseEvent* event) { bool result(false); if (m_conn) { @@ -89,8 +84,7 @@ bool NodeEditor::processMouseMove(QGraphicsSceneMouseEvent* event) return result; } -bool NodeEditor::processMouseRelease(QGraphicsSceneMouseEvent* event) -{ +bool NodeEditor::processMouseRelease(QGraphicsSceneMouseEvent* event) { bool result(false); if (m_conn && event->button() == Qt::LeftButton) { diff --git a/GUI/coregui/Views/SampleDesigner/NodeEditor.h b/GUI/coregui/Views/SampleDesigner/NodeEditor.h index ccae2951ceac85762edd6b869076ba3be7c89f36..97d47547419ff3f4600df1c091ca421d52965bee 100644 --- a/GUI/coregui/Views/SampleDesigner/NodeEditor.h +++ b/GUI/coregui/Views/SampleDesigner/NodeEditor.h @@ -32,8 +32,7 @@ class QGraphicsSceneMouseEvent; //! The NodeEditor class implement for QGraphicsScene an editable schematic //! of the dependency graph, displaying nodes and the connections between their //! attributes -class NodeEditor : public QObject -{ +class NodeEditor : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/NodeEditorConnection.cpp b/GUI/coregui/Views/SampleDesigner/NodeEditorConnection.cpp index d89b425fafc83bd96376f8ab7aff0bde9930d7e4..8e20aa2685220049238e166669aa4ca94acac064 100644 --- a/GUI/coregui/Views/SampleDesigner/NodeEditorConnection.cpp +++ b/GUI/coregui/Views/SampleDesigner/NodeEditorConnection.cpp @@ -21,8 +21,7 @@ #include <QPen> NodeEditorConnection::NodeEditorConnection(QGraphicsItem* parent, QGraphicsScene* scene) - : QGraphicsPathItem(parent), m_port1(0), m_port2(0) -{ + : QGraphicsPathItem(parent), m_port1(0), m_port2(0) { setFlag(QGraphicsItem::ItemIsSelectable, true); setPen(QPen(Qt::darkGray, 2)); setBrush(Qt::NoBrush); @@ -31,8 +30,7 @@ NodeEditorConnection::NodeEditorConnection(QGraphicsItem* parent, QGraphicsScene scene->addItem(this); } -NodeEditorConnection::~NodeEditorConnection() -{ +NodeEditorConnection::~NodeEditorConnection() { if (m_port1) m_port1->remove(this); @@ -40,38 +38,32 @@ NodeEditorConnection::~NodeEditorConnection() m_port2->remove(this); } -void NodeEditorConnection::setPos1(const QPointF& p) -{ +void NodeEditorConnection::setPos1(const QPointF& p) { pos1 = p; } -void NodeEditorConnection::setPos2(const QPointF& p) -{ +void NodeEditorConnection::setPos2(const QPointF& p) { pos2 = p; } -void NodeEditorConnection::setPort1(NodeEditorPort* p) -{ +void NodeEditorConnection::setPort1(NodeEditorPort* p) { m_port1 = p; m_port1->append(this); setPos1(p->scenePos()); } -void NodeEditorConnection::setPort2(NodeEditorPort* p) -{ +void NodeEditorConnection::setPort2(NodeEditorPort* p) { m_port2 = p; m_port2->append(this); setPos2(p->scenePos()); } -void NodeEditorConnection::updatePosFromPorts() -{ +void NodeEditorConnection::updatePosFromPorts() { pos1 = m_port1->scenePos(); pos2 = m_port2->scenePos(); } -void NodeEditorConnection::updatePath() -{ +void NodeEditorConnection::updatePath() { QPainterPath p; p.moveTo(pos1); qreal dx = pos2.x() - pos1.x(); @@ -82,31 +74,26 @@ void NodeEditorConnection::updatePath() setPath(p); } -NodeEditorPort* NodeEditorConnection::port1() const -{ +NodeEditorPort* NodeEditorConnection::port1() const { return m_port1; } -NodeEditorPort* NodeEditorConnection::port2() const -{ +NodeEditorPort* NodeEditorConnection::port2() const { return m_port2; } -NodeEditorPort* NodeEditorConnection::inputPort() -{ +NodeEditorPort* NodeEditorConnection::inputPort() { ASSERT(m_port1 && m_port2); return (m_port1->isInput() ? m_port1 : m_port2); } -NodeEditorPort* NodeEditorConnection::outputPort() -{ +NodeEditorPort* NodeEditorConnection::outputPort() { ASSERT(m_port1 && m_port2); return (m_port1->isOutput() ? m_port1 : m_port2); } void NodeEditorConnection::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, - QWidget* widget) -{ + QWidget* widget) { Q_UNUSED(option) Q_UNUSED(widget) @@ -120,16 +107,14 @@ void NodeEditorConnection::paint(QPainter* painter, const QStyleOptionGraphicsIt painter->drawPath(path()); } -ConnectableView* NodeEditorConnection::getParentView() -{ +ConnectableView* NodeEditorConnection::getParentView() { ASSERT(inputPort() != outputPort()); ConnectableView* result = dynamic_cast<ConnectableView*>(inputPort()->parentItem()); ASSERT(result); return result; } -ConnectableView* NodeEditorConnection::getChildView() -{ +ConnectableView* NodeEditorConnection::getChildView() { ASSERT(inputPort() != outputPort()); ConnectableView* result = dynamic_cast<ConnectableView*>(outputPort()->parentItem()); ASSERT(result); diff --git a/GUI/coregui/Views/SampleDesigner/NodeEditorConnection.h b/GUI/coregui/Views/SampleDesigner/NodeEditorConnection.h index df5a93c67eea09b28aa0e337673e8d69f0b94aaf..86addb689c3534b0600e52ff0cfc56e23fe77fbe 100644 --- a/GUI/coregui/Views/SampleDesigner/NodeEditorConnection.h +++ b/GUI/coregui/Views/SampleDesigner/NodeEditorConnection.h @@ -27,8 +27,7 @@ class NodeEditorPort; class ConnectableView; -class NodeEditorConnection : public QGraphicsPathItem -{ +class NodeEditorConnection : public QGraphicsPathItem { public: NodeEditorConnection(QGraphicsItem* parent = 0, QGraphicsScene* scene = 0); virtual ~NodeEditorConnection(); diff --git a/GUI/coregui/Views/SampleDesigner/NodeEditorPort.cpp b/GUI/coregui/Views/SampleDesigner/NodeEditorPort.cpp index b3b4daf6e3ed8619582ff00a2754978e0202c6a7..59a8a20a568eb67bbabfe73959a87235aa46c8b6 100644 --- a/GUI/coregui/Views/SampleDesigner/NodeEditorPort.cpp +++ b/GUI/coregui/Views/SampleDesigner/NodeEditorPort.cpp @@ -29,8 +29,7 @@ NodeEditorPort::NodeEditorPort(QGraphicsItem* parent, const QString& name, , m_port_type(port_type) , m_radius(0) , m_margin(0) - , m_label(nullptr) -{ + , m_label(nullptr) { m_radius = StyleUtils::SizeOfLetterM().width() * 0.4; m_margin = m_radius * 0.5; m_color = getPortTypeColor(port_type); @@ -49,8 +48,7 @@ NodeEditorPort::NodeEditorPort(QGraphicsItem* parent, const QString& name, } } -NodeEditorPort::~NodeEditorPort() -{ +NodeEditorPort::~NodeEditorPort() { while (m_connections.size() > 0) { auto conn = m_connections.last(); conn->setSelected(false); @@ -58,29 +56,24 @@ NodeEditorPort::~NodeEditorPort() } } -bool NodeEditorPort::isOutput() -{ +bool NodeEditorPort::isOutput() { return (m_direction == OUTPUT); } -bool NodeEditorPort::isInput() -{ +bool NodeEditorPort::isInput() { return !isOutput(); } -void NodeEditorPort::remove(NodeEditorConnection* connection) -{ +void NodeEditorPort::remove(NodeEditorConnection* connection) { if (m_connections.contains(connection)) m_connections.remove(m_connections.indexOf(connection)); } -void NodeEditorPort::append(NodeEditorConnection* connection) -{ +void NodeEditorPort::append(NodeEditorConnection* connection) { m_connections.append(connection); } -bool NodeEditorPort::isConnected(NodeEditorPort* other) -{ +bool NodeEditorPort::isConnected(NodeEditorPort* other) { for (auto conn : m_connections) if (conn->port1() == other || conn->port2() == other) return true; @@ -88,8 +81,7 @@ bool NodeEditorPort::isConnected(NodeEditorPort* other) return false; } -QColor NodeEditorPort::getPortTypeColor(NodeEditorPort::EPortType port_type) -{ +QColor NodeEditorPort::getPortTypeColor(NodeEditorPort::EPortType port_type) { switch (port_type) { case DEFAULT: return QColor(Qt::gray); @@ -106,8 +98,7 @@ QColor NodeEditorPort::getPortTypeColor(NodeEditorPort::EPortType port_type) } } -QVariant NodeEditorPort::itemChange(GraphicsItemChange change, const QVariant& value) -{ +QVariant NodeEditorPort::itemChange(GraphicsItemChange change, const QVariant& value) { if (change == ItemScenePositionHasChanged) { for (auto conn : m_connections) { conn->updatePosFromPorts(); @@ -117,8 +108,7 @@ QVariant NodeEditorPort::itemChange(GraphicsItemChange change, const QVariant& v return value; } -void NodeEditorPort::setLabel(QString name) -{ +void NodeEditorPort::setLabel(QString name) { if (!m_label) m_label = new QGraphicsTextItem(this); m_label->setPlainText(name); diff --git a/GUI/coregui/Views/SampleDesigner/NodeEditorPort.h b/GUI/coregui/Views/SampleDesigner/NodeEditorPort.h index 6cfc10bd6a5e535b19c0dd2da74ec9b9b68cbeb0..50e1f33497bfc6d93892941ff6da73ed1c82f052 100644 --- a/GUI/coregui/Views/SampleDesigner/NodeEditorPort.h +++ b/GUI/coregui/Views/SampleDesigner/NodeEditorPort.h @@ -28,8 +28,7 @@ class NodeEditorConnection; class IView; -class NodeEditorPort : public QGraphicsPathItem -{ +class NodeEditorPort : public QGraphicsPathItem { public: //! type of ports, same type can be connected together enum EPortType { DEFAULT, INTERFERENCE, PARTICLE_LAYOUT, FORM_FACTOR, TRANSFORMATION }; @@ -76,23 +75,19 @@ private: QGraphicsTextItem* m_label; }; -inline const QString& NodeEditorPort::portName() const -{ +inline const QString& NodeEditorPort::portName() const { return m_name; } -inline int NodeEditorPort::type() const -{ +inline int NodeEditorPort::type() const { return ViewTypes::NODE_EDITOR_PORT; } -inline bool NodeEditorPort::isConnected() -{ +inline bool NodeEditorPort::isConnected() { return m_connections.size(); } -inline NodeEditorPort::EPortType NodeEditorPort::getPortType() const -{ +inline NodeEditorPort::EPortType NodeEditorPort::getPortType() const { return m_port_type; } diff --git a/GUI/coregui/Views/SampleDesigner/ParticleCompositionView.cpp b/GUI/coregui/Views/SampleDesigner/ParticleCompositionView.cpp index 242ba32df5f89b899172e8f9ec528d6d1e6ce8a2..bfcec92559e266e55f81484a652ef24f08df1851 100644 --- a/GUI/coregui/Views/SampleDesigner/ParticleCompositionView.cpp +++ b/GUI/coregui/Views/SampleDesigner/ParticleCompositionView.cpp @@ -17,8 +17,7 @@ #include "GUI/coregui/Views/SampleDesigner/DesignerHelper.h" #include "GUI/coregui/utils/StyleUtils.h" -ParticleCompositionView::ParticleCompositionView(QGraphicsItem* parent) : ConnectableView(parent) -{ +ParticleCompositionView::ParticleCompositionView(QGraphicsItem* parent) : ConnectableView(parent) { setName("ParticleComposition"); setColor(DesignerHelper::getDefaultParticleColor()); setRectangle(DesignerHelper::getDefaultBoundingRect("ParticleCoreShell")); @@ -31,8 +30,7 @@ ParticleCompositionView::ParticleCompositionView(QGraphicsItem* parent) : Connec m_label_vspace = StyleUtils::SizeOfLetterM().height() * 3.0; } -void ParticleCompositionView::addView(IView* childView, int /* row */) -{ +void ParticleCompositionView::addView(IView* childView, int /* row */) { int index = 0; if (this->getItem()->tagFromItem(childView->getItem()) == ParticleItem::T_TRANSFORMATION) index = 1; diff --git a/GUI/coregui/Views/SampleDesigner/ParticleCompositionView.h b/GUI/coregui/Views/SampleDesigner/ParticleCompositionView.h index 02f6bd38d69fee0e2299780c9b14c1352c0a40a2..6e36b57e24dca9d9fff32f8ade0e50e2fe6e21fe 100644 --- a/GUI/coregui/Views/SampleDesigner/ParticleCompositionView.h +++ b/GUI/coregui/Views/SampleDesigner/ParticleCompositionView.h @@ -18,8 +18,7 @@ #include "GUI/coregui/Views/SampleDesigner/ConnectableView.h" //! Class representing view of Particle item -class ParticleCompositionView : public ConnectableView -{ +class ParticleCompositionView : public ConnectableView { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/ParticleCoreShellView.cpp b/GUI/coregui/Views/SampleDesigner/ParticleCoreShellView.cpp index 6e7fec1bcbde576d1d6b5d29a9e2a6a374bd66b1..8c029db18cd1ef8849e4b2d366969f3e3c544ec7 100644 --- a/GUI/coregui/Views/SampleDesigner/ParticleCoreShellView.cpp +++ b/GUI/coregui/Views/SampleDesigner/ParticleCoreShellView.cpp @@ -17,8 +17,7 @@ #include "GUI/coregui/Views/SampleDesigner/DesignerHelper.h" #include "GUI/coregui/utils/StyleUtils.h" -ParticleCoreShellView::ParticleCoreShellView(QGraphicsItem* parent) : ConnectableView(parent) -{ +ParticleCoreShellView::ParticleCoreShellView(QGraphicsItem* parent) : ConnectableView(parent) { setName("ParticleCoreShell"); setColor(DesignerHelper::getDefaultParticleColor()); setRectangle(DesignerHelper::getDefaultBoundingRect("ParticleCoreShell")); @@ -34,8 +33,7 @@ ParticleCoreShellView::ParticleCoreShellView(QGraphicsItem* parent) : Connectabl m_label_vspace = StyleUtils::SizeOfLetterM().height() * 3.0; } -void ParticleCoreShellView::addView(IView* childView, int /* row */) -{ +void ParticleCoreShellView::addView(IView* childView, int /* row */) { int index = 0; if (this->getItem()->tagFromItem(childView->getItem()) == ParticleCoreShellItem::T_CORE) { index = 0; diff --git a/GUI/coregui/Views/SampleDesigner/ParticleCoreShellView.h b/GUI/coregui/Views/SampleDesigner/ParticleCoreShellView.h index 3f04710dcf2daa7b9a9775c683737b07ad633b16..6f192a2da5e0384455b8fa8a677e9d9d9ec38746 100644 --- a/GUI/coregui/Views/SampleDesigner/ParticleCoreShellView.h +++ b/GUI/coregui/Views/SampleDesigner/ParticleCoreShellView.h @@ -18,8 +18,7 @@ #include "GUI/coregui/Views/SampleDesigner/ConnectableView.h" //! Class representing view of Particle item -class ParticleCoreShellView : public ConnectableView -{ +class ParticleCoreShellView : public ConnectableView { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/ParticleDistributionView.cpp b/GUI/coregui/Views/SampleDesigner/ParticleDistributionView.cpp index ccb08869f52957bab26731648eef66335bdfffeb..9195e23146e91eebd7a737aa8b93f7af3a7515f7 100644 --- a/GUI/coregui/Views/SampleDesigner/ParticleDistributionView.cpp +++ b/GUI/coregui/Views/SampleDesigner/ParticleDistributionView.cpp @@ -17,8 +17,8 @@ #include "GUI/coregui/Views/SampleDesigner/DesignerHelper.h" #include "GUI/coregui/utils/StyleUtils.h" -ParticleDistributionView::ParticleDistributionView(QGraphicsItem* parent) : ConnectableView(parent) -{ +ParticleDistributionView::ParticleDistributionView(QGraphicsItem* parent) + : ConnectableView(parent) { setName("ParticleDistribution"); setColor(DesignerHelper::getDefaultParticleColor()); setRectangle(DesignerHelper::getDefaultBoundingRect("ParticleDistribution")); @@ -31,7 +31,6 @@ ParticleDistributionView::ParticleDistributionView(QGraphicsItem* parent) : Conn m_label_vspace = StyleUtils::SizeOfLetterM().height() * 3.0; } -void ParticleDistributionView::addView(IView* childView, int /* row */) -{ +void ParticleDistributionView::addView(IView* childView, int /* row */) { connectInputPort(dynamic_cast<ConnectableView*>(childView), 0); } diff --git a/GUI/coregui/Views/SampleDesigner/ParticleDistributionView.h b/GUI/coregui/Views/SampleDesigner/ParticleDistributionView.h index 6a0ca512ed47e4d1968f0913e49ea37131a80aa3..40e3393447cf5a18584da2938c304b530247e39d 100644 --- a/GUI/coregui/Views/SampleDesigner/ParticleDistributionView.h +++ b/GUI/coregui/Views/SampleDesigner/ParticleDistributionView.h @@ -18,8 +18,7 @@ #include "GUI/coregui/Views/SampleDesigner/ConnectableView.h" //! Class representing view of distributed particle item -class ParticleDistributionView : public ConnectableView -{ +class ParticleDistributionView : public ConnectableView { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/ParticleLayoutView.cpp b/GUI/coregui/Views/SampleDesigner/ParticleLayoutView.cpp index ca26323e7ae30139d350e322bc0191b3fac9de2c..535a31da0d991f6ef2052ce0d6dfe961154c5afb 100644 --- a/GUI/coregui/Views/SampleDesigner/ParticleLayoutView.cpp +++ b/GUI/coregui/Views/SampleDesigner/ParticleLayoutView.cpp @@ -18,8 +18,7 @@ #include "GUI/coregui/Views/SampleDesigner/ParticleView.h" #include "GUI/coregui/utils/GUIHelpers.h" -ParticleLayoutView::ParticleLayoutView(QGraphicsItem* parent) : ConnectableView(parent) -{ +ParticleLayoutView::ParticleLayoutView(QGraphicsItem* parent) : ConnectableView(parent) { setName("ParticleLayout"); setColor(QColor(135, 206, 50)); setRectangle(DesignerHelper::getParticleLayoutBoundingRect()); @@ -33,8 +32,7 @@ ParticleLayoutView::ParticleLayoutView(QGraphicsItem* parent) : ConnectableView( "to have coherent scattering"); } -void ParticleLayoutView::addView(IView* childView, int /* row */) -{ +void ParticleLayoutView::addView(IView* childView, int /* row */) { if (childView->type() == ViewTypes::PARTICLE) { connectInputPort(dynamic_cast<ConnectableView*>(childView), 0); } else if (childView->type() == ViewTypes::INTERFERENCE_FUNCTION_1D_LATTICE diff --git a/GUI/coregui/Views/SampleDesigner/ParticleLayoutView.h b/GUI/coregui/Views/SampleDesigner/ParticleLayoutView.h index 169e4b68907524687ef122ccb14895ccfe3e3158..c24f70432729124345f8a7c943351463a172650c 100644 --- a/GUI/coregui/Views/SampleDesigner/ParticleLayoutView.h +++ b/GUI/coregui/Views/SampleDesigner/ParticleLayoutView.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Views/SampleDesigner/ConnectableView.h" -class ParticleLayoutView : public ConnectableView -{ +class ParticleLayoutView : public ConnectableView { public: ParticleLayoutView(QGraphicsItem* parent = 0); diff --git a/GUI/coregui/Views/SampleDesigner/ParticleView.cpp b/GUI/coregui/Views/SampleDesigner/ParticleView.cpp index 97b6c97895bc2e789e5b3c8be705cb6bf0f3aee7..b405832ccdda84b8df21f55c755de67b48ffa859 100644 --- a/GUI/coregui/Views/SampleDesigner/ParticleView.cpp +++ b/GUI/coregui/Views/SampleDesigner/ParticleView.cpp @@ -23,8 +23,7 @@ #include <QPainter> #include <QStyleOptionGraphicsItem> -ParticleView::ParticleView(QGraphicsItem* parent) : ConnectableView(parent) -{ +ParticleView::ParticleView(QGraphicsItem* parent) : ConnectableView(parent) { setName("Particle"); setColor(DesignerHelper::getDefaultParticleColor()); setRectangle(DesignerHelper::getParticleBoundingRect()); @@ -35,8 +34,8 @@ ParticleView::ParticleView(QGraphicsItem* parent) : ConnectableView(parent) m_label_vspace = StyleUtils::SizeOfLetterM().height() * 3.0; } -void ParticleView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) -{ +void ParticleView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, + QWidget* widget) { Q_UNUSED(widget); painter->setRenderHint(QPainter::SmoothPixmapTransform); painter->setRenderHint(QPainter::Antialiasing); @@ -68,16 +67,14 @@ void ParticleView::paint(QPainter* painter, const QStyleOptionGraphicsItem* opti // painter->drawImage(target, m_pixmap); } -void ParticleView::onPropertyChange(const QString& propertyName) -{ +void ParticleView::onPropertyChange(const QString& propertyName) { if (propertyName == ParticleItem::P_FORM_FACTOR) update_appearance(); IView::onPropertyChange(propertyName); } -void ParticleView::addView(IView* childView, int /*row*/) -{ +void ParticleView::addView(IView* childView, int /*row*/) { if (childView->type() == ViewTypes::TRANSFORMATION) { connectInputPort(dynamic_cast<ConnectableView*>(childView), 0); } else { @@ -85,15 +82,13 @@ void ParticleView::addView(IView* childView, int /*row*/) } } -void ParticleView::update_appearance() -{ +void ParticleView::update_appearance() { updatePixmap(); updateToolTip(); ConnectableView::update_appearance(); } -void ParticleView::updatePixmap() -{ +void ParticleView::updatePixmap() { if (!getItem()) return; @@ -102,8 +97,7 @@ void ParticleView::updatePixmap() m_pixmap = QPixmap(filename); } -void ParticleView::updateToolTip() -{ +void ParticleView::updateToolTip() { if (!getItem()) return; diff --git a/GUI/coregui/Views/SampleDesigner/ParticleView.h b/GUI/coregui/Views/SampleDesigner/ParticleView.h index 572cb27d8fe943cfb35fd25c48948bf9991ae0e2..41d9c78c74f9d429cd2f52f5777ac9aef5db0a6a 100644 --- a/GUI/coregui/Views/SampleDesigner/ParticleView.h +++ b/GUI/coregui/Views/SampleDesigner/ParticleView.h @@ -19,8 +19,7 @@ #include <QPixmap> //! Class representing view of Particle item -class ParticleView : public ConnectableView -{ +class ParticleView : public ConnectableView { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/RealSpacePanel.cpp b/GUI/coregui/Views/SampleDesigner/RealSpacePanel.cpp index 3cbf21eac7818fb65e4fcf260ecfc2c3d8c59b84..0a39fb225e81d79a8b62daba78a9151b0e0dacf0 100644 --- a/GUI/coregui/Views/SampleDesigner/RealSpacePanel.cpp +++ b/GUI/coregui/Views/SampleDesigner/RealSpacePanel.cpp @@ -18,8 +18,7 @@ RealSpacePanel::RealSpacePanel(SampleModel* sampleModel, QItemSelectionModel* selectionModel, QWidget* parent) - : QWidget(parent), m_realSpaceWidget(nullptr) -{ + : QWidget(parent), m_realSpaceWidget(nullptr) { setWindowTitle("Real Space"); setObjectName("Sample3DPanel"); @@ -33,7 +32,6 @@ RealSpacePanel::RealSpacePanel(SampleModel* sampleModel, QItemSelectionModel* se setLayout(layout); } -QSize RealSpacePanel::sizeHint() const -{ +QSize RealSpacePanel::sizeHint() const { return QSize(300, 300); } diff --git a/GUI/coregui/Views/SampleDesigner/RealSpacePanel.h b/GUI/coregui/Views/SampleDesigner/RealSpacePanel.h index 091b89a952c83bd3407fcf2b5380b779ac21b211..7b94b71ec1d28fc092be5fb0f09c35d0651097de 100644 --- a/GUI/coregui/Views/SampleDesigner/RealSpacePanel.h +++ b/GUI/coregui/Views/SampleDesigner/RealSpacePanel.h @@ -23,8 +23,7 @@ class RealSpaceWidget; //! Panel with item selector, property editor on the right side of RealSpaceWidget. -class RealSpacePanel : public QWidget -{ +class RealSpacePanel : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/SampleDesigner.cpp b/GUI/coregui/Views/SampleDesigner/SampleDesigner.cpp index b410bb79b52da7e5e3f17db0f0041ce12a332702..1c5ea08cd63e07b66872a76f2cd13b1a01188965 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleDesigner.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleDesigner.cpp @@ -19,23 +19,20 @@ #include "Sample/Scattering/ISample.h" SampleDesigner::SampleDesigner(QWidget* parent) - : SampleDesignerInterface(parent), m_designerScene(0), m_designerView(0) -{ + : SampleDesignerInterface(parent), m_designerScene(0), m_designerView(0) { m_designerScene = new DesignerScene(parent); m_designerView = new DesignerView(m_designerScene, parent); } SampleDesigner::~SampleDesigner() = default; -void SampleDesigner::setModels(ApplicationModels* models) -{ +void SampleDesigner::setModels(ApplicationModels* models) { m_designerScene->setSampleModel(models->sampleModel()); m_designerScene->setInstrumentModel(models->instrumentModel()); m_designerScene->setMaterialModel(models->materialModel()); } -void SampleDesigner::setSelectionModel(QItemSelectionModel* model, FilterPropertyProxy* proxy) -{ +void SampleDesigner::setSelectionModel(QItemSelectionModel* model, FilterPropertyProxy* proxy) { if (model) m_designerScene->setSelectionModel(model, proxy); } diff --git a/GUI/coregui/Views/SampleDesigner/SampleDesigner.h b/GUI/coregui/Views/SampleDesigner/SampleDesigner.h index 0a872d646f23a9d5d5fb3ab2fc069c70e23c1383..af42b9b96c7437851fc1d1da146c2e5e9cd1ba90 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleDesigner.h +++ b/GUI/coregui/Views/SampleDesigner/SampleDesigner.h @@ -28,8 +28,7 @@ class FilterPropertyProxy; class ApplicationModels; //! sample designer interface -class SampleDesignerInterface : public QObject -{ +class SampleDesignerInterface : public QObject { Q_OBJECT public: @@ -41,8 +40,7 @@ public: }; //! sample designer provide central window with graphic scene to drag and drop -class SampleDesigner : public SampleDesignerInterface -{ +class SampleDesigner : public SampleDesignerInterface { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.cpp b/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.cpp index 49d9ba56f917fe461a5d611c67eeb518d70e32e2..cabfe5b9c47b1d55e1206e3d5f12a25a8a33edfc 100644 --- a/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.cpp +++ b/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.cpp @@ -23,8 +23,7 @@ SamplePropertyWidget::SamplePropertyWidget(QItemSelectionModel* selection_model, QWidget* parent) : QWidget(parent) , m_selection_model(nullptr) - , m_propertyEditor(new ComponentEditor(ComponentEditor::FullTree)) -{ + , m_propertyEditor(new ComponentEditor(ComponentEditor::FullTree)) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); setWindowTitle(QLatin1String("Property Editor")); setObjectName(QLatin1String("SamplePropertyWidget")); @@ -39,18 +38,15 @@ SamplePropertyWidget::SamplePropertyWidget(QItemSelectionModel* selection_model, setLayout(mainLayout); } -QSize SamplePropertyWidget::sizeHint() const -{ +QSize SamplePropertyWidget::sizeHint() const { return QSize(230, 256); } -QSize SamplePropertyWidget::minimumSizeHint() const -{ +QSize SamplePropertyWidget::minimumSizeHint() const { return QSize(230, 64); } -void SamplePropertyWidget::setSelectionModel(QItemSelectionModel* selection_model) -{ +void SamplePropertyWidget::setSelectionModel(QItemSelectionModel* selection_model) { if (selection_model == m_selection_model) return; @@ -69,8 +65,7 @@ void SamplePropertyWidget::setSelectionModel(QItemSelectionModel* selection_mode // TODO Refactor this together with whole SampleView. Remove knowledge about proxy model. -void SamplePropertyWidget::selectionChanged(const QItemSelection& selected, const QItemSelection&) -{ +void SamplePropertyWidget::selectionChanged(const QItemSelection& selected, const QItemSelection&) { QModelIndexList indices = selected.indexes(); if (!indices.empty()) { diff --git a/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.h b/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.h index 4e037f11e2a07c5391d7dbb0dde6c3b4f6762e58..1ad629b1bbd62212b34e7e5400f6b57585d2b9c4 100644 --- a/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.h +++ b/GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.h @@ -24,8 +24,7 @@ class ComponentEditor; //! Property editor to modify property of the object currently selected on the //! graphics scene. Located in the bottom right corner of SampleView. -class SamplePropertyWidget : public QWidget -{ +class SamplePropertyWidget : public QWidget { Q_OBJECT public: SamplePropertyWidget(QItemSelectionModel* selection_model, QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp b/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp index ac4bccef322f2588843a26e8b33c74270bb6439a..c529e94d7062fc98ac9f21237069da188a5b74de 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp @@ -27,8 +27,7 @@ //! main tool bar on top of SampleView window SampleToolBar::SampleToolBar(SampleViewActions* sampleActions, QWidget* parent) - : StyledToolBar(parent), m_sampleViewActions(sampleActions) -{ + : StyledToolBar(parent), m_sampleViewActions(sampleActions) { // Select & Pan auto selectionPointerButton = new QToolButton; selectionPointerButton->setCheckable(true); @@ -45,9 +44,9 @@ SampleToolBar::SampleToolBar(SampleViewActions* sampleActions, QWidget* parent) m_pointerModeGroup->addButton(selectionPointerButton, DesignerView::RUBBER_SELECTION); m_pointerModeGroup->addButton(handPointerButton, DesignerView::HAND_DRAG); connect(m_pointerModeGroup, - static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), - this, &SampleToolBar::selectionMode); - // TODO: replace buttonClicked by idClicked when Qt5.14 is available + static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, + &SampleToolBar::selectionMode); + // TODO: replace buttonClicked by idClicked when Qt5.14 is available addWidget(selectionPointerButton); addWidget(handPointerButton); @@ -124,19 +123,16 @@ SampleToolBar::SampleToolBar(SampleViewActions* sampleActions, QWidget* parent) addWidget(m_RealSpaceViewerButton); } -void SampleToolBar::onViewSelectionMode(int mode) -{ +void SampleToolBar::onViewSelectionMode(int mode) { if (mode == DesignerView::RUBBER_SELECTION || mode == DesignerView::HAND_DRAG) m_pointerModeGroup->button(mode)->setChecked(true); } -void SampleToolBar::onScaleComboChanged(const QString& scale_string) -{ +void SampleToolBar::onScaleComboChanged(const QString& scale_string) { double scale = scale_string.left(scale_string.indexOf("%")).toDouble() / 100.0; emit changeScale(scale); } -void SampleToolBar::onMaterialEditorCall() -{ +void SampleToolBar::onMaterialEditorCall() { ExternalProperty mp = MaterialItemUtils::selectMaterialProperty(); } diff --git a/GUI/coregui/Views/SampleDesigner/SampleToolBar.h b/GUI/coregui/Views/SampleDesigner/SampleToolBar.h index 5cfaa7bd2cdad9318b525f58dc45e08c61918154..f88d884e4a01debcf15d765a3731c81ddcd388dc 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleToolBar.h +++ b/GUI/coregui/Views/SampleDesigner/SampleToolBar.h @@ -29,8 +29,7 @@ class SampleViewActions; //! The SampleToolBar class represents a main toolbar on top of SampleView window -class SampleToolBar : public StyledToolBar -{ +class SampleToolBar : public StyledToolBar { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/SampleTreeWidget.cpp b/GUI/coregui/Views/SampleDesigner/SampleTreeWidget.cpp index b3984a889b3c6219706a16492d0129d7161fc2bb..4461e5ab38a2fffde88a2e33aee291ee38fcc704 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleTreeWidget.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleTreeWidget.cpp @@ -22,8 +22,7 @@ #include <QVBoxLayout> SampleTreeWidget::SampleTreeWidget(QWidget* parent, SampleModel* model) - : QWidget(parent), m_treeView(new ItemTreeView), m_sampleModel(model) -{ + : QWidget(parent), m_treeView(new ItemTreeView), m_sampleModel(model) { setWindowTitle("Sample Tree"); setObjectName(QLatin1String("SampleTreeWidget")); @@ -51,13 +50,11 @@ SampleTreeWidget::SampleTreeWidget(QWidget* parent, SampleModel* model) SLOT(expandAll())); } -QTreeView* SampleTreeWidget::treeView() -{ +QTreeView* SampleTreeWidget::treeView() { return m_treeView; } -void SampleTreeWidget::showContextMenu(const QPoint& pnt) -{ +void SampleTreeWidget::showContextMenu(const QPoint& pnt) { QMenu menu; QMenu add_menu("Add"); QVector<QString> addItemNames; @@ -90,8 +87,7 @@ void SampleTreeWidget::showContextMenu(const QPoint& pnt) } } -void SampleTreeWidget::addItem(const QString& item_name) -{ +void SampleTreeWidget::addItem(const QString& item_name) { QModelIndex currentIndex = FilterPropertyProxy::toSourceIndex(treeView()->currentIndex()); QModelIndex currentIndexAtColumnZero = getIndexAtColumnZero(currentIndex); @@ -102,8 +98,7 @@ void SampleTreeWidget::addItem(const QString& item_name) } } -void SampleTreeWidget::deleteItem() -{ +void SampleTreeWidget::deleteItem() { QModelIndex currentIndex = FilterPropertyProxy::toSourceIndex(treeView()->currentIndex()); if (!currentIndex.isValid()) @@ -115,15 +110,13 @@ void SampleTreeWidget::deleteItem() } } -void SampleTreeWidget::scrollToIndex(const QModelIndex& index) -{ +void SampleTreeWidget::scrollToIndex(const QModelIndex& index) { if (index.isValid()) { treeView()->scrollTo(index); } } -QModelIndex SampleTreeWidget::getIndexAtColumnZero(const QModelIndex& index) -{ +QModelIndex SampleTreeWidget::getIndexAtColumnZero(const QModelIndex& index) { if (index == QModelIndex() || index.column() == 0) return index; QModelIndex parent_index = m_sampleModel->parent(index); diff --git a/GUI/coregui/Views/SampleDesigner/SampleTreeWidget.h b/GUI/coregui/Views/SampleDesigner/SampleTreeWidget.h index 7af425d7eb9e213562081021fb494885ae2267dd..72aea18dc2789db287b9367f55cde56065fc5ba7 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleTreeWidget.h +++ b/GUI/coregui/Views/SampleDesigner/SampleTreeWidget.h @@ -26,8 +26,7 @@ class QAction; //! Holds tree to select top level sample items. Part of SampleView. -class SampleTreeWidget : public QWidget -{ +class SampleTreeWidget : public QWidget { Q_OBJECT public: SampleTreeWidget(QWidget* parent, SampleModel* model); diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewActions.cpp b/GUI/coregui/Views/SampleDesigner/SampleViewActions.cpp index ee1d50ccbeb7493a4d91249f9b28df3eac5b752c..cb0eb5bd35e1fcf89f9550448816dfa18514a054 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleViewActions.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleViewActions.cpp @@ -19,26 +19,20 @@ #include <QDockWidget> SampleViewActions::SampleViewActions(SampleModel* model, SampleView* parent) - : QObject(parent), m_model(model), m_sampleView(parent), m_selection_model(nullptr) -{ -} + : QObject(parent), m_model(model), m_sampleView(parent), m_selection_model(nullptr) {} -void SampleViewActions::setSelectionModel(QItemSelectionModel* selection_model) -{ +void SampleViewActions::setSelectionModel(QItemSelectionModel* selection_model) { m_selection_model = selection_model; } -SampleModel* SampleViewActions::sampleModel() -{ +SampleModel* SampleViewActions::sampleModel() { return m_model; } -QItemSelectionModel* SampleViewActions::selectionModel() -{ +QItemSelectionModel* SampleViewActions::selectionModel() { return m_selection_model; } -void SampleViewActions::onToggleRealSpaceView() -{ +void SampleViewActions::onToggleRealSpaceView() { m_sampleView->docks()->toggleDock(SampleViewDocks::REALSPACEPANEL); } diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewActions.h b/GUI/coregui/Views/SampleDesigner/SampleViewActions.h index a673df13845133c3f7f55067c5349234c633a374..e3ab38c8c593b5488271182a40a0a84376cbbae3 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleViewActions.h +++ b/GUI/coregui/Views/SampleDesigner/SampleViewActions.h @@ -23,8 +23,7 @@ class SampleView; //! Holds all actions of SampleView. -class SampleViewActions : public QObject -{ +class SampleViewActions : public QObject { Q_OBJECT public: SampleViewActions(SampleModel* model, SampleView* parent); diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewAligner.cpp b/GUI/coregui/Views/SampleDesigner/SampleViewAligner.cpp index 4d3f0ce81ec12f021da48882c01d80f65745eef0..c58e5acc78bc6a1ccb8eb7b519ace29c51f01787 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleViewAligner.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleViewAligner.cpp @@ -19,26 +19,21 @@ #include "GUI/coregui/utils/StyleUtils.h" #include <QModelIndex> -namespace -{ -int step_width() -{ +namespace { +int step_width() { return StyleUtils::SizeOfLetterM().width() * 12.5; } -int step_height() -{ +int step_height() { return StyleUtils::SizeOfLetterM().height() * 11; } } // namespace -SampleViewAligner::SampleViewAligner(DesignerScene* scene) : m_scene(scene) -{ +SampleViewAligner::SampleViewAligner(DesignerScene* scene) : m_scene(scene) { ASSERT(m_scene); } //! Spring based implified algorithm for smart alignment -void SampleViewAligner::smartAlign() -{ +void SampleViewAligner::smartAlign() { m_views.clear(); updateViews(); updateForces(); @@ -47,8 +42,7 @@ void SampleViewAligner::smartAlign() //! Forms list of all views which are subject for smart alignment (i.e. views //! which do not have parent view) -void SampleViewAligner::updateViews(const QModelIndex& parentIndex) -{ +void SampleViewAligner::updateViews(const QModelIndex& parentIndex) { SampleModel* sampleModel = m_scene->getSampleModel(); for (int i_row = 0; i_row < sampleModel->rowCount(parentIndex); ++i_row) { QModelIndex itemIndex = sampleModel->index(i_row, 0, parentIndex); @@ -61,8 +55,7 @@ void SampleViewAligner::updateViews(const QModelIndex& parentIndex) } //! Calculates forces acting on all views for smart alignment -void SampleViewAligner::updateForces() -{ +void SampleViewAligner::updateForces() { m_viewToPos.clear(); for (IView* view : m_views) { calculateForces(view); @@ -71,8 +64,7 @@ void SampleViewAligner::updateForces() //! Calculates forces acting on single view (simplified force directed spring algorithm) //! and deduce new position of views. -void SampleViewAligner::calculateForces(IView* view) -{ +void SampleViewAligner::calculateForces(IView* view) { qreal xvel = 0; qreal yvel = 0; @@ -103,8 +95,7 @@ void SampleViewAligner::calculateForces(IView* view) } //! Applies calculated positions to views -void SampleViewAligner::advance() -{ +void SampleViewAligner::advance() { for (IView* view : m_views) { view->setPos(m_viewToPos[view]); } @@ -115,8 +106,7 @@ void SampleViewAligner::advance() //! Weirdness of given function is due to the fact, that, for example, ParticleLayout view //! should interact not with Layer view, but with its parent - MultiLayer view. //! Similarly, MultiLayer is not interacting with its Layers, but directly with the ParticleLayout. -QList<IView*> SampleViewAligner::getConnectedViews(IView* view) -{ +QList<IView*> SampleViewAligner::getConnectedViews(IView* view) { QList<IView*> result; SessionItem* itemOfView = view->getItem(); @@ -149,8 +139,7 @@ QList<IView*> SampleViewAligner::getConnectedViews(IView* view) } //! Aligns sample starting from -void SampleViewAligner::alignSample(SessionItem* item, QPointF reference, bool force_alignment) -{ +void SampleViewAligner::alignSample(SessionItem* item, QPointF reference, bool force_alignment) { ASSERT(item); alignSample(m_scene->getSampleModel()->indexOfItem(item), reference, force_alignment); } @@ -160,8 +149,7 @@ void SampleViewAligner::alignSample(SessionItem* item, QPointF reference, bool f //! if force_alignment=true the position will be changed anyway. //! Position of View which has parent item (like Layer) will remain unchainged. void SampleViewAligner::alignSample(const QModelIndex& parentIndex, QPointF reference, - bool force_alignment) -{ + bool force_alignment) { SampleModel* sampleModel = m_scene->getSampleModel(); if (IView* view = getViewForIndex(parentIndex)) { @@ -185,8 +173,7 @@ void SampleViewAligner::alignSample(const QModelIndex& parentIndex, QPointF refe } } -IView* SampleViewAligner::getViewForIndex(const QModelIndex& index) -{ +IView* SampleViewAligner::getViewForIndex(const QModelIndex& index) { SampleModel* sampleModel = m_scene->getSampleModel(); SessionItem* item = sampleModel->itemForIndex(index); return m_scene->getViewForItem(item); diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewAligner.h b/GUI/coregui/Views/SampleDesigner/SampleViewAligner.h index e9b96d1f8e6b9f7a612b3fdc739900b35e56206a..679458c1ef8e446534845668e4796d8c0413b44c 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleViewAligner.h +++ b/GUI/coregui/Views/SampleDesigner/SampleViewAligner.h @@ -24,8 +24,7 @@ class SessionItem; //! Makes alignment of sample droped on graphics scene. //! Implements additional algorithm for smart alignment. -class SampleViewAligner -{ +class SampleViewAligner { public: SampleViewAligner(DesignerScene* scene); diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewDocks.cpp b/GUI/coregui/Views/SampleDesigner/SampleViewDocks.cpp index 7667cfb4dd1ac7af5bb2a92d054296d8b14be135..97240d4b04e7d707ce642f6ce86ca21a28c96ad8 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleViewDocks.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleViewDocks.cpp @@ -34,8 +34,7 @@ SampleViewDocks::SampleViewDocks(SampleView* parent) , m_propertyWidget(new SamplePropertyWidget(m_treeWidget->treeView()->selectionModel(), parent)) , m_scriptPanel(new ScriptPanel(parent)) , m_realSpacePanel(new RealSpacePanel(parent->models()->sampleModel(), - m_treeWidget->treeView()->selectionModel(), parent)) -{ + m_treeWidget->treeView()->selectionModel(), parent)) { addWidget(WIDGET_BOX, m_widgetBox, Qt::LeftDockWidgetArea); addWidget(SAMPLE_TREE, m_treeWidget, Qt::RightDockWidgetArea); addWidget(PROPERTY_EDITOR, m_propertyWidget, Qt::RightDockWidgetArea); @@ -60,23 +59,19 @@ SampleViewDocks::SampleViewDocks(SampleView* parent) onResetLayout(); } -SampleWidgetBox* SampleViewDocks::widgetBox() -{ +SampleWidgetBox* SampleViewDocks::widgetBox() { return m_widgetBox; } -SampleTreeWidget* SampleViewDocks::treeWidget() -{ +SampleTreeWidget* SampleViewDocks::treeWidget() { return m_treeWidget; } -SamplePropertyWidget* SampleViewDocks::propertyWidget() -{ +SamplePropertyWidget* SampleViewDocks::propertyWidget() { return m_propertyWidget; } -void SampleViewDocks::onResetLayout() -{ +void SampleViewDocks::onResetLayout() { DocksController::onResetLayout(); mainWindow()->tabifyDockWidget(findDock(REALSPACEPANEL), findDock(INFO)); findDock(REALSPACEPANEL)->raise(); // makes first tab active @@ -85,13 +80,11 @@ void SampleViewDocks::onResetLayout() findDock(INFO)->hide(); } -void SampleViewDocks::toggleDock(int id) -{ +void SampleViewDocks::toggleDock(int id) { auto dock = findDock(id); dock->setHidden(!dock->isHidden()); } -SampleDesigner* SampleViewDocks::sampleDesigner() -{ +SampleDesigner* SampleViewDocks::sampleDesigner() { return m_sampleDesigner; } diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewDocks.h b/GUI/coregui/Views/SampleDesigner/SampleViewDocks.h index 66403aca957eaa5518667736403602d09f9994c8..fe2d0d615c1453927c3cba9738f3eb98fd5426bf 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleViewDocks.h +++ b/GUI/coregui/Views/SampleDesigner/SampleViewDocks.h @@ -28,8 +28,7 @@ class QAction; //! Holds all docked widgets for SampleView. -class SampleViewDocks : public DocksController -{ +class SampleViewDocks : public DocksController { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewFactory.cpp b/GUI/coregui/Views/SampleDesigner/SampleViewFactory.cpp index e24ecc5dbe8708b07c84a646dbc28413829c4259..ac0a15a401223c09b23157db8a43396d9aef9a12 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleViewFactory.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleViewFactory.cpp @@ -41,8 +41,7 @@ QStringList SampleViewFactory::m_valid_item_names = QStringList() << "InterferenceHardDisk" << "InterferenceRadialParaCrystal"; -bool SampleViewFactory::isValidType(const QString& name) -{ +bool SampleViewFactory::isValidType(const QString& name) { if (name.startsWith("FormFactor")) { return true; } else { @@ -50,8 +49,7 @@ bool SampleViewFactory::isValidType(const QString& name) } } -IView* SampleViewFactory::createSampleView(const QString& name) -{ +IView* SampleViewFactory::createSampleView(const QString& name) { if (name == "MultiLayer") { return new MultiLayerView(); } else if (name == "Layer") { diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewFactory.h b/GUI/coregui/Views/SampleDesigner/SampleViewFactory.h index 0b1ca6e73462f4831d402fb056892d95cbf43f94..b3980ad0a3eb7fe6f64467ef6198af1ede0344ac 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleViewFactory.h +++ b/GUI/coregui/Views/SampleDesigner/SampleViewFactory.h @@ -20,8 +20,7 @@ class IView; -class SampleViewFactory -{ +class SampleViewFactory { public: static bool isValidType(const QString& name); static IView* createSampleView(const QString& name); diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.cpp b/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.cpp index d8028cd1cdd0db9269b9070346c430ba577a2891..c837a822be03025f56a4631286a1dd555da75e83 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.cpp @@ -20,8 +20,7 @@ #include <QToolButton> SampleViewStatusBar::SampleViewStatusBar(MainWindow* mainWindow) - : QWidget(mainWindow), m_dockMenuButton(nullptr), m_mainWindow(mainWindow) -{ + : QWidget(mainWindow), m_dockMenuButton(nullptr), m_mainWindow(mainWindow) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); auto layout = new QHBoxLayout; @@ -41,8 +40,7 @@ SampleViewStatusBar::SampleViewStatusBar(MainWindow* mainWindow) //! Init appearance of MainWindow's statusBar. -void SampleViewStatusBar::initAppearance() -{ +void SampleViewStatusBar::initAppearance() { ASSERT(m_mainWindow); m_mainWindow->statusBar()->addWidget(this, 1); m_mainWindow->statusBar()->setSizeGripEnabled(false); diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.h b/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.h index 0f949ebb5e7fcda38be122a9d59f2938aeb8bd05..b54ef00c91a6a0801ab52befaf8723bfea47bda5 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.h +++ b/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.h @@ -23,8 +23,7 @@ class QComboBox; //! Narrow status bar at very bottom of SampleView to access dock menu. -class SampleViewStatusBar : public QWidget -{ +class SampleViewStatusBar : public QWidget { Q_OBJECT public: SampleViewStatusBar(MainWindow* mainWindow); diff --git a/GUI/coregui/Views/SampleDesigner/SampleWidgetBox.cpp b/GUI/coregui/Views/SampleDesigner/SampleWidgetBox.cpp index 4c0a372850bf23612891328459650a107f1b83ad..cf1b72afe2711753b5da0bc850f5fffb9d20d9aa 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleWidgetBox.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleWidgetBox.cpp @@ -22,8 +22,7 @@ #endif SampleWidgetBox::SampleWidgetBox(SampleDesignerInterface* core, QWidget* parent) - : QWidget(parent), m_core(core), m_widgetBox(0) -{ + : QWidget(parent), m_core(core), m_widgetBox(0) { setWindowTitle(QLatin1String("Widget Box")); setObjectName(QLatin1String("WidgetBox")); // Manhattan::StyledBar *bar = new Manhattan::StyledBar(this); diff --git a/GUI/coregui/Views/SampleDesigner/SampleWidgetBox.h b/GUI/coregui/Views/SampleDesigner/SampleWidgetBox.h index 4311cf17285e91a71213c776a240df357d55cdd8..c5c1c28dbc8a839a51a05000376e32ed49fe45e6 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleWidgetBox.h +++ b/GUI/coregui/Views/SampleDesigner/SampleWidgetBox.h @@ -21,8 +21,7 @@ class QDesignerWidgetBoxInterface; class SampleDesignerInterface; //! widget box and tool window on the left side of SampleView -class SampleWidgetBox : public QWidget -{ +class SampleWidgetBox : public QWidget { public: explicit SampleWidgetBox(SampleDesignerInterface* core, QWidget* parent); diff --git a/GUI/coregui/Views/SampleDesigner/ScriptPanel.cpp b/GUI/coregui/Views/SampleDesigner/ScriptPanel.cpp index e36fcdbc403f16e76f2bf57381010ad0d357c56a..fbeac540180ab8cdfa50b4e4fa181cab2372eb16 100644 --- a/GUI/coregui/Views/SampleDesigner/ScriptPanel.cpp +++ b/GUI/coregui/Views/SampleDesigner/ScriptPanel.cpp @@ -19,8 +19,7 @@ #include <QStackedWidget> ScriptPanel::ScriptPanel(QWidget* parent) - : InfoPanel(parent), m_pySampleWidget(new PySampleWidget(this)) -{ + : InfoPanel(parent), m_pySampleWidget(new PySampleWidget(this)) { setWindowTitle("Python Script"); setObjectName("ScriptPanel"); @@ -30,12 +29,10 @@ ScriptPanel::ScriptPanel(QWidget* parent) m_toolBar->hide(); } -void ScriptPanel::setSampleModel(SampleModel* sampleModel) -{ +void ScriptPanel::setSampleModel(SampleModel* sampleModel) { m_pySampleWidget->setSampleModel(sampleModel); } -void ScriptPanel::setInstrumentModel(InstrumentModel* instrumentModel) -{ +void ScriptPanel::setInstrumentModel(InstrumentModel* instrumentModel) { m_pySampleWidget->setInstrumentModel(instrumentModel); } diff --git a/GUI/coregui/Views/SampleDesigner/ScriptPanel.h b/GUI/coregui/Views/SampleDesigner/ScriptPanel.h index c2b0c4193ca06b5fb961def202c6d6a6bacc9de4..578244418dc96f9d7b3bb9af8e8c51bd3ca40ac9 100644 --- a/GUI/coregui/Views/SampleDesigner/ScriptPanel.h +++ b/GUI/coregui/Views/SampleDesigner/ScriptPanel.h @@ -23,8 +23,7 @@ class PySampleWidget; //! Resides at the bottom of SampleView and displays a Python script. -class ScriptPanel : public InfoPanel -{ +class ScriptPanel : public InfoPanel { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/TransformationView.cpp b/GUI/coregui/Views/SampleDesigner/TransformationView.cpp index ffad31c1ea18252e160f2774242a41a35dd2ddc0..674adc23ed6e6487eec083a0ca638ed9d49b4e90 100644 --- a/GUI/coregui/Views/SampleDesigner/TransformationView.cpp +++ b/GUI/coregui/Views/SampleDesigner/TransformationView.cpp @@ -15,8 +15,7 @@ #include "GUI/coregui/Views/SampleDesigner/TransformationView.h" #include "GUI/coregui/Views/SampleDesigner/DesignerHelper.h" -TransformationView::TransformationView(QGraphicsItem* parent) : ConnectableView(parent) -{ +TransformationView::TransformationView(QGraphicsItem* parent) : ConnectableView(parent) { setName("Rotation"); setColor(DesignerHelper::getDefaultTransformationColor()); setRectangle(DesignerHelper::getTransformationBoundingRect()); diff --git a/GUI/coregui/Views/SampleDesigner/TransformationView.h b/GUI/coregui/Views/SampleDesigner/TransformationView.h index 08ad05542380a3d4db3467be6dd970388ed31d3b..d24d0811f09eba5def3999eae9253da7778a630c 100644 --- a/GUI/coregui/Views/SampleDesigner/TransformationView.h +++ b/GUI/coregui/Views/SampleDesigner/TransformationView.h @@ -17,8 +17,7 @@ #include "GUI/coregui/Views/SampleDesigner/ConnectableView.h" -class TransformationView : public ConnectableView -{ +class TransformationView : public ConnectableView { Q_OBJECT public: diff --git a/GUI/coregui/Views/SampleDesigner/ViewTypes.h b/GUI/coregui/Views/SampleDesigner/ViewTypes.h index 1df3c178d723c2db1d8a581e186054e0a6b4d988..110946d99100ea2853462e7bea52569ca53e5aab 100644 --- a/GUI/coregui/Views/SampleDesigner/ViewTypes.h +++ b/GUI/coregui/Views/SampleDesigner/ViewTypes.h @@ -19,8 +19,7 @@ //! Type definition for graphics items. -namespace ViewTypes -{ +namespace ViewTypes { enum EWidgetTypes { IVIEW = QGraphicsItem::UserType + 1, // = 65537 diff --git a/GUI/coregui/Views/SampleView.cpp b/GUI/coregui/Views/SampleView.cpp index f3a385f47323e95a979fccd1cf66fd4d387f5608..07e9941409c37d857da18630fcc271cfde7e0d3c 100644 --- a/GUI/coregui/Views/SampleView.cpp +++ b/GUI/coregui/Views/SampleView.cpp @@ -30,46 +30,39 @@ SampleView::SampleView(MainWindow* mainWindow) , m_docks(new SampleViewDocks(this)) , m_actions(new SampleViewActions(mainWindow->models()->sampleModel(), this)) , m_toolBar(nullptr) - , m_statusBar(new SampleViewStatusBar(mainWindow)) -{ + , m_statusBar(new SampleViewStatusBar(mainWindow)) { setObjectName("SampleView"); m_actions->setSelectionModel(selectionModel()); connectSignals(); } -ApplicationModels* SampleView::models() -{ +ApplicationModels* SampleView::models() { return m_models; } -SampleViewDocks* SampleView::docks() -{ +SampleViewDocks* SampleView::docks() { return m_docks; } -void SampleView::onDockMenuRequest() -{ +void SampleView::onDockMenuRequest() { std::unique_ptr<QMenu> menu(createPopupMenu()); menu->exec(QCursor::pos()); } -void SampleView::showEvent(QShowEvent* event) -{ +void SampleView::showEvent(QShowEvent* event) { if (isVisible()) m_statusBar->show(); Manhattan::FancyMainWindow::showEvent(event); } -void SampleView::hideEvent(QHideEvent* event) -{ +void SampleView::hideEvent(QHideEvent* event) { if (isHidden()) m_statusBar->hide(); Manhattan::FancyMainWindow::hideEvent(event); } -void SampleView::connectSignals() -{ +void SampleView::connectSignals() { connect(this, &SampleView::resetLayout, m_docks, &SampleViewDocks::onResetLayout); connect(m_statusBar, &SampleViewStatusBar::dockMenuRequest, this, &SampleView::onDockMenuRequest); @@ -92,12 +85,10 @@ void SampleView::connectSignals() addToolBar(m_toolBar); } -QItemSelectionModel* SampleView::selectionModel() -{ +QItemSelectionModel* SampleView::selectionModel() { return m_docks->treeWidget()->treeView()->selectionModel(); } -SampleDesigner* SampleView::sampleDesigner() -{ +SampleDesigner* SampleView::sampleDesigner() { return m_docks->sampleDesigner(); } diff --git a/GUI/coregui/Views/SampleView.h b/GUI/coregui/Views/SampleView.h index b237cd6055048e5550667dd3bee64736c3974f19..0c69b7ad239a6625e05e0b1d4b86644bf09e1b9d 100644 --- a/GUI/coregui/Views/SampleView.h +++ b/GUI/coregui/Views/SampleView.h @@ -28,8 +28,7 @@ class QShowEvent; class QHideEvent; class SampleViewActions; -class SampleView : public Manhattan::FancyMainWindow -{ +class SampleView : public Manhattan::FancyMainWindow { Q_OBJECT public: diff --git a/GUI/coregui/Views/SessionModelView.cpp b/GUI/coregui/Views/SessionModelView.cpp index be6283e890a7a92f58eb21800fec50a8c57af5fd..d83986aba11ac65bbf1f21e32eb63431dce8697a 100644 --- a/GUI/coregui/Views/SessionModelView.cpp +++ b/GUI/coregui/Views/SessionModelView.cpp @@ -26,8 +26,7 @@ #include <QToolButton> #include <QVBoxLayout> -namespace -{ +namespace { const bool show_test_view = false; } @@ -37,8 +36,7 @@ SessionModelView::SessionModelView(MainWindow* mainWindow) , m_toolBar(new QToolBar) , m_tabs(new QTabWidget) , m_expandCollapseButton(new QToolButton) - , m_delegate(new SessionModelDelegate(this)) -{ + , m_delegate(new SessionModelDelegate(this)) { auto layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); @@ -60,15 +58,13 @@ SessionModelView::SessionModelView(MainWindow* mainWindow) init_test_view(); } -void SessionModelView::onExpandCollapseTree() -{ +void SessionModelView::onExpandCollapseTree() { m_content.at(m_tabs->currentIndex())->toggleExpanded(); } //! Creates content for tab widget. -void SessionModelView::init_tabs() -{ +void SessionModelView::init_tabs() { ASSERT(m_content.empty()); for (auto model : modelsForTabs()) { @@ -81,8 +77,7 @@ void SessionModelView::init_tabs() //! Returns list of models to show in tabs. -QList<SessionModel*> SessionModelView::modelsForTabs() -{ +QList<SessionModel*> SessionModelView::modelsForTabs() { QList<SessionModel*> result = QList<SessionModel*>() << m_mainWindow->instrumentModel() << m_mainWindow->sampleModel() << m_mainWindow->realDataModel() << m_mainWindow->materialModel() @@ -90,8 +85,7 @@ QList<SessionModel*> SessionModelView::modelsForTabs() return result; } -void SessionModelView::init_test_view() -{ +void SessionModelView::init_test_view() { auto view = new TestView(m_mainWindow); int index = m_tabs->addTab(view, "Test View"); m_tabs->setCurrentIndex(index); diff --git a/GUI/coregui/Views/SessionModelView.h b/GUI/coregui/Views/SessionModelView.h index 1cff5e40faea2fb49441c66035cf8e616393e4af..ac50f7ec70f0fe09f0a3e5d50dd75b1d8e86fda1 100644 --- a/GUI/coregui/Views/SessionModelView.h +++ b/GUI/coregui/Views/SessionModelView.h @@ -29,8 +29,7 @@ class SessionModelDelegate; //! models. It appears as an additional view in the main navigation bar on the left, right //! after the jobView (if corresponding setting of MainWindow is On). -class SessionModelView : public QWidget -{ +class SessionModelView : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/SimulationView.cpp b/GUI/coregui/Views/SimulationView.cpp index 5a4b49d74e192136074c4ee0f5acc1523365f2d6..e45f389b63a674afc48cba12dd1b532da004b519 100644 --- a/GUI/coregui/Views/SimulationView.cpp +++ b/GUI/coregui/Views/SimulationView.cpp @@ -21,8 +21,7 @@ SimulationView::SimulationView(MainWindow* mainWindow) : QWidget(mainWindow) , m_simulationSetupWidget(new SimulationSetupWidget) - , m_toolBar(new StyledToolBar) -{ + , m_toolBar(new StyledToolBar) { m_toolBar->setFixedHeight(m_toolBar->minimumHeight()); m_simulationSetupWidget->setApplicationModels(mainWindow->models()); @@ -35,17 +34,14 @@ SimulationView::SimulationView(MainWindow* mainWindow) setLayout(mainLayout); } -void SimulationView::onRunSimulationShortcut() -{ +void SimulationView::onRunSimulationShortcut() { m_simulationSetupWidget->onRunSimulation(); } -void SimulationView::showEvent(QShowEvent*) -{ +void SimulationView::showEvent(QShowEvent*) { updateSimulationViewElements(); } -void SimulationView::updateSimulationViewElements() -{ +void SimulationView::updateSimulationViewElements() { m_simulationSetupWidget->updateViewElements(); } diff --git a/GUI/coregui/Views/SimulationView.h b/GUI/coregui/Views/SimulationView.h index de5609904f2d6c3c91dd34e28ba368ad681a1a1f..3c54d5e8d4ceca3ec97d22862d0f34040eb7d361 100644 --- a/GUI/coregui/Views/SimulationView.h +++ b/GUI/coregui/Views/SimulationView.h @@ -21,8 +21,7 @@ class MainWindow; class SimulationSetupWidget; class StyledToolBar; -class SimulationView : public QWidget -{ +class SimulationView : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/SimulationWidgets/PythonScriptWidget.cpp b/GUI/coregui/Views/SimulationWidgets/PythonScriptWidget.cpp index 5b016d7a743029067a4db2c370cca88a625bffb9..a03ac81497c08dc6c364ba1c30d62ef6a63bb455 100644 --- a/GUI/coregui/Views/SimulationWidgets/PythonScriptWidget.cpp +++ b/GUI/coregui/Views/SimulationWidgets/PythonScriptWidget.cpp @@ -36,8 +36,7 @@ PythonScriptWidget::PythonScriptWidget(QWidget* parent) : QDialog(parent) , m_toolBar(nullptr) , m_textEdit(new QTextEdit) - , m_warningSign(new WarningSign(m_textEdit)) -{ + , m_warningSign(new WarningSign(m_textEdit)) { setWindowTitle("Python Script View"); setMinimumSize(128, 128); resize(512, 400); @@ -81,8 +80,7 @@ PythonScriptWidget::PythonScriptWidget(QWidget* parent) void PythonScriptWidget::generatePythonScript(const MultiLayerItem* sampleItem, const InstrumentItem* instrumentItem, const SimulationOptionsItem* optionItem, - const QString& outputDir) -{ + const QString& outputDir) { m_outputDir = outputDir; m_warningSign->clear(); @@ -106,8 +104,7 @@ void PythonScriptWidget::generatePythonScript(const MultiLayerItem* sampleItem, } } -void PythonScriptWidget::onExportToFileButton() -{ +void PythonScriptWidget::onExportToFileButton() { QString dirname(m_outputDir); if (dirname.isEmpty()) dirname = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); diff --git a/GUI/coregui/Views/SimulationWidgets/PythonScriptWidget.h b/GUI/coregui/Views/SimulationWidgets/PythonScriptWidget.h index c340a46f8d70dca37b5a7a5299c8b9ee3abada80..1b43cadd2d27ba40f0c33e30cfc030bf77a8b549 100644 --- a/GUI/coregui/Views/SimulationWidgets/PythonScriptWidget.h +++ b/GUI/coregui/Views/SimulationWidgets/PythonScriptWidget.h @@ -27,8 +27,7 @@ class SimulationOptionsItem; //! The PythonScriptWidget displays a python script which represents full simulation. //! Part of SimulationSetupWidget -class PythonScriptWidget : public QDialog -{ +class PythonScriptWidget : public QDialog { Q_OBJECT public: diff --git a/GUI/coregui/Views/SimulationWidgets/SimulationDataSelectorWidget.cpp b/GUI/coregui/Views/SimulationWidgets/SimulationDataSelectorWidget.cpp index 80011311fec5d5050d14d0a4b6319b6d13610f5e..bb75633eb3755c88496e9d44c463348526662f0b 100644 --- a/GUI/coregui/Views/SimulationWidgets/SimulationDataSelectorWidget.cpp +++ b/GUI/coregui/Views/SimulationWidgets/SimulationDataSelectorWidget.cpp @@ -27,8 +27,7 @@ #include <QLabel> #include <QVBoxLayout> -namespace -{ +namespace { const QString select_instrument_tooltip = "Select Instrument to simulate from those defined in Instrument View"; const QString select_sample_tooltip = "Select Sample to simulate from those defined in Sample View"; @@ -41,8 +40,7 @@ SimulationDataSelectorWidget::SimulationDataSelectorWidget(QWidget* parent) , m_instrumentCombo(new QComboBox) , m_sampleCombo(new QComboBox) , m_realDataCombo(new QComboBox) - , m_applicationModels(0) -{ + , m_applicationModels(0) { QVBoxLayout* mainLayout = new QVBoxLayout; mainLayout->setMargin(0); mainLayout->setSpacing(0); @@ -79,8 +77,7 @@ SimulationDataSelectorWidget::SimulationDataSelectorWidget(QWidget* parent) setLayout(mainLayout); } -void SimulationDataSelectorWidget::setApplicationModels(ApplicationModels* applicationModels) -{ +void SimulationDataSelectorWidget::setApplicationModels(ApplicationModels* applicationModels) { m_applicationModels = applicationModels; updateViewElements(); } @@ -88,8 +85,7 @@ void SimulationDataSelectorWidget::setApplicationModels(ApplicationModels* appli //! Returns selected MultiLayerItem taking into account that there might be several //! multilayers with same name. -const MultiLayerItem* SimulationDataSelectorWidget::selectedMultiLayerItem() const -{ +const MultiLayerItem* SimulationDataSelectorWidget::selectedMultiLayerItem() const { auto items = m_applicationModels->sampleModel()->topItems<MultiLayerItem>(); if (items.isEmpty()) return nullptr; @@ -99,8 +95,7 @@ const MultiLayerItem* SimulationDataSelectorWidget::selectedMultiLayerItem() con //! Returns selected InstrumentItem taking into account that there might be several //! instruments with same name. -const InstrumentItem* SimulationDataSelectorWidget::selectedInstrumentItem() const -{ +const InstrumentItem* SimulationDataSelectorWidget::selectedInstrumentItem() const { auto items = m_applicationModels->instrumentModel()->topItems<InstrumentItem>(); return items.isEmpty() ? nullptr : items.at(selectedInstrumentIndex()); } @@ -108,8 +103,7 @@ const InstrumentItem* SimulationDataSelectorWidget::selectedInstrumentItem() con //! Returns selected InstrumentItem taking into account that there might be several //! instruments with same name. -const RealDataItem* SimulationDataSelectorWidget::selectedRealDataItem() const -{ +const RealDataItem* SimulationDataSelectorWidget::selectedRealDataItem() const { auto items = m_applicationModels->realDataModel()->topItems(); if (items.isEmpty()) return nullptr; @@ -119,8 +113,7 @@ const RealDataItem* SimulationDataSelectorWidget::selectedRealDataItem() const return nullptr; } -void SimulationDataSelectorWidget::updateViewElements() -{ +void SimulationDataSelectorWidget::updateViewElements() { ASSERT(m_applicationModels); updateSelection(m_instrumentCombo, ModelUtils::topItemNames(m_applicationModels->instrumentModel())); @@ -130,18 +123,15 @@ void SimulationDataSelectorWidget::updateViewElements() true); } -int SimulationDataSelectorWidget::selectedInstrumentIndex() const -{ +int SimulationDataSelectorWidget::selectedInstrumentIndex() const { return m_instrumentCombo->currentIndex(); } -int SimulationDataSelectorWidget::selectedSampleIndex() const -{ +int SimulationDataSelectorWidget::selectedSampleIndex() const { return m_sampleCombo->currentIndex(); } -int SimulationDataSelectorWidget::selectedRealDataIndex() const -{ +int SimulationDataSelectorWidget::selectedRealDataIndex() const { // -1 because m_realDataCombo always contains "None" as a first entry return m_realDataCombo->currentIndex() - 1; } @@ -150,8 +140,7 @@ int SimulationDataSelectorWidget::selectedRealDataIndex() const //! If allow_none == true, additional "None" item will be added to the combo. void SimulationDataSelectorWidget::updateSelection(QComboBox* comboBox, QStringList itemList, - bool allow_none) -{ + bool allow_none) { QString previousItem = comboBox->currentText(); comboBox->clear(); diff --git a/GUI/coregui/Views/SimulationWidgets/SimulationDataSelectorWidget.h b/GUI/coregui/Views/SimulationWidgets/SimulationDataSelectorWidget.h index 5080a8111774f7733c9a4961de9ab8cc440899a9..93ba9e0fb1a5957495f724b35e3a68f513b82e46 100644 --- a/GUI/coregui/Views/SimulationWidgets/SimulationDataSelectorWidget.h +++ b/GUI/coregui/Views/SimulationWidgets/SimulationDataSelectorWidget.h @@ -26,8 +26,7 @@ class RealDataItem; //! The SimulationDataSelectorWidget class represents widget to select instrument, sample and //! real data. Located at the top of SimulationView. -class SimulationDataSelectorWidget : public QWidget -{ +class SimulationDataSelectorWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/SimulationWidgets/SimulationOptionsWidget.cpp b/GUI/coregui/Views/SimulationWidgets/SimulationOptionsWidget.cpp index bff84cbbfffbefcb50af15aac90e681cb1282d45..c586f52136c03064bfe1db6aceea780875f20def 100644 --- a/GUI/coregui/Views/SimulationWidgets/SimulationOptionsWidget.cpp +++ b/GUI/coregui/Views/SimulationWidgets/SimulationOptionsWidget.cpp @@ -19,8 +19,7 @@ #include <QVBoxLayout> SimulationOptionsWidget::SimulationOptionsWidget(QWidget* parent) - : QWidget(parent), m_boxEditor(new ComponentFlatView) -{ + : QWidget(parent), m_boxEditor(new ComponentFlatView) { auto groupBox = new QGroupBox("ISimulation Parameters"); auto groupLayout = new QVBoxLayout; @@ -35,8 +34,7 @@ SimulationOptionsWidget::SimulationOptionsWidget(QWidget* parent) setLayout(mainLayout); } -void SimulationOptionsWidget::setItem(SimulationOptionsItem* item) -{ +void SimulationOptionsWidget::setItem(SimulationOptionsItem* item) { m_boxEditor->clearEditor(); m_boxEditor->setItem(item); } diff --git a/GUI/coregui/Views/SimulationWidgets/SimulationOptionsWidget.h b/GUI/coregui/Views/SimulationWidgets/SimulationOptionsWidget.h index 5cb44bcc6326710b52c4e8549327bef89ae1c7df..724fb0ba5cf21700f79c8d7655762ca9df08dc9d 100644 --- a/GUI/coregui/Views/SimulationWidgets/SimulationOptionsWidget.h +++ b/GUI/coregui/Views/SimulationWidgets/SimulationOptionsWidget.h @@ -23,8 +23,7 @@ class ComponentFlatView; //! Holds widgets related to the setup of simulation/job options (nthreads, run policy, //! computation method). Part of SimulationView/SimulationSetupWidet -class SimulationOptionsWidget : public QWidget -{ +class SimulationOptionsWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/SimulationWidgets/SimulationSetupAssistant.cpp b/GUI/coregui/Views/SimulationWidgets/SimulationSetupAssistant.cpp index cf67fd185c1a0af9137a702cb2f96b75571ac58f..e0834d0c706e4c6973ac6ce010383bb64056a1ec 100644 --- a/GUI/coregui/Views/SimulationWidgets/SimulationSetupAssistant.cpp +++ b/GUI/coregui/Views/SimulationWidgets/SimulationSetupAssistant.cpp @@ -25,8 +25,7 @@ SimulationSetupAssistant::SimulationSetupAssistant() : m_isValid(false) {} bool SimulationSetupAssistant::isValidSimulationSetup(const MultiLayerItem* multiLayerItem, const InstrumentItem* instrumentItem, - const RealDataItem* realData) -{ + const RealDataItem* realData) { clear(); checkMultiLayerItem(multiLayerItem); @@ -39,14 +38,12 @@ bool SimulationSetupAssistant::isValidSimulationSetup(const MultiLayerItem* mult return m_isValid; } -void SimulationSetupAssistant::clear() -{ +void SimulationSetupAssistant::clear() { m_isValid = true; m_messages.clear(); } -void SimulationSetupAssistant::checkMultiLayerItem(const MultiLayerItem* multiLayerItem) -{ +void SimulationSetupAssistant::checkMultiLayerItem(const MultiLayerItem* multiLayerItem) { if (!multiLayerItem) { m_messages.append("No sample selected"); m_isValid = false; @@ -59,8 +56,7 @@ void SimulationSetupAssistant::checkMultiLayerItem(const MultiLayerItem* multiLa } } -void SimulationSetupAssistant::checkInstrumentItem(const InstrumentItem* instrumentItem) -{ +void SimulationSetupAssistant::checkInstrumentItem(const InstrumentItem* instrumentItem) { if (!instrumentItem) { m_messages.append("No instrument selected"); m_isValid = false; @@ -71,8 +67,7 @@ void SimulationSetupAssistant::checkInstrumentItem(const InstrumentItem* instrum //! its axes will be compared with current detector item. void SimulationSetupAssistant::checkFittingSetup(const InstrumentItem* instrumentItem, - const RealDataItem* realData) -{ + const RealDataItem* realData) { if (!realData || !instrumentItem || instrumentItem->alignedWith(realData)) return; @@ -83,8 +78,7 @@ void SimulationSetupAssistant::checkFittingSetup(const InstrumentItem* instrumen //! Composes the error message for message box. -QString SimulationSetupAssistant::composeMessage() -{ +QString SimulationSetupAssistant::composeMessage() { QString result("Can't run the job with current settings\n\n"); for (auto message : m_messages) { QString text = QString("- %1 \n").arg(message); diff --git a/GUI/coregui/Views/SimulationWidgets/SimulationSetupAssistant.h b/GUI/coregui/Views/SimulationWidgets/SimulationSetupAssistant.h index dbdaf69a41c4e91a73165205a7987e4ca574f459..f56e35fc12a8991fa7c701ee96ac0d79935a32e1 100644 --- a/GUI/coregui/Views/SimulationWidgets/SimulationSetupAssistant.h +++ b/GUI/coregui/Views/SimulationWidgets/SimulationSetupAssistant.h @@ -24,8 +24,7 @@ class RealDataItem; //! The SimulationSetupAssistant class provides sample, instrument and real data validation before //! submitting the job. -class SimulationSetupAssistant -{ +class SimulationSetupAssistant { public: SimulationSetupAssistant(); diff --git a/GUI/coregui/Views/SimulationWidgets/SimulationSetupWidget.cpp b/GUI/coregui/Views/SimulationWidgets/SimulationSetupWidget.cpp index f6e877598c3d13dee1f7d3890f3b314da46a0b06..0f4c300f6e1e42c554453d9fc5e1e8a5729f86b4 100644 --- a/GUI/coregui/Views/SimulationWidgets/SimulationSetupWidget.cpp +++ b/GUI/coregui/Views/SimulationWidgets/SimulationSetupWidget.cpp @@ -34,8 +34,7 @@ SimulationSetupWidget::SimulationSetupWidget(QWidget* parent) , runSimulationButton(0) , exportToPyScriptButton(0) , m_simDataSelectorWidget(new SimulationDataSelectorWidget(this)) - , m_simOptionsWidget(new SimulationOptionsWidget(this)) -{ + , m_simOptionsWidget(new SimulationOptionsWidget(this)) { QVBoxLayout* mainLayout = new QVBoxLayout; mainLayout->addWidget(m_simDataSelectorWidget); mainLayout->addWidget(m_simOptionsWidget); @@ -48,8 +47,7 @@ SimulationSetupWidget::SimulationSetupWidget(QWidget* parent) connect(exportToPyScriptButton, SIGNAL(clicked()), this, SLOT(onExportToPythonScript())); } -void SimulationSetupWidget::setApplicationModels(ApplicationModels* model) -{ +void SimulationSetupWidget::setApplicationModels(ApplicationModels* model) { ASSERT(model); if (model != m_applicationModels) { m_applicationModels = model; @@ -58,14 +56,12 @@ void SimulationSetupWidget::setApplicationModels(ApplicationModels* model) } } -void SimulationSetupWidget::updateViewElements() -{ +void SimulationSetupWidget::updateViewElements() { m_simDataSelectorWidget->updateViewElements(); m_simOptionsWidget->setItem(m_applicationModels->documentModel()->simulationOptionsItem()); } -void SimulationSetupWidget::onRunSimulation() -{ +void SimulationSetupWidget::onRunSimulation() { const MultiLayerItem* multiLayerItem = m_simDataSelectorWidget->selectedMultiLayerItem(); const auto instrumentItem = m_simDataSelectorWidget->selectedInstrumentItem(); const RealDataItem* realDataItem = m_simDataSelectorWidget->selectedRealDataItem(); @@ -82,8 +78,7 @@ void SimulationSetupWidget::onRunSimulation() m_applicationModels->jobModel()->runJob(jobItem->index()); } -void SimulationSetupWidget::onExportToPythonScript() -{ +void SimulationSetupWidget::onExportToPythonScript() { const MultiLayerItem* multiLayerItem = m_simDataSelectorWidget->selectedMultiLayerItem(); const auto instrumentItem = m_simDataSelectorWidget->selectedInstrumentItem(); @@ -100,8 +95,7 @@ void SimulationSetupWidget::onExportToPythonScript() AppSvc::projectManager()->projectDir()); } -QWidget* SimulationSetupWidget::createButtonWidget() -{ +QWidget* SimulationSetupWidget::createButtonWidget() { QWidget* result = new QWidget; QHBoxLayout* simButtonLayout = new QHBoxLayout; diff --git a/GUI/coregui/Views/SimulationWidgets/SimulationSetupWidget.h b/GUI/coregui/Views/SimulationWidgets/SimulationSetupWidget.h index bbd0601398bedcc444058908fab4303042a0950e..5ab36fde8d75a802799d3c528976e8dcbe814205 100644 --- a/GUI/coregui/Views/SimulationWidgets/SimulationSetupWidget.h +++ b/GUI/coregui/Views/SimulationWidgets/SimulationSetupWidget.h @@ -26,8 +26,7 @@ class ApplicationModels; //! The SimulationSetupWidget class represents a main widget to define simulation settings //! and run the simulation. Belongs to the SimulationView. -class SimulationSetupWidget : public QWidget -{ +class SimulationSetupWidget : public QWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/SpecularDataWidgets/Plot1DCanvas.cpp b/GUI/coregui/Views/SpecularDataWidgets/Plot1DCanvas.cpp index e0e34226b4c93ebe0621b4f1ca514abb31aa9abd..daa2cddff42f540136d7693134f67d0abc0c6229 100644 --- a/GUI/coregui/Views/SpecularDataWidgets/Plot1DCanvas.cpp +++ b/GUI/coregui/Views/SpecularDataWidgets/Plot1DCanvas.cpp @@ -22,8 +22,7 @@ Plot1DCanvas::Plot1DCanvas(QWidget* parent) : SessionItemWidget(parent) , m_plot(new Plot1D) , m_canvasEvent(new FontScalingEvent(m_plot, this)) - , m_statusLabel(new PlotStatusLabel(m_plot, this)) -{ + , m_statusLabel(new PlotStatusLabel(m_plot, this)) { this->installEventFilter(m_canvasEvent); QVBoxLayout* layout = new QVBoxLayout; layout->setMargin(0); @@ -37,29 +36,24 @@ Plot1DCanvas::Plot1DCanvas(QWidget* parent) setStatusLabelEnabled(false); } -void Plot1DCanvas::setItem(SessionItem* dataItemView) -{ +void Plot1DCanvas::setItem(SessionItem* dataItemView) { SessionItemWidget::setItem(dataItemView); m_plot->setItem(dataItemView); } -Plot1D* Plot1DCanvas::plot1D() -{ +Plot1D* Plot1DCanvas::plot1D() { return m_plot; } -QCustomPlot* Plot1DCanvas::customPlot() -{ +QCustomPlot* Plot1DCanvas::customPlot() { return m_plot->customPlot(); } -void Plot1DCanvas::setStatusLabelEnabled(bool flag) -{ +void Plot1DCanvas::setStatusLabelEnabled(bool flag) { m_statusLabel->setLabelEnabled(flag); m_statusLabel->setHidden(!flag); } -void Plot1DCanvas::onStatusString(const QString& name) -{ +void Plot1DCanvas::onStatusString(const QString& name) { m_statusLabel->setText(name); } diff --git a/GUI/coregui/Views/SpecularDataWidgets/Plot1DCanvas.h b/GUI/coregui/Views/SpecularDataWidgets/Plot1DCanvas.h index edde0eca490448d25a69e01a804eb5e8af00a153..a01f3fa30a23462483ba688c6b98e1211ac6af88 100644 --- a/GUI/coregui/Views/SpecularDataWidgets/Plot1DCanvas.h +++ b/GUI/coregui/Views/SpecularDataWidgets/Plot1DCanvas.h @@ -26,8 +26,7 @@ class Plot1D; //! for specular data presentation, and provides //! status string appearance. -class Plot1DCanvas : public SessionItemWidget -{ +class Plot1DCanvas : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.cpp b/GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.cpp index ab4efeb54166278f1fafb44d6d0f4ac6b9ba43c1..afb34d5740bb136628e9da8fd7c40ebfd82db1a6 100644 --- a/GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.cpp +++ b/GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.cpp @@ -43,56 +43,47 @@ SpecularDataCanvas::SpecularDataCanvas(QWidget* parent) &SpecularDataCanvas::onMousePress, Qt::UniqueConnection); } -void SpecularDataCanvas::setItem(SessionItem* intensityItem) -{ +void SpecularDataCanvas::setItem(SessionItem* intensityItem) { SessionItemWidget::setItem(intensityItem); m_plot_canvas->setItem(intensityItem); } -QSize SpecularDataCanvas::sizeHint() const -{ +QSize SpecularDataCanvas::sizeHint() const { return QSize(500, 400); } -QSize SpecularDataCanvas::minimumSizeHint() const -{ +QSize SpecularDataCanvas::minimumSizeHint() const { return QSize(128, 128); } -QList<QAction*> SpecularDataCanvas::actionList() -{ +QList<QAction*> SpecularDataCanvas::actionList() { return QList<QAction*>() << m_reset_view_action << m_save_plot_action; } -void SpecularDataCanvas::onResetViewAction() -{ +void SpecularDataCanvas::onResetViewAction() { specularDataItem()->resetView(); } -void SpecularDataCanvas::onSavePlotAction() -{ +void SpecularDataCanvas::onSavePlotAction() { QString dirname = AppSvc::projectManager()->userExportDir(); SavePlotAssistant saveAssistant; saveAssistant.savePlot(dirname, m_plot_canvas->customPlot(), specularDataItem()->getOutputData()); } -void SpecularDataCanvas::onMousePress(QMouseEvent* event) -{ +void SpecularDataCanvas::onMousePress(QMouseEvent* event) { if (event->button() == Qt::RightButton) emit customContextMenuRequested(event->globalPos()); } -SpecularDataItem* SpecularDataCanvas::specularDataItem() -{ +SpecularDataItem* SpecularDataCanvas::specularDataItem() { SpecularDataItem* result = dynamic_cast<SpecularDataItem*>(currentItem()); ASSERT(result); return result; } // TODO: try to reuse IntensityDataCanvas::initActions somehow -void SpecularDataCanvas::initActions() -{ +void SpecularDataCanvas::initActions() { m_reset_view_action = new QAction(this); m_reset_view_action->setText("Center view"); m_reset_view_action->setIcon(QIcon(":/images/camera-metering-center.svg")); diff --git a/GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.h b/GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.h index 62f1f9f7577bfac79ae1d3ee03567fbe469c4dd0..93a2af94170bb64639362f1029f2dd9b8a43a1b6 100644 --- a/GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.h +++ b/GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.h @@ -21,8 +21,7 @@ class SpecularDataItem; class SpecularPlotCanvas; -class SpecularDataCanvas : public SessionItemWidget -{ +class SpecularDataCanvas : public SessionItemWidget { Q_OBJECT public: explicit SpecularDataCanvas(QWidget* parent = nullptr); diff --git a/GUI/coregui/Views/SpecularDataWidgets/SpecularDataWidget.cpp b/GUI/coregui/Views/SpecularDataWidgets/SpecularDataWidget.cpp index bf7c36e52502632560ce20765ee380aaa10ac5eb..6ea63125c4878c4a708d51d8a895e50012ec2330 100644 --- a/GUI/coregui/Views/SpecularDataWidgets/SpecularDataWidget.cpp +++ b/GUI/coregui/Views/SpecularDataWidgets/SpecularDataWidget.cpp @@ -25,8 +25,7 @@ SpecularDataWidget::SpecularDataWidget(QWidget* parent) : SessionItemWidget(parent) , m_intensity_canvas(new SpecularDataCanvas) - , m_property_widget(new IntensityDataPropertyWidget) -{ + , m_property_widget(new IntensityDataPropertyWidget) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); auto hlayout = new QHBoxLayout; @@ -48,27 +47,23 @@ SpecularDataWidget::SpecularDataWidget(QWidget* parent) m_property_widget->setVisible(false); } -void SpecularDataWidget::setItem(SessionItem* jobItem) -{ +void SpecularDataWidget::setItem(SessionItem* jobItem) { SessionItemWidget::setItem(jobItem); m_intensity_canvas->setItem(specularDataItem()); m_property_widget->setItem(specularDataItem()); } -QList<QAction*> SpecularDataWidget::actionList() -{ +QList<QAction*> SpecularDataWidget::actionList() { return m_intensity_canvas->actionList() + m_property_widget->actionList(); } -void SpecularDataWidget::onContextMenuRequest(const QPoint& point) -{ +void SpecularDataWidget::onContextMenuRequest(const QPoint& point) { QMenu menu; for (auto action : actionList()) menu.addAction(action); menu.exec(point); } -SpecularDataItem* SpecularDataWidget::specularDataItem() -{ +SpecularDataItem* SpecularDataWidget::specularDataItem() { return DataItemUtils::specularDataItem(currentItem()); } diff --git a/GUI/coregui/Views/SpecularDataWidgets/SpecularDataWidget.h b/GUI/coregui/Views/SpecularDataWidgets/SpecularDataWidget.h index 672c5db405aaebec0718fbd9ce38868762a5ca16..f2551d0ffccc1d50275387b98bc7159818cfd1c9 100644 --- a/GUI/coregui/Views/SpecularDataWidgets/SpecularDataWidget.h +++ b/GUI/coregui/Views/SpecularDataWidgets/SpecularDataWidget.h @@ -21,8 +21,7 @@ class SpecularDataCanvas; class SpecularDataItem; class IntensityDataPropertyWidget; -class SpecularDataWidget : public SessionItemWidget -{ +class SpecularDataWidget : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/SpecularDataWidgets/SpecularPlot.cpp b/GUI/coregui/Views/SpecularDataWidgets/SpecularPlot.cpp index 64f6a4d1dd5a38f18bec925e3a68b8865c32a23f..daf17e4fcfe8ca03a180c9d60436ba231294b3a7 100644 --- a/GUI/coregui/Views/SpecularDataWidgets/SpecularPlot.cpp +++ b/GUI/coregui/Views/SpecularDataWidgets/SpecularPlot.cpp @@ -21,8 +21,7 @@ #include "GUI/coregui/Views/IntensityDataWidgets/ColorMapUtils.h" #include "GUI/coregui/Views/IntensityDataWidgets/PlotEventInfo.h" -namespace -{ +namespace { const int replot_update_interval = 10; int bin(double x, const QCPGraph* graph); @@ -32,8 +31,7 @@ SpecularPlot::SpecularPlot(QWidget* parent) : ScientificPlot(parent, PLOT_TYPE::Plot1D) , m_custom_plot(new QCustomPlot) , m_update_timer(new UpdateTimer(replot_update_interval, this)) - , m_block_update(true) -{ + , m_block_update(true) { initPlot(); QVBoxLayout* vlayout = new QVBoxLayout(this); @@ -45,8 +43,7 @@ SpecularPlot::SpecularPlot(QWidget* parent) setMouseTrackingEnabled(true); } -PlotEventInfo SpecularPlot::eventInfo(double xpos, double ypos) const -{ +PlotEventInfo SpecularPlot::eventInfo(double xpos, double ypos) const { PlotEventInfo result(plotType()); if (!specularItem()) return result; @@ -60,19 +57,16 @@ PlotEventInfo SpecularPlot::eventInfo(double xpos, double ypos) const return result; } -void SpecularPlot::setLog(bool log) -{ +void SpecularPlot::setLog(bool log) { ColorMapUtils::setLogz(m_custom_plot->yAxis, log); ColorMapUtils::setLogz(m_custom_plot->yAxis2, log); } -void SpecularPlot::resetView() -{ +void SpecularPlot::resetView() { specularItem()->resetView(); } -void SpecularPlot::onPropertyChanged(const QString& property_name) -{ +void SpecularPlot::onPropertyChanged(const QString& property_name) { if (m_block_update) return; @@ -82,29 +76,25 @@ void SpecularPlot::onPropertyChanged(const QString& property_name) } } -void SpecularPlot::onXaxisRangeChanged(QCPRange newRange) -{ +void SpecularPlot::onXaxisRangeChanged(QCPRange newRange) { m_block_update = true; specularItem()->setLowerX(newRange.lower); specularItem()->setUpperX(newRange.upper); m_block_update = false; } -void SpecularPlot::onYaxisRangeChanged(QCPRange newRange) -{ +void SpecularPlot::onYaxisRangeChanged(QCPRange newRange) { m_block_update = true; specularItem()->setLowerY(newRange.lower); specularItem()->setUpperY(newRange.upper); m_block_update = false; } -void SpecularPlot::onTimeToReplot() -{ +void SpecularPlot::onTimeToReplot() { m_custom_plot->replot(); } -void SpecularPlot::subscribeToItem() -{ +void SpecularPlot::subscribeToItem() { setPlotFromItem(specularItem()); specularItem()->mapper()->setOnPropertyChange( @@ -123,13 +113,11 @@ void SpecularPlot::subscribeToItem() setConnected(true); } -void SpecularPlot::unsubscribeFromItem() -{ +void SpecularPlot::unsubscribeFromItem() { setConnected(false); } -void SpecularPlot::initPlot() -{ +void SpecularPlot::initPlot() { m_custom_plot->addGraph(); QPen pen(QColor(0, 0, 255, 200)); @@ -142,14 +130,12 @@ void SpecularPlot::initPlot() QFont(QFont().family(), Constants::plot_tick_label_size())); } -void SpecularPlot::setConnected(bool isConnected) -{ +void SpecularPlot::setConnected(bool isConnected) { setAxesRangeConnected(isConnected); setUpdateTimerConnected(isConnected); } -void SpecularPlot::setAxesRangeConnected(bool isConnected) -{ +void SpecularPlot::setAxesRangeConnected(bool isConnected) { if (isConnected) { connect(m_custom_plot->xAxis, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, @@ -170,8 +156,7 @@ void SpecularPlot::setAxesRangeConnected(bool isConnected) } } -void SpecularPlot::setUpdateTimerConnected(bool isConnected) -{ +void SpecularPlot::setUpdateTimerConnected(bool isConnected) { if (isConnected) connect(m_update_timer, &UpdateTimer::timeToUpdate, this, &SpecularPlot::onTimeToReplot, Qt::UniqueConnection); @@ -179,8 +164,7 @@ void SpecularPlot::setUpdateTimerConnected(bool isConnected) disconnect(m_update_timer, &UpdateTimer::timeToUpdate, this, &SpecularPlot::onTimeToReplot); } -void SpecularPlot::setPlotFromItem(SpecularDataItem* specularItem) -{ +void SpecularPlot::setPlotFromItem(SpecularDataItem* specularItem) { ASSERT(specularItem); m_block_update = true; @@ -195,8 +179,7 @@ void SpecularPlot::setPlotFromItem(SpecularDataItem* specularItem) m_block_update = false; } -void SpecularPlot::setAxesRangeFromItem(SpecularDataItem* item) -{ +void SpecularPlot::setAxesRangeFromItem(SpecularDataItem* item) { m_custom_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); m_custom_plot->axisRect()->setupFullAxesBox(true); @@ -207,14 +190,12 @@ void SpecularPlot::setAxesRangeFromItem(SpecularDataItem* item) setAxesRangeConnected(true); } -void SpecularPlot::setAxesLabelsFromItem(SpecularDataItem* item) -{ +void SpecularPlot::setAxesLabelsFromItem(SpecularDataItem* item) { setLabel(item->xAxisItem(), m_custom_plot->xAxis, item->getXaxisTitle()); setLabel(item->yAxisItem(), m_custom_plot->yAxis, item->getYaxisTitle()); } -void SpecularPlot::setLabel(const BasicAxisItem* item, QCPAxis* axis, QString label) -{ +void SpecularPlot::setLabel(const BasicAxisItem* item, QCPAxis* axis, QString label) { ASSERT(item && axis); if (item->getItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE).toBool()) axis->setLabel(std::move(label)); @@ -222,8 +203,7 @@ void SpecularPlot::setLabel(const BasicAxisItem* item, QCPAxis* axis, QString la axis->setLabel(QString()); } -void SpecularPlot::setDataFromItem(SpecularDataItem* item) -{ +void SpecularPlot::setDataFromItem(SpecularDataItem* item) { ASSERT(item); auto data = item->getOutputData(); if (!data) @@ -236,19 +216,16 @@ void SpecularPlot::setDataFromItem(SpecularDataItem* item) } } -SpecularDataItem* SpecularPlot::specularItem() -{ +SpecularDataItem* SpecularPlot::specularItem() { return const_cast<SpecularDataItem*>(static_cast<const SpecularPlot*>(this)->specularItem()); } -const SpecularDataItem* SpecularPlot::specularItem() const -{ +const SpecularDataItem* SpecularPlot::specularItem() const { const auto result = dynamic_cast<const SpecularDataItem*>(currentItem()); return result; } -void SpecularPlot::modifyAxesProperties(const QString& axisName, const QString& propertyName) -{ +void SpecularPlot::modifyAxesProperties(const QString& axisName, const QString& propertyName) { if (m_block_update) return; @@ -280,15 +257,12 @@ void SpecularPlot::modifyAxesProperties(const QString& axisName, const QString& } } -void SpecularPlot::replot() -{ +void SpecularPlot::replot() { m_update_timer->scheduleUpdate(); } -namespace -{ -int bin(double x, const QCPGraph* graph) -{ +namespace { +int bin(double x, const QCPGraph* graph) { const int key_start = graph->findBegin(x); const int key_end = graph->findBegin(x, false); // false = do not expand range if (key_end == key_start || key_end == graph->dataCount()) diff --git a/GUI/coregui/Views/SpecularDataWidgets/SpecularPlot.h b/GUI/coregui/Views/SpecularDataWidgets/SpecularPlot.h index 0880e9906e8b874fc112afd55e7b7a43e9e6c7bc..d92fede3c2bedef5ea1f84d1953862e702324ed2 100644 --- a/GUI/coregui/Views/SpecularDataWidgets/SpecularPlot.h +++ b/GUI/coregui/Views/SpecularDataWidgets/SpecularPlot.h @@ -29,8 +29,7 @@ class UpdateTimer; //! Provides minimal functionality for data plotting and axes interaction. Should be a component //! for more complicated plotting widgets. Corresponds to ColorMap for 2D intensity data. -class SpecularPlot : public ScientificPlot -{ +class SpecularPlot : public ScientificPlot { Q_OBJECT public: diff --git a/GUI/coregui/Views/SpecularDataWidgets/SpecularPlotCanvas.cpp b/GUI/coregui/Views/SpecularDataWidgets/SpecularPlotCanvas.cpp index c78e651231e585deab841887150f54159028cdb2..70e00cbc8bba139eebb6ca326c262100c8895fdd 100644 --- a/GUI/coregui/Views/SpecularDataWidgets/SpecularPlotCanvas.cpp +++ b/GUI/coregui/Views/SpecularDataWidgets/SpecularPlotCanvas.cpp @@ -23,8 +23,7 @@ SpecularPlotCanvas::SpecularPlotCanvas(QWidget* parent) : SessionItemWidget(parent) , m_plot(new SpecularPlot) , m_canvasEvent(new FontScalingEvent(m_plot, this)) - , m_statusLabel(new PlotStatusLabel(m_plot, this)) -{ + , m_statusLabel(new PlotStatusLabel(m_plot, this)) { this->installEventFilter(m_canvasEvent); QVBoxLayout* layout = new QVBoxLayout; layout->setMargin(0); @@ -38,29 +37,24 @@ SpecularPlotCanvas::SpecularPlotCanvas(QWidget* parent) setStatusLabelEnabled(false); } -void SpecularPlotCanvas::setItem(SessionItem* specularDataItem) -{ +void SpecularPlotCanvas::setItem(SessionItem* specularDataItem) { SessionItemWidget::setItem(specularDataItem); m_plot->setItem(dynamic_cast<SpecularDataItem*>(specularDataItem)); } -SpecularPlot* SpecularPlotCanvas::specularPlot() -{ +SpecularPlot* SpecularPlotCanvas::specularPlot() { return m_plot; } -QCustomPlot* SpecularPlotCanvas::customPlot() -{ +QCustomPlot* SpecularPlotCanvas::customPlot() { return m_plot->customPlot(); } -void SpecularPlotCanvas::setStatusLabelEnabled(bool flag) -{ +void SpecularPlotCanvas::setStatusLabelEnabled(bool flag) { m_statusLabel->setLabelEnabled(flag); m_statusLabel->setHidden(!flag); } -void SpecularPlotCanvas::onStatusString(const QString& name) -{ +void SpecularPlotCanvas::onStatusString(const QString& name) { m_statusLabel->setText(name); } diff --git a/GUI/coregui/Views/SpecularDataWidgets/SpecularPlotCanvas.h b/GUI/coregui/Views/SpecularDataWidgets/SpecularPlotCanvas.h index 874caed238d858c3edf9e8816096b26f9ac948ce..0bd9375673b7a3938e3e45fef88033bfcb5020ae 100644 --- a/GUI/coregui/Views/SpecularDataWidgets/SpecularPlotCanvas.h +++ b/GUI/coregui/Views/SpecularDataWidgets/SpecularPlotCanvas.h @@ -25,8 +25,7 @@ class SpecularPlot; //! The SpecularPlotCanvas class contains SpecularPlot for specular data presentation, and provides //! status string appearance. -class SpecularPlotCanvas : public SessionItemWidget -{ +class SpecularPlotCanvas : public SessionItemWidget { Q_OBJECT public: diff --git a/GUI/coregui/Views/TestView.cpp b/GUI/coregui/Views/TestView.cpp index 80ce5deab800adbd43d78edf8b6079ff453ad4c7..4e0cef27357881d92a3a2c2dcb45d267d3aaa71a 100644 --- a/GUI/coregui/Views/TestView.cpp +++ b/GUI/coregui/Views/TestView.cpp @@ -35,8 +35,7 @@ #include <QCheckBox> #include <QLineEdit> -namespace -{ +namespace { // These functions are required for testing purposes only // They must be removed after completion of // SpecularDataWidget @@ -44,8 +43,7 @@ double getTestValue(size_t bin, double factor); SpecularDataItem* fillTestItem(SessionItem* item, double factor); } // namespace -TestView::TestView(MainWindow* mainWindow) : QWidget(mainWindow), m_mainWindow(mainWindow) -{ +TestView::TestView(MainWindow* mainWindow) : QWidget(mainWindow), m_mainWindow(mainWindow) { // test_ComponentProxyModel(); // test_MaterialEditor(); // test_MinimizerSettings(); @@ -55,8 +53,7 @@ TestView::TestView(MainWindow* mainWindow) : QWidget(mainWindow), m_mainWindow(m // test_specular_data_widget(); } -void TestView::test_ComponentProxyModel() -{ +void TestView::test_ComponentProxyModel() { auto layout = new QHBoxLayout(); layout->setMargin(0); layout->setSpacing(0); @@ -66,8 +63,7 @@ void TestView::test_ComponentProxyModel() setLayout(layout); } -void TestView::test_MaterialEditor() -{ +void TestView::test_MaterialEditor() { MaterialEditor* materialEditor = new MaterialEditor(m_mainWindow->materialModel()); QVBoxLayout* layout = new QVBoxLayout; layout->setMargin(0); @@ -76,8 +72,7 @@ void TestView::test_MaterialEditor() setLayout(layout); } -void TestView::test_MinimizerSettings() -{ +void TestView::test_MinimizerSettings() { MinimizerSettingsWidget* widget = new MinimizerSettingsWidget; QVBoxLayout* layout = new QVBoxLayout; layout->setMargin(0); @@ -91,8 +86,7 @@ void TestView::test_MinimizerSettings() widget->setItem(minimizerItem); } -void TestView::test_AccordionWidget() -{ +void TestView::test_AccordionWidget() { AccordionWidget* myAccordion = new AccordionWidget(); myAccordion->setMultiActive(true); // add the Accordion to your layout @@ -164,8 +158,7 @@ void TestView::test_AccordionWidget() } } -void TestView::test_ba3d() -{ +void TestView::test_ba3d() { // After putting this 3D view in Sample Viewer with the necessary changes, it does not work // in test view and needs to be refactored in order to be used. @@ -177,8 +170,7 @@ void TestView::test_ba3d() setLayout(layout); } -void TestView::test_specular_data_widget() -{ +void TestView::test_specular_data_widget() { SessionModel* tempModel = new SessionModel("Test", this); // creating job item @@ -213,17 +205,14 @@ void TestView::test_specular_data_widget() setLayout(layout); } -namespace -{ -double getTestValue(size_t bin, double factor) -{ +namespace { +double getTestValue(size_t bin, double factor) { const double angle_factor = M_PI / (180.0 * 100.0); const double angle = bin * angle_factor; return (std::cos(angle * 1000.0) + 1.5) * std::exp(-(bin * factor / 100.0)); } -SpecularDataItem* fillTestItem(SessionItem* item, double factor) -{ +SpecularDataItem* fillTestItem(SessionItem* item, double factor) { SpecularDataItem* result = dynamic_cast<SpecularDataItem*>(item); ASSERT(result); auto outputData = std::make_unique<OutputData<double>>(); diff --git a/GUI/coregui/Views/TestView.h b/GUI/coregui/Views/TestView.h index e4f4a2b5b2c059c7a4198e8f4823a1bd56228a97..03a59a5e23c0175f7871d039c4a7f9607838ef9e 100644 --- a/GUI/coregui/Views/TestView.h +++ b/GUI/coregui/Views/TestView.h @@ -19,8 +19,7 @@ class MainWindow; -class TestView : public QWidget -{ +class TestView : public QWidget { Q_OBJECT public: TestView(MainWindow* mainWindow = nullptr); diff --git a/GUI/coregui/Views/WelcomeView.cpp b/GUI/coregui/Views/WelcomeView.cpp index 8eb1e165b20b36b8eb35e192130bac2dcd8a545e..6522bf1f18b432af11eea95dc63adc0dd0dac31d 100644 --- a/GUI/coregui/Views/WelcomeView.cpp +++ b/GUI/coregui/Views/WelcomeView.cpp @@ -28,8 +28,7 @@ #include <QUrl> #include <QVBoxLayout> -namespace -{ +namespace { const int buttonHeight = 45; const int buttonWidth = 140; @@ -45,8 +44,7 @@ WelcomeView::WelcomeView(MainWindow* parent) , m_newUsertButton(nullptr) , m_currentProjectLabel(nullptr) , m_recentProjectLayout(nullptr) - , m_notifierWidget(new UpdateNotifierWidget(parent->updateNotifier())) -{ + , m_notifierWidget(new UpdateNotifierWidget(parent->updateNotifier())) { QPalette palette; palette.setColor(QPalette::Window, QColor(240, 240, 240, 255)); setAutoFillBackground(true); @@ -83,8 +81,7 @@ WelcomeView::WelcomeView(MainWindow* parent) updateRecentProjectPanel(); } -void WelcomeView::generateRecentProjectList() -{ +void WelcomeView::generateRecentProjectList() { auto recentProLabel = new QLabel("Recent Projects:"); recentProLabel->setFont(StyleUtils::sectionFont()); @@ -107,8 +104,7 @@ void WelcomeView::generateRecentProjectList() } //! returns current project name suited for displaying on current project layout -QString WelcomeView::currentProjectFancyName() -{ +QString WelcomeView::currentProjectFancyName() { QString result("Untitled"); if (auto projectDocument = projectManager()->document()) { if (projectDocument->hasValidNameAndPath()) @@ -120,40 +116,33 @@ QString WelcomeView::currentProjectFancyName() } //! updates label with current project name in picturesque manner -void WelcomeView::setCurrentProjectName(const QString& name) -{ +void WelcomeView::setCurrentProjectName(const QString& name) { m_currentProjectLabel->setTextAnimated(name); } -ProjectManager* WelcomeView::projectManager() -{ +ProjectManager* WelcomeView::projectManager() { return m_mainWindow->projectManager(); } -void WelcomeView::onWebLinkClicked(const QUrl& url) -{ +void WelcomeView::onWebLinkClicked(const QUrl& url) { QDesktopServices::openUrl(url); } -void WelcomeView::onNewUser() -{ +void WelcomeView::onNewUser() { QDesktopServices::openUrl(QUrl("http://www.bornagainproject.org")); } -void WelcomeView::updateRecentProjectPanel() -{ +void WelcomeView::updateRecentProjectPanel() { LayoutUtils::clearLayout(m_recentProjectLayout); generateRecentProjectList(); update(); } -void WelcomeView::showEvent(QShowEvent*) -{ +void WelcomeView::showEvent(QShowEvent*) { updateRecentProjectPanel(); } -QWidget* WelcomeView::createProjectWidget() -{ +QWidget* WelcomeView::createProjectWidget() { auto layout = new QHBoxLayout; layout->addLayout(createButtonLayout()); layout->addWidget(createSeparationFrame()); @@ -167,8 +156,7 @@ QWidget* WelcomeView::createProjectWidget() return result; } -QBoxLayout* WelcomeView::createButtonLayout() -{ +QBoxLayout* WelcomeView::createButtonLayout() { m_newProjectButton = new QPushButton("New Project"); m_newProjectButton->setMinimumWidth(buttonWidth); m_newProjectButton->setMinimumHeight(buttonHeight); @@ -198,8 +186,7 @@ QBoxLayout* WelcomeView::createButtonLayout() return result; } -QBoxLayout* WelcomeView::createCurrentProjectLayout() -{ +QBoxLayout* WelcomeView::createCurrentProjectLayout() { auto result = new QVBoxLayout; result->setContentsMargins(30, 0, 0, 0); @@ -213,15 +200,13 @@ QBoxLayout* WelcomeView::createCurrentProjectLayout() return result; } -QBoxLayout* WelcomeView::createRecentProjectLayout() -{ +QBoxLayout* WelcomeView::createRecentProjectLayout() { m_recentProjectLayout = new QVBoxLayout; m_recentProjectLayout->setContentsMargins(30, 0, 0, 0); return m_recentProjectLayout; } -QBoxLayout* WelcomeView::createProjectLayout() -{ +QBoxLayout* WelcomeView::createProjectLayout() { auto result = new QVBoxLayout; result->addLayout(createCurrentProjectLayout()); result->addSpacing(15); @@ -229,8 +214,7 @@ QBoxLayout* WelcomeView::createProjectLayout() return result; } -QFrame* WelcomeView::createSeparationFrame() -{ +QFrame* WelcomeView::createSeparationFrame() { auto result = new QFrame; result->setFrameShape(QFrame::VLine); result->setFrameShadow(QFrame::Sunken); diff --git a/GUI/coregui/Views/WelcomeView.h b/GUI/coregui/Views/WelcomeView.h index 502ff09e40451a97da501a2970f0b895b17eff90..d776e4e7627a349171d02d51830b6966a260cc57 100644 --- a/GUI/coregui/Views/WelcomeView.h +++ b/GUI/coregui/Views/WelcomeView.h @@ -27,8 +27,7 @@ class UpdateNotifierWidget; class QLabel; class QFrame; -class WelcomeView : public QWidget -{ +class WelcomeView : public QWidget { Q_OBJECT public: WelcomeView(MainWindow* parent); diff --git a/GUI/coregui/Views/widgetbox/deviceprofile_p.h b/GUI/coregui/Views/widgetbox/deviceprofile_p.h index 46500b34fe0f591f62f4a8e6872caf4fe37fb21a..94129fb11d5ff8e0782b33596e2755429558efb7 100644 --- a/GUI/coregui/Views/widgetbox/deviceprofile_p.h +++ b/GUI/coregui/Views/widgetbox/deviceprofile_p.h @@ -64,8 +64,7 @@ class QDesignerFormEditorInterface; class QWidget; class QStyle; -namespace qdesigner_internal -{ +namespace qdesigner_internal { class DeviceProfileData; @@ -74,8 +73,7 @@ class DeviceProfileData; * style of the form. This class represents a device * profile. */ -class QDESIGNER_SHARED_EXPORT DeviceProfile -{ +class QDESIGNER_SHARED_EXPORT DeviceProfile { public: DeviceProfile(); @@ -141,12 +139,10 @@ private: QSharedDataPointer<DeviceProfileData> m_d; }; -inline bool operator==(const DeviceProfile& s1, const DeviceProfile& s2) -{ +inline bool operator==(const DeviceProfile& s1, const DeviceProfile& s2) { return s1.equals(s2); } -inline bool operator!=(const DeviceProfile& s1, const DeviceProfile& s2) -{ +inline bool operator!=(const DeviceProfile& s1, const DeviceProfile& s2) { return !s1.equals(s2); } diff --git a/GUI/coregui/Views/widgetbox/formwindowbase_p.h b/GUI/coregui/Views/widgetbox/formwindowbase_p.h index ba7e283ceaeac5160f1718c7590973ad4542d8f4..a7f909a97e573af45f1252662de5e535ab6213b8 100644 --- a/GUI/coregui/Views/widgetbox/formwindowbase_p.h +++ b/GUI/coregui/Views/widgetbox/formwindowbase_p.h @@ -69,8 +69,7 @@ class QMenu; class QtResourceSet; class QDesignerPropertySheet; -namespace qdesigner_internal -{ +namespace qdesigner_internal { class QEditorFormBuilder; class DeviceProfile; @@ -80,8 +79,7 @@ class DesignerPixmapCache; class DesignerIconCache; class FormWindowBasePrivate; -class QDESIGNER_SHARED_EXPORT FormWindowBase : public QDesignerFormWindowInterface -{ +class QDESIGNER_SHARED_EXPORT FormWindowBase : public QDesignerFormWindowInterface { Q_OBJECT public: enum HighlightMode { Restore, Highlight }; diff --git a/GUI/coregui/Views/widgetbox/qdesigner_dnditem_p.h b/GUI/coregui/Views/widgetbox/qdesigner_dnditem_p.h index dfbdcc3fa70682b7a2475e3aaa0ecca3b16ee08d..0db1bc775b49c15c344884b7db4a4c2b75e021bb 100644 --- a/GUI/coregui/Views/widgetbox/qdesigner_dnditem_p.h +++ b/GUI/coregui/Views/widgetbox/qdesigner_dnditem_p.h @@ -66,11 +66,9 @@ class QDrag; class QImage; class QDropEvent; -namespace qdesigner_internal -{ +namespace qdesigner_internal { -class QDESIGNER_SHARED_EXPORT QDesignerDnDItem : public QDesignerDnDItemInterface -{ +class QDESIGNER_SHARED_EXPORT QDesignerDnDItem : public QDesignerDnDItemInterface { public: explicit QDesignerDnDItem(DropType type, QWidget* source = 0); virtual ~QDesignerDnDItem(); @@ -101,8 +99,7 @@ private: // Mime data for use with designer drag and drop operations. -class QDESIGNER_SHARED_EXPORT QDesignerMimeData : public QMimeData -{ +class QDESIGNER_SHARED_EXPORT QDesignerMimeData : public QMimeData { Q_OBJECT public: diff --git a/GUI/coregui/Views/widgetbox/qdesigner_formbuilder_p.h b/GUI/coregui/Views/widgetbox/qdesigner_formbuilder_p.h index 082c590f0aece2320e1e9b2532b2676655e46385..6d8e1af5f1625405d7cb3ba612446e3162edecff 100644 --- a/GUI/coregui/Views/widgetbox/qdesigner_formbuilder_p.h +++ b/GUI/coregui/Views/widgetbox/qdesigner_formbuilder_p.h @@ -68,8 +68,7 @@ class QDesignerFormWindowInterface; class QPixmap; class QtResourceSet; -namespace qdesigner_internal -{ +namespace qdesigner_internal { class DesignerPixmapCache; class DesignerIconCache; @@ -77,8 +76,7 @@ class DesignerIconCache; /* Form builder used for previewing forms and widget box. * It applies the system settings to its toplevel window. */ -class QDESIGNER_SHARED_EXPORT QDesignerFormBuilder : public QFormBuilder -{ +class QDESIGNER_SHARED_EXPORT QDesignerFormBuilder : public QFormBuilder { public: QDesignerFormBuilder(QDesignerFormEditorInterface* core, const DeviceProfile& deviceProfile = DeviceProfile()); @@ -88,8 +86,7 @@ public: QDesignerFormBuilder(QDesignerFormEditorInterface* core, Mode mode, const DeviceProfile& deviceProfile = DeviceProfile()); - virtual QWidget* createWidget(DomWidget* ui_widget, QWidget* parentWidget = 0) - { + virtual QWidget* createWidget(DomWidget* ui_widget, QWidget* parentWidget = 0) { return QFormBuilder::createItemPtr(ui_widget, parentWidget); } @@ -165,8 +162,7 @@ private: // widgets in the template, it implements the handling of custom widgets // (adding of them to the widget database). -class QDESIGNER_SHARED_EXPORT NewFormWidgetFormBuilder : public QDesignerFormBuilder -{ +class QDESIGNER_SHARED_EXPORT NewFormWidgetFormBuilder : public QDesignerFormBuilder { public: NewFormWidgetFormBuilder(QDesignerFormEditorInterface* core, const DeviceProfile& deviceProfile = DeviceProfile()); diff --git a/GUI/coregui/Views/widgetbox/qdesigner_utils_p.h b/GUI/coregui/Views/widgetbox/qdesigner_utils_p.h index df363c65efa1727ba92a9b438d33dd2fe1299dca..4ab5f62f3561c5cf5c699b5057363d143d01d0fa 100644 --- a/GUI/coregui/Views/widgetbox/qdesigner_utils_p.h +++ b/GUI/coregui/Views/widgetbox/qdesigner_utils_p.h @@ -68,8 +68,7 @@ QT_BEGIN_NAMESPACE class QDebug; -namespace qdesigner_internal -{ +namespace qdesigner_internal { class QDesignerFormWindowCommand; class DesignerIconCache; class FormWindowBase; @@ -89,8 +88,7 @@ QDESIGNER_SHARED_EXPORT void reloadIconResources(DesignerIconCache* iconCache, Q * in both ways. Template of int type since unsigned is more suitable for flags. * The keyToValue() is ignorant of scopes, it can handle fully qualified or unqualified names. */ -template <class IntType> class MetaEnum -{ +template <class IntType> class MetaEnum { public: typedef QMap<QString, IntType> KeyToValueMap; @@ -122,26 +120,21 @@ private: template <class IntType> MetaEnum<IntType>::MetaEnum(const QString& name, const QString& scope, const QString& separator) - : m_name(name), m_scope(scope), m_separator(separator) -{ -} + : m_name(name), m_scope(scope), m_separator(separator) {} -template <class IntType> void MetaEnum<IntType>::addKey(IntType value, const QString& name) -{ +template <class IntType> void MetaEnum<IntType>::addKey(IntType value, const QString& name) { m_keyToValueMap.insert(name, value); m_keys.append(name); } -template <class IntType> QString MetaEnum<IntType>::valueToKey(IntType value, bool* ok) const -{ +template <class IntType> QString MetaEnum<IntType>::valueToKey(IntType value, bool* ok) const { const QString rc = m_keyToValueMap.key(value); if (ok) *ok = !rc.isEmpty(); return rc; } -template <class IntType> IntType MetaEnum<IntType>::keyToValue(QString key, bool* ok) const -{ +template <class IntType> IntType MetaEnum<IntType>::keyToValue(QString key, bool* ok) const { if (!m_scope.isEmpty() && key.startsWith(m_scope)) key.remove(0, m_scope.size() + m_separator.size()); const typename KeyToValueMap::const_iterator it = m_keyToValueMap.find(key); @@ -152,8 +145,7 @@ template <class IntType> IntType MetaEnum<IntType>::keyToValue(QString key, bool } template <class IntType> -void MetaEnum<IntType>::appendQualifiedName(const QString& key, QString& target) const -{ +void MetaEnum<IntType>::appendQualifiedName(const QString& key, QString& target) const { if (!m_scope.isEmpty()) { target += m_scope; target += m_separator; @@ -163,8 +155,7 @@ void MetaEnum<IntType>::appendQualifiedName(const QString& key, QString& target) // -------------- DesignerMetaEnum: Meta type for enumerations -class QDESIGNER_SHARED_EXPORT DesignerMetaEnum : public MetaEnum<int> -{ +class QDESIGNER_SHARED_EXPORT DesignerMetaEnum : public MetaEnum<int> { public: DesignerMetaEnum(const QString& name, const QString& scope, const QString& separator); DesignerMetaEnum() {} @@ -183,8 +174,7 @@ public: // Note that while the handling of flags is done using unsigned integers, the actual values returned // by the property system are integers. -class QDESIGNER_SHARED_EXPORT DesignerMetaFlags : public MetaEnum<uint> -{ +class QDESIGNER_SHARED_EXPORT DesignerMetaFlags : public MetaEnum<uint> { public: DesignerMetaFlags(const QString& name, const QString& scope, const QString& separator); DesignerMetaFlags() {} @@ -219,8 +209,7 @@ struct QDESIGNER_SHARED_EXPORT PropertySheetFlagValue { }; // -------------- PixmapValue: Returned by the property sheet for pixmaps -class QDESIGNER_SHARED_EXPORT PropertySheetPixmapValue -{ +class QDESIGNER_SHARED_EXPORT PropertySheetPixmapValue { public: PropertySheetPixmapValue(const QString& path); PropertySheetPixmapValue(); @@ -233,8 +222,7 @@ public: enum PixmapSource { LanguageResourcePixmap, ResourcePixmap, FilePixmap }; static PixmapSource getPixmapSource(QDesignerFormEditorInterface* core, const QString& path); - PixmapSource pixmapSource(QDesignerFormEditorInterface* core) const - { + PixmapSource pixmapSource(QDesignerFormEditorInterface* core) const { return getPixmapSource(core, m_path); } @@ -251,8 +239,7 @@ private: class PropertySheetIconValueData; -class QDESIGNER_SHARED_EXPORT PropertySheetIconValue -{ +class QDESIGNER_SHARED_EXPORT PropertySheetIconValue { public: PropertySheetIconValue(const PropertySheetPixmapValue& pixmap); PropertySheetIconValue(); @@ -294,8 +281,7 @@ private: QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug, const PropertySheetIconValue&); -class QDESIGNER_SHARED_EXPORT DesignerPixmapCache : public QObject -{ +class QDESIGNER_SHARED_EXPORT DesignerPixmapCache : public QObject { Q_OBJECT public: DesignerPixmapCache(QObject* parent = 0); @@ -309,8 +295,7 @@ private: friend class FormWindowBase; }; -class QDESIGNER_SHARED_EXPORT DesignerIconCache : public QObject -{ +class QDESIGNER_SHARED_EXPORT DesignerIconCache : public QObject { Q_OBJECT public: explicit DesignerIconCache(DesignerPixmapCache* pixmapCache, QObject* parent = 0); @@ -326,8 +311,7 @@ private: }; // -------------- PropertySheetTranslatableData: Base class for translatable properties. -class QDESIGNER_SHARED_EXPORT PropertySheetTranslatableData -{ +class QDESIGNER_SHARED_EXPORT PropertySheetTranslatableData { protected: PropertySheetTranslatableData(bool translatable = true, const QString& disambiguation = "", const QString& comment = ""); @@ -348,8 +332,7 @@ private: }; // -------------- StringValue: Returned by the property sheet for strings -class QDESIGNER_SHARED_EXPORT PropertySheetStringValue : public PropertySheetTranslatableData -{ +class QDESIGNER_SHARED_EXPORT PropertySheetStringValue : public PropertySheetTranslatableData { public: PropertySheetStringValue(const QString& value = "", bool translatable = true, const QString& disambiguation = "", const QString& comment = ""); @@ -367,8 +350,7 @@ private: }; // -------------- StringValue: Returned by the property sheet for string lists -class QDESIGNER_SHARED_EXPORT PropertySheetStringListValue : public PropertySheetTranslatableData -{ +class QDESIGNER_SHARED_EXPORT PropertySheetStringListValue : public PropertySheetTranslatableData { public: PropertySheetStringListValue(const QStringList& value = {}, bool translatable = true, const QString& disambiguation = "", const QString& comment = ""); @@ -386,8 +368,7 @@ private: }; // -------------- StringValue: Returned by the property sheet for strings -class QDESIGNER_SHARED_EXPORT PropertySheetKeySequenceValue : public PropertySheetTranslatableData -{ +class QDESIGNER_SHARED_EXPORT PropertySheetKeySequenceValue : public PropertySheetTranslatableData { public: PropertySheetKeySequenceValue(const QKeySequence& value = {}, bool translatable = true, const QString& disambiguation = "", const QString& comment = ""); @@ -426,8 +407,7 @@ Q_DECLARE_METATYPE(qdesigner_internal::PropertySheetKeySequenceValue) QT_BEGIN_NAMESPACE -namespace qdesigner_internal -{ +namespace qdesigner_internal { // Create a command to change a text property (that is, create a reset property command if the text // is empty) @@ -449,8 +429,7 @@ QDESIGNER_SHARED_EXPORT QString qtify(const QString& name); * Does nothing if the incoming widget already has updatesEnabled==false * which is important to avoid side-effects when putting it into QStackedLayout. */ -class QDESIGNER_SHARED_EXPORT UpdateBlocker -{ +class QDESIGNER_SHARED_EXPORT UpdateBlocker { Q_DISABLE_COPY(UpdateBlocker) public: @@ -462,11 +441,9 @@ private: const bool m_enabled; }; -namespace Utils -{ +namespace Utils { -inline int valueOf(const QVariant& value, bool* ok = 0) -{ +inline int valueOf(const QVariant& value, bool* ok = 0) { if (value.canConvert<PropertySheetEnumValue>()) { if (ok) *ok = true; @@ -479,8 +456,7 @@ inline int valueOf(const QVariant& value, bool* ok = 0) return value.toInt(ok); } -inline bool isObjectAncestorOf(QObject* ancestor, QObject* child) -{ +inline bool isObjectAncestorOf(QObject* ancestor, QObject* child) { QObject* obj = child; while (obj != 0) { if (obj == ancestor) @@ -490,8 +466,7 @@ inline bool isObjectAncestorOf(QObject* ancestor, QObject* child) return false; } -inline bool isCentralWidget(QDesignerFormWindowInterface* fw, QWidget* widget) -{ +inline bool isCentralWidget(QDesignerFormWindowInterface* fw, QWidget* widget) { if (!fw || !widget) return false; diff --git a/GUI/coregui/Views/widgetbox/qdesigner_widgetbox_p.h b/GUI/coregui/Views/widgetbox/qdesigner_widgetbox_p.h index 79abc1e3250f8acb1ea6986e6d4fb65ceadaa33e..f19d8b5f1bb09ae69bb4633091fedc360dcdc6e9 100644 --- a/GUI/coregui/Views/widgetbox/qdesigner_widgetbox_p.h +++ b/GUI/coregui/Views/widgetbox/qdesigner_widgetbox_p.h @@ -62,13 +62,11 @@ QT_BEGIN_NAMESPACE class DomUI; -namespace qdesigner_internal -{ +namespace qdesigner_internal { // A widget box with a load mode that allows for updating custom widgets. -class QDESIGNER_SHARED_EXPORT QDesignerWidgetBox : public QDesignerWidgetBoxInterface -{ +class QDESIGNER_SHARED_EXPORT QDesignerWidgetBox : public QDesignerWidgetBoxInterface { Q_OBJECT public: enum LoadMode { LoadMerge, LoadReplace, LoadCustomWidgetsOnly }; diff --git a/GUI/coregui/Views/widgetbox/qsimpleresource_p.h b/GUI/coregui/Views/widgetbox/qsimpleresource_p.h index b5747f9cbca3b05a873c4b77240686cecdbe02d5..8b3a3da237df2d9f24cce1430d42f5662b2281d9 100644 --- a/GUI/coregui/Views/widgetbox/qsimpleresource_p.h +++ b/GUI/coregui/Views/widgetbox/qsimpleresource_p.h @@ -66,13 +66,11 @@ class DomSlots; class QDesignerFormEditorInterface; -namespace qdesigner_internal -{ +namespace qdesigner_internal { class WidgetDataBaseItem; -class QDESIGNER_SHARED_EXPORT QSimpleResource : public QAbstractFormBuilder -{ +class QDESIGNER_SHARED_EXPORT QSimpleResource : public QAbstractFormBuilder { public: explicit QSimpleResource(QDesignerFormEditorInterface* core); virtual ~QSimpleResource(); @@ -133,8 +131,7 @@ struct QDESIGNER_SHARED_EXPORT FormBuilderClipboard { // Base class for a form builder used in the editor that // provides copy and paste.(move into base interface) -class QDESIGNER_SHARED_EXPORT QEditorFormBuilder : public QSimpleResource -{ +class QDESIGNER_SHARED_EXPORT QEditorFormBuilder : public QSimpleResource { public: explicit QEditorFormBuilder(QDesignerFormEditorInterface* core) : QSimpleResource(core) {} diff --git a/GUI/coregui/Views/widgetbox/shared_enums_p.h b/GUI/coregui/Views/widgetbox/shared_enums_p.h index 93133d3423b2390ce827981f575956aab5638911..371ba593198efad4513a0e05b3ef671c9892f310 100644 --- a/GUI/coregui/Views/widgetbox/shared_enums_p.h +++ b/GUI/coregui/Views/widgetbox/shared_enums_p.h @@ -57,8 +57,7 @@ QT_BEGIN_NAMESPACE -namespace qdesigner_internal -{ +namespace qdesigner_internal { // Validation mode of text property line edits enum TextPropertyValidationMode { diff --git a/GUI/coregui/Views/widgetbox/sheet_delegate_p.h b/GUI/coregui/Views/widgetbox/sheet_delegate_p.h index 63db521107f243c9435e2ae2b1a08376caa29ff0..56b554aa48a5b4f99bba3828f559312a7360f3b8 100644 --- a/GUI/coregui/Views/widgetbox/sheet_delegate_p.h +++ b/GUI/coregui/Views/widgetbox/sheet_delegate_p.h @@ -62,11 +62,9 @@ QT_BEGIN_NAMESPACE class QTreeView; -namespace qdesigner_internal -{ +namespace qdesigner_internal { -class QDESIGNER_SHARED_EXPORT SheetDelegate : public QItemDelegate -{ +class QDESIGNER_SHARED_EXPORT SheetDelegate : public QItemDelegate { Q_OBJECT public: SheetDelegate(QTreeView* view, QWidget* parent); diff --git a/GUI/coregui/Views/widgetbox/spacer_widget_p.h b/GUI/coregui/Views/widgetbox/spacer_widget_p.h index 56391fbcdb9819fb7115198046e85857c52bdb0c..38dd411de3657516b347ce80d3135a2da954a2fa 100644 --- a/GUI/coregui/Views/widgetbox/spacer_widget_p.h +++ b/GUI/coregui/Views/widgetbox/spacer_widget_p.h @@ -62,8 +62,7 @@ QT_BEGIN_NAMESPACE class QDesignerFormWindowInterface; -class QDESIGNER_SHARED_EXPORT Spacer : public QWidget -{ +class QDESIGNER_SHARED_EXPORT Spacer : public QWidget { Q_OBJECT Q_ENUMS(SizeType) diff --git a/GUI/coregui/Views/widgetbox/ui4_p.h b/GUI/coregui/Views/widgetbox/ui4_p.h index da857ca9a995cd6f6ff54d2b47b729e6404af128..ff10b9a7498b127e697a7475e1de5f871142fa09 100644 --- a/GUI/coregui/Views/widgetbox/ui4_p.h +++ b/GUI/coregui/Views/widgetbox/ui4_p.h @@ -80,8 +80,7 @@ QT_BEGIN_NAMESPACE #endif #ifdef QFORMINTERNAL_NAMESPACE -namespace QFormInternal -{ +namespace QFormInternal { #endif /******************************************************************************* @@ -158,8 +157,7 @@ class DomStringPropertySpecification; ** Declarations */ -class QDESIGNER_UILIB_EXPORT DomUI -{ +class QDESIGNER_UILIB_EXPORT DomUI { public: DomUI(); ~DomUI(); @@ -172,8 +170,7 @@ public: // attribute accessors inline bool hasAttributeVersion() const { return m_has_attr_version; } inline QString attributeVersion() const { return m_attr_version; } - inline void setAttributeVersion(const QString& a) - { + inline void setAttributeVersion(const QString& a) { m_attr_version = a; m_has_attr_version = true; } @@ -181,8 +178,7 @@ public: inline bool hasAttributeLanguage() const { return m_has_attr_language; } inline QString attributeLanguage() const { return m_attr_language; } - inline void setAttributeLanguage(const QString& a) - { + inline void setAttributeLanguage(const QString& a) { m_attr_language = a; m_has_attr_language = true; } @@ -190,8 +186,7 @@ public: inline bool hasAttributeDisplayname() const { return m_has_attr_displayname; } inline QString attributeDisplayname() const { return m_attr_displayname; } - inline void setAttributeDisplayname(const QString& a) - { + inline void setAttributeDisplayname(const QString& a) { m_attr_displayname = a; m_has_attr_displayname = true; } @@ -199,8 +194,7 @@ public: inline bool hasAttributeStdsetdef() const { return m_has_attr_stdsetdef; } inline int attributeStdsetdef() const { return m_attr_stdsetdef; } - inline void setAttributeStdsetdef(int a) - { + inline void setAttributeStdsetdef(int a) { m_attr_stdsetdef = a; m_has_attr_stdsetdef = true; } @@ -208,8 +202,7 @@ public: inline bool hasAttributeStdSetDef() const { return m_has_attr_stdSetDef; } inline int attributeStdSetDef() const { return m_attr_stdSetDef; } - inline void setAttributeStdSetDef(int a) - { + inline void setAttributeStdSetDef(int a) { m_attr_stdSetDef = a; m_has_attr_stdSetDef = true; } @@ -376,8 +369,7 @@ private: void operator=(const DomUI& other); }; -class QDESIGNER_UILIB_EXPORT DomIncludes -{ +class QDESIGNER_UILIB_EXPORT DomIncludes { public: DomIncludes(); ~DomIncludes(); @@ -406,8 +398,7 @@ private: void operator=(const DomIncludes& other); }; -class QDESIGNER_UILIB_EXPORT DomInclude -{ +class QDESIGNER_UILIB_EXPORT DomInclude { public: DomInclude(); ~DomInclude(); @@ -420,8 +411,7 @@ public: // attribute accessors inline bool hasAttributeLocation() const { return m_has_attr_location; } inline QString attributeLocation() const { return m_attr_location; } - inline void setAttributeLocation(const QString& a) - { + inline void setAttributeLocation(const QString& a) { m_attr_location = a; m_has_attr_location = true; } @@ -429,8 +419,7 @@ public: inline bool hasAttributeImpldecl() const { return m_has_attr_impldecl; } inline QString attributeImpldecl() const { return m_attr_impldecl; } - inline void setAttributeImpldecl(const QString& a) - { + inline void setAttributeImpldecl(const QString& a) { m_attr_impldecl = a; m_has_attr_impldecl = true; } @@ -455,8 +444,7 @@ private: void operator=(const DomInclude& other); }; -class QDESIGNER_UILIB_EXPORT DomResources -{ +class QDESIGNER_UILIB_EXPORT DomResources { public: DomResources(); ~DomResources(); @@ -469,8 +457,7 @@ public: // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -497,8 +484,7 @@ private: void operator=(const DomResources& other); }; -class QDESIGNER_UILIB_EXPORT DomResource -{ +class QDESIGNER_UILIB_EXPORT DomResource { public: DomResource(); ~DomResource(); @@ -511,8 +497,7 @@ public: // attribute accessors inline bool hasAttributeLocation() const { return m_has_attr_location; } inline QString attributeLocation() const { return m_attr_location; } - inline void setAttributeLocation(const QString& a) - { + inline void setAttributeLocation(const QString& a) { m_attr_location = a; m_has_attr_location = true; } @@ -534,8 +519,7 @@ private: void operator=(const DomResource& other); }; -class QDESIGNER_UILIB_EXPORT DomActionGroup -{ +class QDESIGNER_UILIB_EXPORT DomActionGroup { public: DomActionGroup(); ~DomActionGroup(); @@ -548,8 +532,7 @@ public: // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -588,8 +571,7 @@ private: void operator=(const DomActionGroup& other); }; -class QDESIGNER_UILIB_EXPORT DomAction -{ +class QDESIGNER_UILIB_EXPORT DomAction { public: DomAction(); ~DomAction(); @@ -602,8 +584,7 @@ public: // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -611,8 +592,7 @@ public: inline bool hasAttributeMenu() const { return m_has_attr_menu; } inline QString attributeMenu() const { return m_attr_menu; } - inline void setAttributeMenu(const QString& a) - { + inline void setAttributeMenu(const QString& a) { m_attr_menu = a; m_has_attr_menu = true; } @@ -646,8 +626,7 @@ private: void operator=(const DomAction& other); }; -class QDESIGNER_UILIB_EXPORT DomActionRef -{ +class QDESIGNER_UILIB_EXPORT DomActionRef { public: DomActionRef(); ~DomActionRef(); @@ -660,8 +639,7 @@ public: // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -683,8 +661,7 @@ private: void operator=(const DomActionRef& other); }; -class QDESIGNER_UILIB_EXPORT DomButtonGroup -{ +class QDESIGNER_UILIB_EXPORT DomButtonGroup { public: DomButtonGroup(); ~DomButtonGroup(); @@ -697,8 +674,7 @@ public: // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -729,8 +705,7 @@ private: void operator=(const DomButtonGroup& other); }; -class QDESIGNER_UILIB_EXPORT DomButtonGroups -{ +class QDESIGNER_UILIB_EXPORT DomButtonGroups { public: DomButtonGroups(); ~DomButtonGroups(); @@ -759,8 +734,7 @@ private: void operator=(const DomButtonGroups& other); }; -class QDESIGNER_UILIB_EXPORT DomImages -{ +class QDESIGNER_UILIB_EXPORT DomImages { public: DomImages(); ~DomImages(); @@ -789,8 +763,7 @@ private: void operator=(const DomImages& other); }; -class QDESIGNER_UILIB_EXPORT DomImage -{ +class QDESIGNER_UILIB_EXPORT DomImage { public: DomImage(); ~DomImage(); @@ -803,8 +776,7 @@ public: // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -834,8 +806,7 @@ private: void operator=(const DomImage& other); }; -class QDESIGNER_UILIB_EXPORT DomImageData -{ +class QDESIGNER_UILIB_EXPORT DomImageData { public: DomImageData(); ~DomImageData(); @@ -848,8 +819,7 @@ public: // attribute accessors inline bool hasAttributeFormat() const { return m_has_attr_format; } inline QString attributeFormat() const { return m_attr_format; } - inline void setAttributeFormat(const QString& a) - { + inline void setAttributeFormat(const QString& a) { m_attr_format = a; m_has_attr_format = true; } @@ -857,8 +827,7 @@ public: inline bool hasAttributeLength() const { return m_has_attr_length; } inline int attributeLength() const { return m_attr_length; } - inline void setAttributeLength(int a) - { + inline void setAttributeLength(int a) { m_attr_length = a; m_has_attr_length = true; } @@ -883,8 +852,7 @@ private: void operator=(const DomImageData& other); }; -class QDESIGNER_UILIB_EXPORT DomCustomWidgets -{ +class QDESIGNER_UILIB_EXPORT DomCustomWidgets { public: DomCustomWidgets(); ~DomCustomWidgets(); @@ -913,8 +881,7 @@ private: void operator=(const DomCustomWidgets& other); }; -class QDESIGNER_UILIB_EXPORT DomHeader -{ +class QDESIGNER_UILIB_EXPORT DomHeader { public: DomHeader(); ~DomHeader(); @@ -927,8 +894,7 @@ public: // attribute accessors inline bool hasAttributeLocation() const { return m_has_attr_location; } inline QString attributeLocation() const { return m_attr_location; } - inline void setAttributeLocation(const QString& a) - { + inline void setAttributeLocation(const QString& a) { m_attr_location = a; m_has_attr_location = true; } @@ -950,8 +916,7 @@ private: void operator=(const DomHeader& other); }; -class QDESIGNER_UILIB_EXPORT DomCustomWidget -{ +class QDESIGNER_UILIB_EXPORT DomCustomWidget { public: DomCustomWidget(); ~DomCustomWidget(); @@ -1024,14 +989,12 @@ public: inline bool hasElementSlots() const { return m_children & Slots; } void clearElementSlots(); - inline DomPropertySpecifications* elementPropertyspecifications() const - { + inline DomPropertySpecifications* elementPropertyspecifications() const { return m_propertyspecifications; } DomPropertySpecifications* takeElementPropertyspecifications(); void setElementPropertyspecifications(DomPropertySpecifications* a); - inline bool hasElementPropertyspecifications() const - { + inline bool hasElementPropertyspecifications() const { return m_children & Propertyspecifications; } void clearElementPropertyspecifications(); @@ -1074,8 +1037,7 @@ private: void operator=(const DomCustomWidget& other); }; -class QDESIGNER_UILIB_EXPORT DomProperties -{ +class QDESIGNER_UILIB_EXPORT DomProperties { public: DomProperties(); ~DomProperties(); @@ -1104,8 +1066,7 @@ private: void operator=(const DomProperties& other); }; -class QDESIGNER_UILIB_EXPORT DomPropertyData -{ +class QDESIGNER_UILIB_EXPORT DomPropertyData { public: DomPropertyData(); ~DomPropertyData(); @@ -1118,8 +1079,7 @@ public: // attribute accessors inline bool hasAttributeType() const { return m_has_attr_type; } inline QString attributeType() const { return m_attr_type; } - inline void setAttributeType(const QString& a) - { + inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; } @@ -1141,8 +1101,7 @@ private: void operator=(const DomPropertyData& other); }; -class QDESIGNER_UILIB_EXPORT DomSizePolicyData -{ +class QDESIGNER_UILIB_EXPORT DomSizePolicyData { public: DomSizePolicyData(); ~DomSizePolicyData(); @@ -1179,8 +1138,7 @@ private: void operator=(const DomSizePolicyData& other); }; -class QDESIGNER_UILIB_EXPORT DomLayoutDefault -{ +class QDESIGNER_UILIB_EXPORT DomLayoutDefault { public: DomLayoutDefault(); ~DomLayoutDefault(); @@ -1193,8 +1151,7 @@ public: // attribute accessors inline bool hasAttributeSpacing() const { return m_has_attr_spacing; } inline int attributeSpacing() const { return m_attr_spacing; } - inline void setAttributeSpacing(int a) - { + inline void setAttributeSpacing(int a) { m_attr_spacing = a; m_has_attr_spacing = true; } @@ -1202,8 +1159,7 @@ public: inline bool hasAttributeMargin() const { return m_has_attr_margin; } inline int attributeMargin() const { return m_attr_margin; } - inline void setAttributeMargin(int a) - { + inline void setAttributeMargin(int a) { m_attr_margin = a; m_has_attr_margin = true; } @@ -1228,8 +1184,7 @@ private: void operator=(const DomLayoutDefault& other); }; -class QDESIGNER_UILIB_EXPORT DomLayoutFunction -{ +class QDESIGNER_UILIB_EXPORT DomLayoutFunction { public: DomLayoutFunction(); ~DomLayoutFunction(); @@ -1242,8 +1197,7 @@ public: // attribute accessors inline bool hasAttributeSpacing() const { return m_has_attr_spacing; } inline QString attributeSpacing() const { return m_attr_spacing; } - inline void setAttributeSpacing(const QString& a) - { + inline void setAttributeSpacing(const QString& a) { m_attr_spacing = a; m_has_attr_spacing = true; } @@ -1251,8 +1205,7 @@ public: inline bool hasAttributeMargin() const { return m_has_attr_margin; } inline QString attributeMargin() const { return m_attr_margin; } - inline void setAttributeMargin(const QString& a) - { + inline void setAttributeMargin(const QString& a) { m_attr_margin = a; m_has_attr_margin = true; } @@ -1277,8 +1230,7 @@ private: void operator=(const DomLayoutFunction& other); }; -class QDESIGNER_UILIB_EXPORT DomTabStops -{ +class QDESIGNER_UILIB_EXPORT DomTabStops { public: DomTabStops(); ~DomTabStops(); @@ -1307,8 +1259,7 @@ private: void operator=(const DomTabStops& other); }; -class QDESIGNER_UILIB_EXPORT DomLayout -{ +class QDESIGNER_UILIB_EXPORT DomLayout { public: DomLayout(); ~DomLayout(); @@ -1321,8 +1272,7 @@ public: // attribute accessors inline bool hasAttributeClass() const { return m_has_attr_class; } inline QString attributeClass() const { return m_attr_class; } - inline void setAttributeClass(const QString& a) - { + inline void setAttributeClass(const QString& a) { m_attr_class = a; m_has_attr_class = true; } @@ -1330,8 +1280,7 @@ public: inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -1339,8 +1288,7 @@ public: inline bool hasAttributeStretch() const { return m_has_attr_stretch; } inline QString attributeStretch() const { return m_attr_stretch; } - inline void setAttributeStretch(const QString& a) - { + inline void setAttributeStretch(const QString& a) { m_attr_stretch = a; m_has_attr_stretch = true; } @@ -1348,8 +1296,7 @@ public: inline bool hasAttributeRowStretch() const { return m_has_attr_rowStretch; } inline QString attributeRowStretch() const { return m_attr_rowStretch; } - inline void setAttributeRowStretch(const QString& a) - { + inline void setAttributeRowStretch(const QString& a) { m_attr_rowStretch = a; m_has_attr_rowStretch = true; } @@ -1357,8 +1304,7 @@ public: inline bool hasAttributeColumnStretch() const { return m_has_attr_columnStretch; } inline QString attributeColumnStretch() const { return m_attr_columnStretch; } - inline void setAttributeColumnStretch(const QString& a) - { + inline void setAttributeColumnStretch(const QString& a) { m_attr_columnStretch = a; m_has_attr_columnStretch = true; } @@ -1366,8 +1312,7 @@ public: inline bool hasAttributeRowMinimumHeight() const { return m_has_attr_rowMinimumHeight; } inline QString attributeRowMinimumHeight() const { return m_attr_rowMinimumHeight; } - inline void setAttributeRowMinimumHeight(const QString& a) - { + inline void setAttributeRowMinimumHeight(const QString& a) { m_attr_rowMinimumHeight = a; m_has_attr_rowMinimumHeight = true; } @@ -1375,8 +1320,7 @@ public: inline bool hasAttributeColumnMinimumWidth() const { return m_has_attr_columnMinimumWidth; } inline QString attributeColumnMinimumWidth() const { return m_attr_columnMinimumWidth; } - inline void setAttributeColumnMinimumWidth(const QString& a) - { + inline void setAttributeColumnMinimumWidth(const QString& a) { m_attr_columnMinimumWidth = a; m_has_attr_columnMinimumWidth = true; } @@ -1429,8 +1373,7 @@ private: void operator=(const DomLayout& other); }; -class QDESIGNER_UILIB_EXPORT DomLayoutItem -{ +class QDESIGNER_UILIB_EXPORT DomLayoutItem { public: DomLayoutItem(); ~DomLayoutItem(); @@ -1443,8 +1386,7 @@ public: // attribute accessors inline bool hasAttributeRow() const { return m_has_attr_row; } inline int attributeRow() const { return m_attr_row; } - inline void setAttributeRow(int a) - { + inline void setAttributeRow(int a) { m_attr_row = a; m_has_attr_row = true; } @@ -1452,8 +1394,7 @@ public: inline bool hasAttributeColumn() const { return m_has_attr_column; } inline int attributeColumn() const { return m_attr_column; } - inline void setAttributeColumn(int a) - { + inline void setAttributeColumn(int a) { m_attr_column = a; m_has_attr_column = true; } @@ -1461,8 +1402,7 @@ public: inline bool hasAttributeRowSpan() const { return m_has_attr_rowSpan; } inline int attributeRowSpan() const { return m_attr_rowSpan; } - inline void setAttributeRowSpan(int a) - { + inline void setAttributeRowSpan(int a) { m_attr_rowSpan = a; m_has_attr_rowSpan = true; } @@ -1470,8 +1410,7 @@ public: inline bool hasAttributeColSpan() const { return m_has_attr_colSpan; } inline int attributeColSpan() const { return m_attr_colSpan; } - inline void setAttributeColSpan(int a) - { + inline void setAttributeColSpan(int a) { m_attr_colSpan = a; m_has_attr_colSpan = true; } @@ -1479,8 +1418,7 @@ public: inline bool hasAttributeAlignment() const { return m_has_attr_alignment; } inline QString attributeAlignment() const { return m_attr_alignment; } - inline void setAttributeAlignment(const QString& a) - { + inline void setAttributeAlignment(const QString& a) { m_attr_alignment = a; m_has_attr_alignment = true; } @@ -1532,8 +1470,7 @@ private: void operator=(const DomLayoutItem& other); }; -class QDESIGNER_UILIB_EXPORT DomRow -{ +class QDESIGNER_UILIB_EXPORT DomRow { public: DomRow(); ~DomRow(); @@ -1562,8 +1499,7 @@ private: void operator=(const DomRow& other); }; -class QDESIGNER_UILIB_EXPORT DomColumn -{ +class QDESIGNER_UILIB_EXPORT DomColumn { public: DomColumn(); ~DomColumn(); @@ -1592,8 +1528,7 @@ private: void operator=(const DomColumn& other); }; -class QDESIGNER_UILIB_EXPORT DomItem -{ +class QDESIGNER_UILIB_EXPORT DomItem { public: DomItem(); ~DomItem(); @@ -1606,8 +1541,7 @@ public: // attribute accessors inline bool hasAttributeRow() const { return m_has_attr_row; } inline int attributeRow() const { return m_attr_row; } - inline void setAttributeRow(int a) - { + inline void setAttributeRow(int a) { m_attr_row = a; m_has_attr_row = true; } @@ -1615,8 +1549,7 @@ public: inline bool hasAttributeColumn() const { return m_has_attr_column; } inline int attributeColumn() const { return m_attr_column; } - inline void setAttributeColumn(int a) - { + inline void setAttributeColumn(int a) { m_attr_column = a; m_has_attr_column = true; } @@ -1650,8 +1583,7 @@ private: void operator=(const DomItem& other); }; -class QDESIGNER_UILIB_EXPORT DomWidget -{ +class QDESIGNER_UILIB_EXPORT DomWidget { public: DomWidget(); ~DomWidget(); @@ -1664,8 +1596,7 @@ public: // attribute accessors inline bool hasAttributeClass() const { return m_has_attr_class; } inline QString attributeClass() const { return m_attr_class; } - inline void setAttributeClass(const QString& a) - { + inline void setAttributeClass(const QString& a) { m_attr_class = a; m_has_attr_class = true; } @@ -1673,8 +1604,7 @@ public: inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -1682,8 +1612,7 @@ public: inline bool hasAttributeNative() const { return m_has_attr_native; } inline bool attributeNative() const { return m_attr_native; } - inline void setAttributeNative(bool a) - { + inline void setAttributeNative(bool a) { m_attr_native = a; m_has_attr_native = true; } @@ -1783,8 +1712,7 @@ private: void operator=(const DomWidget& other); }; -class QDESIGNER_UILIB_EXPORT DomSpacer -{ +class QDESIGNER_UILIB_EXPORT DomSpacer { public: DomSpacer(); ~DomSpacer(); @@ -1797,8 +1725,7 @@ public: // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -1825,8 +1752,7 @@ private: void operator=(const DomSpacer& other); }; -class QDESIGNER_UILIB_EXPORT DomColor -{ +class QDESIGNER_UILIB_EXPORT DomColor { public: DomColor(); ~DomColor(); @@ -1839,8 +1765,7 @@ public: // attribute accessors inline bool hasAttributeAlpha() const { return m_has_attr_alpha; } inline int attributeAlpha() const { return m_attr_alpha; } - inline void setAttributeAlpha(int a) - { + inline void setAttributeAlpha(int a) { m_attr_alpha = a; m_has_attr_alpha = true; } @@ -1881,8 +1806,7 @@ private: void operator=(const DomColor& other); }; -class QDESIGNER_UILIB_EXPORT DomGradientStop -{ +class QDESIGNER_UILIB_EXPORT DomGradientStop { public: DomGradientStop(); ~DomGradientStop(); @@ -1895,8 +1819,7 @@ public: // attribute accessors inline bool hasAttributePosition() const { return m_has_attr_position; } inline double attributePosition() const { return m_attr_position; } - inline void setAttributePosition(double a) - { + inline void setAttributePosition(double a) { m_attr_position = a; m_has_attr_position = true; } @@ -1926,8 +1849,7 @@ private: void operator=(const DomGradientStop& other); }; -class QDESIGNER_UILIB_EXPORT DomGradient -{ +class QDESIGNER_UILIB_EXPORT DomGradient { public: DomGradient(); ~DomGradient(); @@ -1940,8 +1862,7 @@ public: // attribute accessors inline bool hasAttributeStartX() const { return m_has_attr_startX; } inline double attributeStartX() const { return m_attr_startX; } - inline void setAttributeStartX(double a) - { + inline void setAttributeStartX(double a) { m_attr_startX = a; m_has_attr_startX = true; } @@ -1949,8 +1870,7 @@ public: inline bool hasAttributeStartY() const { return m_has_attr_startY; } inline double attributeStartY() const { return m_attr_startY; } - inline void setAttributeStartY(double a) - { + inline void setAttributeStartY(double a) { m_attr_startY = a; m_has_attr_startY = true; } @@ -1958,8 +1878,7 @@ public: inline bool hasAttributeEndX() const { return m_has_attr_endX; } inline double attributeEndX() const { return m_attr_endX; } - inline void setAttributeEndX(double a) - { + inline void setAttributeEndX(double a) { m_attr_endX = a; m_has_attr_endX = true; } @@ -1967,8 +1886,7 @@ public: inline bool hasAttributeEndY() const { return m_has_attr_endY; } inline double attributeEndY() const { return m_attr_endY; } - inline void setAttributeEndY(double a) - { + inline void setAttributeEndY(double a) { m_attr_endY = a; m_has_attr_endY = true; } @@ -1976,8 +1894,7 @@ public: inline bool hasAttributeCentralX() const { return m_has_attr_centralX; } inline double attributeCentralX() const { return m_attr_centralX; } - inline void setAttributeCentralX(double a) - { + inline void setAttributeCentralX(double a) { m_attr_centralX = a; m_has_attr_centralX = true; } @@ -1985,8 +1902,7 @@ public: inline bool hasAttributeCentralY() const { return m_has_attr_centralY; } inline double attributeCentralY() const { return m_attr_centralY; } - inline void setAttributeCentralY(double a) - { + inline void setAttributeCentralY(double a) { m_attr_centralY = a; m_has_attr_centralY = true; } @@ -1994,8 +1910,7 @@ public: inline bool hasAttributeFocalX() const { return m_has_attr_focalX; } inline double attributeFocalX() const { return m_attr_focalX; } - inline void setAttributeFocalX(double a) - { + inline void setAttributeFocalX(double a) { m_attr_focalX = a; m_has_attr_focalX = true; } @@ -2003,8 +1918,7 @@ public: inline bool hasAttributeFocalY() const { return m_has_attr_focalY; } inline double attributeFocalY() const { return m_attr_focalY; } - inline void setAttributeFocalY(double a) - { + inline void setAttributeFocalY(double a) { m_attr_focalY = a; m_has_attr_focalY = true; } @@ -2012,8 +1926,7 @@ public: inline bool hasAttributeRadius() const { return m_has_attr_radius; } inline double attributeRadius() const { return m_attr_radius; } - inline void setAttributeRadius(double a) - { + inline void setAttributeRadius(double a) { m_attr_radius = a; m_has_attr_radius = true; } @@ -2021,8 +1934,7 @@ public: inline bool hasAttributeAngle() const { return m_has_attr_angle; } inline double attributeAngle() const { return m_attr_angle; } - inline void setAttributeAngle(double a) - { + inline void setAttributeAngle(double a) { m_attr_angle = a; m_has_attr_angle = true; } @@ -2030,8 +1942,7 @@ public: inline bool hasAttributeType() const { return m_has_attr_type; } inline QString attributeType() const { return m_attr_type; } - inline void setAttributeType(const QString& a) - { + inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; } @@ -2039,8 +1950,7 @@ public: inline bool hasAttributeSpread() const { return m_has_attr_spread; } inline QString attributeSpread() const { return m_attr_spread; } - inline void setAttributeSpread(const QString& a) - { + inline void setAttributeSpread(const QString& a) { m_attr_spread = a; m_has_attr_spread = true; } @@ -2048,8 +1958,7 @@ public: inline bool hasAttributeCoordinateMode() const { return m_has_attr_coordinateMode; } inline QString attributeCoordinateMode() const { return m_attr_coordinateMode; } - inline void setAttributeCoordinateMode(const QString& a) - { + inline void setAttributeCoordinateMode(const QString& a) { m_attr_coordinateMode = a; m_has_attr_coordinateMode = true; } @@ -2112,8 +2021,7 @@ private: void operator=(const DomGradient& other); }; -class QDESIGNER_UILIB_EXPORT DomBrush -{ +class QDESIGNER_UILIB_EXPORT DomBrush { public: DomBrush(); ~DomBrush(); @@ -2126,8 +2034,7 @@ public: // attribute accessors inline bool hasAttributeBrushStyle() const { return m_has_attr_brushStyle; } inline QString attributeBrushStyle() const { return m_attr_brushStyle; } - inline void setAttributeBrushStyle(const QString& a) - { + inline void setAttributeBrushStyle(const QString& a) { m_attr_brushStyle = a; m_has_attr_brushStyle = true; } @@ -2167,8 +2074,7 @@ private: void operator=(const DomBrush& other); }; -class QDESIGNER_UILIB_EXPORT DomColorRole -{ +class QDESIGNER_UILIB_EXPORT DomColorRole { public: DomColorRole(); ~DomColorRole(); @@ -2181,8 +2087,7 @@ public: // attribute accessors inline bool hasAttributeRole() const { return m_has_attr_role; } inline QString attributeRole() const { return m_attr_role; } - inline void setAttributeRole(const QString& a) - { + inline void setAttributeRole(const QString& a) { m_attr_role = a; m_has_attr_role = true; } @@ -2212,8 +2117,7 @@ private: void operator=(const DomColorRole& other); }; -class QDESIGNER_UILIB_EXPORT DomColorGroup -{ +class QDESIGNER_UILIB_EXPORT DomColorGroup { public: DomColorGroup(); ~DomColorGroup(); @@ -2246,8 +2150,7 @@ private: void operator=(const DomColorGroup& other); }; -class QDESIGNER_UILIB_EXPORT DomPalette -{ +class QDESIGNER_UILIB_EXPORT DomPalette { public: DomPalette(); ~DomPalette(); @@ -2293,8 +2196,7 @@ private: void operator=(const DomPalette& other); }; -class QDESIGNER_UILIB_EXPORT DomFont -{ +class QDESIGNER_UILIB_EXPORT DomFont { public: DomFont(); ~DomFont(); @@ -2390,8 +2292,7 @@ private: void operator=(const DomFont& other); }; -class QDESIGNER_UILIB_EXPORT DomPoint -{ +class QDESIGNER_UILIB_EXPORT DomPoint { public: DomPoint(); ~DomPoint(); @@ -2428,8 +2329,7 @@ private: void operator=(const DomPoint& other); }; -class QDESIGNER_UILIB_EXPORT DomRect -{ +class QDESIGNER_UILIB_EXPORT DomRect { public: DomRect(); ~DomRect(); @@ -2478,8 +2378,7 @@ private: void operator=(const DomRect& other); }; -class QDESIGNER_UILIB_EXPORT DomLocale -{ +class QDESIGNER_UILIB_EXPORT DomLocale { public: DomLocale(); ~DomLocale(); @@ -2492,8 +2391,7 @@ public: // attribute accessors inline bool hasAttributeLanguage() const { return m_has_attr_language; } inline QString attributeLanguage() const { return m_attr_language; } - inline void setAttributeLanguage(const QString& a) - { + inline void setAttributeLanguage(const QString& a) { m_attr_language = a; m_has_attr_language = true; } @@ -2501,8 +2399,7 @@ public: inline bool hasAttributeCountry() const { return m_has_attr_country; } inline QString attributeCountry() const { return m_attr_country; } - inline void setAttributeCountry(const QString& a) - { + inline void setAttributeCountry(const QString& a) { m_attr_country = a; m_has_attr_country = true; } @@ -2527,8 +2424,7 @@ private: void operator=(const DomLocale& other); }; -class QDESIGNER_UILIB_EXPORT DomSizePolicy -{ +class QDESIGNER_UILIB_EXPORT DomSizePolicy { public: DomSizePolicy(); ~DomSizePolicy(); @@ -2541,8 +2437,7 @@ public: // attribute accessors inline bool hasAttributeHSizeType() const { return m_has_attr_hSizeType; } inline QString attributeHSizeType() const { return m_attr_hSizeType; } - inline void setAttributeHSizeType(const QString& a) - { + inline void setAttributeHSizeType(const QString& a) { m_attr_hSizeType = a; m_has_attr_hSizeType = true; } @@ -2550,8 +2445,7 @@ public: inline bool hasAttributeVSizeType() const { return m_has_attr_vSizeType; } inline QString attributeVSizeType() const { return m_attr_vSizeType; } - inline void setAttributeVSizeType(const QString& a) - { + inline void setAttributeVSizeType(const QString& a) { m_attr_vSizeType = a; m_has_attr_vSizeType = true; } @@ -2601,8 +2495,7 @@ private: void operator=(const DomSizePolicy& other); }; -class QDESIGNER_UILIB_EXPORT DomSize -{ +class QDESIGNER_UILIB_EXPORT DomSize { public: DomSize(); ~DomSize(); @@ -2639,8 +2532,7 @@ private: void operator=(const DomSize& other); }; -class QDESIGNER_UILIB_EXPORT DomDate -{ +class QDESIGNER_UILIB_EXPORT DomDate { public: DomDate(); ~DomDate(); @@ -2683,8 +2575,7 @@ private: void operator=(const DomDate& other); }; -class QDESIGNER_UILIB_EXPORT DomTime -{ +class QDESIGNER_UILIB_EXPORT DomTime { public: DomTime(); ~DomTime(); @@ -2727,8 +2618,7 @@ private: void operator=(const DomTime& other); }; -class QDESIGNER_UILIB_EXPORT DomDateTime -{ +class QDESIGNER_UILIB_EXPORT DomDateTime { public: DomDateTime(); ~DomDateTime(); @@ -2789,8 +2679,7 @@ private: void operator=(const DomDateTime& other); }; -class QDESIGNER_UILIB_EXPORT DomStringList -{ +class QDESIGNER_UILIB_EXPORT DomStringList { public: DomStringList(); ~DomStringList(); @@ -2803,8 +2692,7 @@ public: // attribute accessors inline bool hasAttributeNotr() const { return m_has_attr_notr; } inline QString attributeNotr() const { return m_attr_notr; } - inline void setAttributeNotr(const QString& a) - { + inline void setAttributeNotr(const QString& a) { m_attr_notr = a; m_has_attr_notr = true; } @@ -2812,8 +2700,7 @@ public: inline bool hasAttributeComment() const { return m_has_attr_comment; } inline QString attributeComment() const { return m_attr_comment; } - inline void setAttributeComment(const QString& a) - { + inline void setAttributeComment(const QString& a) { m_attr_comment = a; m_has_attr_comment = true; } @@ -2821,8 +2708,7 @@ public: inline bool hasAttributeExtraComment() const { return m_has_attr_extraComment; } inline QString attributeExtraComment() const { return m_attr_extraComment; } - inline void setAttributeExtraComment(const QString& a) - { + inline void setAttributeExtraComment(const QString& a) { m_attr_extraComment = a; m_has_attr_extraComment = true; } @@ -2855,8 +2741,7 @@ private: void operator=(const DomStringList& other); }; -class QDESIGNER_UILIB_EXPORT DomResourcePixmap -{ +class QDESIGNER_UILIB_EXPORT DomResourcePixmap { public: DomResourcePixmap(); ~DomResourcePixmap(); @@ -2869,8 +2754,7 @@ public: // attribute accessors inline bool hasAttributeResource() const { return m_has_attr_resource; } inline QString attributeResource() const { return m_attr_resource; } - inline void setAttributeResource(const QString& a) - { + inline void setAttributeResource(const QString& a) { m_attr_resource = a; m_has_attr_resource = true; } @@ -2878,8 +2762,7 @@ public: inline bool hasAttributeAlias() const { return m_has_attr_alias; } inline QString attributeAlias() const { return m_attr_alias; } - inline void setAttributeAlias(const QString& a) - { + inline void setAttributeAlias(const QString& a) { m_attr_alias = a; m_has_attr_alias = true; } @@ -2904,8 +2787,7 @@ private: void operator=(const DomResourcePixmap& other); }; -class QDESIGNER_UILIB_EXPORT DomResourceIcon -{ +class QDESIGNER_UILIB_EXPORT DomResourceIcon { public: DomResourceIcon(); ~DomResourceIcon(); @@ -2918,8 +2800,7 @@ public: // attribute accessors inline bool hasAttributeTheme() const { return m_has_attr_theme; } inline QString attributeTheme() const { return m_attr_theme; } - inline void setAttributeTheme(const QString& a) - { + inline void setAttributeTheme(const QString& a) { m_attr_theme = a; m_has_attr_theme = true; } @@ -2927,8 +2808,7 @@ public: inline bool hasAttributeResource() const { return m_has_attr_resource; } inline QString attributeResource() const { return m_attr_resource; } - inline void setAttributeResource(const QString& a) - { + inline void setAttributeResource(const QString& a) { m_attr_resource = a; m_has_attr_resource = true; } @@ -3019,8 +2899,7 @@ private: void operator=(const DomResourceIcon& other); }; -class QDESIGNER_UILIB_EXPORT DomString -{ +class QDESIGNER_UILIB_EXPORT DomString { public: DomString(); ~DomString(); @@ -3033,8 +2912,7 @@ public: // attribute accessors inline bool hasAttributeNotr() const { return m_has_attr_notr; } inline QString attributeNotr() const { return m_attr_notr; } - inline void setAttributeNotr(const QString& a) - { + inline void setAttributeNotr(const QString& a) { m_attr_notr = a; m_has_attr_notr = true; } @@ -3042,8 +2920,7 @@ public: inline bool hasAttributeComment() const { return m_has_attr_comment; } inline QString attributeComment() const { return m_attr_comment; } - inline void setAttributeComment(const QString& a) - { + inline void setAttributeComment(const QString& a) { m_attr_comment = a; m_has_attr_comment = true; } @@ -3051,8 +2928,7 @@ public: inline bool hasAttributeExtraComment() const { return m_has_attr_extraComment; } inline QString attributeExtraComment() const { return m_attr_extraComment; } - inline void setAttributeExtraComment(const QString& a) - { + inline void setAttributeExtraComment(const QString& a) { m_attr_extraComment = a; m_has_attr_extraComment = true; } @@ -3080,8 +2956,7 @@ private: void operator=(const DomString& other); }; -class QDESIGNER_UILIB_EXPORT DomPointF -{ +class QDESIGNER_UILIB_EXPORT DomPointF { public: DomPointF(); ~DomPointF(); @@ -3118,8 +2993,7 @@ private: void operator=(const DomPointF& other); }; -class QDESIGNER_UILIB_EXPORT DomRectF -{ +class QDESIGNER_UILIB_EXPORT DomRectF { public: DomRectF(); ~DomRectF(); @@ -3168,8 +3042,7 @@ private: void operator=(const DomRectF& other); }; -class QDESIGNER_UILIB_EXPORT DomSizeF -{ +class QDESIGNER_UILIB_EXPORT DomSizeF { public: DomSizeF(); ~DomSizeF(); @@ -3206,8 +3079,7 @@ private: void operator=(const DomSizeF& other); }; -class QDESIGNER_UILIB_EXPORT DomChar -{ +class QDESIGNER_UILIB_EXPORT DomChar { public: DomChar(); ~DomChar(); @@ -3238,8 +3110,7 @@ private: void operator=(const DomChar& other); }; -class QDESIGNER_UILIB_EXPORT DomUrl -{ +class QDESIGNER_UILIB_EXPORT DomUrl { public: DomUrl(); ~DomUrl(); @@ -3271,8 +3142,7 @@ private: void operator=(const DomUrl& other); }; -class QDESIGNER_UILIB_EXPORT DomProperty -{ +class QDESIGNER_UILIB_EXPORT DomProperty { public: DomProperty(); ~DomProperty(); @@ -3285,8 +3155,7 @@ public: // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -3294,8 +3163,7 @@ public: inline bool hasAttributeStdset() const { return m_has_attr_stdset; } inline int attributeStdset() const { return m_attr_stdset; } - inline void setAttributeStdset(int a) - { + inline void setAttributeStdset(int a) { m_attr_stdset = a; m_has_attr_stdset = true; } @@ -3511,8 +3379,7 @@ private: void operator=(const DomProperty& other); }; -class QDESIGNER_UILIB_EXPORT DomConnections -{ +class QDESIGNER_UILIB_EXPORT DomConnections { public: DomConnections(); ~DomConnections(); @@ -3541,8 +3408,7 @@ private: void operator=(const DomConnections& other); }; -class QDESIGNER_UILIB_EXPORT DomConnection -{ +class QDESIGNER_UILIB_EXPORT DomConnection { public: DomConnection(); ~DomConnection(); @@ -3598,8 +3464,7 @@ private: void operator=(const DomConnection& other); }; -class QDESIGNER_UILIB_EXPORT DomConnectionHints -{ +class QDESIGNER_UILIB_EXPORT DomConnectionHints { public: DomConnectionHints(); ~DomConnectionHints(); @@ -3628,8 +3493,7 @@ private: void operator=(const DomConnectionHints& other); }; -class QDESIGNER_UILIB_EXPORT DomConnectionHint -{ +class QDESIGNER_UILIB_EXPORT DomConnectionHint { public: DomConnectionHint(); ~DomConnectionHint(); @@ -3642,8 +3506,7 @@ public: // attribute accessors inline bool hasAttributeType() const { return m_has_attr_type; } inline QString attributeType() const { return m_attr_type; } - inline void setAttributeType(const QString& a) - { + inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; } @@ -3678,8 +3541,7 @@ private: void operator=(const DomConnectionHint& other); }; -class QDESIGNER_UILIB_EXPORT DomScript -{ +class QDESIGNER_UILIB_EXPORT DomScript { public: DomScript(); ~DomScript(); @@ -3692,8 +3554,7 @@ public: // attribute accessors inline bool hasAttributeSource() const { return m_has_attr_source; } inline QString attributeSource() const { return m_attr_source; } - inline void setAttributeSource(const QString& a) - { + inline void setAttributeSource(const QString& a) { m_attr_source = a; m_has_attr_source = true; } @@ -3701,8 +3562,7 @@ public: inline bool hasAttributeLanguage() const { return m_has_attr_language; } inline QString attributeLanguage() const { return m_attr_language; } - inline void setAttributeLanguage(const QString& a) - { + inline void setAttributeLanguage(const QString& a) { m_attr_language = a; m_has_attr_language = true; } @@ -3727,8 +3587,7 @@ private: void operator=(const DomScript& other); }; -class QDESIGNER_UILIB_EXPORT DomWidgetData -{ +class QDESIGNER_UILIB_EXPORT DomWidgetData { public: DomWidgetData(); ~DomWidgetData(); @@ -3757,8 +3616,7 @@ private: void operator=(const DomWidgetData& other); }; -class QDESIGNER_UILIB_EXPORT DomDesignerData -{ +class QDESIGNER_UILIB_EXPORT DomDesignerData { public: DomDesignerData(); ~DomDesignerData(); @@ -3787,8 +3645,7 @@ private: void operator=(const DomDesignerData& other); }; -class QDESIGNER_UILIB_EXPORT DomSlots -{ +class QDESIGNER_UILIB_EXPORT DomSlots { public: DomSlots(); ~DomSlots(); @@ -3821,8 +3678,7 @@ private: void operator=(const DomSlots& other); }; -class QDESIGNER_UILIB_EXPORT DomPropertySpecifications -{ +class QDESIGNER_UILIB_EXPORT DomPropertySpecifications { public: DomPropertySpecifications(); ~DomPropertySpecifications(); @@ -3834,8 +3690,7 @@ public: // attribute accessors // child element accessors - inline QList<DomStringPropertySpecification*> elementStringpropertyspecification() const - { + inline QList<DomStringPropertySpecification*> elementStringpropertyspecification() const { return m_stringpropertyspecification; } void setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a); @@ -3854,8 +3709,7 @@ private: void operator=(const DomPropertySpecifications& other); }; -class QDESIGNER_UILIB_EXPORT DomStringPropertySpecification -{ +class QDESIGNER_UILIB_EXPORT DomStringPropertySpecification { public: DomStringPropertySpecification(); ~DomStringPropertySpecification(); @@ -3868,8 +3722,7 @@ public: // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) - { + inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } @@ -3877,8 +3730,7 @@ public: inline bool hasAttributeType() const { return m_has_attr_type; } inline QString attributeType() const { return m_attr_type; } - inline void setAttributeType(const QString& a) - { + inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; } @@ -3886,8 +3738,7 @@ public: inline bool hasAttributeNotr() const { return m_has_attr_notr; } inline QString attributeNotr() const { return m_attr_notr; } - inline void setAttributeNotr(const QString& a) - { + inline void setAttributeNotr(const QString& a) { m_attr_notr = a; m_has_attr_notr = true; } diff --git a/GUI/coregui/Views/widgetbox/widgetbox.cpp b/GUI/coregui/Views/widgetbox/widgetbox.cpp index 4447a6a75ea403e59cd43938d0b19393096ac405..8ae294153595f7e0ceedf79e7548d2991199d302 100644 --- a/GUI/coregui/Views/widgetbox/widgetbox.cpp +++ b/GUI/coregui/Views/widgetbox/widgetbox.cpp @@ -64,15 +64,12 @@ #include <iostream> QT_BEGIN_NAMESPACE -namespace qdesigner_internal -{ +namespace qdesigner_internal { -class WidgetBoxFilterLineEdit : public QLineEdit -{ +class WidgetBoxFilterLineEdit : public QLineEdit { public: explicit WidgetBoxFilterLineEdit(QWidget* parent = 0) - : QLineEdit(parent), m_defaultFocusPolicy(focusPolicy()) - { + : QLineEdit(parent), m_defaultFocusPolicy(focusPolicy()) { setFocusPolicy(Qt::NoFocus); } @@ -84,15 +81,13 @@ private: const Qt::FocusPolicy m_defaultFocusPolicy; }; -void WidgetBoxFilterLineEdit::mousePressEvent(QMouseEvent* e) -{ +void WidgetBoxFilterLineEdit::mousePressEvent(QMouseEvent* e) { if (!hasFocus()) // Explicitly focus on click. setFocus(Qt::OtherFocusReason); QLineEdit::mousePressEvent(e); } -void WidgetBoxFilterLineEdit::focusInEvent(QFocusEvent* e) -{ +void WidgetBoxFilterLineEdit::focusInEvent(QFocusEvent* e) { // Refuse the focus if the mouse it outside. In addition to the mouse // press logic, this prevents a re-focussing which occurs once // we actually had focus @@ -110,8 +105,7 @@ void WidgetBoxFilterLineEdit::focusInEvent(QFocusEvent* e) // WidgetBox::WidgetBox(QDesignerFormEditorInterface *core, QWidget *parent, Qt::WindowFlags flags) WidgetBox::WidgetBox(SampleDesignerInterface* core, QWidget* parent, Qt::WindowFlags flags) - : QDesignerWidgetBox(parent, flags), m_core(core), m_view(new WidgetBoxTreeWidget(m_core)) -{ + : QDesignerWidgetBox(parent, flags), m_core(core), m_view(new WidgetBoxTreeWidget(m_core)) { QVBoxLayout* l = new QVBoxLayout(this); l->setMargin(0); l->setSpacing(0); @@ -160,14 +154,12 @@ WidgetBox::~WidgetBox() = default; // return m_core; //} -SampleDesignerInterface* WidgetBox::core() const -{ +SampleDesignerInterface* WidgetBox::core() const { return m_core; } void WidgetBox::handleMousePress(const QString& name, const QString& xml, - const QPoint& global_mouse_pos) -{ + const QPoint& global_mouse_pos) { Q_UNUSED(global_mouse_pos); if (QApplication::mouseButtons() != Qt::LeftButton) return; @@ -176,79 +168,64 @@ void WidgetBox::handleMousePress(const QString& name, const QString& xml, DesignerMimeData::execDrag(name, xml, this); } -int WidgetBox::categoryCount() const -{ +int WidgetBox::categoryCount() const { return m_view->categoryCount(); } -QDesignerWidgetBoxInterface::Category WidgetBox::category(int cat_idx) const -{ +QDesignerWidgetBoxInterface::Category WidgetBox::category(int cat_idx) const { return m_view->category(cat_idx); } -void WidgetBox::addCategory(const Category& cat) -{ +void WidgetBox::addCategory(const Category& cat) { m_view->addCategory(cat); } -void WidgetBox::removeCategory(int cat_idx) -{ +void WidgetBox::removeCategory(int cat_idx) { m_view->removeCategory(cat_idx); } -int WidgetBox::widgetCount(int cat_idx) const -{ +int WidgetBox::widgetCount(int cat_idx) const { return m_view->widgetCount(cat_idx); } -QDesignerWidgetBoxInterface::Widget WidgetBox::widget(int cat_idx, int wgt_idx) const -{ +QDesignerWidgetBoxInterface::Widget WidgetBox::widget(int cat_idx, int wgt_idx) const { return m_view->widget(cat_idx, wgt_idx); } -void WidgetBox::addWidget(int cat_idx, const Widget& wgt) -{ +void WidgetBox::addWidget(int cat_idx, const Widget& wgt) { m_view->addWidget(cat_idx, wgt); } -void WidgetBox::removeWidget(int cat_idx, int wgt_idx) -{ +void WidgetBox::removeWidget(int cat_idx, int wgt_idx) { m_view->removeWidget(cat_idx, wgt_idx); } -void WidgetBox::dropWidgets(const QList<QDesignerDnDItemInterface*>& item_list, const QPoint&) -{ +void WidgetBox::dropWidgets(const QList<QDesignerDnDItemInterface*>& item_list, const QPoint&) { m_view->dropWidgets(item_list); } -void WidgetBox::setFileName(const QString& file_name) -{ +void WidgetBox::setFileName(const QString& file_name) { m_view->setFileName(file_name); } -QString WidgetBox::fileName() const -{ +QString WidgetBox::fileName() const { return m_view->fileName(); } -bool WidgetBox::load() -{ +bool WidgetBox::load() { // std::cout << "WidgetBox::load() -> We are here" << std::endl; return m_view->load(loadMode()); } -bool WidgetBox::loadContents(const QString& contents) -{ +bool WidgetBox::loadContents(const QString& contents) { return m_view->loadContents(contents); } -bool WidgetBox::save() -{ +bool WidgetBox::save() { return m_view->save(); } -static const QDesignerMimeData* checkDragEvent(QDropEvent* event, bool acceptEventsFromWidgetBox) -{ +static const QDesignerMimeData* checkDragEvent(QDropEvent* event, bool acceptEventsFromWidgetBox) { // std::cout << "QDesignerMimeData *checkDragEvent() -> ?" << std::endl; const QDesignerMimeData* mimeData = qobject_cast<const QDesignerMimeData*>(event->mimeData()); if (!mimeData) { @@ -268,20 +245,17 @@ static const QDesignerMimeData* checkDragEvent(QDropEvent* event, bool acceptEve return mimeData; } -void WidgetBox::dragEnterEvent(QDragEnterEvent* event) -{ +void WidgetBox::dragEnterEvent(QDragEnterEvent* event) { // We accept event originating from the widget box also here, // because otherwise Windows will not show the DnD pixmap. checkDragEvent(event, true); } -void WidgetBox::dragMoveEvent(QDragMoveEvent* event) -{ +void WidgetBox::dragMoveEvent(QDragMoveEvent* event) { checkDragEvent(event, true); } -void WidgetBox::dropEvent(QDropEvent* event) -{ +void WidgetBox::dropEvent(QDropEvent* event) { const QDesignerMimeData* mimeData = checkDragEvent(event, false); if (!mimeData) return; @@ -290,8 +264,7 @@ void WidgetBox::dropEvent(QDropEvent* event) QDesignerMimeData::removeMovedWidgetsFromSourceForm(mimeData->items()); } -QIcon WidgetBox::iconForWidget(const QString& className, const QString& category) const -{ +QIcon WidgetBox::iconForWidget(const QString& className, const QString& category) const { Widget widgetData; if (!findWidget(this, className, category, &widgetData)) return QIcon(); diff --git a/GUI/coregui/Views/widgetbox/widgetbox.h b/GUI/coregui/Views/widgetbox/widgetbox.h index 105f04487ca6f6d86890548a899ac80d3a17b07a..2cfe0a1d1fbec09a37beb04afcb1eddcc0cf9d6c 100644 --- a/GUI/coregui/Views/widgetbox/widgetbox.h +++ b/GUI/coregui/Views/widgetbox/widgetbox.h @@ -54,13 +54,11 @@ class QDesignerFormWindowInterface; class SampleDesignerInterface; -namespace qdesigner_internal -{ +namespace qdesigner_internal { class WidgetBoxTreeWidget; -class QT_WIDGETBOX_EXPORT WidgetBox : public QDesignerWidgetBox -{ +class QT_WIDGETBOX_EXPORT WidgetBox : public QDesignerWidgetBox { Q_OBJECT public: // explicit WidgetBox(QDesignerFormEditorInterface *core, QWidget *parent = 0, diff --git a/GUI/coregui/Views/widgetbox/widgetboxcategorylistview.cpp b/GUI/coregui/Views/widgetbox/widgetboxcategorylistview.cpp index b93e52622cc2c9460197226124684920c3c939fc..9ebf2cdc6c50d7d32de935d8ca6469c53d168f6c 100644 --- a/GUI/coregui/Views/widgetbox/widgetboxcategorylistview.cpp +++ b/GUI/coregui/Views/widgetbox/widgetboxcategorylistview.cpp @@ -74,8 +74,7 @@ QT_BEGIN_NAMESPACE enum { FILTER_ROLE = Qt::UserRole + 11 }; -static QString domToString(const QDomElement& elt) -{ +static QString domToString(const QDomElement& elt) { QString result; QTextStream stream(&result, QIODevice::WriteOnly); elt.save(stream, 2); @@ -83,15 +82,13 @@ static QString domToString(const QDomElement& elt) return result; } -static QDomDocument stringToDom(const QString& xml) -{ +static QDomDocument stringToDom(const QString& xml) { QDomDocument result; result.setContent(xml); return result; } -namespace qdesigner_internal -{ +namespace qdesigner_internal { // Entry of the model list @@ -112,16 +109,13 @@ WidgetBoxCategoryEntry::WidgetBoxCategoryEntry() : editable(false) {} WidgetBoxCategoryEntry::WidgetBoxCategoryEntry(const QDesignerWidgetBoxInterface::Widget& w, const QString& filterIn, const QIcon& i, bool e) - : widget(w), filter(filterIn), icon(i), editable(e) -{ -} + : widget(w), filter(filterIn), icon(i), editable(e) {} /* WidgetBoxCategoryModel, representing a list of category entries. Uses a * QAbstractListModel since the behaviour depends on the view mode of the list * view, it does not return text in the case of IconMode. */ -class WidgetBoxCategoryModel : public QAbstractListModel -{ +class WidgetBoxCategoryModel : public QAbstractListModel { public: // explicit WidgetBoxCategoryModel(QDesignerFormEditorInterface *core, QObject *parent = 0); explicit WidgetBoxCategoryModel(SampleDesignerInterface* core, QObject* parent = 0); @@ -172,19 +166,16 @@ WidgetBoxCategoryModel::WidgetBoxCategoryModel(SampleDesignerInterface* core, QO #endif // m_core(core), - m_viewMode(QListView::ListMode) -{ + m_viewMode(QListView::ListMode) { ASSERT(m_classNameRegExp.isValid()); Q_UNUSED(core); } -QListView::ViewMode WidgetBoxCategoryModel::viewMode() const -{ +QListView::ViewMode WidgetBoxCategoryModel::viewMode() const { return m_viewMode; } -void WidgetBoxCategoryModel::setViewMode(QListView::ViewMode vm) -{ +void WidgetBoxCategoryModel::setViewMode(QListView::ViewMode vm) { if (m_viewMode == vm) return; const bool empty = m_items.isEmpty(); @@ -195,8 +186,7 @@ void WidgetBoxCategoryModel::setViewMode(QListView::ViewMode vm) endResetModel(); } -int WidgetBoxCategoryModel::indexOfWidget(const QString& name) -{ +int WidgetBoxCategoryModel::indexOfWidget(const QString& name) { const int count = m_items.size(); for (int i = 0; i < count; i++) if (m_items.at(i).widget.name() == name) @@ -204,8 +194,7 @@ int WidgetBoxCategoryModel::indexOfWidget(const QString& name) return -1; } -QDesignerWidgetBoxInterface::Category WidgetBoxCategoryModel::category() const -{ +QDesignerWidgetBoxInterface::Category WidgetBoxCategoryModel::category() const { QDesignerWidgetBoxInterface::Category rc; const WidgetBoxCategoryEntrys::const_iterator cend = m_items.constEnd(); for (WidgetBoxCategoryEntrys::const_iterator it = m_items.constBegin(); it != cend; ++it) @@ -213,8 +202,7 @@ QDesignerWidgetBoxInterface::Category WidgetBoxCategoryModel::category() const return rc; } -bool WidgetBoxCategoryModel::removeCustomWidgets() -{ +bool WidgetBoxCategoryModel::removeCustomWidgets() { // Typically, we are a whole category of custom widgets, so, remove all // and do reset. bool changed = false; @@ -233,8 +221,7 @@ bool WidgetBoxCategoryModel::removeCustomWidgets() } void WidgetBoxCategoryModel::addWidget(const QDesignerWidgetBoxInterface::Widget& widget, - const QIcon& icon, bool editable) -{ + const QIcon& icon, bool editable) { // build item. Filter on name + class name if it is different and not a layout. QString filter = widget.name(); if (!filter.contains("Layout") && m_classNameRegExp.indexIn(widget.domXml()) != -1) { @@ -281,8 +268,7 @@ void WidgetBoxCategoryModel::addWidget(const QDesignerWidgetBoxInterface::Widget endInsertRows(); } -QVariant WidgetBoxCategoryModel::data(const QModelIndex& index, int role) const -{ +QVariant WidgetBoxCategoryModel::data(const QModelIndex& index, int role) const { const int row = index.row(); if (row < 0 || row >= m_items.size()) return QVariant(); @@ -315,8 +301,7 @@ QVariant WidgetBoxCategoryModel::data(const QModelIndex& index, int role) const return QVariant(); } -bool WidgetBoxCategoryModel::setData(const QModelIndex& index, const QVariant& value, int role) -{ +bool WidgetBoxCategoryModel::setData(const QModelIndex& index, const QVariant& value, int role) { const int row = index.row(); if (role != Qt::EditRole || row < 0 || row >= m_items.size() || value.type() != QVariant::String) @@ -336,8 +321,7 @@ bool WidgetBoxCategoryModel::setData(const QModelIndex& index, const QVariant& v return true; } -Qt::ItemFlags WidgetBoxCategoryModel::flags(const QModelIndex& index) const -{ +Qt::ItemFlags WidgetBoxCategoryModel::flags(const QModelIndex& index) const { Qt::ItemFlags rc = Qt::ItemIsEnabled; const int row = index.row(); if (row >= 0 && row < m_items.size()) @@ -350,13 +334,11 @@ Qt::ItemFlags WidgetBoxCategoryModel::flags(const QModelIndex& index) const return rc; } -int WidgetBoxCategoryModel::rowCount(const QModelIndex& /*parent*/) const -{ +int WidgetBoxCategoryModel::rowCount(const QModelIndex& /*parent*/) const { return m_items.size(); } -bool WidgetBoxCategoryModel::removeRows(int row, int count, const QModelIndex& parent) -{ +bool WidgetBoxCategoryModel::removeRows(int row, int count, const QModelIndex& parent) { if (row < 0 || count < 1) return false; const int size = m_items.size(); @@ -370,13 +352,12 @@ bool WidgetBoxCategoryModel::removeRows(int row, int count, const QModelIndex& p return true; } -QDesignerWidgetBoxInterface::Widget WidgetBoxCategoryModel::widgetAt(const QModelIndex& index) const -{ +QDesignerWidgetBoxInterface::Widget +WidgetBoxCategoryModel::widgetAt(const QModelIndex& index) const { return widgetAt(index.row()); } -QDesignerWidgetBoxInterface::Widget WidgetBoxCategoryModel::widgetAt(int row) const -{ +QDesignerWidgetBoxInterface::Widget WidgetBoxCategoryModel::widgetAt(int row) const { if (row < 0 || row >= m_items.size()) return QDesignerWidgetBoxInterface::Widget(); return m_items.at(row).widget; @@ -384,8 +365,7 @@ QDesignerWidgetBoxInterface::Widget WidgetBoxCategoryModel::widgetAt(int row) co /* WidgetSubBoxItemDelegate, ensures a valid name using a regexp validator */ -class WidgetBoxCategoryEntryDelegate : public QItemDelegate -{ +class WidgetBoxCategoryEntryDelegate : public QItemDelegate { public: explicit WidgetBoxCategoryEntryDelegate(QWidget* parent = 0) : QItemDelegate(parent) {} QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, @@ -394,8 +374,7 @@ public: QWidget* WidgetBoxCategoryEntryDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ + const QModelIndex& index) const { QWidget* result = QItemDelegate::createEditor(parent, option, index); if (QLineEdit* line_edit = qobject_cast<QLineEdit*>(result)) { QRegExp re = QRegExp("[_a-zA-Z][_a-zA-Z0-9]*"); @@ -412,8 +391,7 @@ QWidget* WidgetBoxCategoryEntryDelegate::createEditor(QWidget* parent, WidgetBoxCategoryListView::WidgetBoxCategoryListView(SampleDesignerInterface* core, QWidget* parent) : QListView(parent) , m_proxyModel(new QSortFilterProxyModel(this)) - , m_model(new WidgetBoxCategoryModel(core, this)) -{ + , m_model(new WidgetBoxCategoryModel(core, this)) { setFocusPolicy(Qt::NoFocus); setFrameShape(QFrame::NoFrame); // setIconSize(QSize(22, 22)); @@ -437,14 +415,12 @@ WidgetBoxCategoryListView::WidgetBoxCategoryListView(SampleDesignerInterface* co SIGNAL(scratchPadChanged())); } -void WidgetBoxCategoryListView::setViewMode(ViewMode vm) -{ +void WidgetBoxCategoryListView::setViewMode(ViewMode vm) { QListView::setViewMode(vm); m_model->setViewMode(vm); } -void WidgetBoxCategoryListView::setCurrentItem(EAccessMode am, int row) -{ +void WidgetBoxCategoryListView::setCurrentItem(EAccessMode am, int row) { const QModelIndex index = am == FILTERED ? m_proxyModel->index(row, 0) : m_proxyModel->mapFromSource(m_model->index(row, 0)); @@ -452,8 +428,7 @@ void WidgetBoxCategoryListView::setCurrentItem(EAccessMode am, int row) setCurrentIndex(index); } -void WidgetBoxCategoryListView::slotPressed(const QModelIndex& index) -{ +void WidgetBoxCategoryListView::slotPressed(const QModelIndex& index) { const QDesignerWidgetBoxInterface::Widget wgt = m_model->widgetAt(m_proxyModel->mapToSource(index)); if (wgt.isNull()) @@ -461,8 +436,7 @@ void WidgetBoxCategoryListView::slotPressed(const QModelIndex& index) emit pressed(wgt.name(), widgetDomXml(wgt), QCursor::pos()); } -void WidgetBoxCategoryListView::removeCurrentItem() -{ +void WidgetBoxCategoryListView::removeCurrentItem() { const QModelIndex index = currentIndex(); if (!index.isValid() || !m_proxyModel->removeRow(index.row())) return; @@ -476,55 +450,46 @@ void WidgetBoxCategoryListView::removeCurrentItem() } } -void WidgetBoxCategoryListView::editCurrentItem() -{ +void WidgetBoxCategoryListView::editCurrentItem() { const QModelIndex index = currentIndex(); if (index.isValid()) edit(index); } -int WidgetBoxCategoryListView::count(EAccessMode am) const -{ +int WidgetBoxCategoryListView::count(EAccessMode am) const { return am == FILTERED ? m_proxyModel->rowCount() : m_model->rowCount(); } -int WidgetBoxCategoryListView::mapRowToSource(int filterRow) const -{ +int WidgetBoxCategoryListView::mapRowToSource(int filterRow) const { const QModelIndex filterIndex = m_proxyModel->index(filterRow, 0); return m_proxyModel->mapToSource(filterIndex).row(); } QDesignerWidgetBoxInterface::Widget -WidgetBoxCategoryListView::widgetAt(EAccessMode am, const QModelIndex& index) const -{ +WidgetBoxCategoryListView::widgetAt(EAccessMode am, const QModelIndex& index) const { const QModelIndex unfilteredIndex = am == FILTERED ? m_proxyModel->mapToSource(index) : index; return m_model->widgetAt(unfilteredIndex); } QDesignerWidgetBoxInterface::Widget WidgetBoxCategoryListView::widgetAt(EAccessMode am, - int row) const -{ + int row) const { return m_model->widgetAt(am == UNFILTERED ? row : mapRowToSource(row)); } -void WidgetBoxCategoryListView::removeRow(EAccessMode am, int row) -{ +void WidgetBoxCategoryListView::removeRow(EAccessMode am, int row) { m_model->removeRow(am == UNFILTERED ? row : mapRowToSource(row)); } -bool WidgetBoxCategoryListView::containsWidget(const QString& name) -{ +bool WidgetBoxCategoryListView::containsWidget(const QString& name) { return m_model->indexOfWidget(name) != -1; } void WidgetBoxCategoryListView::addWidget(const QDesignerWidgetBoxInterface::Widget& widget, - const QIcon& icon, bool editable) -{ + const QIcon& icon, bool editable) { m_model->addWidget(widget, icon, editable); } -QString WidgetBoxCategoryListView::widgetDomXml(const QDesignerWidgetBoxInterface::Widget& widget) -{ +QString WidgetBoxCategoryListView::widgetDomXml(const QDesignerWidgetBoxInterface::Widget& widget) { QString domXml = widget.domXml(); if (domXml.isEmpty()) { @@ -537,18 +502,15 @@ QString WidgetBoxCategoryListView::widgetDomXml(const QDesignerWidgetBoxInterfac return domXml; } -void WidgetBoxCategoryListView::filter(const QRegExp& re) -{ +void WidgetBoxCategoryListView::filter(const QRegExp& re) { m_proxyModel->setFilterRegExp(re); } -QDesignerWidgetBoxInterface::Category WidgetBoxCategoryListView::category() const -{ +QDesignerWidgetBoxInterface::Category WidgetBoxCategoryListView::category() const { return m_model->category(); } -bool WidgetBoxCategoryListView::removeCustomWidgets() -{ +bool WidgetBoxCategoryListView::removeCustomWidgets() { return m_model->removeCustomWidgets(); } } // namespace qdesigner_internal diff --git a/GUI/coregui/Views/widgetbox/widgetboxcategorylistview.h b/GUI/coregui/Views/widgetbox/widgetboxcategorylistview.h index 3c3efc6928fd77ef69d6637fa571e06fe0fa5d4e..da7147a071a8660bb6b86cce0d3e934ba004c744 100644 --- a/GUI/coregui/Views/widgetbox/widgetboxcategorylistview.h +++ b/GUI/coregui/Views/widgetbox/widgetboxcategorylistview.h @@ -57,15 +57,13 @@ class QRegExp; class SampleDesignerInterface; -namespace qdesigner_internal -{ +namespace qdesigner_internal { class WidgetBoxCategoryModel; // List view of a category, switchable between icon and list mode. // Provides a filtered view. -class WidgetBoxCategoryListView : public QListView -{ +class WidgetBoxCategoryListView : public QListView { Q_OBJECT public: // Whether to access the filtered or unfiltered view diff --git a/GUI/coregui/Views/widgetbox/widgetboxtreewidget.cpp b/GUI/coregui/Views/widgetbox/widgetboxtreewidget.cpp index a3439cd39a851a993d84bd5700fe71d7cb1376ae..a4beefcc42663e8ba4a6e73473c2fea6f207ec60 100644 --- a/GUI/coregui/Views/widgetbox/widgetboxtreewidget.cpp +++ b/GUI/coregui/Views/widgetbox/widgetboxtreewidget.cpp @@ -87,8 +87,7 @@ static const char* scratchPadValueC = "scratchpad"; static const char* qtLogoC = "qtlogo.png"; static const char* invisibleNameC = "[invisible]"; -QIcon createIconSet(const QString& name) -{ +QIcon createIconSet(const QString& name) { return QIcon(QString::fromUtf8(":/widgetbox/") + name); } @@ -96,22 +95,18 @@ enum ETopLevelRole { NORMAL_ITEM, SCRATCHPAD_ITEM, CUSTOM_ITEM }; QT_BEGIN_NAMESPACE -static void setTopLevelRole(ETopLevelRole tlr, QTreeWidgetItem* item) -{ +static void setTopLevelRole(ETopLevelRole tlr, QTreeWidgetItem* item) { item->setData(0, Qt::UserRole, QVariant(tlr)); } -static ETopLevelRole topLevelRole(const QTreeWidgetItem* item) -{ +static ETopLevelRole topLevelRole(const QTreeWidgetItem* item) { return static_cast<ETopLevelRole>(item->data(0, Qt::UserRole).toInt()); } -namespace qdesigner_internal -{ +namespace qdesigner_internal { WidgetBoxTreeWidget::WidgetBoxTreeWidget(SampleDesignerInterface* core, QWidget* parent) - : QTreeWidget(parent), m_core(core), m_iconMode(false), m_scratchPadDeleteTimer(nullptr) -{ + : QTreeWidget(parent), m_core(core), m_iconMode(false), m_scratchPadDeleteTimer(nullptr) { setFocusPolicy(Qt::NoFocus); setIndentation(0); setRootIsDecorated(false); @@ -129,8 +124,7 @@ WidgetBoxTreeWidget::WidgetBoxTreeWidget(SampleDesignerInterface* core, QWidget* SLOT(handleMousePress(QTreeWidgetItem*))); } -QIcon WidgetBoxTreeWidget::iconForWidget(QString iconName) const -{ +QIcon WidgetBoxTreeWidget::iconForWidget(QString iconName) const { if (iconName.isEmpty()) iconName = QLatin1String(qtLogoC); @@ -142,8 +136,7 @@ QIcon WidgetBoxTreeWidget::iconForWidget(QString iconName) const return createIconSet(iconName); } -WidgetBoxCategoryListView* WidgetBoxTreeWidget::categoryViewAt(int idx) const -{ +WidgetBoxCategoryListView* WidgetBoxTreeWidget::categoryViewAt(int idx) const { WidgetBoxCategoryListView* rc = nullptr; if (QTreeWidgetItem* cat_item = topLevelItem(idx)) if (QTreeWidgetItem* embedItem = cat_item->child(0)) @@ -152,34 +145,28 @@ WidgetBoxCategoryListView* WidgetBoxTreeWidget::categoryViewAt(int idx) const return rc; } -void WidgetBoxTreeWidget::saveExpandedState() const -{ +void WidgetBoxTreeWidget::saveExpandedState() const { return; } -void WidgetBoxTreeWidget::restoreExpandedState() -{ +void WidgetBoxTreeWidget::restoreExpandedState() { std::cout << "WidgetBoxTreeWidget::restoreExpandedState() -> XXX Not implemented." << std::endl; return; } -WidgetBoxTreeWidget::~WidgetBoxTreeWidget() -{ +WidgetBoxTreeWidget::~WidgetBoxTreeWidget() { saveExpandedState(); } -void WidgetBoxTreeWidget::setFileName(const QString& file_name) -{ +void WidgetBoxTreeWidget::setFileName(const QString& file_name) { m_file_name = file_name; } -QString WidgetBoxTreeWidget::fileName() const -{ +QString WidgetBoxTreeWidget::fileName() const { return m_file_name; } -bool WidgetBoxTreeWidget::save() -{ +bool WidgetBoxTreeWidget::save() { if (fileName().isEmpty()) return false; @@ -202,13 +189,11 @@ bool WidgetBoxTreeWidget::save() return true; } -void WidgetBoxTreeWidget::slotSave() -{ +void WidgetBoxTreeWidget::slotSave() { save(); } -void WidgetBoxTreeWidget::handleMousePress(QTreeWidgetItem* item) -{ +void WidgetBoxTreeWidget::handleMousePress(QTreeWidgetItem* item) { if (item == nullptr) return; @@ -225,8 +210,7 @@ void WidgetBoxTreeWidget::handleMousePress(QTreeWidgetItem* item) } } -int WidgetBoxTreeWidget::ensureScratchpad() -{ +int WidgetBoxTreeWidget::ensureScratchpad() { const int existingIndex = indexOfScratchpad(); if (existingIndex != -1) return existingIndex; @@ -239,8 +223,7 @@ int WidgetBoxTreeWidget::ensureScratchpad() } WidgetBoxCategoryListView* WidgetBoxTreeWidget::addCategoryView(QTreeWidgetItem* parent, - bool iconMode) -{ + bool iconMode) { QTreeWidgetItem* embed_item = new QTreeWidgetItem(parent); embed_item->setFlags(Qt::ItemIsEnabled); WidgetBoxCategoryListView* categoryView = new WidgetBoxCategoryListView(m_core, this); @@ -254,8 +237,7 @@ WidgetBoxCategoryListView* WidgetBoxTreeWidget::addCategoryView(QTreeWidgetItem* return categoryView; } -int WidgetBoxTreeWidget::indexOfScratchpad() const -{ +int WidgetBoxTreeWidget::indexOfScratchpad() const { if (const int numTopLevels = topLevelItemCount()) { for (int i = numTopLevels - 1; i >= 0; --i) { if (topLevelRole(topLevelItem(i)) == SCRATCHPAD_ITEM) @@ -265,8 +247,7 @@ int WidgetBoxTreeWidget::indexOfScratchpad() const return -1; } -int WidgetBoxTreeWidget::indexOfCategory(const QString& name) const -{ +int WidgetBoxTreeWidget::indexOfCategory(const QString& name) const { const int topLevelCount = topLevelItemCount(); for (int i = 0; i < topLevelCount; ++i) { if (topLevelItem(i)->text(0) == name) @@ -275,8 +256,7 @@ int WidgetBoxTreeWidget::indexOfCategory(const QString& name) const return -1; } -bool WidgetBoxTreeWidget::load(QDesignerWidgetBox::LoadMode loadMode) -{ +bool WidgetBoxTreeWidget::load(QDesignerWidgetBox::LoadMode loadMode) { switch (loadMode) { case QDesignerWidgetBox::LoadReplace: clear(); @@ -298,8 +278,7 @@ bool WidgetBoxTreeWidget::load(QDesignerWidgetBox::LoadMode loadMode) return loadContents(contents); } -bool WidgetBoxTreeWidget::loadContents(const QString& contents) -{ +bool WidgetBoxTreeWidget::loadContents(const QString& contents) { QString errorMessage; CategoryList cat_list; if (!readCategories(m_file_name, contents, &cat_list, &errorMessage)) { @@ -312,8 +291,7 @@ bool WidgetBoxTreeWidget::loadContents(const QString& contents) return true; } -void WidgetBoxTreeWidget::addCustomCategories(bool replace) -{ +void WidgetBoxTreeWidget::addCustomCategories(bool replace) { if (replace) { // clear out all existing custom widgets if (const int numTopLevels = topLevelItemCount()) { @@ -328,16 +306,14 @@ void WidgetBoxTreeWidget::addCustomCategories(bool replace) addCategory(*it); } -static inline QString msgXmlError(const QString& fileName, const QXmlStreamReader& r) -{ +static inline QString msgXmlError(const QString& fileName, const QXmlStreamReader& r) { return QString("An error has been encountered at line %1 of %2: %3") .arg(r.lineNumber()) .arg(fileName, r.errorString()); } bool WidgetBoxTreeWidget::readCategories(const QString& fileName, const QString& contents, - CategoryList* cats, QString* errorMessage) -{ + CategoryList* cats, QString* errorMessage) { // Read widget box XML: // //<widgetbox version="4.5"> @@ -450,8 +426,7 @@ bool WidgetBoxTreeWidget::readCategories(const QString& fileName, const QString& * in which case the reader has its error flag set. If successful, the current item * of the reader will be the closing element (</ui> or </widget>) */ -bool WidgetBoxTreeWidget::readWidget(Widget* w, const QString& xml, QXmlStreamReader& r) -{ +bool WidgetBoxTreeWidget::readWidget(Widget* w, const QString& xml, QXmlStreamReader& r) { qint64 startTagPosition = 0, endTagPosition = 0; int nesting = 0; @@ -515,8 +490,7 @@ bool WidgetBoxTreeWidget::readWidget(Widget* w, const QString& xml, QXmlStreamRe } void WidgetBoxTreeWidget::writeCategories(QXmlStreamWriter& writer, - const CategoryList& cat_list) const -{ + const CategoryList& cat_list) const { const QString widgetbox = QLatin1String(widgetBoxRootElementC); const QString name = QLatin1String(nameAttributeC); const QString type = QLatin1String(typeAttributeC); @@ -574,8 +548,7 @@ void WidgetBoxTreeWidget::writeCategories(QXmlStreamWriter& writer, writer.writeEndElement(); // widgetBox } -WidgetBoxTreeWidget::CategoryList WidgetBoxTreeWidget::loadCustomCategoryList() const -{ +WidgetBoxTreeWidget::CategoryList WidgetBoxTreeWidget::loadCustomCategoryList() const { CategoryList result; std::cout << "WidgetBoxTreeWidget::loadCustomCategoryList() -> XXX Not implemented." @@ -583,8 +556,7 @@ WidgetBoxTreeWidget::CategoryList WidgetBoxTreeWidget::loadCustomCategoryList() return result; } -void WidgetBoxTreeWidget::adjustSubListSize(QTreeWidgetItem* cat_item) -{ +void WidgetBoxTreeWidget::adjustSubListSize(QTreeWidgetItem* cat_item) { QTreeWidgetItem* embedItem = cat_item->child(0); if (embedItem == nullptr) return; @@ -598,13 +570,11 @@ void WidgetBoxTreeWidget::adjustSubListSize(QTreeWidgetItem* cat_item) embedItem->setSizeHint(0, QSize(-1, height - 1)); } -int WidgetBoxTreeWidget::categoryCount() const -{ +int WidgetBoxTreeWidget::categoryCount() const { return topLevelItemCount(); } -WidgetBoxTreeWidget::Category WidgetBoxTreeWidget::category(int cat_idx) const -{ +WidgetBoxTreeWidget::Category WidgetBoxTreeWidget::category(int cat_idx) const { if (cat_idx >= topLevelItemCount()) return Category(); @@ -628,8 +598,7 @@ WidgetBoxTreeWidget::Category WidgetBoxTreeWidget::category(int cat_idx) const return result; } -void WidgetBoxTreeWidget::addCategory(const Category& cat) -{ +void WidgetBoxTreeWidget::addCategory(const Category& cat) { if (cat.widgetCount() == 0) return; @@ -676,23 +645,20 @@ void WidgetBoxTreeWidget::addCategory(const Category& cat) adjustSubListSize(cat_item); } -void WidgetBoxTreeWidget::removeCategory(int cat_idx) -{ +void WidgetBoxTreeWidget::removeCategory(int cat_idx) { if (cat_idx >= topLevelItemCount()) return; delete takeTopLevelItem(cat_idx); } -int WidgetBoxTreeWidget::widgetCount(int cat_idx) const -{ +int WidgetBoxTreeWidget::widgetCount(int cat_idx) const { if (cat_idx >= topLevelItemCount()) return 0; // SDK functions want unfiltered access return categoryViewAt(cat_idx)->count(WidgetBoxCategoryListView::UNFILTERED); } -WidgetBoxTreeWidget::Widget WidgetBoxTreeWidget::widget(int cat_idx, int wgt_idx) const -{ +WidgetBoxTreeWidget::Widget WidgetBoxTreeWidget::widget(int cat_idx, int wgt_idx) const { if (cat_idx >= topLevelItemCount()) return Widget(); // SDK functions want unfiltered access @@ -700,8 +666,7 @@ WidgetBoxTreeWidget::Widget WidgetBoxTreeWidget::widget(int cat_idx, int wgt_idx return categoryView->widgetAt(WidgetBoxCategoryListView::UNFILTERED, wgt_idx); } -void WidgetBoxTreeWidget::addWidget(int cat_idx, const Widget& wgt) -{ +void WidgetBoxTreeWidget::addWidget(int cat_idx, const Widget& wgt) { if (cat_idx >= topLevelItemCount()) return; @@ -713,8 +678,7 @@ void WidgetBoxTreeWidget::addWidget(int cat_idx, const Widget& wgt) adjustSubListSize(cat_item); } -void WidgetBoxTreeWidget::removeWidget(int cat_idx, int wgt_idx) -{ +void WidgetBoxTreeWidget::removeWidget(int cat_idx, int wgt_idx) { if (cat_idx >= topLevelItemCount()) return; @@ -728,16 +692,14 @@ void WidgetBoxTreeWidget::removeWidget(int cat_idx, int wgt_idx) categoryView->removeRow(am, wgt_idx); } -void WidgetBoxTreeWidget::slotScratchPadItemDeleted() -{ +void WidgetBoxTreeWidget::slotScratchPadItemDeleted() { const int scratch_idx = indexOfScratchpad(); QTreeWidgetItem* scratch_item = topLevelItem(scratch_idx); adjustSubListSize(scratch_item); save(); } -void WidgetBoxTreeWidget::slotLastScratchPadItemDeleted() -{ +void WidgetBoxTreeWidget::slotLastScratchPadItemDeleted() { // Remove the scratchpad in the next idle loop if (!m_scratchPadDeleteTimer) { m_scratchPadDeleteTimer = new QTimer(this); @@ -749,8 +711,7 @@ void WidgetBoxTreeWidget::slotLastScratchPadItemDeleted() m_scratchPadDeleteTimer->start(); } -void WidgetBoxTreeWidget::deleteScratchpad() -{ +void WidgetBoxTreeWidget::deleteScratchpad() { const int idx = indexOfScratchpad(); if (idx == -1) return; @@ -758,20 +719,17 @@ void WidgetBoxTreeWidget::deleteScratchpad() save(); } -void WidgetBoxTreeWidget::slotListMode() -{ +void WidgetBoxTreeWidget::slotListMode() { m_iconMode = false; updateViewMode(); } -void WidgetBoxTreeWidget::slotIconMode() -{ +void WidgetBoxTreeWidget::slotIconMode() { m_iconMode = true; updateViewMode(); } -void WidgetBoxTreeWidget::updateViewMode() -{ +void WidgetBoxTreeWidget::updateViewMode() { if (const int numTopLevels = topLevelItemCount()) { for (int i = numTopLevels - 1; i >= 0; --i) { QTreeWidgetItem* topLevel = topLevelItem(i); @@ -789,8 +747,7 @@ void WidgetBoxTreeWidget::updateViewMode() updateGeometries(); } -void WidgetBoxTreeWidget::resizeEvent(QResizeEvent* e) -{ +void WidgetBoxTreeWidget::resizeEvent(QResizeEvent* e) { QTreeWidget::resizeEvent(e); if (const int numTopLevels = topLevelItemCount()) { for (int i = numTopLevels - 1; i >= 0; --i) @@ -798,8 +755,7 @@ void WidgetBoxTreeWidget::resizeEvent(QResizeEvent* e) } } -void WidgetBoxTreeWidget::contextMenuEvent(QContextMenuEvent* e) -{ +void WidgetBoxTreeWidget::contextMenuEvent(QContextMenuEvent* e) { QTreeWidgetItem* item = itemAt(e->pos()); const bool scratchpad_menu = item != nullptr && item->parent() != nullptr @@ -834,8 +790,7 @@ void WidgetBoxTreeWidget::contextMenuEvent(QContextMenuEvent* e) menu.exec(mapToGlobal(e->pos())); } -void WidgetBoxTreeWidget::dropWidgets(const QList<QDesignerDnDItemInterface*>& item_list) -{ +void WidgetBoxTreeWidget::dropWidgets(const QList<QDesignerDnDItemInterface*>& item_list) { QTreeWidgetItem* scratch_item = nullptr; WidgetBoxCategoryListView* categoryView = nullptr; bool added = false; @@ -899,8 +854,7 @@ void WidgetBoxTreeWidget::dropWidgets(const QList<QDesignerDnDItemInterface*>& i } } -void WidgetBoxTreeWidget::filter(const QString& f) -{ +void WidgetBoxTreeWidget::filter(const QString& f) { const bool empty = f.isEmpty(); QRegExp re = empty ? QRegExp() : QRegExp(f, Qt::CaseInsensitive, QRegExp::FixedString); const int numTopLevels = topLevelItemCount(); diff --git a/GUI/coregui/Views/widgetbox/widgetboxtreewidget.h b/GUI/coregui/Views/widgetbox/widgetboxtreewidget.h index 4e7c131b437aab4c6c1a96ee1ac062e1556dbf7e..035f9af3e417e39f51071feb5899ff98f9558c7d 100644 --- a/GUI/coregui/Views/widgetbox/widgetboxtreewidget.h +++ b/GUI/coregui/Views/widgetbox/widgetboxtreewidget.h @@ -60,14 +60,12 @@ class QTimer; class SampleDesignerInterface; -namespace qdesigner_internal -{ +namespace qdesigner_internal { class WidgetBoxCategoryListView; //! WidgetBoxTreeWidget: A tree of categories -class WidgetBoxTreeWidget : public QTreeWidget -{ +class WidgetBoxTreeWidget : public QTreeWidget { Q_OBJECT public: diff --git a/GUI/coregui/mainwindow/AppSvc.cpp b/GUI/coregui/mainwindow/AppSvc.cpp index fbc9643d2b6a62c3c83aef71f4f4f34bb403af9f..532cc05b5c6cee7b2617638367739c9aaa3d344d 100644 --- a/GUI/coregui/mainwindow/AppSvc.cpp +++ b/GUI/coregui/mainwindow/AppSvc.cpp @@ -15,40 +15,33 @@ #include "GUI/coregui/mainwindow/AppSvc.h" #include "GUI/coregui/utils/GUIHelpers.h" -ProjectManager* AppSvc::projectManager() -{ +ProjectManager* AppSvc::projectManager() { return instance().this_projectManager(); } -void AppSvc::subscribe(ProjectManager* projectManager) -{ +void AppSvc::subscribe(ProjectManager* projectManager) { return instance().this_subscribe(projectManager); } -void AppSvc::unsubscribe(ProjectManager* projectManager) -{ +void AppSvc::unsubscribe(ProjectManager* projectManager) { instance().this_unsubscribe(projectManager); } -MaterialModel* AppSvc::materialModel() -{ +MaterialModel* AppSvc::materialModel() { return instance().this_materialModel(); } -void AppSvc::subscribe(MaterialModel* materialModel) -{ +void AppSvc::subscribe(MaterialModel* materialModel) { return instance().this_subscribe(materialModel); } -void AppSvc::unsubscribe(MaterialModel* materialModel) -{ +void AppSvc::unsubscribe(MaterialModel* materialModel) { instance().this_unsubscribe(materialModel); } AppSvc::AppSvc() : m_projectManager(nullptr), m_materialModel(nullptr) {} -ProjectManager* AppSvc::this_projectManager() -{ +ProjectManager* AppSvc::this_projectManager() { if (!m_projectManager) throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to access " "non existing ProjectManager."); @@ -56,13 +49,11 @@ ProjectManager* AppSvc::this_projectManager() return m_projectManager; } -MaterialModel* AppSvc::this_materialModel() -{ +MaterialModel* AppSvc::this_materialModel() { return m_materialModel; } -void AppSvc::this_subscribe(ProjectManager* projectManager) -{ +void AppSvc::this_subscribe(ProjectManager* projectManager) { if (m_projectManager != nullptr) throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to subscribe " "ProjectManager twice."); @@ -70,8 +61,7 @@ void AppSvc::this_subscribe(ProjectManager* projectManager) m_projectManager = projectManager; } -void AppSvc::this_unsubscribe(ProjectManager* projectManager) -{ +void AppSvc::this_unsubscribe(ProjectManager* projectManager) { if (m_projectManager != projectManager) throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to unsubscribe " "ProjectManager before it was subscribed."); @@ -79,8 +69,7 @@ void AppSvc::this_unsubscribe(ProjectManager* projectManager) m_projectManager = nullptr; } -void AppSvc::this_subscribe(MaterialModel* materialModel) -{ +void AppSvc::this_subscribe(MaterialModel* materialModel) { if (m_materialModel) throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to subscribe " "MaterialModel twice."); @@ -88,8 +77,7 @@ void AppSvc::this_subscribe(MaterialModel* materialModel) m_materialModel = materialModel; } -void AppSvc::this_unsubscribe(MaterialModel* materialModel) -{ +void AppSvc::this_unsubscribe(MaterialModel* materialModel) { if (m_materialModel != materialModel) throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to unsubscribe " "MaterialModel before it was subscribed."); diff --git a/GUI/coregui/mainwindow/AppSvc.h b/GUI/coregui/mainwindow/AppSvc.h index 6e625182d290b02012b81fd4483bb3f027a710d4..444b151d9af987f4b820426a2ae695d700314690 100644 --- a/GUI/coregui/mainwindow/AppSvc.h +++ b/GUI/coregui/mainwindow/AppSvc.h @@ -22,8 +22,7 @@ class MaterialModel; //! The AppSvc class provides common access for key components of the GUI. -class AppSvc : public ISingleton<AppSvc> -{ +class AppSvc : public ISingleton<AppSvc> { friend class ISingleton<AppSvc>; public: diff --git a/GUI/coregui/mainwindow/AutosaveController.cpp b/GUI/coregui/mainwindow/AutosaveController.cpp index bc03edefcf580c1e24d3e069fc74960664b236b8..2a194683d2c0a974d36abdd5a8a64e6cc88eb628 100644 --- a/GUI/coregui/mainwindow/AutosaveController.cpp +++ b/GUI/coregui/mainwindow/AutosaveController.cpp @@ -19,19 +19,16 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include <QDir> -namespace -{ +namespace { const int update_every = 20000; // in msec } AutosaveController::AutosaveController(QObject* parent) - : QObject(parent), m_document(0), m_timer(new UpdateTimer(update_every, this)) -{ + : QObject(parent), m_document(0), m_timer(new UpdateTimer(update_every, this)) { connect(m_timer, SIGNAL(timeToUpdate()), this, SLOT(onTimerTimeout())); } -void AutosaveController::setDocument(ProjectDocument* document) -{ +void AutosaveController::setDocument(ProjectDocument* document) { if (document == m_document) return; @@ -48,32 +45,28 @@ void AutosaveController::setDocument(ProjectDocument* document) onDocumentModified(); } -void AutosaveController::setAutosaveTime(int timerInterval) -{ +void AutosaveController::setAutosaveTime(int timerInterval) { m_timer->reset(); m_timer->setWallclockTimer(timerInterval); } //! Returns the name of autosave directory. -QString AutosaveController::autosaveDir() const -{ +QString AutosaveController::autosaveDir() const { if (m_document && m_document->hasValidNameAndPath()) return ProjectUtils::autosaveDir(m_document->projectFileName()); return ""; } -QString AutosaveController::autosaveName() const -{ +QString AutosaveController::autosaveName() const { if (m_document && m_document->hasValidNameAndPath()) return ProjectUtils::autosaveName(m_document->projectFileName()); return ""; } -void AutosaveController::removeAutosaveDir() -{ +void AutosaveController::removeAutosaveDir() { if (autosaveDir().isEmpty()) return; @@ -81,21 +74,18 @@ void AutosaveController::removeAutosaveDir() dir.removeRecursively(); } -void AutosaveController::onTimerTimeout() -{ +void AutosaveController::onTimerTimeout() { if (m_document->isModified()) autosave(); } -void AutosaveController::onDocumentDestroyed(QObject* object) -{ +void AutosaveController::onDocumentDestroyed(QObject* object) { Q_UNUSED(object); m_timer->reset(); m_document = 0; } -void AutosaveController::onDocumentModified() -{ +void AutosaveController::onDocumentModified() { if (!m_document) return; @@ -103,8 +93,7 @@ void AutosaveController::onDocumentModified() m_timer->scheduleUpdate(); } -void AutosaveController::autosave() -{ +void AutosaveController::autosave() { QString name = autosaveName(); if (!name.isEmpty()) { GUIHelpers::createSubdir(m_document->projectDir(), ProjectUtils::autosaveSubdir()); @@ -112,8 +101,7 @@ void AutosaveController::autosave() } } -void AutosaveController::setDocumentConnected(bool set_connected) -{ +void AutosaveController::setDocumentConnected(bool set_connected) { if (!m_document) return; diff --git a/GUI/coregui/mainwindow/AutosaveController.h b/GUI/coregui/mainwindow/AutosaveController.h index afc6f2d5023bf930945eec25d18cb12abf37bd55..f3ce69e01a4bb1f4178404a1f87d164cd3d8374d 100644 --- a/GUI/coregui/mainwindow/AutosaveController.h +++ b/GUI/coregui/mainwindow/AutosaveController.h @@ -22,8 +22,7 @@ class UpdateTimer; //! Triggers autosave request after some accumulated ammount of document changes. -class AutosaveController : public QObject -{ +class AutosaveController : public QObject { Q_OBJECT public: explicit AutosaveController(QObject* parent = 0); diff --git a/GUI/coregui/mainwindow/ISingleton.h b/GUI/coregui/mainwindow/ISingleton.h index 90b61c157cd0002600307088b48fad2678fdc8b5..4fb3417d7d9cfe934f4b615cfbfcde624c4eda2b 100644 --- a/GUI/coregui/mainwindow/ISingleton.h +++ b/GUI/coregui/mainwindow/ISingleton.h @@ -18,11 +18,9 @@ //! Base class for singletons. //! @ingroup tools_internal -template <class T> class ISingleton -{ +template <class T> class ISingleton { public: - static T& instance() - { + static T& instance() { static T m_instance; return m_instance; } diff --git a/GUI/coregui/mainwindow/OutputDataIOHistory.cpp b/GUI/coregui/mainwindow/OutputDataIOHistory.cpp index 39fe31d007bb41595d62b3ebd97b4daa19d3732a..f124d672821698ba8f9362ad1a33003bcdf8f00c 100644 --- a/GUI/coregui/mainwindow/OutputDataIOHistory.cpp +++ b/GUI/coregui/mainwindow/OutputDataIOHistory.cpp @@ -19,8 +19,7 @@ //! Static method to create info for just saved item. -OutputDataSaveInfo OutputDataSaveInfo::createSaved(const SaveLoadInterface* item) -{ +OutputDataSaveInfo OutputDataSaveInfo::createSaved(const SaveLoadInterface* item) { ASSERT(item); OutputDataSaveInfo result; @@ -30,23 +29,20 @@ OutputDataSaveInfo OutputDataSaveInfo::createSaved(const SaveLoadInterface* item return result; } -bool OutputDataSaveInfo::wasModifiedSinceLastSave() const -{ +bool OutputDataSaveInfo::wasModifiedSinceLastSave() const { return wasSavedBefore(m_data->lastModified()); } //! Returns true if IntensityDataItem was saved before given time. -bool OutputDataSaveInfo::wasSavedBefore(const QDateTime& dtime) const -{ +bool OutputDataSaveInfo::wasSavedBefore(const QDateTime& dtime) const { // positive number means that m_last_saved is older than dtime return m_last_saved.msecsTo(dtime) > 0; } //----------------------------------------------------------------------------- -void OutputDataDirHistory::markAsSaved(const SaveLoadInterface* item) -{ +void OutputDataDirHistory::markAsSaved(const SaveLoadInterface* item) { if (contains(item)) throw GUIHelpers::Error("OutputDataDirHistory::markAsSaved() -> Error. " "Already existing item."); @@ -55,14 +51,12 @@ void OutputDataDirHistory::markAsSaved(const SaveLoadInterface* item) m_history.push_back(OutputDataSaveInfo::createSaved(item)); } -bool OutputDataDirHistory::wasModifiedSinceLastSave(const SaveLoadInterface* item) -{ +bool OutputDataDirHistory::wasModifiedSinceLastSave(const SaveLoadInterface* item) { // non existing item is treated as modified since last save return contains(item) ? itemInfo(item).wasModifiedSinceLastSave() : true; } -bool OutputDataDirHistory::contains(const SaveLoadInterface* item) -{ +bool OutputDataDirHistory::contains(const SaveLoadInterface* item) { for (auto& info : m_history) if (info.item() == item) return true; @@ -72,8 +66,7 @@ bool OutputDataDirHistory::contains(const SaveLoadInterface* item) //! Returns list of file names used to save all items in a history. -QStringList OutputDataDirHistory::savedFileNames() const -{ +QStringList OutputDataDirHistory::savedFileNames() const { QStringList result; for (auto& info : m_history) @@ -82,8 +75,7 @@ QStringList OutputDataDirHistory::savedFileNames() const return result; } -OutputDataSaveInfo OutputDataDirHistory::itemInfo(const SaveLoadInterface* item) const -{ +OutputDataSaveInfo OutputDataDirHistory::itemInfo(const SaveLoadInterface* item) const { for (auto& info : m_history) { if (info.item() == item) return info; @@ -94,14 +86,12 @@ OutputDataSaveInfo OutputDataDirHistory::itemInfo(const SaveLoadInterface* item) //----------------------------------------------------------------------------- -bool OutputDataIOHistory::hasHistory(const QString& dirname) const -{ +bool OutputDataIOHistory::hasHistory(const QString& dirname) const { return m_dir_history.find(dirname) == m_dir_history.end() ? false : true; } bool OutputDataIOHistory::wasModifiedSinceLastSave(const QString& dirname, - const SaveLoadInterface* item) -{ + const SaveLoadInterface* item) { if (!hasHistory(dirname)) throw GUIHelpers::Error("OutputDataIOHistory::wasModifiedSinceLastSave() -> Error. " "No info for directory '" @@ -111,15 +101,13 @@ bool OutputDataIOHistory::wasModifiedSinceLastSave(const QString& dirname, //! Sets history for given directory. Previous history will be rewritten. -void OutputDataIOHistory::setHistory(const QString& dirname, const OutputDataDirHistory& history) -{ +void OutputDataIOHistory::setHistory(const QString& dirname, const OutputDataDirHistory& history) { ASSERT(dirname.isEmpty() == false); m_dir_history[dirname] = history; } -QStringList OutputDataIOHistory::savedFileNames(const QString& dirname) const -{ +QStringList OutputDataIOHistory::savedFileNames(const QString& dirname) const { if (!hasHistory(dirname)) throw GUIHelpers::Error("OutputDataIOHistory::savedFileNames() -> Error. " "No info for directory '" diff --git a/GUI/coregui/mainwindow/OutputDataIOHistory.h b/GUI/coregui/mainwindow/OutputDataIOHistory.h index 85a0305252088b563ffa20317b62f1dbe5f98fd7..b65a35f1639192a0132bacb2a11c7556beeece93 100644 --- a/GUI/coregui/mainwindow/OutputDataIOHistory.h +++ b/GUI/coregui/mainwindow/OutputDataIOHistory.h @@ -23,8 +23,7 @@ class SaveLoadInterface; //! Holds information about last save for items with non-XML data. -class OutputDataSaveInfo -{ +class OutputDataSaveInfo { public: OutputDataSaveInfo() : m_data(nullptr) {} @@ -46,8 +45,7 @@ private: //! Save history information for collection of items with non-XML data. -class OutputDataDirHistory -{ +class OutputDataDirHistory { public: OutputDataDirHistory() {} @@ -67,8 +65,7 @@ private: //! Save history information for set of directories. -class OutputDataIOHistory -{ +class OutputDataIOHistory { public: bool hasHistory(const QString& dirname) const; diff --git a/GUI/coregui/mainwindow/OutputDataIOService.cpp b/GUI/coregui/mainwindow/OutputDataIOService.cpp index fb956c67687eb45a721779bb6fe0adcea667ace7..87a8f902db8cf4c120215ef0e98ed6075b5e211c 100644 --- a/GUI/coregui/mainwindow/OutputDataIOService.cpp +++ b/GUI/coregui/mainwindow/OutputDataIOService.cpp @@ -21,31 +21,26 @@ #include "GUI/coregui/mainwindow/SaveLoadInterface.h" #include "GUI/coregui/utils/MessageService.h" -namespace -{ +namespace { JobItem* parentJobItem(SaveLoadInterface* item); } // namespace OutputDataIOService::OutputDataIOService(QObject* parent) - : QObject(parent), m_applicationModels(nullptr) -{ + : QObject(parent), m_applicationModels(nullptr) { setObjectName("OutputDataIOService"); } OutputDataIOService::OutputDataIOService(ApplicationModels* models, QObject* parent) - : QObject(parent), m_applicationModels(nullptr) -{ + : QObject(parent), m_applicationModels(nullptr) { setObjectName("OutputDataIOService"); setApplicationModels(models); } -void OutputDataIOService::setApplicationModels(ApplicationModels* models) -{ +void OutputDataIOService::setApplicationModels(ApplicationModels* models) { m_applicationModels = models; } -void OutputDataIOService::save(const QString& projectDir) -{ +void OutputDataIOService::save(const QString& projectDir) { if (!m_history.hasHistory(projectDir)) m_history.setHistory(projectDir, OutputDataDirHistory()); @@ -66,8 +61,7 @@ void OutputDataIOService::save(const QString& projectDir) m_history.setHistory(projectDir, newHistory); } -void OutputDataIOService::load(const QString& projectDir, MessageService* messageService) -{ +void OutputDataIOService::load(const QString& projectDir, MessageService* messageService) { OutputDataDirHistory newHistory; for (auto item : nonXMLItems()) { @@ -100,8 +94,7 @@ void OutputDataIOService::load(const QString& projectDir, MessageService* messag //! Returns all non-XML items available for save/load. -QVector<SaveLoadInterface*> OutputDataIOService::nonXMLItems() const -{ +QVector<SaveLoadInterface*> OutputDataIOService::nonXMLItems() const { QVector<SaveLoadInterface*> result; if (!m_applicationModels) @@ -118,16 +111,13 @@ QVector<SaveLoadInterface*> OutputDataIOService::nonXMLItems() const //! All files in oldSaves list, which are not in newSaves list, will be removed. void OutputDataIOService::cleanOldFiles(const QString& projectDir, const QStringList& oldSaves, - const QStringList& newSaves) -{ + const QStringList& newSaves) { QStringList to_remove = ProjectUtils::substract(oldSaves, newSaves); ProjectUtils::removeFiles(projectDir, to_remove); } -namespace -{ -JobItem* parentJobItem(SaveLoadInterface* item) -{ +namespace { +JobItem* parentJobItem(SaveLoadInterface* item) { auto session_item = dynamic_cast<SessionItem*>(item); // sidecast auto jobItem = dynamic_cast<const JobItem*>(ModelPath::ancestor(session_item, "JobItem")); return const_cast<JobItem*>(jobItem); diff --git a/GUI/coregui/mainwindow/OutputDataIOService.h b/GUI/coregui/mainwindow/OutputDataIOService.h index fe29265a90e58908002ec17bc72ca90a8e352d85..d371ba64f4b341aad07b8ec9423175e59201fbbb 100644 --- a/GUI/coregui/mainwindow/OutputDataIOService.h +++ b/GUI/coregui/mainwindow/OutputDataIOService.h @@ -27,8 +27,7 @@ class SaveLoadInterface; //! Listens all models and keep tracks of changes in items. Provides logic to //! not to re-save already saved data. -class OutputDataIOService : public QObject -{ +class OutputDataIOService : public QObject { Q_OBJECT public: explicit OutputDataIOService(QObject* parent = nullptr); diff --git a/GUI/coregui/mainwindow/ProjectFlags.h b/GUI/coregui/mainwindow/ProjectFlags.h index 2eecae7ae7afacbcb322850586a90287a220a4ee..2d6fbe2b5095d307508d3a1c054cfb3ad437537e 100644 --- a/GUI/coregui/mainwindow/ProjectFlags.h +++ b/GUI/coregui/mainwindow/ProjectFlags.h @@ -17,8 +17,7 @@ #include <QFlags> -class ProjectFlags -{ +class ProjectFlags { public: enum EDocumentStatus { STATUS_OK = 0x0001, @@ -28,8 +27,7 @@ public: Q_DECLARE_FLAGS(DocumentStatus, EDocumentStatus) - static void setFlag(ProjectFlags::DocumentStatus& flags, EDocumentStatus status) - { + static void setFlag(ProjectFlags::DocumentStatus& flags, EDocumentStatus status) { flags |= status; } }; diff --git a/GUI/coregui/mainwindow/ProjectUtils.cpp b/GUI/coregui/mainwindow/ProjectUtils.cpp index f916c3658a354692ee91168adb78e4a582f35251..4da93f5df29a895fe4bcc44ff273a0c0ee4da516 100644 --- a/GUI/coregui/mainwindow/ProjectUtils.cpp +++ b/GUI/coregui/mainwindow/ProjectUtils.cpp @@ -23,57 +23,48 @@ #include <QDir> #include <QFileInfo> -QString ProjectUtils::projectName(const QString& projectFileName) -{ +QString ProjectUtils::projectName(const QString& projectFileName) { QFileInfo info(projectFileName); return info.baseName(); } -QString ProjectUtils::projectDir(const QString& projectFileName) -{ +QString ProjectUtils::projectDir(const QString& projectFileName) { QFileInfo info(projectFileName); return info.path(); } -QString ProjectUtils::autosaveSubdir() -{ +QString ProjectUtils::autosaveSubdir() { return "autosave"; } //! From '/projects/Untitled2/Untitled2.pro' returns '/projects/Untitled2/autosave'. -QString ProjectUtils::autosaveDir(const QString& projectFileName) -{ +QString ProjectUtils::autosaveDir(const QString& projectFileName) { return ProjectUtils::projectDir(projectFileName) + "/" + autosaveSubdir(); } //! From '/projects/Untitled2/Untitled2.pro' returns '/projects/Untitled2/autosave/Untitled2.pro'. -QString ProjectUtils::autosaveName(const QString& projectFileName) -{ +QString ProjectUtils::autosaveName(const QString& projectFileName) { return ProjectUtils::autosaveDir(projectFileName) + "/" + ProjectUtils::projectName(projectFileName) + ProjectDocument::projectFileExtension(); } -bool ProjectUtils::exists(const QString& fileName) -{ +bool ProjectUtils::exists(const QString& fileName) { QFileInfo info(fileName); return info.exists(); } -bool ProjectUtils::hasAutosavedData(const QString& projectFileName) -{ +bool ProjectUtils::hasAutosavedData(const QString& projectFileName) { return exists(projectFileName) && exists(autosaveName(projectFileName)); } -QString ProjectUtils::lastModified(const QString& fileName) -{ +QString ProjectUtils::lastModified(const QString& fileName) { QFileInfo info(fileName); return info.lastModified().toString("hh:mm:ss, MMMM d, yyyy"); } -QStringList ProjectUtils::nonXMLDataInDir(const QString& dirname) -{ +QStringList ProjectUtils::nonXMLDataInDir(const QString& dirname) { QDir dir(dirname); if (!dir.exists()) @@ -84,8 +75,7 @@ QStringList ProjectUtils::nonXMLDataInDir(const QString& dirname) return dir.entryList(ItemFileNameUtils::nonXMLFileNameFilters()); } -bool ProjectUtils::removeRecursively(const QString& dirname) -{ +bool ProjectUtils::removeRecursively(const QString& dirname) { QDir dir(dirname); if (!dir.exists()) @@ -96,8 +86,7 @@ bool ProjectUtils::removeRecursively(const QString& dirname) return dir.removeRecursively(); } -bool ProjectUtils::removeFile(const QString& dirname, const QString& filename) -{ +bool ProjectUtils::removeFile(const QString& dirname, const QString& filename) { QString name = dirname + "/" + filename; QFile fin(name); @@ -109,8 +98,7 @@ bool ProjectUtils::removeFile(const QString& dirname, const QString& filename) return fin.remove(); } -bool ProjectUtils::removeFiles(const QString& dirname, const QStringList& filenames) -{ +bool ProjectUtils::removeFiles(const QString& dirname, const QStringList& filenames) { bool success(true); for (auto& name : filenames) @@ -119,8 +107,7 @@ bool ProjectUtils::removeFiles(const QString& dirname, const QStringList& filena return success; } -QStringList ProjectUtils::substract(const QStringList& lhs, const QStringList& rhs) -{ +QStringList ProjectUtils::substract(const QStringList& lhs, const QStringList& rhs) { #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) auto lhs_set = QSet<QString>{lhs.begin(), lhs.end()}; auto rhs_set = QSet<QString>{rhs.begin(), rhs.end()}; @@ -132,8 +119,7 @@ QStringList ProjectUtils::substract(const QStringList& lhs, const QStringList& r #endif } -QString ProjectUtils::readTextFile(const QString& fileName) -{ +QString ProjectUtils::readTextFile(const QString& fileName) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) throw GUIHelpers::Error("ProjectUtils::readTextFile -> Error. Can't open the file '" @@ -142,7 +128,6 @@ QString ProjectUtils::readTextFile(const QString& fileName) return in.readAll(); } -QString ProjectUtils::userExportDir() -{ +QString ProjectUtils::userExportDir() { return AppSvc::projectManager()->userExportDir(); } diff --git a/GUI/coregui/mainwindow/ProjectUtils.h b/GUI/coregui/mainwindow/ProjectUtils.h index 2241f1670211d1e59dde775170b1a6393f12f8c3..f088db375779084598d37bce261fa20c3eb279bd 100644 --- a/GUI/coregui/mainwindow/ProjectUtils.h +++ b/GUI/coregui/mainwindow/ProjectUtils.h @@ -19,8 +19,7 @@ //! Defines convenience function for project manager and document. -namespace ProjectUtils -{ +namespace ProjectUtils { //! Returns project name deduced from project file name. QString projectName(const QString& projectFileName); diff --git a/GUI/coregui/mainwindow/PyImportAssistant.cpp b/GUI/coregui/mainwindow/PyImportAssistant.cpp index a79b32ebde68c523c3f89f529f35303b31e23035..021d70b6f92bf48803c31a7949cf8c33db649ac3 100644 --- a/GUI/coregui/mainwindow/PyImportAssistant.cpp +++ b/GUI/coregui/mainwindow/PyImportAssistant.cpp @@ -32,14 +32,12 @@ #include <QFileDialog> #include <QTextStream> -namespace -{ +namespace { //! Returns directory with BornAgain library. If PYTHONPATH is not empty, //! returns an empty string. -std::string bornagainDir() -{ +std::string bornagainDir() { std::string pythonPath = SysUtils::getenv("PYTHONPATH"); return pythonPath.empty() ? BABuild::buildLibDir() : std::string(); } @@ -47,8 +45,7 @@ std::string bornagainDir() //! Returns a name from the list which looks like a function name intended for sample //! creation. -QString getCandidate(const QStringList& funcNames) -{ +QString getCandidate(const QStringList& funcNames) { if (funcNames.isEmpty()) return ""; @@ -63,12 +60,10 @@ QString getCandidate(const QStringList& funcNames) } // namespace -PyImportAssistant::PyImportAssistant(MainWindow* mainwin) : QObject(mainwin), m_mainWindow(mainwin) -{ -} +PyImportAssistant::PyImportAssistant(MainWindow* mainwin) + : QObject(mainwin), m_mainWindow(mainwin) {} -void PyImportAssistant::exec() -{ +void PyImportAssistant::exec() { auto fileName = fileNameToOpen(); if (fileName.isEmpty()) @@ -91,8 +86,7 @@ void PyImportAssistant::exec() //! Lets user to select Python file on disk. -QString PyImportAssistant::fileNameToOpen() -{ +QString PyImportAssistant::fileNameToOpen() { QString dirname = AppSvc::projectManager()->userImportDir(); QString result = QFileDialog::getOpenFileName(m_mainWindow, "Open python script", dirname, @@ -105,8 +99,7 @@ QString PyImportAssistant::fileNameToOpen() //! Saves file location as a future import dir. -void PyImportAssistant::saveImportDir(const QString& fileName) -{ +void PyImportAssistant::saveImportDir(const QString& fileName) { if (fileName.isEmpty()) return; @@ -116,8 +109,7 @@ void PyImportAssistant::saveImportDir(const QString& fileName) //! Read content of text file and returns it as a multi-line string. //! Pop-ups warning dialog in the case of failure. -QString PyImportAssistant::readFile(const QString& fileName) -{ +QString PyImportAssistant::readFile(const QString& fileName) { QString result; try { @@ -135,8 +127,7 @@ QString PyImportAssistant::readFile(const QString& fileName) //! Returns the name of function which might generate a MultiLayer in Python code snippet. //! Pop-ups dialog and asks user for help in the case of doubts. -QString PyImportAssistant::getPySampleFunctionName(const QString& snippet) -{ +QString PyImportAssistant::getPySampleFunctionName(const QString& snippet) { QStringList funcList; QApplication::setOverrideCursor(Qt::WaitCursor); @@ -159,8 +150,7 @@ QString PyImportAssistant::getPySampleFunctionName(const QString& snippet) //! Lets user select a function name which generates a MultiLayer. -QString PyImportAssistant::selectPySampleFunction(const QStringList& funcNames) -{ +QString PyImportAssistant::selectPySampleFunction(const QStringList& funcNames) { QString result; if (funcNames.empty()) { @@ -188,8 +178,7 @@ QString PyImportAssistant::selectPySampleFunction(const QStringList& funcNames) //! Function is supposed to be in code provided by 'snippet'. std::unique_ptr<MultiLayer> PyImportAssistant::createMultiLayer(const QString& snippet, - const QString& funcName) -{ + const QString& funcName) { std::unique_ptr<MultiLayer> result; QApplication::setOverrideCursor(Qt::WaitCursor); @@ -210,8 +199,7 @@ std::unique_ptr<MultiLayer> PyImportAssistant::createMultiLayer(const QString& s //! Populates GUI models with domain multilayer. -void PyImportAssistant::populateModels(const MultiLayer& multilayer, const QString& sampleName) -{ +void PyImportAssistant::populateModels(const MultiLayer& multilayer, const QString& sampleName) { try { QString name = sampleName; if (multilayer.getName() != "MultiLayer") diff --git a/GUI/coregui/mainwindow/PyImportAssistant.h b/GUI/coregui/mainwindow/PyImportAssistant.h index ae2ccc9522646d6d6316573635897d70db6abd63..e5b49814f0879af16e91dc418dfc2d2d56513a83 100644 --- a/GUI/coregui/mainwindow/PyImportAssistant.h +++ b/GUI/coregui/mainwindow/PyImportAssistant.h @@ -25,8 +25,7 @@ class MultiLayer; //! Assists in importing Python object to GUI models. -class PyImportAssistant : public QObject -{ +class PyImportAssistant : public QObject { Q_OBJECT public: PyImportAssistant(MainWindow* mainwin); diff --git a/GUI/coregui/mainwindow/SaveLoadInterface.cpp b/GUI/coregui/mainwindow/SaveLoadInterface.cpp index d01175b7ff7220da57257e466fec178235d18ee2..3f71b2c38e0247103e74809e44f782d5fa607402 100644 --- a/GUI/coregui/mainwindow/SaveLoadInterface.cpp +++ b/GUI/coregui/mainwindow/SaveLoadInterface.cpp @@ -16,8 +16,7 @@ SaveLoadInterface::~SaveLoadInterface() = default; -QString SaveLoadInterface::fileName(const QString& projectDir) const -{ +QString SaveLoadInterface::fileName(const QString& projectDir) const { const auto filename = fileName(); return projectDir.isEmpty() ? filename : projectDir + "/" + filename; } diff --git a/GUI/coregui/mainwindow/SaveLoadInterface.h b/GUI/coregui/mainwindow/SaveLoadInterface.h index 4a3ecfe3e0402ed936ac0aabe31f52dc7effb074..9f9aa7c7a75bafbfd3e2d8e6176e672290117686 100644 --- a/GUI/coregui/mainwindow/SaveLoadInterface.h +++ b/GUI/coregui/mainwindow/SaveLoadInterface.h @@ -21,8 +21,7 @@ //! Purely virtual interface to handle non-XML //! data save and load. -class SaveLoadInterface -{ +class SaveLoadInterface { public: virtual ~SaveLoadInterface(); diff --git a/GUI/coregui/mainwindow/SaveService.cpp b/GUI/coregui/mainwindow/SaveService.cpp index f6ea9905b6ff73beb9343aca3ae570f41b7d3902..70144ca08b0778e566dd82df6923c74247be5000 100644 --- a/GUI/coregui/mainwindow/SaveService.cpp +++ b/GUI/coregui/mainwindow/SaveService.cpp @@ -25,12 +25,9 @@ #include <QTime> SaveService::SaveService(QObject* parent) - : QObject(parent), m_is_saving(false), m_autosave(nullptr), m_document(nullptr) -{ -} + : QObject(parent), m_is_saving(false), m_autosave(nullptr), m_document(nullptr) {} -void SaveService::setDocument(ProjectDocument* document) -{ +void SaveService::setDocument(ProjectDocument* document) { m_document = document; if (m_autosave) @@ -39,16 +36,14 @@ void SaveService::setDocument(ProjectDocument* document) m_save_queue.clear(); } -void SaveService::save(const QString& project_file_name) -{ +void SaveService::save(const QString& project_file_name) { ASSERT(m_document); m_save_queue.enqueue(project_file_name); process_queue(); } -void SaveService::setAutosaveEnabled(bool value) -{ +void SaveService::setAutosaveEnabled(bool value) { if (value) { delete m_autosave; m_autosave = new AutosaveController(this); @@ -61,28 +56,24 @@ void SaveService::setAutosaveEnabled(bool value) } } -bool SaveService::isAutosaveEnabled() const -{ +bool SaveService::isAutosaveEnabled() const { return m_autosave; } -void SaveService::setAutosaveTime(int timerInterval) -{ +void SaveService::setAutosaveTime(int timerInterval) { if (!m_autosave) setAutosaveEnabled(true); m_autosave->setAutosaveTime(timerInterval); } -bool SaveService::isSaving() const -{ +bool SaveService::isSaving() const { return m_is_saving; } //! -void SaveService::stopService() -{ +void SaveService::stopService() { QApplication::setOverrideCursor(Qt::WaitCursor); if (isSaving()) { @@ -103,13 +94,11 @@ void SaveService::stopService() QApplication::restoreOverrideCursor(); } -void SaveService::onAutosaveRequest() -{ +void SaveService::onAutosaveRequest() { save(m_autosave->autosaveName()); } -void SaveService::onProjectSaved() -{ +void SaveService::onProjectSaved() { ASSERT(m_document); ASSERT(m_is_saving); @@ -120,8 +109,7 @@ void SaveService::onProjectSaved() process_queue(); } -void SaveService::process_queue() -{ +void SaveService::process_queue() { ASSERT(m_document); if (m_is_saving) diff --git a/GUI/coregui/mainwindow/SaveService.h b/GUI/coregui/mainwindow/SaveService.h index c6bcac24a08c69b60af1415bea95242f803e53e8..b8630ef65840f77b7c26ec09407b12b14fe772ce 100644 --- a/GUI/coregui/mainwindow/SaveService.h +++ b/GUI/coregui/mainwindow/SaveService.h @@ -23,8 +23,7 @@ class AutosaveController; //! Provides save/autosave of ProjectDocument in a thread. -class SaveService : public QObject -{ +class SaveService : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/mainwindow/SaveThread.cpp b/GUI/coregui/mainwindow/SaveThread.cpp index d1a5ef7d340bb5c5571000e636f663658864b188..60ad6cc698bd1f1df7074b40b59636963de64320 100644 --- a/GUI/coregui/mainwindow/SaveThread.cpp +++ b/GUI/coregui/mainwindow/SaveThread.cpp @@ -18,20 +18,17 @@ SaveThread::SaveThread(QObject* parent) : QThread(parent), m_document(nullptr) {} -SaveThread::~SaveThread() -{ +SaveThread::~SaveThread() { wait(); } -void SaveThread::run() -{ +void SaveThread::run() { ASSERT(m_document); m_document->save_project_data(m_projectFile); emit saveReady(); } -void SaveThread::setSaveContext(ProjectDocument* document, const QString& project_file_name) -{ +void SaveThread::setSaveContext(ProjectDocument* document, const QString& project_file_name) { m_document = document; m_projectFile = project_file_name; } diff --git a/GUI/coregui/mainwindow/SaveThread.h b/GUI/coregui/mainwindow/SaveThread.h index f16d7bceddd5cc655c357a62b0e3143eb78a3251..18670c874eaaad9f3372f113e778fa335d0b4d79 100644 --- a/GUI/coregui/mainwindow/SaveThread.h +++ b/GUI/coregui/mainwindow/SaveThread.h @@ -22,8 +22,7 @@ class ProjectDocument; //! Performs saving of heavy intensity data in a thread. -class SaveThread : public QThread -{ +class SaveThread : public QThread { Q_OBJECT public: explicit SaveThread(QObject* parent = 0); diff --git a/GUI/coregui/mainwindow/SplashScreen.cpp b/GUI/coregui/mainwindow/SplashScreen.cpp index 103e1c583e28613c586eac5700a0d58caeb90682..d7cb05ebd8db05d209c190d583b7655f0ea43a5d 100644 --- a/GUI/coregui/mainwindow/SplashScreen.cpp +++ b/GUI/coregui/mainwindow/SplashScreen.cpp @@ -22,7 +22,8 @@ #include <QTime> SplashScreen::SplashScreen(QWidget*) - : QSplashScreen(QPixmap(":/images/splashscreen.png")), m_percentage_done(0) + : QSplashScreen(QPixmap(":/images/splashscreen.png")) + , m_percentage_done(0) { QSplashScreen::setCursor(Qt::BusyCursor); @@ -33,8 +34,7 @@ SplashScreen::SplashScreen(QWidget*) QSplashScreen::setFont(font); } -void SplashScreen::start(int show_during) -{ +void SplashScreen::start(int show_during) { show(); QTime dieTime = QTime::currentTime().addMSecs(show_during); QElapsedTimer timer; @@ -45,8 +45,7 @@ void SplashScreen::start(int show_during) } } -void SplashScreen::setProgress(int value) -{ +void SplashScreen::setProgress(int value) { m_percentage_done = value; if (m_percentage_done > 100) m_percentage_done = 100; @@ -55,8 +54,7 @@ void SplashScreen::setProgress(int value) update(); } -void SplashScreen::drawContents(QPainter* painter) -{ +void SplashScreen::drawContents(QPainter* painter) { QSplashScreen::drawContents(painter); auto img_rect = frameGeometry(); diff --git a/GUI/coregui/mainwindow/SplashScreen.h b/GUI/coregui/mainwindow/SplashScreen.h index 5029aa433c68a71b429790733aa13863ca6aad3b..30efc4b57e18121707a54f40d1c04e4ffb5d0a7b 100644 --- a/GUI/coregui/mainwindow/SplashScreen.h +++ b/GUI/coregui/mainwindow/SplashScreen.h @@ -17,8 +17,7 @@ #include <QSplashScreen> -class SplashScreen : public QSplashScreen -{ +class SplashScreen : public QSplashScreen { Q_OBJECT public: explicit SplashScreen(QWidget* parent = nullptr); diff --git a/GUI/coregui/mainwindow/StyledToolBar.cpp b/GUI/coregui/mainwindow/StyledToolBar.cpp index 5bc42d0051e8231310a1751fb3cfc5f3d34c7776..d11b4faffa8bbd1fe21de153bd1f2e71a20fafc2 100644 --- a/GUI/coregui/mainwindow/StyledToolBar.cpp +++ b/GUI/coregui/mainwindow/StyledToolBar.cpp @@ -16,8 +16,7 @@ #include <QLabel> #include <QStyle> -StyledToolBar::StyledToolBar(QWidget* parent) : QToolBar(parent) -{ +StyledToolBar::StyledToolBar(QWidget* parent) : QToolBar(parent) { setMovable(false); const int size = style()->pixelMetric(QStyle::PM_ToolBarIconSize); setIconSize(QSize(size, size)); @@ -25,8 +24,7 @@ StyledToolBar::StyledToolBar(QWidget* parent) : QToolBar(parent) setContentsMargins(0, 0, 0, 0); } -void StyledToolBar::addStyledSeparator() -{ +void StyledToolBar::addStyledSeparator() { addWidget(new QLabel(" ")); addSeparator(); addWidget(new QLabel(" ")); @@ -34,21 +32,18 @@ void StyledToolBar::addStyledSeparator() //! Width of the spacing between buttons -void StyledToolBar::addSpacing(int width) -{ +void StyledToolBar::addSpacing(int width) { QString space; space.fill(' ', width); addWidget(new QLabel(space)); } -void StyledToolBar::addStyledExpand() -{ +void StyledToolBar::addStyledExpand() { QWidget* empty = new QWidget(); empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); addWidget(empty); } -void StyledToolBar::contextMenuEvent(QContextMenuEvent*) -{ +void StyledToolBar::contextMenuEvent(QContextMenuEvent*) { // Context menu reimplemented to suppress the default one } diff --git a/GUI/coregui/mainwindow/StyledToolBar.h b/GUI/coregui/mainwindow/StyledToolBar.h index a46b5f1315cb34f198ab6bddabe01b01b54a5dd6..f16a9c87a193ba14b87cc4cae7659e3fa3f5bf56 100644 --- a/GUI/coregui/mainwindow/StyledToolBar.h +++ b/GUI/coregui/mainwindow/StyledToolBar.h @@ -19,8 +19,7 @@ //! The StyledToolBar class represents our standard narrow toolbar with the height 24 pixels. -class StyledToolBar : public QToolBar -{ +class StyledToolBar : public QToolBar { Q_OBJECT public: diff --git a/GUI/coregui/mainwindow/UpdateNotifier.cpp b/GUI/coregui/mainwindow/UpdateNotifier.cpp index 4286d38c9c584da754f39562adaa68c43f48b4d6..c447598eede866de07d4f74e44120ab0b03acb65 100644 --- a/GUI/coregui/mainwindow/UpdateNotifier.cpp +++ b/GUI/coregui/mainwindow/UpdateNotifier.cpp @@ -18,14 +18,12 @@ #include <QtNetwork> UpdateNotifier::UpdateNotifier(QObject* parent) - : QObject(parent), m_networkAccessManager(new QNetworkAccessManager(parent)) -{ + : QObject(parent), m_networkAccessManager(new QNetworkAccessManager(parent)) { connect(m_networkAccessManager, &QNetworkAccessManager::finished, this, &UpdateNotifier::replyFinished); } -void UpdateNotifier::checkForUpdates() -{ +void UpdateNotifier::checkForUpdates() { if (hasDefinedUpdatesFlag()) { if (updatesFlag()) { QString address(Constants::S_VERSION_URL); @@ -43,8 +41,7 @@ void UpdateNotifier::checkForUpdates() } } -void UpdateNotifier::replyFinished(QNetworkReply* reply) -{ +void UpdateNotifier::replyFinished(QNetworkReply* reply) { QString replyString; if (reply->error() == QNetworkReply::NoError) { if (reply->isReadable()) { @@ -73,8 +70,7 @@ void UpdateNotifier::replyFinished(QNetworkReply* reply) reply->deleteLater(); } -void UpdateNotifier::setCheckUpdatesFlag(bool flag) -{ +void UpdateNotifier::setCheckUpdatesFlag(bool flag) { QSettings settings; settings.beginGroup(Constants::S_UPDATES); settings.setValue(Constants::S_CHECKFORUPDATES, flag); @@ -83,8 +79,7 @@ void UpdateNotifier::setCheckUpdatesFlag(bool flag) //! Returns true if there is defined flag requiring check for updates. -bool UpdateNotifier::updatesFlag() const -{ +bool UpdateNotifier::updatesFlag() const { QSettings settings; if (settings.childGroups().contains(Constants::S_UPDATES)) { settings.beginGroup(Constants::S_UPDATES); @@ -95,8 +90,7 @@ bool UpdateNotifier::updatesFlag() const //! Returns true if settings contain record about user choice for updates. -bool UpdateNotifier::hasDefinedUpdatesFlag() const -{ +bool UpdateNotifier::hasDefinedUpdatesFlag() const { QSettings settings; return settings.childGroups().contains(Constants::S_UPDATES); } diff --git a/GUI/coregui/mainwindow/UpdateNotifier.h b/GUI/coregui/mainwindow/UpdateNotifier.h index 56ccfbdd60ecf6efde21ffd7acdb6e3fbec397f0..b4d365af184a177892320c4aa7cdc43193d08c8e 100644 --- a/GUI/coregui/mainwindow/UpdateNotifier.h +++ b/GUI/coregui/mainwindow/UpdateNotifier.h @@ -20,8 +20,7 @@ class QNetworkAccessManager; class QNetworkReply; -class UpdateNotifier : public QObject -{ +class UpdateNotifier : public QObject { Q_OBJECT public: UpdateNotifier(QObject* parent = 0); diff --git a/GUI/coregui/mainwindow/UpdateNotifierWidget.cpp b/GUI/coregui/mainwindow/UpdateNotifierWidget.cpp index dc9af66805abcdcca9e94dfd020bae747604fee5..21999a5424be79ed17b1c2752d9f591d50cff926 100644 --- a/GUI/coregui/mainwindow/UpdateNotifierWidget.cpp +++ b/GUI/coregui/mainwindow/UpdateNotifierWidget.cpp @@ -22,13 +22,11 @@ #include <QTimer> #include <QUrl> -namespace -{ +namespace { const QString yes = "yes"; const QString no = "no"; -QString update_question() -{ +QString update_question() { QString result = QString("Should BornAgain check for updates automatically? - " " <a href=\"%1\">yes</a> /" " <a href=\"%2\">no</a>") @@ -41,8 +39,7 @@ UpdateNotifierWidget::UpdateNotifierWidget(UpdateNotifier* updateNotifier, QWidg : QWidget(parent) , m_updateNotifier(updateNotifier) , m_updateLabel(new QLabel) - , m_check_for_updates(true) -{ + , m_check_for_updates(true) { auto layout = new QHBoxLayout(); layout->addWidget(m_updateLabel); setLayout(layout); @@ -68,8 +65,7 @@ UpdateNotifierWidget::UpdateNotifierWidget(UpdateNotifier* updateNotifier, QWidg //! Schedule check for updates if it was not done yet. -void UpdateNotifierWidget::showEvent(QShowEvent* event) -{ +void UpdateNotifierWidget::showEvent(QShowEvent* event) { QWidget::showEvent(event); if (m_check_for_updates) { m_check_for_updates = false; @@ -79,15 +75,13 @@ void UpdateNotifierWidget::showEvent(QShowEvent* event) //! Updates label when notification is coming. -void UpdateNotifierWidget::onUpdateNotification(const QString& text) -{ +void UpdateNotifierWidget::onUpdateNotification(const QString& text) { m_updateLabel->setText(text); } //! Processes mouse click on update notification label. -void UpdateNotifierWidget::onLinkActivated(const QString& text) -{ +void UpdateNotifierWidget::onLinkActivated(const QString& text) { if (text == yes) { m_updateNotifier->setCheckUpdatesFlag(true); m_updateNotifier->checkForUpdates(); diff --git a/GUI/coregui/mainwindow/UpdateNotifierWidget.h b/GUI/coregui/mainwindow/UpdateNotifierWidget.h index 25ddebb49e2b0921b89f09b0a4aab7094ead8bf0..5caaee0ee0b5cf4b76e0ba5c2885d49d859cfa14 100644 --- a/GUI/coregui/mainwindow/UpdateNotifierWidget.h +++ b/GUI/coregui/mainwindow/UpdateNotifierWidget.h @@ -23,8 +23,7 @@ class QShowEvent; //! Small on WelcomeView for notofications about updates. -class UpdateNotifierWidget : public QWidget -{ +class UpdateNotifierWidget : public QWidget { Q_OBJECT public: explicit UpdateNotifierWidget(UpdateNotifier* updateNotifier, QWidget* parent = nullptr); diff --git a/GUI/coregui/mainwindow/aboutapplicationdialog.cpp b/GUI/coregui/mainwindow/aboutapplicationdialog.cpp index eb502fd398bc9092008bbdfa4e63c19812d117fd..a50e65d4400330f8f0c79cb58dc66c782b06ac34 100644 --- a/GUI/coregui/mainwindow/aboutapplicationdialog.cpp +++ b/GUI/coregui/mainwindow/aboutapplicationdialog.cpp @@ -21,11 +21,9 @@ #include <QPushButton> #include <QVBoxLayout> -namespace -{ +namespace { -QLabel* createLinkLabel() -{ +QLabel* createLinkLabel() { auto result = new QLabel(); result->setTextFormat(Qt::RichText); result->setTextInteractionFlags(Qt::TextBrowserInteraction); @@ -34,8 +32,7 @@ QLabel* createLinkLabel() return result; } -QLabel* createCopyrightLabel() -{ +QLabel* createCopyrightLabel() { QDate date = QDate::currentDate(); QString copyright = QString("Copyright: Forschungszentrum Jülich GmbH ").append(date.toString("yyyy")); @@ -45,8 +42,7 @@ QLabel* createCopyrightLabel() return result; } -QLabel* createLogoLabel() -{ +QLabel* createLogoLabel() { QPixmap logo(":/images/about_icon.awk", "JPG"); auto result = new QLabel; result->setPixmap(logo.scaled(656, 674, Qt::KeepAspectRatio)); @@ -54,8 +50,7 @@ QLabel* createLogoLabel() } } // namespace -AboutApplicationDialog::AboutApplicationDialog(QWidget* parent) : QDialog(parent) -{ +AboutApplicationDialog::AboutApplicationDialog(QWidget* parent) : QDialog(parent) { QColor bgColor(240, 240, 240, 255); QPalette palette; palette.setColor(QPalette::Window, bgColor); @@ -76,8 +71,7 @@ AboutApplicationDialog::AboutApplicationDialog(QWidget* parent) : QDialog(parent setLayout(mainLayout); } -QBoxLayout* AboutApplicationDialog::createLogoLayout() -{ +QBoxLayout* AboutApplicationDialog::createLogoLayout() { auto result = new QVBoxLayout; QPixmap logo(":/images/about_icon.png"); @@ -91,8 +85,7 @@ QBoxLayout* AboutApplicationDialog::createLogoLayout() return result; } -QBoxLayout* AboutApplicationDialog::createTextLayout() -{ +QBoxLayout* AboutApplicationDialog::createTextLayout() { auto result = new QVBoxLayout; QFont titleFont; @@ -131,8 +124,7 @@ QBoxLayout* AboutApplicationDialog::createTextLayout() return result; } -QBoxLayout* AboutApplicationDialog::createButtonLayout() -{ +QBoxLayout* AboutApplicationDialog::createButtonLayout() { auto result = new QHBoxLayout; auto closeButton = new QPushButton("Close"); diff --git a/GUI/coregui/mainwindow/aboutapplicationdialog.h b/GUI/coregui/mainwindow/aboutapplicationdialog.h index f6af8ea9cfc0b53764dc04ed0b8e6b91ae3131a7..72228cce0e509c0ccc304063d408bcb26b58adb9 100644 --- a/GUI/coregui/mainwindow/aboutapplicationdialog.h +++ b/GUI/coregui/mainwindow/aboutapplicationdialog.h @@ -21,8 +21,7 @@ class QBoxLayout; //! About BornAgain dialog. -class AboutApplicationDialog : public QDialog -{ +class AboutApplicationDialog : public QDialog { Q_OBJECT public: AboutApplicationDialog(QWidget* parent = 0); diff --git a/GUI/coregui/mainwindow/actionmanager.cpp b/GUI/coregui/mainwindow/actionmanager.cpp index 74ade1605abc25dcf53bba96053c1cc12f08426c..19d08d7f1e9bdbd845e6438527df126ff9973131 100644 --- a/GUI/coregui/mainwindow/actionmanager.cpp +++ b/GUI/coregui/mainwindow/actionmanager.cpp @@ -43,15 +43,13 @@ ActionManager::ActionManager(MainWindow* parent) , m_recentProjectsMenu(nullptr) , m_helpMenu(nullptr) , m_importMenu(nullptr) - , m_runSimulationShortcut(nullptr) -{ + , m_runSimulationShortcut(nullptr) { createActions(); createMenus(); createGlobalShortcuts(); } -void ActionManager::createActions() -{ +void ActionManager::createActions() { ProjectManager* projectManager = m_mainWindow->projectManager(); ASSERT(projectManager); @@ -94,8 +92,7 @@ void ActionManager::createActions() connect(m_aboutAction, &QAction::triggered, this, &ActionManager::onAboutApplication); } -void ActionManager::createMenus() -{ +void ActionManager::createMenus() { m_menuBar = new QMenuBar(0); // No parent (System menu bar on Mac OS X) if (!GUI_OS_Utils::HostOsInfo::isMacHost()) @@ -143,16 +140,14 @@ void ActionManager::createMenus() m_helpMenu->addAction(m_aboutAction); } -void ActionManager::createGlobalShortcuts() -{ +void ActionManager::createGlobalShortcuts() { m_runSimulationShortcut = new QShortcut(QKeySequence("Ctrl+r"), m_mainWindow); m_runSimulationShortcut->setContext((Qt::ApplicationShortcut)); connect(m_runSimulationShortcut, &QShortcut::activated, m_mainWindow, &MainWindow::onRunSimulationShortcut); } -void ActionManager::aboutToShowFileMenu() -{ +void ActionManager::aboutToShowFileMenu() { m_recentProjectsMenu->clear(); bool hasRecentProjects = false; @@ -173,8 +168,7 @@ void ActionManager::aboutToShowFileMenu() } } -void ActionManager::aboutToShowSettings() -{ +void ActionManager::aboutToShowSettings() { m_settingsMenu->clear(); QSettings settings; @@ -205,14 +199,12 @@ void ActionManager::aboutToShowSettings() m_settingsMenu->setToolTipsVisible(true); } -void ActionManager::toggleCheckForUpdates(bool status) -{ +void ActionManager::toggleCheckForUpdates(bool status) { m_mainWindow->updateNotifier()->setCheckUpdatesFlag(status); m_mainWindow->updateNotifier()->checkForUpdates(); } -void ActionManager::setSessionModelViewActive(bool status) -{ +void ActionManager::setSessionModelViewActive(bool status) { QSettings settings; settings.beginGroup(Constants::S_SESSIONMODELVIEW); settings.setValue(Constants::S_VIEWISACTIVE, status); @@ -220,15 +212,13 @@ void ActionManager::setSessionModelViewActive(bool status) m_mainWindow->onSessionModelViewActive(status); } -void ActionManager::onAboutApplication() -{ +void ActionManager::onAboutApplication() { AboutApplicationDialog dialog(m_mainWindow); dialog.exec(); } #ifdef BORNAGAIN_PYTHON -void ActionManager::onImportFromPythonScript() -{ +void ActionManager::onImportFromPythonScript() { PyImportAssistant assistant(m_mainWindow); assistant.exec(); } diff --git a/GUI/coregui/mainwindow/actionmanager.h b/GUI/coregui/mainwindow/actionmanager.h index a56a59da57866650060d08ba664c376c67e2d0c6..3bce60d22d4804e5131b989f5268118296f5b8dc 100644 --- a/GUI/coregui/mainwindow/actionmanager.h +++ b/GUI/coregui/mainwindow/actionmanager.h @@ -25,8 +25,7 @@ class QShortcut; //! Class to handle MainWindow's menu and corresponding actions -class ActionManager : public QObject -{ +class ActionManager : public QObject { Q_OBJECT public: ActionManager(MainWindow* parent); diff --git a/GUI/coregui/mainwindow/mainwindow.cpp b/GUI/coregui/mainwindow/mainwindow.cpp index 01da746389c78435586999795f697129d68d7242..f0548c7a0f77552c7e879fcd30a125b476c1ea78 100644 --- a/GUI/coregui/mainwindow/mainwindow.cpp +++ b/GUI/coregui/mainwindow/mainwindow.cpp @@ -53,8 +53,7 @@ MainWindow::MainWindow() , m_importDataView(0) , m_simulationView(0) , m_jobView(0) - , m_sessionModelView(0) -{ + , m_sessionModelView(0) { initApplication(); readSettings(); initProgressBar(); @@ -66,71 +65,58 @@ MainWindow::MainWindow() // m_applicationModels->createTestRealData(); } -MaterialModel* MainWindow::materialModel() -{ +MaterialModel* MainWindow::materialModel() { return models()->materialModel(); } -InstrumentModel* MainWindow::instrumentModel() -{ +InstrumentModel* MainWindow::instrumentModel() { return models()->instrumentModel(); } -SampleModel* MainWindow::sampleModel() -{ +SampleModel* MainWindow::sampleModel() { return models()->sampleModel(); } -RealDataModel* MainWindow::realDataModel() -{ +RealDataModel* MainWindow::realDataModel() { return models()->realDataModel(); } -JobModel* MainWindow::jobModel() -{ +JobModel* MainWindow::jobModel() { return models()->jobModel(); } -ApplicationModels* MainWindow::models() -{ +ApplicationModels* MainWindow::models() { return m_applicationModels; } -Manhattan::ProgressBar* MainWindow::progressBar() -{ +Manhattan::ProgressBar* MainWindow::progressBar() { return m_progressBar; } -QStatusBar* MainWindow::statusBar() -{ +QStatusBar* MainWindow::statusBar() { return m_tabWidget->statusBar(); } -ProjectManager* MainWindow::projectManager() -{ +ProjectManager* MainWindow::projectManager() { return m_projectManager; } -UpdateNotifier* MainWindow::updateNotifier() -{ +UpdateNotifier* MainWindow::updateNotifier() { return m_updateNotifier; } -void MainWindow::onFocusRequest(int index) -{ +void MainWindow::onFocusRequest(int index) { m_tabWidget->setCurrentIndex(index); } -void MainWindow::openRecentProject() -{ +void MainWindow::openRecentProject() { if (const QAction* action = qobject_cast<const QAction*>(sender())) { QString file = action->data().value<QString>(); m_projectManager->openProject(file); } } -void MainWindow::onRunSimulationShortcut() -{ +void MainWindow::onRunSimulationShortcut() { // This clearFocus is needed for the propagation of the current editor value, // since the runSimulation method will only change focus after finishing the simulation if (auto widget = QApplication::focusWidget()) @@ -140,8 +126,7 @@ void MainWindow::onRunSimulationShortcut() //! Inserts/removes developers SessionModelView on the left fancy tabbar. //! This SessionModelView will be known for the tab under MAXVIEWCOUNT id (so it is the last one) -void MainWindow::onSessionModelViewActive(bool isActive) -{ +void MainWindow::onSessionModelViewActive(bool isActive) { if (isActive) { if (m_sessionModelView) return; @@ -162,8 +147,7 @@ void MainWindow::onSessionModelViewActive(bool isActive) } } -void MainWindow::closeEvent(QCloseEvent* event) -{ +void MainWindow::closeEvent(QCloseEvent* event) { if (jobModel()->hasUnfinishedJobs()) { QMessageBox::warning(this, "Can't quit the application.", "Can't quit the application while jobs are running.\n" @@ -179,8 +163,7 @@ void MainWindow::closeEvent(QCloseEvent* event) } } -void MainWindow::initApplication() -{ +void MainWindow::initApplication() { QCoreApplication::setApplicationName(QLatin1String(Constants::APPLICATION_NAME)); QCoreApplication::setApplicationVersion(GUIHelpers::getBornAgainVersionString()); QCoreApplication::setOrganizationName(QLatin1String(Constants::APPLICATION_NAME)); @@ -197,14 +180,12 @@ void MainWindow::initApplication() setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); } -void MainWindow::initProgressBar() -{ +void MainWindow::initProgressBar() { m_tabWidget->addBottomCornerWidget(m_progressBar); m_progressBar->hide(); } -void MainWindow::initViews() -{ +void MainWindow::initViews() { m_welcomeView = new WelcomeView(this); m_instrumentView = new InstrumentView(this); m_sampleView = new SampleView(this); @@ -245,8 +226,7 @@ void MainWindow::initViews() setCentralWidget(m_tabWidget); } -void MainWindow::readSettings() -{ +void MainWindow::readSettings() { QSettings settings; if (settings.childGroups().contains(Constants::S_MAINWINDOW)) { settings.beginGroup(Constants::S_MAINWINDOW); @@ -257,8 +237,7 @@ void MainWindow::readSettings() m_projectManager->readSettings(); } -void MainWindow::writeSettings() -{ +void MainWindow::writeSettings() { QSettings settings; settings.beginGroup(Constants::S_MAINWINDOW); settings.setValue(Constants::S_WINDOWSIZE, size()); @@ -268,7 +247,6 @@ void MainWindow::writeSettings() settings.sync(); } -void MainWindow::initConnections() -{ +void MainWindow::initConnections() { connect(m_jobView, &JobView::focusRequest, this, &MainWindow::onFocusRequest); } diff --git a/GUI/coregui/mainwindow/mainwindow.h b/GUI/coregui/mainwindow/mainwindow.h index 99d44680d8debb0fbe000af3912906538c68ed40..7d351dbd5b19ac358ab1b985dd656e0d3b748663 100644 --- a/GUI/coregui/mainwindow/mainwindow.h +++ b/GUI/coregui/mainwindow/mainwindow.h @@ -17,8 +17,7 @@ #include <fancymainwindow.h> -namespace Manhattan -{ +namespace Manhattan { class FancyTabWidget; class ProgressBar; } // namespace Manhattan @@ -42,8 +41,7 @@ class ActionManager; class ToolTipDataBase; class UpdateNotifier; -class MainWindow : public Manhattan::FancyMainWindow -{ +class MainWindow : public Manhattan::FancyMainWindow { Q_OBJECT public: diff --git a/GUI/coregui/mainwindow/mainwindow_constants.h b/GUI/coregui/mainwindow/mainwindow_constants.h index 3384363226ecbd72c1c832f5ce41270ac0aaeaac..2e71547bc63c67917fa3309099f74a79e8f4bc5d 100644 --- a/GUI/coregui/mainwindow/mainwindow_constants.h +++ b/GUI/coregui/mainwindow/mainwindow_constants.h @@ -17,8 +17,7 @@ #include <QString> -namespace Constants -{ +namespace Constants { // general application settings const char APPLICATION_NAME[] = "BornAgain"; diff --git a/GUI/coregui/mainwindow/newprojectdialog.cpp b/GUI/coregui/mainwindow/newprojectdialog.cpp index d20ef4d46697ad143c8c0f72e4760585b5dc863b..47012f7a2178d8ef063c9635ad64fb5d0ce37486 100644 --- a/GUI/coregui/mainwindow/newprojectdialog.cpp +++ b/GUI/coregui/mainwindow/newprojectdialog.cpp @@ -89,23 +89,19 @@ NewProjectDialog::NewProjectDialog(QWidget* parent, const QString& workingDirect setProjectName(projectName); } -QString NewProjectDialog::getWorkingDirectory() const -{ +QString NewProjectDialog::getWorkingDirectory() const { return m_workDirEdit->text(); } -void NewProjectDialog::setWorkingDirectory(const QString& text) -{ +void NewProjectDialog::setWorkingDirectory(const QString& text) { return m_workDirEdit->setText(text); } -void NewProjectDialog::setProjectName(const QString& text) -{ +void NewProjectDialog::setProjectName(const QString& text) { return m_projectNameEdit->setText(text); } -QString NewProjectDialog::getProjectFileName() const -{ +QString NewProjectDialog::getProjectFileName() const { QString projectDir = getWorkingDirectory() + QString("/") + getProjectName(); QString projectFile = getProjectName() + ProjectDocument::projectFileExtension(); QString result = projectDir + QString("/") + projectFile; @@ -113,8 +109,7 @@ QString NewProjectDialog::getProjectFileName() const } //! calls directory selection dialog -void NewProjectDialog::onBrowseDirectory() -{ +void NewProjectDialog::onBrowseDirectory() { QString dirname = QFileDialog::getExistingDirectory( this, "Select directory", getWorkingDirectory(), QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly); @@ -126,8 +121,7 @@ void NewProjectDialog::onBrowseDirectory() } //! Returns true if ProjectPath is valid. Corresponding directory should exists. -void NewProjectDialog::checkIfProjectPathIsValid(const QString& dirname) -{ +void NewProjectDialog::checkIfProjectPathIsValid(const QString& dirname) { if (QFile::exists(dirname)) { setValidProjectPath(true); m_workDirEdit->setText(dirname); @@ -139,8 +133,7 @@ void NewProjectDialog::checkIfProjectPathIsValid(const QString& dirname) //! Returns true if project name is valid. There should not be the directory with such //! name in ProjectPath -void NewProjectDialog::checkIfProjectNameIsValid(const QString& projectName) -{ +void NewProjectDialog::checkIfProjectNameIsValid(const QString& projectName) { QDir projectDir = getWorkingDirectory() + "/" + projectName; if (projectDir.exists()) { setValidProjectName(false); @@ -152,8 +145,7 @@ void NewProjectDialog::checkIfProjectNameIsValid(const QString& projectName) //! sets flags wether project name is valid and then updates color of LineEdit //! and warning message -void NewProjectDialog::setValidProjectName(bool status) -{ +void NewProjectDialog::setValidProjectName(bool status) { m_valid_projectName = status; QPalette palette; if (m_valid_projectName) { @@ -166,8 +158,7 @@ void NewProjectDialog::setValidProjectName(bool status) //! sets flags wether project path is valid and then updates color of LineEdit //! and warning message -void NewProjectDialog::setValidProjectPath(bool status) -{ +void NewProjectDialog::setValidProjectPath(bool status) { m_valid_projectPath = status; QPalette palette; if (m_valid_projectPath) { @@ -179,8 +170,7 @@ void NewProjectDialog::setValidProjectPath(bool status) } //! updates warning label depending on validity of project name and path -void NewProjectDialog::updateWarningStatus() -{ +void NewProjectDialog::updateWarningStatus() { if (m_valid_projectPath && m_valid_projectName) { m_createButton->setEnabled(true); m_warningLabel->setText(""); @@ -200,8 +190,7 @@ void NewProjectDialog::updateWarningStatus() } //! creates directory with selected ProjectName in selected ProjectPath -void NewProjectDialog::createProjectDir() -{ +void NewProjectDialog::createProjectDir() { QDir parentDir = getWorkingDirectory(); if (!parentDir.mkdir(getProjectName())) { m_warningLabel->setText("<font color='darkRed'> Can't make subdirectory' '" diff --git a/GUI/coregui/mainwindow/newprojectdialog.h b/GUI/coregui/mainwindow/newprojectdialog.h index 8d10a4edaa51d8ca5885ed34a47af5c8b2d7aa43..9faa2723941a6afd42ae6fab7b3bd1a1a30c4887 100644 --- a/GUI/coregui/mainwindow/newprojectdialog.h +++ b/GUI/coregui/mainwindow/newprojectdialog.h @@ -21,8 +21,7 @@ class QLabel; //! new project dialog window -class NewProjectDialog : public QDialog -{ +class NewProjectDialog : public QDialog { Q_OBJECT public: NewProjectDialog(QWidget* parent = 0, const QString& workingDirectory = "", diff --git a/GUI/coregui/mainwindow/projectdocument.cpp b/GUI/coregui/mainwindow/projectdocument.cpp index 715f2853036e7949a845bea9a0a59d2adc1db40d..6cb6880c853952811688b52f3356e21814d514c3 100644 --- a/GUI/coregui/mainwindow/projectdocument.cpp +++ b/GUI/coregui/mainwindow/projectdocument.cpp @@ -23,8 +23,7 @@ #include <QElapsedTimer> #include <QXmlStreamReader> -namespace -{ +namespace { const QString minimal_supported_version = "1.6.0"; } @@ -33,57 +32,48 @@ ProjectDocument::ProjectDocument(const QString& projectFileName) , m_modified(false) , m_documentStatus(ProjectFlags::STATUS_OK) , m_messageService(nullptr) - , m_dataService(new OutputDataIOService(this)) -{ + , m_dataService(new OutputDataIOService(this)) { setObjectName("ProjectDocument"); if (!projectFileName.isEmpty()) setProjectFileName(projectFileName); } -QString ProjectDocument::projectName() const -{ +QString ProjectDocument::projectName() const { return m_project_name; } -void ProjectDocument::setProjectName(const QString& text) -{ +void ProjectDocument::setProjectName(const QString& text) { if (m_project_name != text) { m_project_name = text; emit modified(); } } -QString ProjectDocument::projectDir() const -{ +QString ProjectDocument::projectDir() const { return m_project_dir; } -void ProjectDocument::setProjectDir(const QString& text) -{ +void ProjectDocument::setProjectDir(const QString& text) { m_project_dir = text; } -QString ProjectDocument::projectFileName() const -{ +QString ProjectDocument::projectFileName() const { if (!projectName().isEmpty()) return projectDir() + "/" + projectName() + projectFileExtension(); else return ""; } -void ProjectDocument::setProjectFileName(const QString& projectFileName) -{ +void ProjectDocument::setProjectFileName(const QString& projectFileName) { setProjectName(ProjectUtils::projectName(projectFileName)); setProjectDir(ProjectUtils::projectDir(projectFileName)); } -QString ProjectDocument::projectFileExtension() -{ +QString ProjectDocument::projectFileExtension() { return ".pro"; } -void ProjectDocument::setApplicationModels(ApplicationModels* applicationModels) -{ +void ProjectDocument::setApplicationModels(ApplicationModels* applicationModels) { if (applicationModels != m_applicationModels) { disconnectModels(); m_applicationModels = applicationModels; @@ -92,14 +82,12 @@ void ProjectDocument::setApplicationModels(ApplicationModels* applicationModels) } } -void ProjectDocument::save(const QString& project_file_name, bool autoSave) -{ +void ProjectDocument::save(const QString& project_file_name, bool autoSave) { save_project_data(project_file_name); save_project_file(project_file_name, autoSave); } -void ProjectDocument::save_project_file(const QString& project_file_name, bool autoSave) -{ +void ProjectDocument::save_project_file(const QString& project_file_name, bool autoSave) { QElapsedTimer timer; timer.start(); @@ -119,16 +107,14 @@ void ProjectDocument::save_project_file(const QString& project_file_name, bool a } } -void ProjectDocument::save_project_data(const QString& project_file_name) -{ +void ProjectDocument::save_project_data(const QString& project_file_name) { QElapsedTimer timer; timer.start(); m_dataService->save(ProjectUtils::projectDir(project_file_name)); } -void ProjectDocument::load(const QString& project_file_name) -{ +void ProjectDocument::load(const QString& project_file_name) { QElapsedTimer timer1, timer2; timer1.start(); @@ -163,69 +149,57 @@ void ProjectDocument::load(const QString& project_file_name) } } -bool ProjectDocument::hasValidNameAndPath() -{ +bool ProjectDocument::hasValidNameAndPath() { return (!m_project_name.isEmpty() && !m_project_dir.isEmpty()); } -bool ProjectDocument::isModified() -{ +bool ProjectDocument::isModified() { return m_modified; } -void ProjectDocument::setModified(bool flag) -{ +void ProjectDocument::setModified(bool flag) { m_modified = flag; if (m_modified) emit modified(); } -void ProjectDocument::setLogger(MessageService* messageService) -{ +void ProjectDocument::setLogger(MessageService* messageService) { m_messageService = messageService; } -ProjectFlags::DocumentStatus ProjectDocument::documentStatus() const -{ +ProjectFlags::DocumentStatus ProjectDocument::documentStatus() const { return m_documentStatus; } -bool ProjectDocument::isReady() const -{ +bool ProjectDocument::isReady() const { return (m_documentStatus == ProjectFlags::STATUS_OK); } -bool ProjectDocument::hasWarnings() const -{ +bool ProjectDocument::hasWarnings() const { return m_documentStatus.testFlag(ProjectFlags::STATUS_WARNING); } -bool ProjectDocument::hasErrors() const -{ +bool ProjectDocument::hasErrors() const { return m_documentStatus.testFlag(ProjectFlags::STATUS_FAILED); } -bool ProjectDocument::hasData() const -{ +bool ProjectDocument::hasData() const { return !m_dataService->nonXMLItems().isEmpty(); } -QString ProjectDocument::documentVersion() const -{ +QString ProjectDocument::documentVersion() const { QString result(m_currentVersion); if (result.isEmpty()) result = GUIHelpers::getBornAgainVersionString(); return result; } -void ProjectDocument::onModelChanged() -{ +void ProjectDocument::onModelChanged() { m_modified = true; emit modified(); } -void ProjectDocument::readFrom(QIODevice* device) -{ +void ProjectDocument::readFrom(QIODevice* device) { ASSERT(m_messageService); QXmlStreamReader reader(device); @@ -268,8 +242,7 @@ void ProjectDocument::readFrom(QIODevice* device) } } -void ProjectDocument::writeTo(QIODevice* device) -{ +void ProjectDocument::writeTo(QIODevice* device) { QXmlStreamWriter writer(device); writer.setAutoFormatting(true); writer.writeStartDocument(); @@ -287,14 +260,12 @@ void ProjectDocument::writeTo(QIODevice* device) writer.writeEndDocument(); } -void ProjectDocument::disconnectModels() -{ +void ProjectDocument::disconnectModels() { if (m_applicationModels) disconnect(m_applicationModels, SIGNAL(modelChanged()), this, SLOT(onModelChanged())); } -void ProjectDocument::connectModels() -{ +void ProjectDocument::connectModels() { if (m_applicationModels) connect(m_applicationModels, SIGNAL(modelChanged()), this, SLOT(onModelChanged()), Qt::UniqueConnection); diff --git a/GUI/coregui/mainwindow/projectdocument.h b/GUI/coregui/mainwindow/projectdocument.h index d49b0fe55d6de2a484f82106ec82f3fbf97a3ca7..bde31955e97e215d6b0277d88618cbf039fcbb1e 100644 --- a/GUI/coregui/mainwindow/projectdocument.h +++ b/GUI/coregui/mainwindow/projectdocument.h @@ -23,8 +23,7 @@ class ApplicationModels; class MessageService; class OutputDataIOService; -namespace ProjectDocumentXML -{ +namespace ProjectDocumentXML { const QString BornAgainTag("BornAgain"); const QString BornAgainVersionAttribute("Version"); const QString InfoTag("DocumentInfo"); @@ -38,8 +37,7 @@ const QString InfoNameAttribute("ProjectName"); //! projectName() - 'Untitled' //! projectDir() - '/home/users/development/Untitled //! projectFileName() - '/home/users/development/Untitled/Untitled.pro' -class ProjectDocument : public QObject -{ +class ProjectDocument : public QObject { Q_OBJECT public: diff --git a/GUI/coregui/mainwindow/projectmanager.cpp b/GUI/coregui/mainwindow/projectmanager.cpp index 0ddcf9831d7c9ed48ba055458e4acec87a453bb5..803767a699bc38767313d81ca578f7b3915978ed 100644 --- a/GUI/coregui/mainwindow/projectmanager.cpp +++ b/GUI/coregui/mainwindow/projectmanager.cpp @@ -32,8 +32,7 @@ #include <QSettings> #include <QStandardPaths> -namespace -{ +namespace { const QString S_PROJECTMANAGER = "ProjectManager"; const QString S_AUTOSAVE = "EnableAutosave"; const QString S_DEFAULTPROJECTPATH = "DefaultProjectPath"; @@ -52,8 +51,7 @@ ProjectManager::ProjectManager(MainWindow* parent) AppSvc::subscribe(this); } -ProjectManager::~ProjectManager() -{ +ProjectManager::~ProjectManager() { AppSvc::unsubscribe(this); delete m_project_document; delete m_messageService; @@ -61,8 +59,7 @@ ProjectManager::~ProjectManager() //! Reads settings of ProjectManager from global settings. -void ProjectManager::readSettings() -{ +void ProjectManager::readSettings() { QSettings settings; m_workingDirectory = QDir::homePath(); if (settings.childGroups().contains(S_PROJECTMANAGER)) { @@ -85,8 +82,7 @@ void ProjectManager::readSettings() //! Saves settings of ProjectManager in global settings. -void ProjectManager::writeSettings() -{ +void ProjectManager::writeSettings() { QSettings settings; settings.beginGroup(S_PROJECTMANAGER); settings.setValue(S_DEFAULTPROJECTPATH, m_workingDirectory); @@ -98,15 +94,13 @@ void ProjectManager::writeSettings() settings.endGroup(); } -ProjectDocument* ProjectManager::document() -{ +ProjectDocument* ProjectManager::document() { return m_project_document; } //! Returns list of recent projects, validates if projects still exists on disk. -QStringList ProjectManager::recentProjects() -{ +QStringList ProjectManager::recentProjects() { QStringList updatedList; for (QString fileName : m_recentProjects) { QFile fin(fileName); @@ -119,8 +113,7 @@ QStringList ProjectManager::recentProjects() //! Returns name of the current project directory. -QString ProjectManager::projectDir() const -{ +QString ProjectManager::projectDir() const { if (m_project_document && m_project_document->hasValidNameAndPath()) return m_project_document->projectDir(); @@ -129,8 +122,7 @@ QString ProjectManager::projectDir() const //! Returns directory name suitable for saving plots. -QString ProjectManager::userExportDir() const -{ +QString ProjectManager::userExportDir() const { QString result = projectDir(); if (result.isEmpty()) result = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); @@ -140,25 +132,21 @@ QString ProjectManager::userExportDir() const //! Returns directory name which was used by the user to import files. -QString ProjectManager::userImportDir() const -{ +QString ProjectManager::userImportDir() const { return m_importDirectory.isEmpty() ? userExportDir() : m_importDirectory; } //! Sets user import directory in system settings. -void ProjectManager::setImportDir(const QString& dirname) -{ +void ProjectManager::setImportDir(const QString& dirname) { m_importDirectory = dirname; } -bool ProjectManager::isAutosaveEnabled() const -{ +bool ProjectManager::isAutosaveEnabled() const { return m_saveService->isAutosaveEnabled(); } -void ProjectManager::setAutosaveEnabled(bool value) -{ +void ProjectManager::setAutosaveEnabled(bool value) { m_saveService->setAutosaveEnabled(value); QSettings settings; settings.setValue(S_PROJECTMANAGER + "/" + S_AUTOSAVE, value); @@ -166,8 +154,7 @@ void ProjectManager::setAutosaveEnabled(bool value) //! Updates title of main window when the project was modified. -void ProjectManager::onDocumentModified() -{ +void ProjectManager::onDocumentModified() { if (m_project_document->isModified()) { m_mainWindow->setWindowTitle("*" + m_project_document->projectName()); } else { @@ -177,16 +164,14 @@ void ProjectManager::onDocumentModified() //! Clears list of recent projects. -void ProjectManager::clearRecentProjects() -{ +void ProjectManager::clearRecentProjects() { m_recentProjects.clear(); modified(); } //! Processes new project request (close old project, rise dialog for project name, create project). -void ProjectManager::newProject() -{ +void ProjectManager::newProject() { if (!closeCurrentProject()) return; @@ -201,8 +186,7 @@ void ProjectManager::newProject() //! Processes close current project request. Call save/discard/cancel dialog, if necessary. //! Returns false if saving was canceled. -bool ProjectManager::closeCurrentProject() -{ +bool ProjectManager::closeCurrentProject() { if (!m_project_document) return true; @@ -239,8 +223,7 @@ bool ProjectManager::closeCurrentProject() //! Processes save project request. -bool ProjectManager::saveProject(QString projectFileName) -{ +bool ProjectManager::saveProject(QString projectFileName) { if (projectFileName.isEmpty()) { if (m_project_document->hasValidNameAndPath()) projectFileName = m_project_document->projectFileName(); @@ -271,8 +254,7 @@ bool ProjectManager::saveProject(QString projectFileName) //! Processes 'save project as' request. -bool ProjectManager::saveProjectAs() -{ +bool ProjectManager::saveProjectAs() { QString projectFileName = acquireProjectFileName(); if (projectFileName.isEmpty()) @@ -283,8 +265,7 @@ bool ProjectManager::saveProjectAs() //! Opens existing project. If fileName is empty, will popup file selection dialog. -void ProjectManager::openProject(QString fileName) -{ +void ProjectManager::openProject(QString fileName) { if (!closeCurrentProject()) return; @@ -313,8 +294,7 @@ void ProjectManager::openProject(QString fileName) //! Calls dialog window to define project path and name. -void ProjectManager::createNewProject() -{ +void ProjectManager::createNewProject() { if (m_project_document) throw GUIHelpers::Error("ProjectManager::createNewProject() -> Project already exists"); @@ -329,8 +309,7 @@ void ProjectManager::createNewProject() m_saveService->setDocument(m_project_document); } -void ProjectManager::deleteCurrentProject() -{ +void ProjectManager::deleteCurrentProject() { m_saveService->stopService(); delete m_project_document; @@ -340,8 +319,7 @@ void ProjectManager::deleteCurrentProject() //! Load project data from file name. If autosave info exists, opens dialog for project restore. -void ProjectManager::loadProject(const QString& projectFileName) -{ +void ProjectManager::loadProject(const QString& projectFileName) { bool useAutosave = m_saveService && ProjectUtils::hasAutosavedData(projectFileName); if (useAutosave && restoreProjectDialog(projectFileName)) { @@ -358,8 +336,7 @@ void ProjectManager::loadProject(const QString& projectFileName) //! Returns project file name from dialog. -QString ProjectManager::acquireProjectFileName() -{ +QString ProjectManager::acquireProjectFileName() { NewProjectDialog dialog(m_mainWindow, workingDirectory(), untitledProjectName()); if (dialog.exec() != QDialog::Accepted) @@ -372,8 +349,7 @@ QString ProjectManager::acquireProjectFileName() //! Add name of the current project to the name of recent projects -void ProjectManager::addToRecentProjects() -{ +void ProjectManager::addToRecentProjects() { QString fileName = m_project_document->projectFileName(); m_recentProjects.removeAll(fileName); m_recentProjects.prepend(fileName); @@ -383,16 +359,14 @@ void ProjectManager::addToRecentProjects() //! Returns default project path. -QString ProjectManager::workingDirectory() -{ +QString ProjectManager::workingDirectory() { return m_workingDirectory; } //! Will return 'Untitled' if the directory with such name doesn't exist in project //! path. Otherwise will return Untitled1, Untitled2 etc. -QString ProjectManager::untitledProjectName() -{ +QString ProjectManager::untitledProjectName() { QString result = "Untitled"; QDir projectDir = workingDirectory() + "/" + result; if (projectDir.exists()) { @@ -410,8 +384,7 @@ QString ProjectManager::untitledProjectName() return result; } -void ProjectManager::riseProjectLoadFailedDialog() -{ +void ProjectManager::riseProjectLoadFailedDialog() { QString message = QString("Failed to load the project '%1' \n\n").arg(m_project_document->projectFileName()); @@ -421,8 +394,7 @@ void ProjectManager::riseProjectLoadFailedDialog() QMessageBox::warning(m_mainWindow, "Error while opening project file", message); } -void ProjectManager::riseProjectLoadWarningDialog() -{ +void ProjectManager::riseProjectLoadWarningDialog() { ASSERT(m_project_document); ProjectLoadWarningDialog* warningDialog = new ProjectLoadWarningDialog( m_mainWindow, m_messageService, m_project_document->documentVersion()); @@ -433,8 +405,7 @@ void ProjectManager::riseProjectLoadWarningDialog() //! Rises dialog if the project should be restored from autosave. Returns true, if yes. -bool ProjectManager::restoreProjectDialog(const QString& projectFileName) -{ +bool ProjectManager::restoreProjectDialog(const QString& projectFileName) { QString title("Recover project"); QString message = diff --git a/GUI/coregui/mainwindow/projectmanager.h b/GUI/coregui/mainwindow/projectmanager.h index 8de513f0f9388249bfd8d9b28ea46e1a7f3a5238..ed9b397aaa486f1b082e8fe843831de94542ed3f 100644 --- a/GUI/coregui/mainwindow/projectmanager.h +++ b/GUI/coregui/mainwindow/projectmanager.h @@ -25,8 +25,7 @@ class SaveService; //! Handles activity related to opening/save projects. -class ProjectManager : public QObject -{ +class ProjectManager : public QObject { Q_OBJECT public: ProjectManager(MainWindow* parent); diff --git a/GUI/coregui/mainwindow/tooltipdatabase.cpp b/GUI/coregui/mainwindow/tooltipdatabase.cpp index 1283fa44ca93dffcb32791305d4fa2c85bd5932c..3f1f08c11239e716e797e34f3263a1e88d57f149 100644 --- a/GUI/coregui/mainwindow/tooltipdatabase.cpp +++ b/GUI/coregui/mainwindow/tooltipdatabase.cpp @@ -18,8 +18,7 @@ #include <QFile> #include <QXmlStreamReader> -namespace -{ +namespace { const QString modelTag = "ToolTipsData"; const QString contextTag = "context"; const QString categoryTag = "category"; @@ -35,29 +34,25 @@ const QString descriptionProperty = "Description"; ToolTipDataBase* ToolTipDataBase::m_instance = 0; QMap<QString, QString> ToolTipDataBase::m_tagToToolTip = QMap<QString, QString>(); -ToolTipDataBase::ToolTipDataBase(QObject* parent) : QObject(parent) -{ +ToolTipDataBase::ToolTipDataBase(QObject* parent) : QObject(parent) { ASSERT(!m_instance); m_instance = this; initDataBase(); } -ToolTipDataBase::~ToolTipDataBase() -{ +ToolTipDataBase::~ToolTipDataBase() { m_instance = 0; } -QString ToolTipDataBase::widgetboxToolTip(const QString& className) -{ +QString ToolTipDataBase::widgetboxToolTip(const QString& className) { ASSERT(m_instance); QString modelName(className); modelName.remove("FormFactor"); return m_instance->this_getToolTip(sampleViewContext, modelName, titleProperty); } -void ToolTipDataBase::initDataBase() -{ +void ToolTipDataBase::initDataBase() { QFile file(":/mainwindow/tooltips.xml"); if (!file.open(QIODevice::ReadOnly)) throw GUIHelpers::Error(file.errorString()); @@ -108,20 +103,17 @@ void ToolTipDataBase::initDataBase() } QString ToolTipDataBase::getTag(const QString& contextName, const QString& categoryName, - const QString& propertyName) -{ + const QString& propertyName) { return QString("/%1/%2/%3").arg(contextName, categoryName, propertyName); } void ToolTipDataBase::addToolTip(const QString& contextName, const QString& categoryName, - const QString& propertyName, const QString& tooltip) -{ + const QString& propertyName, const QString& tooltip) { if (!tooltip.isEmpty()) m_tagToToolTip[getTag(contextName, categoryName, propertyName)] = tooltip; } QString ToolTipDataBase::this_getToolTip(const QString& contextName, const QString& categoryName, - const QString& propertyName) -{ + const QString& propertyName) { return m_tagToToolTip[getTag(contextName, categoryName, propertyName)]; } diff --git a/GUI/coregui/mainwindow/tooltipdatabase.h b/GUI/coregui/mainwindow/tooltipdatabase.h index 7008954115672fa1f6f61cc84097cff94d8f96ce..6fe704f3246bb1c2c5ec269efa538ce6aa592d58 100644 --- a/GUI/coregui/mainwindow/tooltipdatabase.h +++ b/GUI/coregui/mainwindow/tooltipdatabase.h @@ -19,8 +19,7 @@ #include <QObject> //! The MaterialEditor is the main class to access materials. -class ToolTipDataBase : public QObject -{ +class ToolTipDataBase : public QObject { Q_OBJECT public: explicit ToolTipDataBase(QObject* parent = nullptr); diff --git a/GUI/coregui/utils/CustomEventFilters.cpp b/GUI/coregui/utils/CustomEventFilters.cpp index 918e6e0398a16bb1486bfcf2cfe70c3d9c752dda..4800719ff688fc320fe6667c06154323a252e0c9 100644 --- a/GUI/coregui/utils/CustomEventFilters.cpp +++ b/GUI/coregui/utils/CustomEventFilters.cpp @@ -20,8 +20,7 @@ SpaceKeyEater::SpaceKeyEater(QObject* parent) : QObject(parent) {} -bool SpaceKeyEater::eventFilter(QObject* obj, QEvent* event) -{ +bool SpaceKeyEater::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::KeyPress) { QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event); bool res = QObject::eventFilter(obj, event); @@ -41,8 +40,7 @@ bool SpaceKeyEater::eventFilter(QObject* obj, QEvent* event) WheelEventEater::WheelEventEater(QObject* parent) : QObject(parent) {} -bool WheelEventEater::eventFilter(QObject* obj, QEvent* event) -{ +bool WheelEventEater::eventFilter(QObject* obj, QEvent* event) { if (QAbstractSpinBox* spinBox = qobject_cast<QAbstractSpinBox*>(obj)) { if (event->type() == QEvent::Wheel) { @@ -72,8 +70,7 @@ bool WheelEventEater::eventFilter(QObject* obj, QEvent* event) // ---------------------------------------------------------------------------- -bool DeleteEventFilter::eventFilter(QObject* dist, QEvent* event) -{ +bool DeleteEventFilter::eventFilter(QObject* dist, QEvent* event) { Q_UNUSED(dist); if (event->type() == QEvent::KeyPress) { QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event); @@ -87,8 +84,7 @@ bool DeleteEventFilter::eventFilter(QObject* dist, QEvent* event) LostFocusFilter::LostFocusFilter(QObject* parent) : QObject(parent) {} -bool LostFocusFilter::eventFilter(QObject* obj, QEvent* event) -{ +bool LostFocusFilter::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::FocusOut) return true; @@ -98,12 +94,9 @@ bool LostFocusFilter::eventFilter(QObject* obj, QEvent* event) // ---------------------------------------------------------------------------- ShortcodeFilter::ShortcodeFilter(const QString& shortcode, QObject* parent) - : QObject(parent), m_shortcode(shortcode), m_index(0) -{ -} + : QObject(parent), m_shortcode(shortcode), m_index(0) {} -bool ShortcodeFilter::eventFilter(QObject* obj, QEvent* event) -{ +bool ShortcodeFilter::eventFilter(QObject* obj, QEvent* event) { Q_UNUSED(obj); if (event->type() == QEvent::KeyPress) { QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event); @@ -129,8 +122,7 @@ bool ShortcodeFilter::eventFilter(QObject* obj, QEvent* event) RightMouseButtonEater::RightMouseButtonEater(QObject* parent) : QObject(parent) {} -bool RightMouseButtonEater::eventFilter(QObject* obj, QEvent* event) -{ +bool RightMouseButtonEater::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::MouseButtonPress) { QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); if (mouseEvent->button() == Qt::RightButton) { @@ -150,14 +142,12 @@ bool RightMouseButtonEater::eventFilter(QObject* obj, QEvent* event) //! to trigger QTreeView delegate's mechanism to switch editors on "tab" press key. //! https://stackoverflow.com/questions/12145522/why-pressing-of-tab-key-emits-only-qeventshortcutoverride-event -TabFromFocusProxy::TabFromFocusProxy(QWidget* parent) : QObject(parent), m_parent(parent) -{ +TabFromFocusProxy::TabFromFocusProxy(QWidget* parent) : QObject(parent), m_parent(parent) { if (parent->focusProxy()) parent->focusProxy()->installEventFilter(this); } -bool TabFromFocusProxy::eventFilter(QObject* obj, QEvent* event) -{ +bool TabFromFocusProxy::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::KeyPress) { QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event); if (keyEvent->key() == Qt::Key_Tab || keyEvent->key() == Qt::Key_Backtab) { diff --git a/GUI/coregui/utils/CustomEventFilters.h b/GUI/coregui/utils/CustomEventFilters.h index 89054b07555364cff28c0de286a0d4d57f8f152f..8e5904ca2f081f20b15cdfcd1166fefc88c37a21 100644 --- a/GUI/coregui/utils/CustomEventFilters.h +++ b/GUI/coregui/utils/CustomEventFilters.h @@ -19,8 +19,7 @@ //! Filter out space bar key events, which is special case for dialog windows. -class SpaceKeyEater : public QObject -{ +class SpaceKeyEater : public QObject { Q_OBJECT public: SpaceKeyEater(QObject* parent = 0); @@ -32,8 +31,7 @@ protected: //! Event filter to install on combo boxes and spin boxes to not //! to react on wheel events during scrolling of InstrumentComponentWidget. -class WheelEventEater : public QObject -{ +class WheelEventEater : public QObject { Q_OBJECT public: WheelEventEater(QObject* parent = 0); @@ -44,8 +42,7 @@ protected: //! Lisens for press-del-key events -class DeleteEventFilter : public QObject -{ +class DeleteEventFilter : public QObject { Q_OBJECT public: DeleteEventFilter(QObject* parent = 0) : QObject(parent) {} @@ -59,8 +56,7 @@ signals: //! Event filter to prevent lost of focus by custom material editor. -class LostFocusFilter : public QObject -{ +class LostFocusFilter : public QObject { Q_OBJECT public: LostFocusFilter(QObject* parent = 0); @@ -71,8 +67,7 @@ protected: //! Event filter for global tracking of shortcodes. -class ShortcodeFilter : public QObject -{ +class ShortcodeFilter : public QObject { Q_OBJECT public: ShortcodeFilter(const QString& shortcode, QObject* parent = 0); @@ -88,8 +83,7 @@ protected: //! Filter out right mouse button events. -class RightMouseButtonEater : public QObject -{ +class RightMouseButtonEater : public QObject { Q_OBJECT public: RightMouseButtonEater(QObject* parent = 0); @@ -100,8 +94,7 @@ protected: //! Propagate tab events from focusProxy to parent. -class TabFromFocusProxy : public QObject -{ +class TabFromFocusProxy : public QObject { Q_OBJECT public: TabFromFocusProxy(QWidget* parent = 0); diff --git a/GUI/coregui/utils/FancyLabel.cpp b/GUI/coregui/utils/FancyLabel.cpp index ab3e30259cb4b8a9662610fbef7fbd1c3867ead4..c826b549b9cc7e98eec9ea27752f829906db85c6 100644 --- a/GUI/coregui/utils/FancyLabel.cpp +++ b/GUI/coregui/utils/FancyLabel.cpp @@ -15,18 +15,15 @@ #include "GUI/coregui/utils/FancyLabel.h" #include <QTimer> -FancyLabel::FancyLabel(const QString& text, QWidget* parent) : QLabel(text, parent) -{ +FancyLabel::FancyLabel(const QString& text, QWidget* parent) : QLabel(text, parent) { init_fancy_label(); } -FancyLabel::FancyLabel(QWidget* parent) : QLabel(parent) -{ +FancyLabel::FancyLabel(QWidget* parent) : QLabel(parent) { init_fancy_label(); } -void FancyLabel::setTextAnimated(const QString& animated_text) -{ +void FancyLabel::setTextAnimated(const QString& animated_text) { if (m_timer->isActive()) { m_timer->stop(); } @@ -47,8 +44,7 @@ void FancyLabel::setTextAnimated(const QString& animated_text) m_timer->start(); } -void FancyLabel::timeout() -{ +void FancyLabel::timeout() { if (m_current_index <= m_text.size()) { setText(m_text.left(m_current_index)); m_current_index++; @@ -57,8 +53,7 @@ void FancyLabel::timeout() m_timer->stop(); } -void FancyLabel::init_fancy_label() -{ +void FancyLabel::init_fancy_label() { m_total_effect_duration = 200; // in msec m_current_index = 0; m_timer = new QTimer(this); diff --git a/GUI/coregui/utils/FancyLabel.h b/GUI/coregui/utils/FancyLabel.h index a232079e93878496f04cbffcc757e7f402ce86fb..6d4d0eb5b8fbdc115327c29b69d29a2b4ab288c0 100644 --- a/GUI/coregui/utils/FancyLabel.h +++ b/GUI/coregui/utils/FancyLabel.h @@ -19,8 +19,7 @@ //! The FancyLabel class is QLabel-like class with trivail animation, when text slowly //! appears on the screen from left to right pretending to be typed -class FancyLabel : public QLabel -{ +class FancyLabel : public QLabel { Q_OBJECT public: FancyLabel(const QString& text, QWidget* parent = 0); diff --git a/GUI/coregui/utils/GUIHelpers.cpp b/GUI/coregui/utils/GUIHelpers.cpp index 9bcb932584c4ecfb05a2db1c994f6fdc2b44519a..c1afeb366a354c2d45ab9f43623c74ae1c1f9dda 100644 --- a/GUI/coregui/utils/GUIHelpers.cpp +++ b/GUI/coregui/utils/GUIHelpers.cpp @@ -24,10 +24,8 @@ #include <QTextStream> #include <QUuid> -namespace -{ -QMap<QString, QString> initializeCharacterMap() -{ +namespace { +QMap<QString, QString> initializeCharacterMap() { QMap<QString, QString> result; result["\\"] = "_backslash_"; result["/"] = "_slash_"; @@ -42,19 +40,16 @@ QMap<QString, QString> initializeCharacterMap() const QMap<QString, QString> invalidCharacterMap = initializeCharacterMap(); } // Anonymous namespace -namespace GUIHelpers -{ +namespace GUIHelpers { Error::~Error() noexcept = default; -const char* Error::what() const noexcept -{ +const char* Error::what() const noexcept { return message.toLatin1().data(); } void information(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText) -{ + const QString& detailedText) { QScopedPointer<QMessageBox> messageBox(new QMessageBox(parent)); if (parent) messageBox->setWindowModality(Qt::WindowModal); @@ -68,8 +63,7 @@ void information(QWidget* parent, const QString& title, const QString& text, } void warning(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText) -{ + const QString& detailedText) { QScopedPointer<QMessageBox> messageBox(new QMessageBox(parent)); if (parent) messageBox->setWindowModality(Qt::WindowModal); @@ -83,8 +77,7 @@ void warning(QWidget* parent, const QString& title, const QString& text, } bool question(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText, const QString& yesText, const QString& noText) -{ + const QString& detailedText, const QString& yesText, const QString& noText) { QScopedPointer<QMessageBox> messageBox(new QMessageBox(parent)); if (parent) messageBox->setWindowModality(Qt::WindowModal); @@ -101,8 +94,7 @@ bool question(QWidget* parent, const QString& title, const QString& text, } bool okToDelete(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText) -{ + const QString& detailedText) { QScopedPointer<QMessageBox> messageBox(new QMessageBox(parent)); if (parent) messageBox->setWindowModality(Qt::WindowModal); @@ -118,8 +110,7 @@ bool okToDelete(QWidget* parent, const QString& title, const QString& text, return messageBox->clickedButton() == deleteButton; } -QString getBornAgainVersionString() -{ +QString getBornAgainVersionString() { return QString::fromStdString(BornAgain::GetVersionNumber()); } @@ -132,8 +123,7 @@ QString getBornAgainVersionString() //! > greaterthan //! | pipe //! ? questionmark -QString getValidFileName(const QString& proposed_name) -{ +QString getValidFileName(const QString& proposed_name) { QString result = proposed_name; for (auto it = invalidCharacterMap.begin(); it != invalidCharacterMap.end(); ++it) { result.replace(it.key(), it.value()); @@ -142,8 +132,7 @@ QString getValidFileName(const QString& proposed_name) } //! parses version string into 3 numbers, returns true in the case of success -bool parseVersion(const QString& version, int& major_num, int& minor_num, int& patch_num) -{ +bool parseVersion(const QString& version, int& major_num, int& minor_num, int& patch_num) { major_num = minor_num = patch_num = 0; bool success(true); QStringList nums = version.split("."); @@ -161,8 +150,7 @@ bool parseVersion(const QString& version, int& major_num, int& minor_num, int& p return success; } -int versionCode(const QString& version) -{ +int versionCode(const QString& version) { int result(-1); int ba_major(0), ba_minor(0), ba_patch(0); @@ -175,14 +163,12 @@ int versionCode(const QString& version) } //! returns true if current BornAgain version match minimal required version -bool isVersionMatchMinimal(const QString& version, const QString& minimal_version) -{ +bool isVersionMatchMinimal(const QString& version, const QString& minimal_version) { return versionCode(version) >= versionCode(minimal_version); } //! Returns file directory from the full file path -QString fileDir(const QString& fileName) -{ +QString fileDir(const QString& fileName) { QFileInfo info(fileName); if (info.exists()) { return info.dir().path(); @@ -192,8 +178,7 @@ QString fileDir(const QString& fileName) //! Returns base name of file. -QString baseName(const QString& fileName) -{ +QString baseName(const QString& fileName) { QFileInfo info(fileName); return info.baseName(); } @@ -201,8 +186,7 @@ QString baseName(const QString& fileName) //! Creates sub directory in given parent directory (should exist). //! If sub-directory already exists, no action will be taken. -void createSubdir(const QString& parentName, const QString& subdirName) -{ +void createSubdir(const QString& parentName, const QString& subdirName) { QDir projectDir(parentName); if (!projectDir.exists(subdirName)) { if (!projectDir.mkdir(subdirName)) @@ -211,8 +195,7 @@ void createSubdir(const QString& parentName, const QString& subdirName) } } -QString currentDateTime() -{ +QString currentDateTime() { return QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss"); ; } @@ -226,16 +209,14 @@ QString currentDateTime() // return result; //} -QVector<double> fromStdVector(const std::vector<double>& data) -{ +QVector<double> fromStdVector(const std::vector<double>& data) { QVector<double> result; result.reserve(int(data.size())); std::copy(data.begin(), data.end(), std::back_inserter(result)); return result; } -QStringList fromStdStrings(const std::vector<std::string>& container) -{ +QStringList fromStdStrings(const std::vector<std::string>& container) { QStringList result; for (std::string str : container) { result.append(QString::fromStdString(str)); @@ -243,13 +224,11 @@ QStringList fromStdStrings(const std::vector<std::string>& container) return result; } -QString createUuid() -{ +QString createUuid() { return QUuid::createUuid().toString(); } -QString readTextFile(const QString& fileName) -{ +QString readTextFile(const QString& fileName) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) throw GUIHelpers::Error("PyImportAssistant::readFile() -> Error. Can't read file '" diff --git a/GUI/coregui/utils/GUIHelpers.h b/GUI/coregui/utils/GUIHelpers.h index e7b28777fdb2f071326999d320517a787750d49c..2d4f5c552c86e7241a02492fc6bf47a13b00c8d0 100644 --- a/GUI/coregui/utils/GUIHelpers.h +++ b/GUI/coregui/utils/GUIHelpers.h @@ -23,10 +23,8 @@ class JobItem; class RealDataItem; -namespace GUIHelpers -{ -class Error : public std::exception -{ +namespace GUIHelpers { +class Error : public std::exception { public: explicit Error(const QString& message) noexcept : message(message) {} virtual ~Error() noexcept; @@ -79,8 +77,7 @@ QString readTextFile(const QString& fileName); } // namespace GUIHelpers -inline std::ostream& operator<<(std::ostream& stream, const QString& str) -{ +inline std::ostream& operator<<(std::ostream& stream, const QString& str) { stream << str.toStdString(); return stream; } diff --git a/GUI/coregui/utils/GUIMessage.cpp b/GUI/coregui/utils/GUIMessage.cpp index c38154fa29a9b3a9a7ac5374f0d34a3cd0577d2c..6290cacf6ee81976b4b70a8be41672a038285030 100644 --- a/GUI/coregui/utils/GUIMessage.cpp +++ b/GUI/coregui/utils/GUIMessage.cpp @@ -20,40 +20,32 @@ GUIMessage::GUIMessage(const QString& senderName, const QString& messageType, : m_sender(nullptr) , m_senderName(senderName) , m_messageType(messageType) - , m_messageDescription(messageDescription) -{ -} + , m_messageDescription(messageDescription) {} GUIMessage::GUIMessage(const QObject* sender, const QString& messageType, const QString& messageDescription) - : m_sender(sender), m_messageType(messageType), m_messageDescription(messageDescription) -{ + : m_sender(sender), m_messageType(messageType), m_messageDescription(messageDescription) { m_senderName = sender->objectName(); } -QString GUIMessage::senderName() const -{ +QString GUIMessage::senderName() const { return m_senderName; } -QString GUIMessage::messageType() const -{ +QString GUIMessage::messageType() const { return m_messageType; } -QString GUIMessage::messageDescription() const -{ +QString GUIMessage::messageDescription() const { return m_messageDescription; } -QString GUIMessage::text() const -{ +QString GUIMessage::text() const { QString result = QString("%1 %2 %3").arg(m_senderName).arg(m_messageType).arg(m_messageDescription); return result; } -const QObject* GUIMessage::sender() const -{ +const QObject* GUIMessage::sender() const { return m_sender; } diff --git a/GUI/coregui/utils/GUIMessage.h b/GUI/coregui/utils/GUIMessage.h index 97756ee37fd2b761566a42a7b26c1ef151d441e4..a18ba4e4ffe3306ca051fa605cbf7dc631a915a5 100644 --- a/GUI/coregui/utils/GUIMessage.h +++ b/GUI/coregui/utils/GUIMessage.h @@ -19,8 +19,7 @@ class QObject; -class GUIMessage -{ +class GUIMessage { public: GUIMessage(const QString& senderName, const QString& messageType, const QString& messageDescription); diff --git a/GUI/coregui/utils/ImportDataInfo.cpp b/GUI/coregui/utils/ImportDataInfo.cpp index 591c966e951050ee1f586d32aaaf8f87fa139bc9..8c0cf8576d6603203e73ad0f77cd46beaca7ed8d 100644 --- a/GUI/coregui/utils/ImportDataInfo.cpp +++ b/GUI/coregui/utils/ImportDataInfo.cpp @@ -18,10 +18,8 @@ #include "GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ -std::vector<Axes::Units> specularUnits() -{ +namespace { +std::vector<Axes::Units> specularUnits() { std::vector<Axes::Units> result; const auto units_map = AxisNames::InitSpecAxis(); for (auto& pair : units_map) @@ -37,58 +35,48 @@ std::map<size_t, std::vector<Axes::Units>> available_units = {{1u, specularUnits ImportDataInfo::ImportDataInfo() = default; ImportDataInfo::ImportDataInfo(ImportDataInfo&& other) - : m_data(std::move(other.m_data)), m_units(other.m_units) -{ -} + : m_data(std::move(other.m_data)), m_units(other.m_units) {} ImportDataInfo::ImportDataInfo(std::unique_ptr<OutputData<double>> data, Axes::Units units) : m_data(units == Axes::Units::NBINS && data ? ImportDataUtils::CreateSimplifiedOutputData(*data) : std::move(data)) - , m_units(units) -{ + , m_units(units) { checkValidity(); } ImportDataInfo::ImportDataInfo(std::unique_ptr<OutputData<double>> data, const QString& units_label) - : m_data(std::move(data)), m_units(JobItemUtils::axesUnitsFromName(units_label)) -{ + : m_data(std::move(data)), m_units(JobItemUtils::axesUnitsFromName(units_label)) { checkValidity(); } ImportDataInfo::~ImportDataInfo() = default; -ImportDataInfo::operator bool() const -{ +ImportDataInfo::operator bool() const { return static_cast<bool>(m_data); } -std::unique_ptr<OutputData<double>> ImportDataInfo::intensityData() const& -{ +std::unique_ptr<OutputData<double>> ImportDataInfo::intensityData() const& { if (!m_data) return nullptr; return std::unique_ptr<OutputData<double>>(m_data->clone()); } -std::unique_ptr<OutputData<double>> ImportDataInfo::intensityData() && -{ +std::unique_ptr<OutputData<double>> ImportDataInfo::intensityData() && { return std::move(m_data); } -size_t ImportDataInfo::dataRank() const -{ +size_t ImportDataInfo::dataRank() const { if (!m_data) return 0; return m_data->rank(); } -QString ImportDataInfo::unitsLabel() const -{ +QString ImportDataInfo::unitsLabel() const { return JobItemUtils::nameFromAxesUnits(m_units); } -QString ImportDataInfo::axisLabel(size_t axis_index) const -{ +QString ImportDataInfo::axisLabel(size_t axis_index) const { if (!m_data) return ""; @@ -105,8 +93,7 @@ QString ImportDataInfo::axisLabel(size_t axis_index) const throw GUIHelpers::Error("Error in ImportDataInfo::axisLabel: unsupported data type"); } -void ImportDataInfo::checkValidity() -{ +void ImportDataInfo::checkValidity() { if (!m_data) return; auto iter = available_units.find(m_data->rank()); diff --git a/GUI/coregui/utils/ImportDataInfo.h b/GUI/coregui/utils/ImportDataInfo.h index 595158b5c19273990ccd98346a7132dc0ad8faeb..3fc48635625fdf54195f1f83f7d6abb310feb1ab 100644 --- a/GUI/coregui/utils/ImportDataInfo.h +++ b/GUI/coregui/utils/ImportDataInfo.h @@ -23,8 +23,7 @@ template <class T> class OutputData; //! Carries information about loaded data. -class ImportDataInfo -{ +class ImportDataInfo { public: ImportDataInfo(); ImportDataInfo(ImportDataInfo&& other); diff --git a/GUI/coregui/utils/ItemIDFactory.cpp b/GUI/coregui/utils/ItemIDFactory.cpp index bc5717545391fdd39a9c613eabdb2f861353aa25..68e43606f3acadde2f86533877ee2a52c83fe129 100644 --- a/GUI/coregui/utils/ItemIDFactory.cpp +++ b/GUI/coregui/utils/ItemIDFactory.cpp @@ -14,14 +14,12 @@ #include "GUI/coregui/utils/ItemIDFactory.h" -ItemIDFactory& ItemIDFactory::instance() -{ +ItemIDFactory& ItemIDFactory::instance() { static ItemIDFactory instance; return instance; } -QString ItemIDFactory::createID(SessionItem* toBeInsertedItem) -{ +QString ItemIDFactory::createID(SessionItem* toBeInsertedItem) { QUuid id = QUuid::createUuid(); QString id_String = id.toString(); @@ -37,24 +35,21 @@ QString ItemIDFactory::createID(SessionItem* toBeInsertedItem) return id_String; } -QString ItemIDFactory::getID(SessionItem* existingItem) -{ +QString ItemIDFactory::getID(SessionItem* existingItem) { if (instance().ItemtoIDMap.contains(existingItem)) return instance().ItemtoIDMap.value(existingItem); else return ""; } -SessionItem* ItemIDFactory::getItem(QString existingID) -{ +SessionItem* ItemIDFactory::getItem(QString existingID) { if (instance().IDtoItemMap.contains(existingID)) return instance().IDtoItemMap.value(existingID); else return nullptr; } -int ItemIDFactory::IDSize() -{ +int ItemIDFactory::IDSize() { static QUuid id = QUuid::createUuid(); return id.toString().size(); } diff --git a/GUI/coregui/utils/ItemIDFactory.h b/GUI/coregui/utils/ItemIDFactory.h index 3fd2f0c650e3f785b350a2b092715a521e6c8a96..a9b0b061dd619bcdbe232aabc66fd5fbe5cc392f 100644 --- a/GUI/coregui/utils/ItemIDFactory.h +++ b/GUI/coregui/utils/ItemIDFactory.h @@ -20,8 +20,7 @@ class SessionItem; -class ItemIDFactory -{ +class ItemIDFactory { public: // delete copy/move constructor/assignment: ItemIDFactory(const ItemIDFactory&) = delete; diff --git a/GUI/coregui/utils/LayoutUtils.cpp b/GUI/coregui/utils/LayoutUtils.cpp index 945b7c32e9fc60226ab1e37c93fc7c9428d88d8d..cfab19346b8a8e638b550443a3fb228293253eaa 100644 --- a/GUI/coregui/utils/LayoutUtils.cpp +++ b/GUI/coregui/utils/LayoutUtils.cpp @@ -18,8 +18,7 @@ #include <QLayoutItem> #include <QWidget> -void LayoutUtils::clearLayout(QLayout* layout, bool deleteWidgets) -{ +void LayoutUtils::clearLayout(QLayout* layout, bool deleteWidgets) { if (!layout) return; @@ -41,8 +40,7 @@ void LayoutUtils::clearLayout(QLayout* layout, bool deleteWidgets) //! Important: according to explanations given, grid layouts can only grow and never shrink. //! -namespace -{ +namespace { void remove(QGridLayout* layout, int row, int column, bool deleteWidgets); void deleteChildWidgets(QLayoutItem* item); } // namespace @@ -56,8 +54,7 @@ void deleteChildWidgets(QLayoutItem* item); * will stay the same after this function has been called). */ -void LayoutUtils::removeRow(QGridLayout* layout, int row, bool deleteWidgets) -{ +void LayoutUtils::removeRow(QGridLayout* layout, int row, bool deleteWidgets) { remove(layout, row, -1, deleteWidgets); layout->setRowMinimumHeight(row, 0); layout->setRowStretch(row, 0); @@ -72,22 +69,19 @@ void LayoutUtils::removeRow(QGridLayout* layout, int row, bool deleteWidgets) * indices will stay the same after this function has been called). */ -void LayoutUtils::removeColumn(QGridLayout* layout, int column, bool deleteWidgets) -{ +void LayoutUtils::removeColumn(QGridLayout* layout, int column, bool deleteWidgets) { remove(layout, -1, column, deleteWidgets); layout->setColumnMinimumWidth(column, 0); layout->setColumnStretch(column, 0); } -void LayoutUtils::clearGridLayout(QGridLayout* layout, bool deleteWidgets) -{ +void LayoutUtils::clearGridLayout(QGridLayout* layout, bool deleteWidgets) { for (int i_row = 0; i_row < layout->rowCount(); ++i_row) { LayoutUtils::removeRow(layout, i_row, deleteWidgets); } } -namespace -{ +namespace { /** * Helper function. Removes all layout items within the given layout @@ -96,8 +90,7 @@ namespace * layout, but also deleted. */ -void remove(QGridLayout* layout, int row, int column, bool deleteWidgets) -{ +void remove(QGridLayout* layout, int row, int column, bool deleteWidgets) { // We avoid usage of QGridLayout::itemAtPosition() here to improve performance. for (int i = layout->count() - 1; i >= 0; i--) { int r, c, rs, cs; @@ -117,8 +110,7 @@ void remove(QGridLayout* layout, int row, int column, bool deleteWidgets) * Helper function. Deletes all child widgets of the given layout item. */ -void deleteChildWidgets(QLayoutItem* item) -{ +void deleteChildWidgets(QLayoutItem* item) { if (item->layout()) { // Process all child items recursively. for (int i = 0; i < item->layout()->count(); i++) { @@ -130,8 +122,7 @@ void deleteChildWidgets(QLayoutItem* item) } // namespace -QWidget* LayoutUtils::placeHolder() -{ +QWidget* LayoutUtils::placeHolder() { auto result = new QWidget; result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); return result; diff --git a/GUI/coregui/utils/LayoutUtils.h b/GUI/coregui/utils/LayoutUtils.h index 15afb3998796f8a4298f1e9f6198370e66dbfa20..3dbad3191038dc1b431060228ed095ec947630ac 100644 --- a/GUI/coregui/utils/LayoutUtils.h +++ b/GUI/coregui/utils/LayoutUtils.h @@ -22,8 +22,7 @@ class QWidget; //! Utility functions to add/remove widgets to the layout on the fly. //! Taken from https://stackoverflow.com/questions/5395266/removing-widgets-from-qgridlayout -namespace LayoutUtils -{ +namespace LayoutUtils { //! Removes content from box layout. void clearLayout(QLayout* layout, bool deleteWidgets = true); diff --git a/GUI/coregui/utils/MessageService.cpp b/GUI/coregui/utils/MessageService.cpp index 93ae12f9305e10550acef94abdcfb0c7121805c0..d9e560a5f44d2b532d64c7a6244dda970b2b1cd6 100644 --- a/GUI/coregui/utils/MessageService.cpp +++ b/GUI/coregui/utils/MessageService.cpp @@ -17,19 +17,16 @@ #include <QObject> #include <QSet> -namespace -{ +namespace { const QString message_error_type = "Error"; const QString message_warning_type = "Warning"; } // namespace -MessageService::~MessageService() -{ +MessageService::~MessageService() { clear(); } -void MessageService::clear() -{ +void MessageService::clear() { for (auto message : m_messages) delete message; @@ -37,28 +34,23 @@ void MessageService::clear() } void MessageService::send_message(QObject* sender, const QString& message_type, - const QString& description) -{ + const QString& description) { m_messages.append(new GUIMessage(sender, message_type, description)); } -void MessageService::send_error(QObject* sender, const QString& description) -{ +void MessageService::send_error(QObject* sender, const QString& description) { send_message(sender, message_error_type, description); } -void MessageService::send_warning(QObject* sender, const QString& description) -{ +void MessageService::send_warning(QObject* sender, const QString& description) { send_message(sender, message_warning_type, description); } -const QList<GUIMessage*> MessageService::messages() const -{ +const QList<GUIMessage*> MessageService::messages() const { return m_messages; } -QStringList MessageService::senderList() const -{ +QStringList MessageService::senderList() const { QSet<QString> set; for (auto message : messages()) set.insert(message->senderName()); @@ -73,8 +65,7 @@ QStringList MessageService::senderList() const //! Reports number of messages of given type reported by the sender. //! If message_type.isEmpty, count all messages of given sender. -int MessageService::messageCount(const QObject* sender, const QString& message_type) const -{ +int MessageService::messageCount(const QObject* sender, const QString& message_type) const { int result(0); for (auto message : messages()) if (sender && message->sender() == sender) { @@ -95,23 +86,20 @@ int MessageService::messageCount(const QObject* sender, const QString& message_t //! Returns number of warnings for given sender. //! If sender is nullptr, report total number of warnings. -int MessageService::warningCount(const QObject* sender) const -{ +int MessageService::warningCount(const QObject* sender) const { return messageCount(sender, message_warning_type); } //! Returns number of errors for given sender. //! If sender is nullptr, report total number of errors. -int MessageService::errorCount(const QObject* sender) const -{ +int MessageService::errorCount(const QObject* sender) const { return messageCount(sender, message_error_type); } //! Returns multi-line string representing error messages of given sender. -QStringList MessageService::errorDescriptionList(const QObject* sender) const -{ +QStringList MessageService::errorDescriptionList(const QObject* sender) const { QStringList result; for (auto message : messages()) diff --git a/GUI/coregui/utils/MessageService.h b/GUI/coregui/utils/MessageService.h index 12066608dc3a875e96fb7a65cc3947309042a59f..ba97373f48e819a78ebfb418f3fc6de041af0095 100644 --- a/GUI/coregui/utils/MessageService.h +++ b/GUI/coregui/utils/MessageService.h @@ -25,8 +25,7 @@ class GUIMessage; //! @class MessageService //! @brief The service to collect messages from different senders. -class MessageService -{ +class MessageService { public: virtual ~MessageService(); diff --git a/GUI/coregui/utils/StyleUtils.cpp b/GUI/coregui/utils/StyleUtils.cpp index 62700857d25d51f68cef55a7743b207c8f949bbc..1839f21ad5e5d61cccf8b74eff5c2c4ad49c5714 100644 --- a/GUI/coregui/utils/StyleUtils.cpp +++ b/GUI/coregui/utils/StyleUtils.cpp @@ -22,27 +22,23 @@ #include <QDialog> #include <QTreeView> -namespace -{ +namespace { Utils::DetailsWidget* createEmptyDetailsWidget(const QString& name, bool expanded); QSize FindSizeOfLetterM(const QWidget* widget); -QSize DefaultSizeOfLetterM() -{ +QSize DefaultSizeOfLetterM() { QWidget widget; return FindSizeOfLetterM(&widget); } } // namespace -void StyleUtils::setPropertyStyle(QTreeView* tree) -{ +void StyleUtils::setPropertyStyle(QTreeView* tree) { ASSERT(tree); tree->setStyleSheet(StyleUtils::propertyTreeStyle()); tree->setAlternatingRowColors(true); } -QString StyleUtils::propertyTreeStyle() -{ +QString StyleUtils::propertyTreeStyle() { QString result; // lines arount cell content @@ -67,8 +63,7 @@ QString StyleUtils::propertyTreeStyle() return result; } -QFont StyleUtils::sectionFont(bool bold) -{ +QFont StyleUtils::sectionFont(bool bold) { QFont result; result.setPointSize(DesignerHelper::getSectionFontSize()); result.setBold(bold); @@ -76,8 +71,7 @@ QFont StyleUtils::sectionFont(bool bold) return result; } -QFont StyleUtils::labelFont(bool bold) -{ +QFont StyleUtils::labelFont(bool bold) { QFont result; result.setPointSize(DesignerHelper::getLabelFontSize()); result.setBold(bold); @@ -85,8 +79,7 @@ QFont StyleUtils::labelFont(bool bold) return result; } -void StyleUtils::setResizable(QDialog* dialog) -{ +void StyleUtils::setResizable(QDialog* dialog) { if (GUI_OS_Utils::HostOsInfo::isMacHost()) { dialog->setWindowFlags(Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint @@ -94,41 +87,34 @@ void StyleUtils::setResizable(QDialog* dialog) } } -QWidget* StyleUtils::createDetailsWidget(QWidget* content, const QString& name, bool expanded) -{ +QWidget* StyleUtils::createDetailsWidget(QWidget* content, const QString& name, bool expanded) { auto result = createEmptyDetailsWidget(name, expanded); result->setWidget(content); return result; } -QWidget* StyleUtils::createDetailsWidget(QLayout* layout, const QString& name, bool expanded) -{ +QWidget* StyleUtils::createDetailsWidget(QLayout* layout, const QString& name, bool expanded) { auto placeholder = new QWidget(); placeholder->setLayout(layout); return createDetailsWidget(placeholder, name, expanded); } -QSize StyleUtils::SizeOfLetterM(const QWidget* widget) -{ +QSize StyleUtils::SizeOfLetterM(const QWidget* widget) { static QSize default_size = DefaultSizeOfLetterM(); return widget ? FindSizeOfLetterM(widget) : default_size; } -int StyleUtils::SystemPointSize() -{ +int StyleUtils::SystemPointSize() { return QApplication::font().pointSize(); } -int StyleUtils::PropertyPanelWidth() -{ +int StyleUtils::PropertyPanelWidth() { return SizeOfLetterM().width() * 16; } -namespace -{ +namespace { -Utils::DetailsWidget* createEmptyDetailsWidget(const QString& name, bool expanded) -{ +Utils::DetailsWidget* createEmptyDetailsWidget(const QString& name, bool expanded) { auto result = new Utils::DetailsWidget; result->setSummaryText(name); result->setSummaryFontBold(true); @@ -139,8 +125,7 @@ Utils::DetailsWidget* createEmptyDetailsWidget(const QString& name, bool expande //! Calculates size of letter `M` for current system font settings. -QSize FindSizeOfLetterM(const QWidget* widget) -{ +QSize FindSizeOfLetterM(const QWidget* widget) { QFontMetrics fontMetric(widget->font()); #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) auto em = fontMetric.horizontalAdvance('M'); diff --git a/GUI/coregui/utils/StyleUtils.h b/GUI/coregui/utils/StyleUtils.h index 51d4341bdc4cd541540ccef0d8a914e0814bd459..84fa2ff9f98a16b4bf507177be17c29357ed9805 100644 --- a/GUI/coregui/utils/StyleUtils.h +++ b/GUI/coregui/utils/StyleUtils.h @@ -23,8 +23,7 @@ class QWidget; class QLayout; class QWidget; -namespace StyleUtils -{ +namespace StyleUtils { //! Sets style for the tree to use in property editors. void setPropertyStyle(QTreeView* tree); diff --git a/GUI/coregui/utils/hostosinfo.h b/GUI/coregui/utils/hostosinfo.h index 91985aa88e5d5782716409353f4b01a33b596aee..1f2b2684d582cbcde68bd809aee911081962123a 100644 --- a/GUI/coregui/utils/hostosinfo.h +++ b/GUI/coregui/utils/hostosinfo.h @@ -17,35 +17,30 @@ #include <QString> -namespace GUI_OS_Utils -{ +namespace GUI_OS_Utils { #define QTC_WIN_EXE_SUFFIX ".exe" enum EOsType { WINDOWS_OS, LINUX_OS, MAC_OS, OTHER_UNIX_OS, OTHER_OS }; -class OsSpecificAspects -{ +class OsSpecificAspects { public: OsSpecificAspects(EOsType osType) : m_osType(osType) {} - QString withExecutableSuffix(const QString& executable) const - { + QString withExecutableSuffix(const QString& executable) const { QString finalName = executable; if (m_osType == WINDOWS_OS) finalName += QLatin1String(QTC_WIN_EXE_SUFFIX); return finalName; } - Qt::CaseSensitivity fileNameCaseSensitivity() const - { + Qt::CaseSensitivity fileNameCaseSensitivity() const { return m_osType == WINDOWS_OS ? Qt::CaseInsensitive : Qt::CaseSensitive; } QChar pathListSeparator() const { return QLatin1Char(m_osType == WINDOWS_OS ? ';' : ':'); } - Qt::KeyboardModifier controlModifier() const - { + Qt::KeyboardModifier controlModifier() const { return m_osType == MAC_OS ? Qt::MetaModifier : Qt::ControlModifier; } @@ -53,8 +48,7 @@ private: const EOsType m_osType; }; -class HostOsInfo -{ +class HostOsInfo { public: static inline EOsType hostOs(); @@ -72,13 +66,11 @@ public: static bool isMacHost() { return hostOs() == MAC_OS; } static inline bool isAnyUnixHost(); - static QString withExecutableSuffix(const QString& executable) - { + static QString withExecutableSuffix(const QString& executable) { return hostOsAspects().withExecutableSuffix(executable); } - static Qt::CaseSensitivity fileNameCaseSensitivity() - { + static Qt::CaseSensitivity fileNameCaseSensitivity() { return hostOsAspects().fileNameCaseSensitivity(); } @@ -90,8 +82,7 @@ private: static OsSpecificAspects hostOsAspects() { return OsSpecificAspects(hostOs()); } }; -EOsType HostOsInfo::hostOs() -{ +EOsType HostOsInfo::hostOs() { #if defined(Q_OS_WIN) return WINDOWS_OS; #elif defined(Q_OS_LINUX) @@ -105,8 +96,7 @@ EOsType HostOsInfo::hostOs() #endif } -bool HostOsInfo::isAnyUnixHost() -{ +bool HostOsInfo::isAnyUnixHost() { #ifdef Q_OS_UNIX return true; #else diff --git a/GUI/coregui/utils/qstringutils.cpp b/GUI/coregui/utils/qstringutils.cpp index ff59743a0b78927e37dc627482fed2cfad09895b..242655381e439fd1dbccc2d4775a99746a2a429c 100644 --- a/GUI/coregui/utils/qstringutils.cpp +++ b/GUI/coregui/utils/qstringutils.cpp @@ -16,11 +16,9 @@ #include "GUI/coregui/utils/hostosinfo.h" #include <QDir> -namespace GUI_StringUtils -{ +namespace GUI_StringUtils { -QString withTildeHomePath(const QString& path) -{ +QString withTildeHomePath(const QString& path) { if (GUI_OS_Utils::HostOsInfo::isWindowsHost()) return path; diff --git a/GUI/coregui/utils/qstringutils.h b/GUI/coregui/utils/qstringutils.h index e4bb614c09951fc7bc57be6ab6286566790d432d..5ad66013672b69ca75eb6ed79eadc7334b8e8009 100644 --- a/GUI/coregui/utils/qstringutils.h +++ b/GUI/coregui/utils/qstringutils.h @@ -17,8 +17,7 @@ #include <QString> -namespace GUI_StringUtils -{ +namespace GUI_StringUtils { QString withTildeHomePath(const QString& path); diff --git a/GUI/main/MessageHandler.cpp b/GUI/main/MessageHandler.cpp index 266f3925c2ff7e1fffcbc901edf0041d11f93fc4..c691f6b8cb9dcd2aaf922572012462fef8b34443 100644 --- a/GUI/main/MessageHandler.cpp +++ b/GUI/main/MessageHandler.cpp @@ -17,8 +17,7 @@ #include <iostream> //! This is set by main to be the message handler of our GUI. -void MessageHandler(QtMsgType type, const QMessageLogContext&, const QString& msg) -{ +void MessageHandler(QtMsgType type, const QMessageLogContext&, const QString& msg) { switch (type) { case QtDebugMsg: if (msg.size() == 0) // KDE will pass a zero-length msg qstring diff --git a/GUI/main/appoptions.cpp b/GUI/main/appoptions.cpp index a2355a1a047ea14eda67afc1f7433fd231adb063..9fadec7c027d2a437df29505c99e637034631092 100644 --- a/GUI/main/appoptions.cpp +++ b/GUI/main/appoptions.cpp @@ -20,14 +20,12 @@ #include <fstream> #include <iostream> -namespace -{ +namespace { const char* geometry = "geometry"; const char* nohighdpi = "nohighdpi"; //! Converts string "1600x1000" to QSize(1600, 1000) -QSize windowSize(const QString& size_string) -{ +QSize windowSize(const QString& size_string) { auto list = size_string.split("x"); if (list.size() != 2) @@ -37,8 +35,7 @@ QSize windowSize(const QString& size_string) } //! Returns true if windows size makes sence. -bool isValid(const QSize& win_size) -{ +bool isValid(const QSize& win_size) { if (win_size.width() > 640 && win_size.height() > 480) return true; @@ -47,8 +44,7 @@ bool isValid(const QSize& win_size) } // namespace -ApplicationOptions::ApplicationOptions(int argc, char** argv) : m_options_is_consistent(false) -{ +ApplicationOptions::ApplicationOptions(int argc, char** argv) : m_options_is_consistent(false) { m_options.add_options()("help,h", "print help message"); m_options.add_options()("with-debug", "run application with debug printout"); m_options.add_options()("no-splash", "do not show splash screen"); @@ -63,25 +59,21 @@ ApplicationOptions::ApplicationOptions(int argc, char** argv) : m_options_is_con //! access variables -const bpo::variable_value& ApplicationOptions::operator[](const std::string& s) const -{ +const bpo::variable_value& ApplicationOptions::operator[](const std::string& s) const { return m_variables_map[s.c_str()]; } -bool ApplicationOptions::find(std::string name) const -{ +bool ApplicationOptions::find(std::string name) const { return (m_variables_map.count(name.c_str())); } -bool ApplicationOptions::isConsistent() const -{ +bool ApplicationOptions::isConsistent() const { return m_options_is_consistent; } //! parse command line arguments -void ApplicationOptions::parseCommandLine(int argc, char** argv) -{ +void ApplicationOptions::parseCommandLine(int argc, char** argv) { m_options_is_consistent = false; // parsing command line arguments try { @@ -106,18 +98,15 @@ void ApplicationOptions::parseCommandLine(int argc, char** argv) } } -boost::program_options::variables_map& ApplicationOptions::getVariables() -{ +boost::program_options::variables_map& ApplicationOptions::getVariables() { return m_variables_map; } -boost::program_options::options_description& ApplicationOptions::getOptions() -{ +boost::program_options::options_description& ApplicationOptions::getOptions() { return m_options; } -void ApplicationOptions::processOptions() -{ +void ApplicationOptions::processOptions() { if (m_variables_map.count("help")) { printHelpMessage(); m_options_is_consistent = false; @@ -137,19 +126,16 @@ void ApplicationOptions::processOptions() } } -void ApplicationOptions::printHelpMessage() const -{ +void ApplicationOptions::printHelpMessage() const { std::cout << "BornAgain Graphical User Interface" << std::endl; std::cout << m_options << std::endl; } -QSize ApplicationOptions::mainWindowSize() const -{ +QSize ApplicationOptions::mainWindowSize() const { QString size_str = QString::fromStdString(m_variables_map[geometry].as<std::string>()); return windowSize(size_str); } -bool ApplicationOptions::disableHighDPISupport() -{ +bool ApplicationOptions::disableHighDPISupport() { return find(nohighdpi); } diff --git a/GUI/main/appoptions.h b/GUI/main/appoptions.h index 797f2fa3a1a075c5a45e0067c578d3a7822ce23e..634e69174f2f83446484b1b681daa4c25a8a728f 100644 --- a/GUI/main/appoptions.h +++ b/GUI/main/appoptions.h @@ -29,8 +29,7 @@ namespace bpo = boost::program_options; //! @ingroup tools_internal //! @brief Handles command line and config file program options -class ApplicationOptions -{ +class ApplicationOptions { public: ApplicationOptions(int argc = 0, char** argv = 0); diff --git a/GUI/main/main.cpp b/GUI/main/main.cpp index 14255dd5b312d9259f175c36d2b19f8e7c41f301..4f23b6c4772c32a4e59862fb57f77ba317112606 100644 --- a/GUI/main/main.cpp +++ b/GUI/main/main.cpp @@ -23,8 +23,7 @@ void messageHandler(QtMsgType, const QMessageLogContext&, const QString&) {} -int main(int argc, char* argv[]) -{ +int main(int argc, char* argv[]) { ApplicationOptions options(argc, argv); if (!options.isConsistent()) return 0; diff --git a/Param/Base/IParameter.h b/Param/Base/IParameter.h index 923e8f15ef2b4a668dda9d4314b6fd678f7463de..59b09db18cab03f2aee808b9a3ceaf55315a5202 100644 --- a/Param/Base/IParameter.h +++ b/Param/Base/IParameter.h @@ -25,8 +25,7 @@ //! This class is templated on the data type of the wrapped parameter. //! @ingroup tools_internal -template <class T> class IParameter -{ +template <class T> class IParameter { public: IParameter() = delete; IParameter(const std::string& name, T* data, const std::string& parent_name, @@ -39,8 +38,7 @@ public: virtual bool isNull() const { return m_data ? false : true; } T& getData() const { return *m_data; } - void setData(T& data) - { + void setData(T& data) { m_data = &data; m_onChange(); } @@ -61,16 +59,14 @@ protected: template <class T> IParameter<T>::IParameter(const std::string& name, T* data, const std::string& parent_name, const std::function<void()>& onChange) - : m_name(name), m_data(data), m_parent_name(parent_name), m_onChange(onChange) -{ + : m_name(name), m_data(data), m_parent_name(parent_name), m_onChange(onChange) { if (!m_data) throw std::runtime_error("Attempt to construct an IParameter with null data pointer"); } //! Returns true if two parameters are pointing to the same raw data. -template <class T> bool IParameter<T>::hasSameData(const IParameter<T>& other) -{ +template <class T> bool IParameter<T>::hasSameData(const IParameter<T>& other) { return &getData() == &other.getData(); } diff --git a/Param/Base/IParameterized.cpp b/Param/Base/IParameterized.cpp index c70adafb5da7307e956db75a66d60c644d1e838b..db193af0b6264f661f3a825de9e389c95f36c3b3 100644 --- a/Param/Base/IParameterized.cpp +++ b/Param/Base/IParameterized.cpp @@ -22,45 +22,39 @@ IParameterized::IParameterized(const std::string& name) : m_name{name}, m_pool{new ParameterPool} {} -IParameterized::IParameterized(const IParameterized& other) : IParameterized(other.getName()) -{ +IParameterized::IParameterized(const IParameterized& other) : IParameterized(other.getName()) { if (!other.parameterPool()->empty()) throw std::runtime_error("BUG: not prepared to copy parameters of " + getName()); } IParameterized::~IParameterized() = default; -ParameterPool* IParameterized::createParameterTree() const -{ +ParameterPool* IParameterized::createParameterTree() const { auto* result = new ParameterPool; m_pool->copyToExternalPool("/" + getName() + "/", result); return result; } -std::string IParameterized::parametersToString() const -{ +std::string IParameterized::parametersToString() const { std::ostringstream result; std::unique_ptr<ParameterPool> P_pool(createParameterTree()); result << *P_pool << "\n"; return result.str(); } -RealParameter& IParameterized::registerParameter(const std::string& name, double* data) -{ +RealParameter& IParameterized::registerParameter(const std::string& name, double* data) { return m_pool->addParameter( new RealParameter(name, data, getName(), [&]() -> void { onChange(); })); } void IParameterized::registerVector(const std::string& base_name, kvector_t* p_vec, - const std::string& units) -{ + const std::string& units) { registerParameter(XComponentName(base_name), &((*p_vec)[0])).setUnit(units); registerParameter(YComponentName(base_name), &((*p_vec)[1])).setUnit(units); registerParameter(ZComponentName(base_name), &((*p_vec)[2])).setUnit(units); } -void IParameterized::setParameterValue(const std::string& name, double value) -{ +void IParameterized::setParameterValue(const std::string& name, double value) { if (name.find('*') == std::string::npos && name.find('/') == std::string::npos) { m_pool->setParameterValue(name, value); } else { @@ -72,42 +66,35 @@ void IParameterized::setParameterValue(const std::string& name, double value) } } -void IParameterized::setVectorValue(const std::string& base_name, kvector_t value) -{ +void IParameterized::setVectorValue(const std::string& base_name, kvector_t value) { setParameterValue(XComponentName(base_name), value.x()); setParameterValue(YComponentName(base_name), value.y()); setParameterValue(ZComponentName(base_name), value.z()); } //! Returns parameter with given 'name'. -RealParameter* IParameterized::parameter(const std::string& name) const -{ +RealParameter* IParameterized::parameter(const std::string& name) const { return m_pool->parameter(name); } -void IParameterized::removeParameter(const std::string& name) -{ +void IParameterized::removeParameter(const std::string& name) { m_pool->removeParameter(name); } -void IParameterized::removeVector(const std::string& base_name) -{ +void IParameterized::removeVector(const std::string& base_name) { removeParameter(XComponentName(base_name)); removeParameter(YComponentName(base_name)); removeParameter(ZComponentName(base_name)); } -std::string IParameterized::XComponentName(const std::string& base_name) -{ +std::string IParameterized::XComponentName(const std::string& base_name) { return base_name + "X"; } -std::string IParameterized::YComponentName(const std::string& base_name) -{ +std::string IParameterized::YComponentName(const std::string& base_name) { return base_name + "Y"; } -std::string IParameterized::ZComponentName(const std::string& base_name) -{ +std::string IParameterized::ZComponentName(const std::string& base_name) { return base_name + "Z"; } diff --git a/Param/Base/IParameterized.h b/Param/Base/IParameterized.h index c0c3fdeedcd469d91d7f05ca30aca4f6fc45cbae..7ed6ea443d5b9ab18d008ed3fd17e335ddd3337f 100644 --- a/Param/Base/IParameterized.h +++ b/Param/Base/IParameterized.h @@ -25,8 +25,7 @@ class RealParameter; //! Manages a local parameter pool, and a tree of child pools. //! @ingroup tools_internal -class IParameterized -{ +class IParameterized { public: IParameterized(const std::string& name = ""); IParameterized(const IParameterized& other); diff --git a/Param/Base/ParameterPool.cpp b/Param/Base/ParameterPool.cpp index e81405a9f89ded01f0f556c3108e191a1e9db9fb..67f49f91c512e3437bfcfdc2f2dc43dca2d3d17c 100644 --- a/Param/Base/ParameterPool.cpp +++ b/Param/Base/ParameterPool.cpp @@ -26,15 +26,13 @@ ParameterPool::ParameterPool() = default; -ParameterPool::~ParameterPool() -{ +ParameterPool::~ParameterPool() { clear(); } //! Returns a literal clone. -ParameterPool* ParameterPool::clone() const -{ +ParameterPool* ParameterPool::clone() const { auto result = new ParameterPool(); for (auto par : m_params) result->addParameter(par->clone()); @@ -43,8 +41,7 @@ ParameterPool* ParameterPool::clone() const //! Clears the parameter map. -void ParameterPool::clear() -{ +void ParameterPool::clear() { for (auto* par : m_params) delete par; m_params.clear(); @@ -55,8 +52,7 @@ void ParameterPool::clear() //! Returning the input pointer allows us to concatenate function calls like //! pool->addParameter( new RealParameter(...) ).setLimits(-1,+1).setFixed().setUnit("nm") -RealParameter& ParameterPool::addParameter(RealParameter* newPar) -{ +RealParameter& ParameterPool::addParameter(RealParameter* newPar) { for (const auto* par : m_params) if (par->getName() == newPar->getName()) throw Exceptions::RuntimeErrorException("ParameterPool::addParameter() -> Error. " @@ -69,8 +65,7 @@ RealParameter& ParameterPool::addParameter(RealParameter* newPar) //! Copies parameters of given pool to _other_ pool, prepeding _prefix_ to the parameter names. -void ParameterPool::copyToExternalPool(const std::string& prefix, ParameterPool* other_pool) const -{ +void ParameterPool::copyToExternalPool(const std::string& prefix, ParameterPool* other_pool) const { for (const auto* par : m_params) { RealParameter* new_par = par->clone(prefix + par->getName()); other_pool->addParameter(new_par); @@ -79,8 +74,7 @@ void ParameterPool::copyToExternalPool(const std::string& prefix, ParameterPool* //! Returns parameter with given _name_. -const RealParameter* ParameterPool::parameter(const std::string& name) const -{ +const RealParameter* ParameterPool::parameter(const std::string& name) const { for (const auto* par : m_params) if (par->getName() == name) return par; @@ -90,15 +84,13 @@ const RealParameter* ParameterPool::parameter(const std::string& name) const //! Returns parameter with given _name_. -RealParameter* ParameterPool::parameter(const std::string& name) -{ +RealParameter* ParameterPool::parameter(const std::string& name) { return const_cast<RealParameter*>(static_cast<const ParameterPool*>(this)->parameter(name)); } //! Returns nonempty vector of parameters that match the _pattern_ ('*' allowed), or throws. -std::vector<RealParameter*> ParameterPool::getMatchedParameters(const std::string& pattern) const -{ +std::vector<RealParameter*> ParameterPool::getMatchedParameters(const std::string& pattern) const { std::vector<RealParameter*> result; // loop over all parameters in the pool for (auto* par : m_params) @@ -111,8 +103,7 @@ std::vector<RealParameter*> ParameterPool::getMatchedParameters(const std::strin //! Returns the one parameter that matches the _pattern_ (wildcards '*' allowed), or throws. -RealParameter* ParameterPool::getUniqueMatch(const std::string& pattern) const -{ +RealParameter* ParameterPool::getUniqueMatch(const std::string& pattern) const { std::vector<RealParameter*> matches = getMatchedParameters(pattern); if (matches.empty()) throw Exceptions::RuntimeErrorException( @@ -125,8 +116,7 @@ RealParameter* ParameterPool::getUniqueMatch(const std::string& pattern) const //! Sets parameter value. -void ParameterPool::setParameterValue(const std::string& name, double value) -{ +void ParameterPool::setParameterValue(const std::string& name, double value) { if (RealParameter* par = parameter(name)) { try { par->setValue(value); @@ -144,8 +134,7 @@ void ParameterPool::setParameterValue(const std::string& name, double value) //! Sets value of the nonzero parameters that match _pattern_ ('*' allowed), or throws. -int ParameterPool::setMatchedParametersValue(const std::string& pattern, double value) -{ +int ParameterPool::setMatchedParametersValue(const std::string& pattern, double value) { int npars = 0; for (RealParameter* par : getMatchedParameters(pattern)) { try { @@ -162,15 +151,13 @@ int ParameterPool::setMatchedParametersValue(const std::string& pattern, double //! Sets value of the one parameter that matches _pattern_ ('*' allowed), or throws. -void ParameterPool::setUniqueMatchValue(const std::string& pattern, double value) -{ +void ParameterPool::setUniqueMatchValue(const std::string& pattern, double value) { if (setMatchedParametersValue(pattern, value) != 1) throw Exceptions::RuntimeErrorException("ParameterPool::setUniqueMatchValue: pattern '" + pattern + "' is not unique"); } -std::vector<std::string> ParameterPool::parameterNames() const -{ +std::vector<std::string> ParameterPool::parameterNames() const { std::vector<std::string> result; for (const auto* par : m_params) result.push_back(par->getName()); @@ -179,34 +166,29 @@ std::vector<std::string> ParameterPool::parameterNames() const //! Removes parameter with given name from the pool. -void ParameterPool::removeParameter(const std::string& name) -{ +void ParameterPool::removeParameter(const std::string& name) { if (RealParameter* par = parameter(name)) { m_params.erase(std::remove(m_params.begin(), m_params.end(), par), m_params.end()); delete par; } } -const RealParameter* ParameterPool::operator[](size_t index) const -{ +const RealParameter* ParameterPool::operator[](size_t index) const { return m_params[check_index(index)]; } -RealParameter* ParameterPool::operator[](size_t index) -{ +RealParameter* ParameterPool::operator[](size_t index) { return const_cast<RealParameter*>(static_cast<const ParameterPool*>(this)->operator[](index)); } -void ParameterPool::print(std::ostream& ostr) const -{ +void ParameterPool::print(std::ostream& ostr) const { for (const auto* par : m_params) ostr << "'" << par->getName() << "'" << ":" << par->value() << "\n"; } //! reports error while finding parameters matching given name. -void ParameterPool::report_find_matched_parameters_error(const std::string& pattern) const -{ +void ParameterPool::report_find_matched_parameters_error(const std::string& pattern) const { std::ostringstream ostr; ostr << "ParameterPool::find_matched_parameters_error() -> Error! "; ostr << "No parameters matching pattern '" << pattern @@ -218,8 +200,7 @@ void ParameterPool::report_find_matched_parameters_error(const std::string& patt //! Reports error while setting parname to given value. void ParameterPool::report_set_value_error(const std::string& parname, double value, - std::string message) const -{ + std::string message) const { std::ostringstream ostr; ostr << "ParameterPool::set_value_error() -> Attempt to set value " << value; ostr << " for parameter '" << parname << "' failed."; @@ -228,8 +209,7 @@ void ParameterPool::report_set_value_error(const std::string& parname, double va throw Exceptions::RuntimeErrorException(ostr.str()); } -size_t ParameterPool::check_index(size_t index) const -{ +size_t ParameterPool::check_index(size_t index) const { if (index >= m_params.size()) throw std::runtime_error("ParameterPool::check_index() -> Error. Index out of bounds"); return index; diff --git a/Param/Base/ParameterPool.h b/Param/Base/ParameterPool.h index 82293188e58eff9353348dfe7608ca415f0aff3c..be23630d7137e682977076683c674a21abfbb06f 100644 --- a/Param/Base/ParameterPool.h +++ b/Param/Base/ParameterPool.h @@ -26,8 +26,7 @@ class RealParameter; //! Container with parameters for IParameterized object. //! @ingroup tools_internal -class ParameterPool : public ICloneable -{ +class ParameterPool : public ICloneable { public: ParameterPool(); virtual ~ParameterPool(); @@ -61,8 +60,7 @@ public: std::vector<std::string> parameterNames() const; - friend std::ostream& operator<<(std::ostream& ostr, const ParameterPool& obj) - { + friend std::ostream& operator<<(std::ostream& ostr, const ParameterPool& obj) { obj.print(ostr); return ostr; } diff --git a/Param/Base/RealParameter.cpp b/Param/Base/RealParameter.cpp index 1e48b1da9133ec0185aa8038621f69f6fb9d687d..c553b5d722bd2b3f90dab9df4640f750ebd7adb6 100644 --- a/Param/Base/RealParameter.cpp +++ b/Param/Base/RealParameter.cpp @@ -18,8 +18,7 @@ RealParameter::RealParameter(const std::string& name, double* par, const std::string& parent_name, const std::function<void()>& onChange, const RealLimits& limits, const Attributes& attr) - : IParameter<double>(name, par, parent_name, onChange), m_limits(limits), m_attr(attr) -{ + : IParameter<double>(name, par, parent_name, onChange), m_limits(limits), m_attr(attr) { if (!m_limits.isInRange(value())) { std::ostringstream message; message << "Cannot initialize parameter " << fullName() << " with value " << value() @@ -28,16 +27,14 @@ RealParameter::RealParameter(const std::string& name, double* par, const std::st } } -RealParameter* RealParameter::clone(const std::string& new_name) const -{ +RealParameter* RealParameter::clone(const std::string& new_name) const { auto* ret = new RealParameter(new_name != "" ? new_name : getName(), m_data, m_parent_name, m_onChange, m_limits); ret->setUnit(unit()); return ret; } -void RealParameter::setValue(double value) -{ +void RealParameter::setValue(double value) { if (value == *m_data) return; // nothing to do @@ -60,42 +57,35 @@ void RealParameter::setValue(double value) m_onChange(); } -double RealParameter::value() const -{ +double RealParameter::value() const { return *m_data; } -RealParameter& RealParameter::setLimits(const RealLimits& limits) -{ +RealParameter& RealParameter::setLimits(const RealLimits& limits) { m_limits = limits; return *this; } -RealLimits RealParameter::limits() const -{ +RealLimits RealParameter::limits() const { return m_limits; } -RealParameter& RealParameter::setLimited(double lower, double upper) -{ +RealParameter& RealParameter::setLimited(double lower, double upper) { setLimits(RealLimits::limited(lower, upper)); return *this; } -RealParameter& RealParameter::setPositive() -{ +RealParameter& RealParameter::setPositive() { setLimits(RealLimits::positive()); return *this; } -RealParameter& RealParameter::setNonnegative() -{ +RealParameter& RealParameter::setNonnegative() { setLimits(RealLimits::nonnegative()); return *this; } -RealParameter& RealParameter::setUnit(const std::string& name) -{ +RealParameter& RealParameter::setUnit(const std::string& name) { if (!(name == "" || name == "nm" || name == "rad" || name == "nm^2")) throw std::runtime_error("RealParameter::setUnit() -> Error. Unexpected unit name " + name); @@ -103,7 +93,6 @@ RealParameter& RealParameter::setUnit(const std::string& name) return *this; } -std::string RealParameter::unit() const -{ +std::string RealParameter::unit() const { return m_unit.getName(); } diff --git a/Param/Base/RealParameter.h b/Param/Base/RealParameter.h index 2b15362d19afab8f35e83b2786dfc31643caade2..ccd3c21e639dd097124870537e0e245340860691 100644 --- a/Param/Base/RealParameter.h +++ b/Param/Base/RealParameter.h @@ -28,8 +28,7 @@ class ParameterPool; //! this class holds Limits, Attributes (currently only fixed or not), and a Unit. //! @ingroup tools_internal -class RealParameter : public IParameter<double> -{ +class RealParameter : public IParameter<double> { public: RealParameter(const std::string& name, double* par, const std::string& parent_name = "", const std::function<void()>& onChange = std::function<void()>(), diff --git a/Param/Base/Unit.h b/Param/Base/Unit.h index 13bf1b2fa8f2413ee8795d434b70002048d4edaf..f259bf3347080c6b66a20992e0564c73d18fa83e 100644 --- a/Param/Base/Unit.h +++ b/Param/Base/Unit.h @@ -19,8 +19,7 @@ //! A physical unit. -class Unit -{ +class Unit { public: explicit Unit(const std::string& name = "") : m_name(name) {} void setUnit(const std::string& name) { m_name = name; } diff --git a/Param/Distrib/DistributionHandler.cpp b/Param/Distrib/DistributionHandler.cpp index 09e470078709346a285bcfe9a4686f16e39fa9f0..6f9e03874994c006f4e0d5001b450936f16d8228 100644 --- a/Param/Distrib/DistributionHandler.cpp +++ b/Param/Distrib/DistributionHandler.cpp @@ -17,15 +17,13 @@ #include "Param/Base/ParameterPool.h" #include "Param/Distrib/Distributions.h" -DistributionHandler::DistributionHandler() : m_nbr_combinations(1) -{ +DistributionHandler::DistributionHandler() : m_nbr_combinations(1) { setName("DistributionHandler"); } DistributionHandler::~DistributionHandler() = default; -void DistributionHandler::addParameterDistribution(const ParameterDistribution& par_distr) -{ +void DistributionHandler::addParameterDistribution(const ParameterDistribution& par_distr) { if (par_distr.getNbrSamples() > 0) { m_distributions.push_back(par_distr); m_nbr_combinations *= par_distr.getNbrSamples(); @@ -33,13 +31,11 @@ void DistributionHandler::addParameterDistribution(const ParameterDistribution& } } -size_t DistributionHandler::getTotalNumberOfSamples() const -{ +size_t DistributionHandler::getTotalNumberOfSamples() const { return m_nbr_combinations; } -double DistributionHandler::setParameterValues(ParameterPool* p_parameter_pool, size_t index) -{ +double DistributionHandler::setParameterValues(ParameterPool* p_parameter_pool, size_t index) { if (index >= m_nbr_combinations) throw Exceptions::RuntimeErrorException( "DistributionWeighter::setParameterValues: " @@ -66,8 +62,7 @@ double DistributionHandler::setParameterValues(ParameterPool* p_parameter_pool, return weight; } -void DistributionHandler::setParameterToMeans(ParameterPool* p_parameter_pool) const -{ +void DistributionHandler::setParameterToMeans(ParameterPool* p_parameter_pool) const { for (auto& distribution : m_distributions) { const std::string par_name = distribution.getMainParameterName(); const double mean_val = distribution.getDistribution()->getMean(); @@ -78,7 +73,6 @@ void DistributionHandler::setParameterToMeans(ParameterPool* p_parameter_pool) c } } -const DistributionHandler::Distributions_t& DistributionHandler::getDistributions() const -{ +const DistributionHandler::Distributions_t& DistributionHandler::getDistributions() const { return m_distributions; } diff --git a/Param/Distrib/DistributionHandler.h b/Param/Distrib/DistributionHandler.h index 673434e1cf639ac4581ce8b1ef3739009cb760a5..e7f5b5b867ac3552bc2c10cdd9c7faebf37a96d6 100644 --- a/Param/Distrib/DistributionHandler.h +++ b/Param/Distrib/DistributionHandler.h @@ -21,8 +21,7 @@ //! Provides the functionality to average over parameter distributions with weights. //! @ingroup algorithms_internal -class DistributionHandler : public IParameterized -{ +class DistributionHandler : public IParameterized { public: typedef std::vector<ParameterDistribution> Distributions_t; DistributionHandler(); diff --git a/Param/Distrib/Distributions.cpp b/Param/Distrib/Distributions.cpp index 01f1570ad9a43f5f0218bb248f9564dc7ff67626..395bcd00e43799eca89fe900852778d18c75112e 100644 --- a/Param/Distrib/Distributions.cpp +++ b/Param/Distrib/Distributions.cpp @@ -23,8 +23,7 @@ #include <limits> #include <sstream> -namespace -{ +namespace { bool DoubleEqual(double a, double b); } @@ -33,16 +32,13 @@ bool DoubleEqual(double a, double b); // ************************************************************************************************ IDistribution1D::IDistribution1D(const NodeMeta& meta, const std::vector<double>& PValues) - : INode(meta, PValues) -{ -} + : INode(meta, PValues) {} //! Returns equidistant samples, using intrinsic parameters, weighted with probabilityDensity(). std::vector<ParameterSample> IDistribution1D::equidistantSamples(size_t nbr_samples, double sigma_factor, - const RealLimits& limits) const -{ + const RealLimits& limits) const { if (nbr_samples == 0) throw Exceptions::OutOfBoundsException( "IDistribution1D::generateSamples: " @@ -55,8 +51,7 @@ std::vector<ParameterSample> IDistribution1D::equidistantSamples(size_t nbr_samp //! Returns equidistant samples from xmin to xmax, weighted with probabilityDensity(). std::vector<ParameterSample> -IDistribution1D::equidistantSamplesInRange(size_t nbr_samples, double xmin, double xmax) const -{ +IDistribution1D::equidistantSamplesInRange(size_t nbr_samples, double xmin, double xmax) const { if (nbr_samples == 0) throw Exceptions::OutOfBoundsException( "IDistribution1D::generateSamples: " @@ -69,8 +64,7 @@ IDistribution1D::equidistantSamplesInRange(size_t nbr_samples, double xmin, doub //! Returns equidistant interpolation points from xmin to xmax. std::vector<double> IDistribution1D::equidistantPointsInRange(size_t nbr_samples, double xmin, - double xmax) const -{ + double xmax) const { if (nbr_samples < 2 || DoubleEqual(xmin, xmax)) return {getMean()}; std::vector<double> result(nbr_samples); @@ -79,15 +73,13 @@ std::vector<double> IDistribution1D::equidistantPointsInRange(size_t nbr_samples return result; } -void IDistribution1D::setUnits(const std::string& units) -{ +void IDistribution1D::setUnits(const std::string& units) { for (auto* par : parameterPool()->parameters()) par->setUnit(units); } void IDistribution1D::adjustMinMaxForLimits(double& xmin, double& xmax, - const RealLimits& limits) const -{ + const RealLimits& limits) const { if (limits.hasLowerLimit() && xmin < limits.lowerLimit()) xmin = limits.lowerLimit(); if (limits.hasUpperLimit() && xmax > limits.upperLimit()) @@ -103,8 +95,7 @@ void IDistribution1D::adjustMinMaxForLimits(double& xmin, double& xmax, //! Returns weighted samples from given interpolation points and probabilityDensity(). std::vector<ParameterSample> -IDistribution1D::generateSamplesFromValues(const std::vector<double>& sample_values) const -{ +IDistribution1D::generateSamplesFromValues(const std::vector<double>& sample_values) const { std::vector<ParameterSample> result; double norm_factor = 0.0; for (double value : sample_values) { @@ -131,21 +122,17 @@ DistributionGate::DistributionGate(const std::vector<double> P) {{"Min", "", "para_tooltip", -INF, +INF, 0}, {"Max", "", "para_tooltip", -INF, +INF, 0}}}, P) , m_min(m_P[0]) - , m_max(m_P[1]) -{ + , m_max(m_P[1]) { if (m_max < m_min) throw Exceptions::ClassInitializationException("DistributionGate: max<min"); } DistributionGate::DistributionGate(double min, double max) - : DistributionGate(std::vector<double>{min, max}) -{ -} + : DistributionGate(std::vector<double>{min, max}) {} DistributionGate::DistributionGate() : DistributionGate(0., 1.) {} -double DistributionGate::probabilityDensity(double x) const -{ +double DistributionGate::probabilityDensity(double x) const { if (x < m_min || x > m_max) return 0.0; if (DoubleEqual(m_min, m_max)) @@ -154,16 +141,14 @@ double DistributionGate::probabilityDensity(double x) const } std::vector<double> DistributionGate::equidistantPoints(size_t nbr_samples, double /*sigma_factor*/, - const RealLimits& limits) const -{ + const RealLimits& limits) const { double xmin = m_min; double xmax = m_max; adjustMinMaxForLimits(xmin, xmax, limits); return equidistantPointsInRange(nbr_samples, xmin, xmax); } -bool DistributionGate::isDelta() const -{ +bool DistributionGate::isDelta() const { return DoubleEqual(m_min, m_max); } @@ -178,29 +163,24 @@ DistributionLorentz::DistributionLorentz(const std::vector<double> P) {"HWHM", "", "para_tooltip", -INF, +INF, 0}}}, P) , m_mean(m_P[0]) - , m_hwhm(m_P[1]) -{ + , m_hwhm(m_P[1]) { if (m_hwhm < 0.0) throw Exceptions::ClassInitializationException("DistributionLorentz: hwhm<0"); } DistributionLorentz::DistributionLorentz(double mean, double hwhm) - : DistributionLorentz(std::vector<double>{mean, hwhm}) -{ -} + : DistributionLorentz(std::vector<double>{mean, hwhm}) {} DistributionLorentz::DistributionLorentz() : DistributionLorentz(0., 1.) {} -double DistributionLorentz::probabilityDensity(double x) const -{ +double DistributionLorentz::probabilityDensity(double x) const { if (m_hwhm == 0.0) return DoubleEqual(x, m_mean) ? 1.0 : 0.0; return m_hwhm / (m_hwhm * m_hwhm + (x - m_mean) * (x - m_mean)) / M_PI; } std::vector<double> DistributionLorentz::equidistantPoints(size_t nbr_samples, double sigma_factor, - const RealLimits& limits) const -{ + const RealLimits& limits) const { if (sigma_factor <= 0.0) sigma_factor = 2.0; double xmin = m_mean - sigma_factor * m_hwhm; @@ -209,8 +189,7 @@ std::vector<double> DistributionLorentz::equidistantPoints(size_t nbr_samples, d return equidistantPointsInRange(nbr_samples, xmin, xmax); } -bool DistributionLorentz::isDelta() const -{ +bool DistributionLorentz::isDelta() const { return m_hwhm == 0.0; } @@ -225,21 +204,17 @@ DistributionGaussian::DistributionGaussian(const std::vector<double> P) {"StdDev", "", "para_tooltip", -INF, +INF, 0}}}, P) , m_mean(m_P[0]) - , m_std_dev(m_P[1]) -{ + , m_std_dev(m_P[1]) { if (m_std_dev < 0.0) throw Exceptions::ClassInitializationException("DistributionGaussian: std_dev < 0"); } DistributionGaussian::DistributionGaussian(double mean, double std_dev) - : DistributionGaussian(std::vector<double>{mean, std_dev}) -{ -} + : DistributionGaussian(std::vector<double>{mean, std_dev}) {} DistributionGaussian::DistributionGaussian() : DistributionGaussian(0., 1.) {} -double DistributionGaussian::probabilityDensity(double x) const -{ +double DistributionGaussian::probabilityDensity(double x) const { if (m_std_dev == 0.0) return DoubleEqual(x, m_mean) ? 1.0 : 0.0; double exponential = std::exp(-(x - m_mean) * (x - m_mean) / (2.0 * m_std_dev * m_std_dev)); @@ -247,8 +222,7 @@ double DistributionGaussian::probabilityDensity(double x) const } std::vector<double> DistributionGaussian::equidistantPoints(size_t nbr_samples, double sigma_factor, - const RealLimits& limits) const -{ + const RealLimits& limits) const { if (sigma_factor <= 0.0) sigma_factor = 2.0; double xmin = m_mean - sigma_factor * m_std_dev; @@ -257,8 +231,7 @@ std::vector<double> DistributionGaussian::equidistantPoints(size_t nbr_samples, return equidistantPointsInRange(nbr_samples, xmin, xmax); } -bool DistributionGaussian::isDelta() const -{ +bool DistributionGaussian::isDelta() const { return m_std_dev == 0.0; } @@ -273,8 +246,7 @@ DistributionLogNormal::DistributionLogNormal(const std::vector<double> P) {"ScaleParameter", "", "para_tooltip", -INF, +INF, 0}}}, P) , m_median(m_P[0]) - , m_scale_param(m_P[1]) -{ + , m_scale_param(m_P[1]) { if (m_scale_param < 0.0) throw Exceptions::ClassInitializationException("DistributionLogNormal: scale_param < 0"); if (m_median <= 0.0) @@ -282,30 +254,25 @@ DistributionLogNormal::DistributionLogNormal(const std::vector<double> P) } DistributionLogNormal::DistributionLogNormal(double median, double scale_param) - : DistributionLogNormal(std::vector<double>{median, scale_param}) -{ -} + : DistributionLogNormal(std::vector<double>{median, scale_param}) {} DistributionTrapezoid::DistributionTrapezoid() : DistributionTrapezoid(0., 0., 1., 0.) {} -double DistributionLogNormal::probabilityDensity(double x) const -{ +double DistributionLogNormal::probabilityDensity(double x) const { if (m_scale_param == 0.0) return DoubleEqual(x, m_median) ? 1.0 : 0.0; double t = std::log(x / m_median) / m_scale_param; return std::exp(-t * t / 2.0) / (x * m_scale_param * std::sqrt(M_TWOPI)); } -double DistributionLogNormal::getMean() const -{ +double DistributionLogNormal::getMean() const { double exponent = m_scale_param * m_scale_param / 2.0; return m_median * std::exp(exponent); } std::vector<double> DistributionLogNormal::equidistantPoints(size_t nbr_samples, double sigma_factor, - const RealLimits& limits) const -{ + const RealLimits& limits) const { if (nbr_samples < 2) { std::vector<double> result; result.push_back(m_median); @@ -319,13 +286,11 @@ std::vector<double> DistributionLogNormal::equidistantPoints(size_t nbr_samples, return equidistantPointsInRange(nbr_samples, xmin, xmax); } -bool DistributionLogNormal::isDelta() const -{ +bool DistributionLogNormal::isDelta() const { return m_scale_param == 0.0; } -void DistributionLogNormal::setUnits(const std::string& units) -{ +void DistributionLogNormal::setUnits(const std::string& units) { parameter("Median")->setUnit(units); // scale parameter remains unitless } @@ -341,21 +306,17 @@ DistributionCosine::DistributionCosine(const std::vector<double> P) {"Sigma", "", "para_tooltip", -INF, +INF, 0}}}, P) , m_mean(m_P[0]) - , m_sigma(m_P[1]) -{ + , m_sigma(m_P[1]) { if (m_sigma < 0.0) throw Exceptions::ClassInitializationException("DistributionCosine: sigma<0"); } DistributionCosine::DistributionCosine(double mean, double sigma) - : DistributionCosine(std::vector<double>{mean, sigma}) -{ -} + : DistributionCosine(std::vector<double>{mean, sigma}) {} DistributionCosine::DistributionCosine() : DistributionCosine(0., 1.) {} -double DistributionCosine::probabilityDensity(double x) const -{ +double DistributionCosine::probabilityDensity(double x) const { if (m_sigma == 0.0) return DoubleEqual(x, m_mean) ? 1.0 : 0.0; if (std::abs(x - m_mean) > M_PI * m_sigma) @@ -364,8 +325,7 @@ double DistributionCosine::probabilityDensity(double x) const } std::vector<double> DistributionCosine::equidistantPoints(size_t nbr_samples, double sigma_factor, - const RealLimits& limits) const -{ + const RealLimits& limits) const { if (sigma_factor <= 0.0 || sigma_factor > 2.0) sigma_factor = 2.0; double xmin = m_mean - sigma_factor * m_sigma * M_PI_2; @@ -374,8 +334,7 @@ std::vector<double> DistributionCosine::equidistantPoints(size_t nbr_samples, do return equidistantPointsInRange(nbr_samples, xmin, xmax); } -bool DistributionCosine::isDelta() const -{ +bool DistributionCosine::isDelta() const { return m_sigma == 0.0; } @@ -394,8 +353,7 @@ DistributionTrapezoid::DistributionTrapezoid(const std::vector<double> P) , m_center(m_P[0]) , m_left(m_P[1]) , m_middle(m_P[2]) - , m_right(m_P[3]) -{ + , m_right(m_P[3]) { if (m_left < 0.0) throw Exceptions::ClassInitializationException("DistributionTrapezoid: leftWidth < 0"); if (m_middle < 0.0) @@ -406,12 +364,9 @@ DistributionTrapezoid::DistributionTrapezoid(const std::vector<double> P) DistributionTrapezoid::DistributionTrapezoid(double center, double left, double middle, double right) - : DistributionTrapezoid(std::vector<double>{center, left, middle, right}) -{ -} + : DistributionTrapezoid(std::vector<double>{center, left, middle, right}) {} -double DistributionTrapezoid::probabilityDensity(double x) const -{ +double DistributionTrapezoid::probabilityDensity(double x) const { double height = 2.0 / (m_left + 2.0 * m_middle + m_right); double min = m_center - m_middle / 2.0 - m_left; if (x < min) @@ -427,8 +382,7 @@ double DistributionTrapezoid::probabilityDensity(double x) const } std::vector<double> DistributionTrapezoid::equidistantPoints(size_t nbr_samples, double, - const RealLimits& limits) const -{ + const RealLimits& limits) const { double xmin = m_center - m_middle / 2.0 - m_left; double xmax = xmin + m_left + m_middle + m_right; adjustLimitsToNonZeroSamples(xmin, xmax, nbr_samples); @@ -436,14 +390,12 @@ std::vector<double> DistributionTrapezoid::equidistantPoints(size_t nbr_samples, return equidistantPointsInRange(nbr_samples, xmin, xmax); } -bool DistributionTrapezoid::isDelta() const -{ +bool DistributionTrapezoid::isDelta() const { return (m_left + m_middle + m_right) == 0.0; } void DistributionTrapezoid::adjustLimitsToNonZeroSamples(double& min, double& max, - size_t nbr_samples) const -{ + size_t nbr_samples) const { if (nbr_samples <= 1) return; size_t N = nbr_samples; @@ -460,10 +412,8 @@ void DistributionTrapezoid::adjustLimitsToNonZeroSamples(double& min, double& ma max -= step; } -namespace -{ -bool DoubleEqual(double a, double b) -{ +namespace { +bool DoubleEqual(double a, double b) { double eps = 10.0 * std::max(std::abs(a) * std::numeric_limits<double>::epsilon(), std::numeric_limits<double>::min()); diff --git a/Param/Distrib/Distributions.h b/Param/Distrib/Distributions.h index b069516309f9444c9e20690d9315797b60d075c3..b6399d2fe65417b47e5e1b51623ec68bf98b6225 100644 --- a/Param/Distrib/Distributions.h +++ b/Param/Distrib/Distributions.h @@ -29,8 +29,7 @@ class ParameterSample; //! Interface for one-dimensional distributions. //! @ingroup distribution_internal -class IDistribution1D : public ICloneable, public INode -{ +class IDistribution1D : public ICloneable, public INode { public: IDistribution1D(const NodeMeta& meta, const std::vector<double>& PValues); @@ -82,8 +81,7 @@ protected: //! Uniform distribution function with half width hwhm. //! @ingroup paramDistribution -class DistributionGate : public IDistribution1D -{ +class DistributionGate : public IDistribution1D { public: DistributionGate(const std::vector<double> P); DistributionGate(double min, double max); @@ -116,8 +114,7 @@ private: //! Lorentz distribution with half width hwhm. //! @ingroup paramDistribution -class DistributionLorentz : public IDistribution1D -{ +class DistributionLorentz : public IDistribution1D { public: DistributionLorentz(const std::vector<double> P); DistributionLorentz(double mean, double hwhm); @@ -149,15 +146,13 @@ private: //! Gaussian distribution with standard deviation std_dev. //! @ingroup paramDistribution -class DistributionGaussian : public IDistribution1D -{ +class DistributionGaussian : public IDistribution1D { public: DistributionGaussian(const std::vector<double> P); DistributionGaussian(double mean, double std_dev); DistributionGaussian(); - DistributionGaussian* clone() const final - { + DistributionGaussian* clone() const final { return new DistributionGaussian(m_mean, m_std_dev); } @@ -185,15 +180,13 @@ private: //! Log-normal distribution. //! @ingroup paramDistribution -class DistributionLogNormal : public IDistribution1D -{ +class DistributionLogNormal : public IDistribution1D { public: DistributionLogNormal(const std::vector<double> P); DistributionLogNormal(double median, double scale_param); DistributionLogNormal() = delete; - DistributionLogNormal* clone() const final - { + DistributionLogNormal* clone() const final { return new DistributionLogNormal(m_median, m_scale_param); } @@ -224,8 +217,7 @@ private: //! Cosine distribution. //! @ingroup paramDistribution -class DistributionCosine : public IDistribution1D -{ +class DistributionCosine : public IDistribution1D { public: DistributionCosine(const std::vector<double> P); DistributionCosine(double mean, double sigma); @@ -257,15 +249,13 @@ private: //! Trapezoidal distribution. //! @ingroup paramDistribution -class DistributionTrapezoid : public IDistribution1D -{ +class DistributionTrapezoid : public IDistribution1D { public: DistributionTrapezoid(const std::vector<double> P); DistributionTrapezoid(double center, double left, double middle, double right); DistributionTrapezoid(); - DistributionTrapezoid* clone() const final - { + DistributionTrapezoid* clone() const final { return new DistributionTrapezoid(m_center, m_left, m_middle, m_right); } diff --git a/Param/Distrib/ParameterDistribution.cpp b/Param/Distrib/ParameterDistribution.cpp index c11dba06c2793114d5df7c4b637e341f8e2fbc6d..dd929e53746a3973668e7bf9f698b269488201df 100644 --- a/Param/Distrib/ParameterDistribution.cpp +++ b/Param/Distrib/ParameterDistribution.cpp @@ -26,8 +26,7 @@ ParameterDistribution::ParameterDistribution(const std::string& par_name, , m_sigma_factor(sigma_factor) , m_limits(limits) , m_xmin(1.0) - , m_xmax(-1.0) -{ + , m_xmax(-1.0) { m_distribution.reset(distribution.clone()); if (m_sigma_factor < 0.0) throw Exceptions::RuntimeErrorException( @@ -47,8 +46,7 @@ ParameterDistribution::ParameterDistribution(const std::string& par_name, , m_nbr_samples(nbr_samples) , m_sigma_factor(0.0) , m_xmin(xmin) - , m_xmax(xmax) -{ + , m_xmax(xmax) { m_distribution.reset(distribution.clone()); if (m_sigma_factor < 0.0) { throw Exceptions::RuntimeErrorException( @@ -75,15 +73,13 @@ ParameterDistribution::ParameterDistribution(const ParameterDistribution& other) , m_linked_par_names(other.m_linked_par_names) , m_limits(other.m_limits) , m_xmin(other.m_xmin) - , m_xmax(other.m_xmax) -{ + , m_xmax(other.m_xmax) { m_distribution.reset(other.m_distribution->clone()); } ParameterDistribution::~ParameterDistribution() = default; -ParameterDistribution& ParameterDistribution::operator=(const ParameterDistribution& other) -{ +ParameterDistribution& ParameterDistribution::operator=(const ParameterDistribution& other) { if (this != &other) { this->m_name = other.m_name; m_nbr_samples = other.m_nbr_samples; @@ -97,33 +93,28 @@ ParameterDistribution& ParameterDistribution::operator=(const ParameterDistribut return *this; } -ParameterDistribution& ParameterDistribution::linkParameter(std::string par_name) -{ +ParameterDistribution& ParameterDistribution::linkParameter(std::string par_name) { m_linked_par_names.push_back(par_name); return *this; } -size_t ParameterDistribution::getNbrSamples() const -{ +size_t ParameterDistribution::getNbrSamples() const { if (m_distribution && m_distribution->isDelta()) return 1; return m_nbr_samples; } -std::vector<ParameterSample> ParameterDistribution::generateSamples() const -{ +std::vector<ParameterSample> ParameterDistribution::generateSamples() const { if (m_xmin < m_xmax) return m_distribution->equidistantSamplesInRange(m_nbr_samples, m_xmin, m_xmax); else return m_distribution->equidistantSamples(m_nbr_samples, m_sigma_factor, m_limits); } -const IDistribution1D* ParameterDistribution::getDistribution() const -{ +const IDistribution1D* ParameterDistribution::getDistribution() const { return m_distribution.get(); } -IDistribution1D* ParameterDistribution::getDistribution() -{ +IDistribution1D* ParameterDistribution::getDistribution() { return m_distribution.get(); } diff --git a/Param/Distrib/ParameterDistribution.h b/Param/Distrib/ParameterDistribution.h index 5b7e3ed62b6a23f3ad51b169ebd533ddd92e4e3d..bf34d1471dc3c1c174131fa10496e0f9b82604df 100644 --- a/Param/Distrib/ParameterDistribution.h +++ b/Param/Distrib/ParameterDistribution.h @@ -25,8 +25,7 @@ class IDistribution1D; //! A parametric distribution function, for use with any model parameter. -class ParameterDistribution : public IParameterized -{ +class ParameterDistribution : public IParameterized { public: ParameterDistribution(const std::string& par_name, const IDistribution1D& distribution, size_t nbr_samples, double sigma_factor = 0.0, diff --git a/Param/Distrib/RangedDistributions.cpp b/Param/Distrib/RangedDistributions.cpp index 8e8b7f4a48f88426304f3333bc24d0ab10f6a655..4de51297e4178c3525b27031eaad0d32cd2dcc16 100644 --- a/Param/Distrib/RangedDistributions.cpp +++ b/Param/Distrib/RangedDistributions.cpp @@ -19,37 +19,34 @@ #include "Param/Varia/PyFmtLimits.h" #include <limits> -namespace -{ +namespace { template <class T> std::unique_ptr<T> makeCopy(const T& item); const double gate_stddev_factor = 2.0 * std::sqrt(3.0); } // namespace RangedDistribution::RangedDistribution() - : m_n_samples(5), m_sigma_factor(2.0), m_limits(RealLimits::limitless()) -{ + : m_n_samples(5), m_sigma_factor(2.0), m_limits(RealLimits::limitless()) { checkInitialization(); } RangedDistribution::RangedDistribution(size_t n_samples, double sigma_factor, const RealLimits& limits) - : m_n_samples(n_samples), m_sigma_factor(sigma_factor), m_limits(limits) -{ + : m_n_samples(n_samples), m_sigma_factor(sigma_factor), m_limits(limits) { checkInitialization(); } RangedDistribution::RangedDistribution(size_t n_samples, double sigma_factor, double min, double max) - : m_n_samples(n_samples), m_sigma_factor(sigma_factor), m_limits(RealLimits::limited(min, max)) -{ + : m_n_samples(n_samples) + , m_sigma_factor(sigma_factor) + , m_limits(RealLimits::limited(min, max)) { checkInitialization(); } RangedDistribution::~RangedDistribution() = default; -std::vector<ParameterSample> RangedDistribution::generateSamples(double mean, double stddev) const -{ +std::vector<ParameterSample> RangedDistribution::generateSamples(double mean, double stddev) const { auto generator = distribution(mean, stddev); if (!generator->isDelta()) return generator->equidistantSamples(m_n_samples, m_sigma_factor, m_limits); @@ -63,8 +60,7 @@ std::vector<ParameterSample> RangedDistribution::generateSamples(double mean, do std::vector<std::vector<ParameterSample>> RangedDistribution::generateSamples(const std::vector<double>& mean, - const std::vector<double>& stddev) const -{ + const std::vector<double>& stddev) const { if (mean.size() != stddev.size()) throw std::runtime_error("Error in RangedDistribution::generateSamples: mean and variance " "vectors shall be of the same size"); @@ -78,16 +74,15 @@ RangedDistribution::generateSamples(const std::vector<double>& mean, return result; } -std::unique_ptr<IDistribution1D> RangedDistribution::distribution(double mean, double stddev) const -{ +std::unique_ptr<IDistribution1D> RangedDistribution::distribution(double mean, + double stddev) const { if (stddev < 0.0) throw std::runtime_error( "Error in RangedDistribution::distribution: standard deviation is less than zero"); return distribution_impl(mean, stddev); } -std::string RangedDistribution::pyString() const -{ +std::string RangedDistribution::pyString() const { std::stringstream result; result << pyfmt::indent() << "distribution = " << name(); result << "(" << m_n_samples << ", " << pyfmt::printDouble(m_sigma_factor); @@ -97,8 +92,7 @@ std::string RangedDistribution::pyString() const return result.str(); } -void RangedDistribution::checkInitialization() -{ +void RangedDistribution::checkInitialization() { if (m_n_samples < 1u) throw std::runtime_error("Error in RangedDistribution::checkInitialization: number of " "samples shall be positive"); @@ -119,29 +113,22 @@ RangedDistributionGate::RangedDistributionGate() : RangedDistribution() {} RangedDistributionGate::RangedDistributionGate(size_t n_samples, double sigma_factor, const RealLimits& limits) - : RangedDistribution(n_samples, sigma_factor, limits) -{ -} + : RangedDistribution(n_samples, sigma_factor, limits) {} RangedDistributionGate::RangedDistributionGate(size_t n_samples, double sigma_factor, double min, double max) - : RangedDistribution(n_samples, sigma_factor, min, max) -{ -} + : RangedDistribution(n_samples, sigma_factor, min, max) {} -RangedDistributionGate* RangedDistributionGate::clone() const -{ +RangedDistributionGate* RangedDistributionGate::clone() const { return makeCopy(*this).release(); } -std::string RangedDistributionGate::name() const -{ +std::string RangedDistributionGate::name() const { return "ba.RangedDistributionGate"; } std::unique_ptr<IDistribution1D> RangedDistributionGate::distribution_impl(double mean, - double stddev) const -{ + double stddev) const { const double x_min = mean - gate_stddev_factor * stddev; const double x_max = mean + gate_stddev_factor * stddev; return std::make_unique<DistributionGate>(x_min, x_max); @@ -151,29 +138,22 @@ RangedDistributionLorentz::RangedDistributionLorentz() : RangedDistribution() {} RangedDistributionLorentz::RangedDistributionLorentz(size_t n_samples, double hwhm_factor, const RealLimits& limits) - : RangedDistribution(n_samples, hwhm_factor, limits) -{ -} + : RangedDistribution(n_samples, hwhm_factor, limits) {} RangedDistributionLorentz::RangedDistributionLorentz(size_t n_samples, double hwhm_factor, double min, double max) - : RangedDistribution(n_samples, hwhm_factor, min, max) -{ -} + : RangedDistribution(n_samples, hwhm_factor, min, max) {} -RangedDistributionLorentz* RangedDistributionLorentz::clone() const -{ +RangedDistributionLorentz* RangedDistributionLorentz::clone() const { return makeCopy(*this).release(); } -std::string RangedDistributionLorentz::name() const -{ +std::string RangedDistributionLorentz::name() const { return "ba.RangedDistributionLorentz"; } std::unique_ptr<IDistribution1D> RangedDistributionLorentz::distribution_impl(double median, - double hwhm) const -{ + double hwhm) const { return std::make_unique<DistributionLorentz>(median, hwhm); } @@ -181,29 +161,22 @@ RangedDistributionGaussian::RangedDistributionGaussian() : RangedDistribution() RangedDistributionGaussian::RangedDistributionGaussian(size_t n_samples, double sigma_factor, const RealLimits& limits) - : RangedDistribution(n_samples, sigma_factor, limits) -{ -} + : RangedDistribution(n_samples, sigma_factor, limits) {} RangedDistributionGaussian::RangedDistributionGaussian(size_t n_samples, double sigma_factor, double min, double max) - : RangedDistribution(n_samples, sigma_factor, min, max) -{ -} + : RangedDistribution(n_samples, sigma_factor, min, max) {} -RangedDistributionGaussian* RangedDistributionGaussian::clone() const -{ +RangedDistributionGaussian* RangedDistributionGaussian::clone() const { return makeCopy(*this).release(); } -std::string RangedDistributionGaussian::name() const -{ +std::string RangedDistributionGaussian::name() const { return "ba.RangedDistributionGaussian"; } -std::unique_ptr<IDistribution1D> RangedDistributionGaussian::distribution_impl(double mean, - double stddev) const -{ +std::unique_ptr<IDistribution1D> +RangedDistributionGaussian::distribution_impl(double mean, double stddev) const { return std::make_unique<DistributionGaussian>(mean, stddev); } @@ -211,29 +184,22 @@ RangedDistributionLogNormal::RangedDistributionLogNormal() : RangedDistribution( RangedDistributionLogNormal::RangedDistributionLogNormal(size_t n_samples, double sigma_factor, const RealLimits& limits) - : RangedDistribution(n_samples, sigma_factor, limits) -{ -} + : RangedDistribution(n_samples, sigma_factor, limits) {} RangedDistributionLogNormal::RangedDistributionLogNormal(size_t n_samples, double sigma_factor, double min, double max) - : RangedDistribution(n_samples, sigma_factor, min, max) -{ -} + : RangedDistribution(n_samples, sigma_factor, min, max) {} -RangedDistributionLogNormal* RangedDistributionLogNormal::clone() const -{ +RangedDistributionLogNormal* RangedDistributionLogNormal::clone() const { return makeCopy(*this).release(); } -std::string RangedDistributionLogNormal::name() const -{ +std::string RangedDistributionLogNormal::name() const { return "ba.RangedDistributionLogNormal"; } -std::unique_ptr<IDistribution1D> RangedDistributionLogNormal::distribution_impl(double mean, - double stddev) const -{ +std::unique_ptr<IDistribution1D> +RangedDistributionLogNormal::distribution_impl(double mean, double stddev) const { const double mean_2 = mean * mean; if (mean_2 <= std::numeric_limits<double>::min()) throw std::runtime_error("Error in DistributionLogNormal::distribution: mean square value " @@ -248,36 +214,27 @@ RangedDistributionCosine::RangedDistributionCosine() : RangedDistribution() {} RangedDistributionCosine::RangedDistributionCosine(size_t n_samples, double sigma_factor, const RealLimits& limits) - : RangedDistribution(n_samples, sigma_factor, limits) -{ -} + : RangedDistribution(n_samples, sigma_factor, limits) {} RangedDistributionCosine::RangedDistributionCosine(size_t n_samples, double sigma_factor, double min, double max) - : RangedDistribution(n_samples, sigma_factor, min, max) -{ -} + : RangedDistribution(n_samples, sigma_factor, min, max) {} -RangedDistributionCosine* RangedDistributionCosine::clone() const -{ +RangedDistributionCosine* RangedDistributionCosine::clone() const { return makeCopy(*this).release(); } -std::string RangedDistributionCosine::name() const -{ +std::string RangedDistributionCosine::name() const { return "ba.RangedDistributionCosine"; } std::unique_ptr<IDistribution1D> RangedDistributionCosine::distribution_impl(double mean, - double stddev) const -{ + double stddev) const { return std::make_unique<DistributionCosine>(mean, stddev); } -namespace -{ -template <class T> std::unique_ptr<T> makeCopy(const T& item) -{ +namespace { +template <class T> std::unique_ptr<T> makeCopy(const T& item) { return std::make_unique<T>(item.nSamples(), item.sigmaFactor(), item.limits()); } } // namespace diff --git a/Param/Distrib/RangedDistributions.h b/Param/Distrib/RangedDistributions.h index 5aeaac7cd7b986102df0239d32142c3e107350a4..828b0d77fb5d1cd8a5391cfb0fc02df0cd71923a 100644 --- a/Param/Distrib/RangedDistributions.h +++ b/Param/Distrib/RangedDistributions.h @@ -33,8 +33,7 @@ class ParameterSample; //! (except for RangedDistributionLorentz which uses median and hwhm). //! @ingroup distribution_internal -class RangedDistribution : public ICloneable -{ +class RangedDistribution : public ICloneable { public: RangedDistribution(); RangedDistribution(size_t n_samples, double sigma_factor, @@ -95,8 +94,7 @@ private: //! Uniform distribution function. //! @ingroup paramDistribution -class RangedDistributionGate : public RangedDistribution -{ +class RangedDistributionGate : public RangedDistribution { public: RangedDistributionGate(); RangedDistributionGate(size_t n_samples, double sigma_factor, @@ -120,8 +118,7 @@ protected: //! Lorentz distribution with median and hwhm. //! @ingroup paramDistribution -class RangedDistributionLorentz : public RangedDistribution -{ +class RangedDistributionLorentz : public RangedDistribution { public: RangedDistributionLorentz(); RangedDistributionLorentz(size_t n_samples, double hwhm_factor, @@ -145,8 +142,7 @@ protected: //! Gaussian distribution with standard deviation std_dev. //! @ingroup paramDistribution -class RangedDistributionGaussian : public RangedDistribution -{ +class RangedDistributionGaussian : public RangedDistribution { public: RangedDistributionGaussian(); RangedDistributionGaussian(size_t n_samples, double sigma_factor, @@ -170,8 +166,7 @@ protected: //! Log-normal distribution. //! @ingroup paramDistribution -class RangedDistributionLogNormal : public RangedDistribution -{ +class RangedDistributionLogNormal : public RangedDistribution { public: RangedDistributionLogNormal(); RangedDistributionLogNormal(size_t n_samples, double sigma_factor, @@ -195,8 +190,7 @@ protected: //! Cosine distribution. //! @ingroup paramDistribution -class RangedDistributionCosine : public RangedDistribution -{ +class RangedDistributionCosine : public RangedDistribution { public: RangedDistributionCosine(); RangedDistributionCosine(size_t n_samples, double sigma_factor, @@ -217,8 +211,7 @@ protected: std::unique_ptr<IDistribution1D> distribution_impl(double mean, double stddev) const override; }; -inline std::ostream& operator<<(std::ostream& os, const RangedDistribution& distribution) -{ +inline std::ostream& operator<<(std::ostream& os, const RangedDistribution& distribution) { return os << distribution.pyString(); } diff --git a/Param/Node/INode.cpp b/Param/Node/INode.cpp index e407691137e5e42dc43ec486c938add00c0df76a..a701361997a450ae144cd37f2cccea0cd0caeac7 100644 --- a/Param/Node/INode.cpp +++ b/Param/Node/INode.cpp @@ -21,15 +21,13 @@ #include <algorithm> #include <exception> -NodeMeta nodeMetaUnion(const std::vector<ParaMeta>& base, const NodeMeta& other) -{ +NodeMeta nodeMetaUnion(const std::vector<ParaMeta>& base, const NodeMeta& other) { return {other.className, other.tooltip, algo::concat(base, other.paraMeta)}; } INode::INode(const NodeMeta& meta, const std::vector<double>& PValues) : /*m_tooltip(meta.tooltip),*/ - m_NP(meta.paraMeta.size()) -{ + m_NP(meta.paraMeta.size()) { m_P.resize(m_NP); setName(meta.className); parameterPool()->clear(); // non-trivially needed by a few children @@ -50,39 +48,32 @@ INode::INode(const NodeMeta& meta, const std::vector<double>& PValues) } } -std::string INode::treeToString() const -{ +std::string INode::treeToString() const { return NodeUtils::nodeToString(*this); } -void INode::registerChild(INode* node) -{ +void INode::registerChild(INode* node) { ASSERT(node); node->setParent(this); } -std::vector<const INode*> INode::getChildren() const -{ +std::vector<const INode*> INode::getChildren() const { return {}; } -void INode::setParent(const INode* newParent) -{ +void INode::setParent(const INode* newParent) { m_parent = newParent; } -const INode* INode::parent() const -{ +const INode* INode::parent() const { return m_parent; } -INode* INode::parent() -{ +INode* INode::parent() { return const_cast<INode*>(m_parent); } -int INode::copyNumber(const INode* node) const -{ +int INode::copyNumber(const INode* node) const { if (node->parent() != this) return -1; @@ -102,8 +93,7 @@ int INode::copyNumber(const INode* node) const return count > 1 ? result : -1; } -std::string INode::displayName() const -{ +std::string INode::displayName() const { std::string result = getName(); if (m_parent) { int index = m_parent->copyNumber(this); @@ -113,8 +103,7 @@ std::string INode::displayName() const return result; } -ParameterPool* INode::createParameterTree() const -{ +ParameterPool* INode::createParameterTree() const { std::unique_ptr<ParameterPool> result(new ParameterPool); NodeIterator<PreorderStrategy> it(this); diff --git a/Param/Node/INode.h b/Param/Node/INode.h index 527b4c970290cd8c00310bd1fb2e77d36a10c0c5..ea18fcfa515b9de83990f3b5d599bb6540dde33b 100644 --- a/Param/Node/INode.h +++ b/Param/Node/INode.h @@ -45,8 +45,7 @@ NodeMeta nodeMetaUnion(const std::vector<ParaMeta>& base, const NodeMeta& other) //! Base class for tree-like structures containing parameterized objects. //! @ingroup tools_internal -class INode : public IParameterized -{ +class INode : public IParameterized { public: INode() : m_NP{0} {} INode(const NodeMeta& meta, const std::vector<double>& PValues); @@ -89,8 +88,7 @@ protected: template <class T> std::vector<const INode*>& operator<<(std::vector<const INode*>& v_node, - const std::unique_ptr<T>& node) -{ + const std::unique_ptr<T>& node) { if (node) v_node.push_back(node.get()); return v_node; @@ -98,35 +96,31 @@ std::vector<const INode*>& operator<<(std::vector<const INode*>& v_node, template <class T> std::vector<const INode*>& operator<<(std::vector<const INode*>&& v_node, - const std::unique_ptr<T>& node) -{ + const std::unique_ptr<T>& node) { if (node) v_node.push_back(node.get()); return v_node; } -inline std::vector<const INode*>& operator<<(std::vector<const INode*>& v_node, const INode* node) -{ +inline std::vector<const INode*>& operator<<(std::vector<const INode*>& v_node, const INode* node) { v_node.push_back(node); return v_node; } -inline std::vector<const INode*>& operator<<(std::vector<const INode*>&& v_node, const INode* node) -{ +inline std::vector<const INode*>& operator<<(std::vector<const INode*>&& v_node, + const INode* node) { v_node.push_back(node); return v_node; } inline std::vector<const INode*>& operator<<(std::vector<const INode*>& v_node, - const std::vector<const INode*>& other) -{ + const std::vector<const INode*>& other) { v_node.insert(v_node.end(), other.begin(), other.end()); return v_node; } inline std::vector<const INode*>& operator<<(std::vector<const INode*>&& v_node, - const std::vector<const INode*>& other) -{ + const std::vector<const INode*>& other) { v_node.insert(v_node.end(), other.begin(), other.end()); return v_node; } diff --git a/Param/Node/INodeVisitor.cpp b/Param/Node/INodeVisitor.cpp index fff73f1e7854dc01204615f9fcb65e651d48d55b..6e70df009b59d05fb4e1fac38fe723c469efcc23 100644 --- a/Param/Node/INodeVisitor.cpp +++ b/Param/Node/INodeVisitor.cpp @@ -15,8 +15,7 @@ #include "Param/Node/IterationStrategy.h" #include "Param/Node/NodeIterator.h" -void VisitNodesPreorder(const INode& node, INodeVisitor& visitor) -{ +void VisitNodesPreorder(const INode& node, INodeVisitor& visitor) { NodeIterator<PreorderStrategy> it(&node); it.first(); while (!it.isDone()) { diff --git a/Param/Node/INodeVisitor.h b/Param/Node/INodeVisitor.h index c724ef69ea1bf9aa0aacb1f93ab13ad1c3ce984d..b038e806ae5ec9b9a368e385d29fc3e80d433332 100644 --- a/Param/Node/INodeVisitor.h +++ b/Param/Node/INodeVisitor.h @@ -142,8 +142,7 @@ class SquareLattice2D; //! From visitor pattern to achieve double dispatch. -class INodeVisitor -{ +class INodeVisitor { public: INodeVisitor() : m_depth(0) {} virtual ~INodeVisitor() {} diff --git a/Param/Node/IterationStrategy.cpp b/Param/Node/IterationStrategy.cpp index a799f3fd410d2846b09b73324ec309fc77ffe842..8d3d34f184536756b4f870b8799fa6b11995ec8d 100644 --- a/Param/Node/IterationStrategy.cpp +++ b/Param/Node/IterationStrategy.cpp @@ -18,20 +18,17 @@ PreorderStrategy::PreorderStrategy() = default; -PreorderStrategy* PreorderStrategy::clone() const -{ +PreorderStrategy* PreorderStrategy::clone() const { return new PreorderStrategy(); } -IteratorMemento PreorderStrategy::first(const INode* p_root) -{ +IteratorMemento PreorderStrategy::first(const INode* p_root) { IteratorMemento iterator_stack; iterator_stack.push_state(IteratorState(p_root)); return iterator_stack; } -void PreorderStrategy::next(IteratorMemento& iterator_stack) const -{ +void PreorderStrategy::next(IteratorMemento& iterator_stack) const { const INode* node = iterator_stack.getCurrent(); ASSERT(node); std::vector<const INode*> children = node->getChildren(); @@ -47,7 +44,6 @@ void PreorderStrategy::next(IteratorMemento& iterator_stack) const } } -bool PreorderStrategy::isDone(IteratorMemento& iterator_stack) const -{ +bool PreorderStrategy::isDone(IteratorMemento& iterator_stack) const { return iterator_stack.empty(); } diff --git a/Param/Node/IterationStrategy.h b/Param/Node/IterationStrategy.h index ac6b7270e8f858fecf4ff367e4a269be4c807115..74668675b2ddea78f192fd31abce76aa662c42a9 100644 --- a/Param/Node/IterationStrategy.h +++ b/Param/Node/IterationStrategy.h @@ -22,8 +22,7 @@ class IteratorMemento; //! //! For definition of different strategies see https://en.wikipedia.org/wiki/Tree_traversal. -class IterationStrategy -{ +class IterationStrategy { public: virtual IterationStrategy* clone() const = 0; @@ -33,8 +32,7 @@ public: }; //! Traverse tree; visit parents before their children. -class PreorderStrategy : public IterationStrategy -{ +class PreorderStrategy : public IterationStrategy { public: PreorderStrategy(); diff --git a/Param/Node/NodeIterator.cpp b/Param/Node/NodeIterator.cpp index 882bbc8278791c60d75e26a6b86861f62812c590..3ec63f0b68fb18340c8fa917ad2a0e9f25fecb14 100644 --- a/Param/Node/NodeIterator.cpp +++ b/Param/Node/NodeIterator.cpp @@ -14,11 +14,9 @@ #include "Param/Node/NodeIterator.h" -IteratorState::IteratorState(const INode* single_element) : m_position(0) -{ +IteratorState::IteratorState(const INode* single_element) : m_position(0) { m_samples.push_back(single_element); } -IteratorState::IteratorState(std::vector<const INode*> samples) : m_samples(samples), m_position(0) -{ -} +IteratorState::IteratorState(std::vector<const INode*> samples) + : m_samples(samples), m_position(0) {} diff --git a/Param/Node/NodeIterator.h b/Param/Node/NodeIterator.h index de34afe5d84960346d07a2577850c5b08e2c629a..afe7857bab7a789f298543a6f873eb6be78c8f68 100644 --- a/Param/Node/NodeIterator.h +++ b/Param/Node/NodeIterator.h @@ -23,8 +23,7 @@ //! Holds state of iterator at single level for SampleTreeIterator. //! @ingroup samples_internal -class IteratorState -{ +class IteratorState { public: IteratorState(const INode* single_element); IteratorState(std::vector<const INode*> samples); @@ -36,8 +35,7 @@ public: void next() { ++m_position; } friend std::ostream& operator<<(std::ostream& output_stream, - IteratorState const& iterator_state) - { + IteratorState const& iterator_state) { return output_stream << "memento state " << iterator_state.m_position << " " << iterator_state.m_samples.size(); } @@ -52,8 +50,7 @@ private: //! Holds all iterator states encountered for SampleTreeIterator. //! @ingroup samples_internal -class IteratorMemento -{ +class IteratorMemento { public: IteratorMemento() {} virtual ~IteratorMemento() {} @@ -62,8 +59,7 @@ public: void pop_state() { m_state_stack.pop(); } IteratorState& get_state() { return m_state_stack.top(); } bool empty() const { return m_state_stack.empty(); } - void reset() - { + void reset() { while (!m_state_stack.empty()) m_state_stack.pop(); } @@ -86,8 +82,7 @@ protected: //! } //! @ingroup samples_internal -template <class Strategy> class NodeIterator -{ +template <class Strategy> class NodeIterator { public: NodeIterator(const INode* root); virtual ~NodeIterator() {} @@ -105,32 +100,25 @@ protected: }; template <class Strategy> -inline NodeIterator<Strategy>::NodeIterator(const INode* root) : m_root(root) -{ -} +inline NodeIterator<Strategy>::NodeIterator(const INode* root) : m_root(root) {} -template <class Strategy> inline void NodeIterator<Strategy>::first() -{ +template <class Strategy> inline void NodeIterator<Strategy>::first() { m_memento_itor = m_strategy.first(m_root); } -template <class Strategy> inline void NodeIterator<Strategy>::next() -{ +template <class Strategy> inline void NodeIterator<Strategy>::next() { m_strategy.next(m_memento_itor); } -template <class Strategy> inline const INode* NodeIterator<Strategy>::getCurrent() -{ +template <class Strategy> inline const INode* NodeIterator<Strategy>::getCurrent() { return m_memento_itor.getCurrent(); } -template <class Strategy> inline bool NodeIterator<Strategy>::isDone() const -{ +template <class Strategy> inline bool NodeIterator<Strategy>::isDone() const { return m_memento_itor.size() == 0; } -template <class Strategy> inline int NodeIterator<Strategy>::depth() const -{ +template <class Strategy> inline int NodeIterator<Strategy>::depth() const { return static_cast<int>(m_memento_itor.size()); } diff --git a/Param/Node/NodeUtils.cpp b/Param/Node/NodeUtils.cpp index 206c5de7a715f9a5d7cce8fafb2985ab9dd5c617..a62e0d9e22c630ab1f33bba61303b00bdd5e35c9 100644 --- a/Param/Node/NodeUtils.cpp +++ b/Param/Node/NodeUtils.cpp @@ -23,19 +23,16 @@ #include <iterator> #include <sstream> -namespace -{ +namespace { // Returns string filled with '.' -std::string s_indent(int depth) -{ +std::string s_indent(int depth) { const int multiplier = 4; return std::string(multiplier * depth, '.'); } // Returns single line string representing pool parameters of given node. -std::string poolToString(const INode& node) -{ +std::string poolToString(const INode& node) { std::ostringstream result; const std::vector<RealParameter*> pars = node.parameterPool()->parameters(); @@ -56,16 +53,14 @@ std::string poolToString(const INode& node) } // Returns a string representing given node. -std::string nodeString(const INode& node, int depth) -{ +std::string nodeString(const INode& node, int depth) { std::ostringstream result; result << s_indent(depth) << node.displayName() << poolToString(node) << "\n"; return result.str(); } } // namespace -std::string NodeUtils::nodeToString(const INode& node) -{ +std::string NodeUtils::nodeToString(const INode& node) { std::ostringstream result; NodeIterator<PreorderStrategy> it(&node); @@ -79,8 +74,7 @@ std::string NodeUtils::nodeToString(const INode& node) return result.str(); } -std::string NodeUtils::nodePath(const INode& node, const INode* root) -{ +std::string NodeUtils::nodePath(const INode& node, const INode* root) { std::vector<std::string> pathElements; const INode* current = &node; while (current && current != root) { diff --git a/Param/Node/NodeUtils.h b/Param/Node/NodeUtils.h index e281615b8e9d033cda469c3e538da3a12d1d7467..bc691b01bad580c92fe0eae14388f0aac56d7773 100644 --- a/Param/Node/NodeUtils.h +++ b/Param/Node/NodeUtils.h @@ -19,8 +19,7 @@ class INode; -namespace NodeUtils -{ +namespace NodeUtils { //! Returns multiline string representing tree structure starting from given node. std::string nodeToString(const INode& node); diff --git a/Param/Varia/ParameterPattern.cpp b/Param/Varia/ParameterPattern.cpp index 9443ab6471b1fde8ec293581f6c263d62dbee831..9148ed597592202df5ef2c706cfb87877849b999 100644 --- a/Param/Varia/ParameterPattern.cpp +++ b/Param/Varia/ParameterPattern.cpp @@ -14,14 +14,12 @@ #include "Param/Varia/ParameterPattern.h" -ParameterPattern& ParameterPattern::beginsWith(std::string start_type) -{ +ParameterPattern& ParameterPattern::beginsWith(std::string start_type) { m_pattern = start_type; return *this; } -ParameterPattern& ParameterPattern::add(std::string object_type) -{ +ParameterPattern& ParameterPattern::add(std::string object_type) { m_pattern = m_pattern + "/" + object_type; return *this; } diff --git a/Param/Varia/ParameterPattern.h b/Param/Varia/ParameterPattern.h index 74f7a7de1831a956f8f3f21c5cfb504c1080054d..07b9768cc3d57f1c7e1f20b29a5b954055a3399d 100644 --- a/Param/Varia/ParameterPattern.h +++ b/Param/Varia/ParameterPattern.h @@ -20,8 +20,7 @@ //! Helper class for constructing parameter patterns. //! @ingroup tools_internal -class ParameterPattern -{ +class ParameterPattern { public: ParameterPattern() {} ParameterPattern(std::string root_object) : m_pattern("/" + root_object) {} diff --git a/Param/Varia/ParameterSample.h b/Param/Varia/ParameterSample.h index bbdc933c63c713984636128fe406f671c6c145fe..ec423e4655a05c8a2c9886fa6fbbc6adce73ecda 100644 --- a/Param/Varia/ParameterSample.h +++ b/Param/Varia/ParameterSample.h @@ -18,8 +18,7 @@ //! A parameter value with a weight, as obtained when sampling from a distribution. //! @ingroup algorithms_internal -class ParameterSample -{ +class ParameterSample { public: ParameterSample(double _value = 0., double _weight = 1.) : value(_value), weight(_weight) {} double value; diff --git a/Param/Varia/ParameterUtils.cpp b/Param/Varia/ParameterUtils.cpp index 2cbee2456af1a5d301d8999ecb83048c0de9a695..a08f8f68641cab6b12dfd97b8bcef6d879e4f39a 100644 --- a/Param/Varia/ParameterUtils.cpp +++ b/Param/Varia/ParameterUtils.cpp @@ -18,19 +18,16 @@ #include "Param/Base/RealParameter.h" #include <memory> -namespace -{ +namespace { //! Returns list of all angle related parameters used in Core library. -std::vector<std::string> angleRelatedParameters() -{ +std::vector<std::string> angleRelatedParameters() { std::vector<std::string> result{ "InclinationAngle", "AzimuthalAngle", "Alpha", "Beta", "Gamma", "Angle"}; return result; } } // namespace -bool ParameterUtils::isAngleRelated(const std::string& par_name) -{ +bool ParameterUtils::isAngleRelated(const std::string& par_name) { static std::vector<std::string> angleRelated = angleRelatedParameters(); for (const auto& par : angleRelated) { @@ -41,8 +38,7 @@ bool ParameterUtils::isAngleRelated(const std::string& par_name) } std::string ParameterUtils::poolParameterUnits(const IParameterized& node, - const std::string& parName) -{ + const std::string& parName) { std::unique_ptr<ParameterPool> pool{node.createParameterTree()}; return pool->getUniqueMatch(parName)->unit(); } diff --git a/Param/Varia/ParameterUtils.h b/Param/Varia/ParameterUtils.h index 2c8cf11c83102110f9f3aafa1ccb82dd467d1738..e7fde0c9cc845f13a6e6f28208395449f5c45332 100644 --- a/Param/Varia/ParameterUtils.h +++ b/Param/Varia/ParameterUtils.h @@ -19,8 +19,7 @@ class IParameterized; -namespace ParameterUtils -{ +namespace ParameterUtils { //! Returns true if given parameter name is related to angles. bool isAngleRelated(const std::string& par_name); diff --git a/Param/Varia/PyFmtLimits.cpp b/Param/Varia/PyFmtLimits.cpp index 45f518a728fa6e04fa3391356b258fb168cf086c..816dd668215a53c53bd531c312cc50b8c0172cff 100644 --- a/Param/Varia/PyFmtLimits.cpp +++ b/Param/Varia/PyFmtLimits.cpp @@ -17,11 +17,9 @@ #include "Fit/Param/RealLimits.h" #include <iomanip> -namespace pyfmt -{ +namespace pyfmt { -std::string printRealLimits(const RealLimits& limits, const std::string& units) -{ +std::string printRealLimits(const RealLimits& limits, const std::string& units) { std::ostringstream result; if (limits.isLimitless()) { @@ -58,8 +56,7 @@ std::string printRealLimits(const RealLimits& limits, const std::string& units) //! similar). Default RealLimits will not be printed, any other will be printed as //! ", ba.RealLimits.limited(1*deg, 2*deg)" -std::string printRealLimitsArg(const RealLimits& limits, const std::string& units) -{ +std::string printRealLimitsArg(const RealLimits& limits, const std::string& units) { return limits.isLimitless() ? "" : ", ba." + printRealLimits(limits, units); } diff --git a/Param/Varia/PyFmtLimits.h b/Param/Varia/PyFmtLimits.h index 68efcec411cac655661238360c09dd3d814fd73c..4ffd3ebd634abe2009a72fcd38e3dc0396ef5017 100644 --- a/Param/Varia/PyFmtLimits.h +++ b/Param/Varia/PyFmtLimits.h @@ -21,8 +21,7 @@ class RealLimits; //! Utility functions for writing Python code snippets. -namespace pyfmt -{ +namespace pyfmt { std::string printRealLimits(const RealLimits& limits, const std::string& units = ""); std::string printRealLimitsArg(const RealLimits& limits, const std::string& units = ""); } // namespace pyfmt diff --git a/Sample/Aggregate/IInterferenceFunction.cpp b/Sample/Aggregate/IInterferenceFunction.cpp index 5e13b0ba5ba367f5c7a9fbd0938958bfa072f433..67d769e75b7581e564d63f4775e72f979fc75466 100644 --- a/Sample/Aggregate/IInterferenceFunction.cpp +++ b/Sample/Aggregate/IInterferenceFunction.cpp @@ -19,41 +19,35 @@ IInterferenceFunction::IInterferenceFunction(const NodeMeta& meta, const std::vector<double>& PValues) - : ISample(meta, PValues) -{ + : ISample(meta, PValues) { registerParameter("PositionVariance", &m_position_var).setUnit("nm^2").setNonnegative(); } -IInterferenceFunction::IInterferenceFunction(double position_var) : m_position_var(position_var) -{ +IInterferenceFunction::IInterferenceFunction(double position_var) : m_position_var(position_var) { registerParameter("PositionVariance", &m_position_var).setUnit("nm^2").setNonnegative(); } // Default implementation of evaluate assumes no inner structure // It is only to be overriden in case of the presence of such inner structure. See for example // InterferenceFunction2DSuperLattice for such a case. -double IInterferenceFunction::evaluate(const kvector_t q, double outer_iff) const -{ +double IInterferenceFunction::evaluate(const kvector_t q, double outer_iff) const { return iff_no_inner(q, outer_iff); } -void IInterferenceFunction::setPositionVariance(double var) -{ +void IInterferenceFunction::setPositionVariance(double var) { if (var < 0.0) throw std::runtime_error("IInterferenceFunction::setPositionVariance: " "variance should be positive."); m_position_var = var; } -double IInterferenceFunction::DWfactor(kvector_t q) const -{ +double IInterferenceFunction::DWfactor(kvector_t q) const { // remove z component for two dimensional interference functions: if (supportsMultilayer()) q.setZ(0.0); return std::exp(-q.mag2() * m_position_var); } -double IInterferenceFunction::iff_no_inner(const kvector_t q, double outer_iff) const -{ +double IInterferenceFunction::iff_no_inner(const kvector_t q, double outer_iff) const { return DWfactor(q) * (iff_without_dw(q) * outer_iff - 1.0) + 1.0; } diff --git a/Sample/Aggregate/IInterferenceFunction.h b/Sample/Aggregate/IInterferenceFunction.h index dbfab0e97cd4e808ff3bb61b6714cf88b47bc2ae..f0918025950e157283e67eea70cfa92ef3a67af8 100644 --- a/Sample/Aggregate/IInterferenceFunction.h +++ b/Sample/Aggregate/IInterferenceFunction.h @@ -20,8 +20,7 @@ //! Abstract base class of interference functions. //! @ingroup distribution_internal -class IInterferenceFunction : public ISample -{ +class IInterferenceFunction : public ISample { public: IInterferenceFunction(const NodeMeta& meta, const std::vector<double>& PValues); IInterferenceFunction(double position_var); diff --git a/Sample/Aggregate/InterferenceFunction1DLattice.cpp b/Sample/Aggregate/InterferenceFunction1DLattice.cpp index 9b1e8a887b64bf2130db3dbda482399c0eb3a09e..2ef04be29407dcba858ec095dc0f33c6ad628d43 100644 --- a/Sample/Aggregate/InterferenceFunction1DLattice.cpp +++ b/Sample/Aggregate/InterferenceFunction1DLattice.cpp @@ -20,8 +20,7 @@ #include "Sample/Correlations/FTDecay2D.h" #include <algorithm> -namespace -{ +namespace { // maximum value for qx*Lambdax const int nmax = 20; // minimum number of neighboring reciprocal lattice points to use @@ -32,8 +31,7 @@ const int min_points = 4; //! @param length: lattice constant in nanometers //! @param xi: rotation of lattice with respect to x-axis in radians InterferenceFunction1DLattice::InterferenceFunction1DLattice(double length, double xi) - : IInterferenceFunction(0), m_length(length), m_xi(xi), m_na{0} -{ + : IInterferenceFunction(0), m_length(length), m_xi(xi), m_na{0} { setName("Interference1DLattice"); registerParameter("Length", &m_length).setUnit("nm").setNonnegative(); registerParameter("Xi", &m_xi).setUnit("rad"); @@ -41,8 +39,7 @@ InterferenceFunction1DLattice::InterferenceFunction1DLattice(double length, doub InterferenceFunction1DLattice::~InterferenceFunction1DLattice() = default; -InterferenceFunction1DLattice* InterferenceFunction1DLattice::clone() const -{ +InterferenceFunction1DLattice* InterferenceFunction1DLattice::clone() const { auto* ret = new InterferenceFunction1DLattice(m_length, m_xi); ret->setPositionVariance(m_position_var); ret->m_na = m_na; @@ -53,8 +50,7 @@ InterferenceFunction1DLattice* InterferenceFunction1DLattice::clone() const //! Sets one-dimensional decay function. //! @param decay: one-dimensional decay function in reciprocal space -void InterferenceFunction1DLattice::setDecayFunction(const IFTDecayFunction1D& decay) -{ +void InterferenceFunction1DLattice::setDecayFunction(const IFTDecayFunction1D& decay) { m_decay.reset(decay.clone()); registerChild(m_decay.get()); double decay_length = m_decay->decayLength(); @@ -63,13 +59,11 @@ void InterferenceFunction1DLattice::setDecayFunction(const IFTDecayFunction1D& d m_na = std::max(m_na, min_points); } -std::vector<const INode*> InterferenceFunction1DLattice::getChildren() const -{ +std::vector<const INode*> InterferenceFunction1DLattice::getChildren() const { return std::vector<const INode*>() << m_decay; } -double InterferenceFunction1DLattice::iff_without_dw(const kvector_t q) const -{ +double InterferenceFunction1DLattice::iff_without_dw(const kvector_t q) const { ASSERT(m_decay); double result = 0.0; double qxr = q.x(); diff --git a/Sample/Aggregate/InterferenceFunction1DLattice.h b/Sample/Aggregate/InterferenceFunction1DLattice.h index aa013e4cc4d667158317e79dd081d952e6016d43..eb95c45d6f09bcca8ccc4a4491b5be38a0c44882 100644 --- a/Sample/Aggregate/InterferenceFunction1DLattice.h +++ b/Sample/Aggregate/InterferenceFunction1DLattice.h @@ -22,8 +22,7 @@ class IFTDecayFunction1D; //! Interference function of a 1D lattice. //! @ingroup interference -class InterferenceFunction1DLattice : public IInterferenceFunction -{ +class InterferenceFunction1DLattice : public IInterferenceFunction { public: InterferenceFunction1DLattice(double length, double xi); ~InterferenceFunction1DLattice() override; diff --git a/Sample/Aggregate/InterferenceFunction2DLattice.cpp b/Sample/Aggregate/InterferenceFunction2DLattice.cpp index f6c57e8d2fa7cd8321465c4d67bf2492549c60f9..eb8ec2fc01b7bc64951ffbe490374f2821da6c90 100644 --- a/Sample/Aggregate/InterferenceFunction2DLattice.cpp +++ b/Sample/Aggregate/InterferenceFunction2DLattice.cpp @@ -18,8 +18,7 @@ #include "Param/Base/RealParameter.h" #include <algorithm> -namespace -{ +namespace { // maximum value for qx*Lambdax and qy*lambday const int nmax = 20; // minimum number of neighboring reciprocal lattice points to use @@ -27,8 +26,7 @@ const int min_points = 4; } // namespace InterferenceFunction2DLattice::InterferenceFunction2DLattice(const Lattice2D& lattice) - : IInterferenceFunction(0), m_integrate_xi(false) -{ + : IInterferenceFunction(0), m_integrate_xi(false) { setName("Interference2DLattice"); m_lattice.reset(lattice.clone()); registerChild(m_lattice.get()); @@ -37,8 +35,7 @@ InterferenceFunction2DLattice::InterferenceFunction2DLattice(const Lattice2D& la InterferenceFunction2DLattice::~InterferenceFunction2DLattice() = default; -InterferenceFunction2DLattice* InterferenceFunction2DLattice::clone() const -{ +InterferenceFunction2DLattice* InterferenceFunction2DLattice::clone() const { auto* ret = new InterferenceFunction2DLattice(*m_lattice); ret->setPositionVariance(m_position_var); ret->setIntegrationOverXi(integrationOverXi()); @@ -49,46 +46,39 @@ InterferenceFunction2DLattice* InterferenceFunction2DLattice::clone() const //! Sets two-dimensional decay function. //! @param decay: two-dimensional decay function in reciprocal space -void InterferenceFunction2DLattice::setDecayFunction(const IFTDecayFunction2D& decay) -{ +void InterferenceFunction2DLattice::setDecayFunction(const IFTDecayFunction2D& decay) { m_decay.reset(decay.clone()); registerChild(m_decay.get()); initialize_calc_factors(); } -void InterferenceFunction2DLattice::setIntegrationOverXi(bool integrate_xi) -{ +void InterferenceFunction2DLattice::setIntegrationOverXi(bool integrate_xi) { m_integrate_xi = integrate_xi; m_lattice->setRotationEnabled(!m_integrate_xi); // deregister Xi in the case of integration } -const Lattice2D& InterferenceFunction2DLattice::lattice() const -{ +const Lattice2D& InterferenceFunction2DLattice::lattice() const { if (!m_lattice) throw std::runtime_error("InterferenceFunction2DLattice::lattice() -> Error. " "No lattice defined."); return *m_lattice; } -double InterferenceFunction2DLattice::getParticleDensity() const -{ +double InterferenceFunction2DLattice::getParticleDensity() const { double area = m_lattice->unitCellArea(); return area == 0.0 ? 0.0 : 1.0 / area; } -std::vector<const INode*> InterferenceFunction2DLattice::getChildren() const -{ +std::vector<const INode*> InterferenceFunction2DLattice::getChildren() const { return std::vector<const INode*>() << m_decay << m_lattice; } -void InterferenceFunction2DLattice::onChange() -{ +void InterferenceFunction2DLattice::onChange() { initialize_rec_vectors(); initialize_calc_factors(); } -double InterferenceFunction2DLattice::iff_without_dw(const kvector_t q) const -{ +double InterferenceFunction2DLattice::iff_without_dw(const kvector_t q) const { if (!m_decay) throw Exceptions::NullPointerException("InterferenceFunction2DLattice::evaluate" " -> Error! No decay function defined."); @@ -101,8 +91,7 @@ double InterferenceFunction2DLattice::iff_without_dw(const kvector_t q) const / M_TWOPI; } -double InterferenceFunction2DLattice::interferenceForXi(double xi) const -{ +double InterferenceFunction2DLattice::interferenceForXi(double xi) const { double result = 0.0; auto q_frac = calculateReciprocalVectorFraction(m_qx, m_qy, xi); @@ -116,8 +105,7 @@ double InterferenceFunction2DLattice::interferenceForXi(double xi) const return getParticleDensity() * result; } -double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint(double qx, double qy) const -{ +double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint(double qx, double qy) const { if (!m_decay) throw Exceptions::NullPointerException( "InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint" @@ -129,8 +117,7 @@ double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint(double qx // Rotate by angle gamma between orthonormal systems std::pair<double, double> InterferenceFunction2DLattice::rotateOrthonormal(double qx, double qy, - double gamma) const -{ + double gamma) const { double q_X = qx * std::cos(gamma) + qy * std::sin(gamma); double q_Y = -qx * std::sin(gamma) + qy * std::cos(gamma); return {q_X, q_Y}; @@ -141,8 +128,7 @@ std::pair<double, double> InterferenceFunction2DLattice::rotateOrthonormal(doubl // vector aligned with the real-space x-axis (same frame as the one stored in m_sbase) std::pair<double, double> InterferenceFunction2DLattice::calculateReciprocalVectorFraction(double qx, double qy, - double xi) const -{ + double xi) const { double a = m_lattice->length1(); double b = m_lattice->length2(); double alpha = m_lattice->latticeAngle(); @@ -161,8 +147,7 @@ InterferenceFunction2DLattice::calculateReciprocalVectorFraction(double qx, doub } // Do not store xi in the reciprocal lattice -void InterferenceFunction2DLattice::initialize_rec_vectors() -{ +void InterferenceFunction2DLattice::initialize_rec_vectors() { if (!m_lattice) throw std::runtime_error("InterferenceFunction2DLattice::initialize_rec_vectors() -> " "Error. No lattice defined yet"); @@ -172,8 +157,7 @@ void InterferenceFunction2DLattice::initialize_rec_vectors() m_sbase = base_lattice.reciprocalBases(); } -void InterferenceFunction2DLattice::initialize_calc_factors() -{ +void InterferenceFunction2DLattice::initialize_calc_factors() { if (!m_decay) throw Exceptions::NullPointerException( "InterferenceFunction2DLattice::initialize_calc_factors" diff --git a/Sample/Aggregate/InterferenceFunction2DLattice.h b/Sample/Aggregate/InterferenceFunction2DLattice.h index 18a372691dd599714dd9169a66ed9a2924c80ffe..e026a586767aa7a992c475a6b783f29b447b851c 100644 --- a/Sample/Aggregate/InterferenceFunction2DLattice.h +++ b/Sample/Aggregate/InterferenceFunction2DLattice.h @@ -23,8 +23,7 @@ //! Interference function of a 2D lattice. //! @ingroup interference -class InterferenceFunction2DLattice : public IInterferenceFunction -{ +class InterferenceFunction2DLattice : public IInterferenceFunction { public: InterferenceFunction2DLattice(const Lattice2D& lattice); ~InterferenceFunction2DLattice() override; diff --git a/Sample/Aggregate/InterferenceFunction2DParaCrystal.cpp b/Sample/Aggregate/InterferenceFunction2DParaCrystal.cpp index fe207d330f1ab716cc41b2a1705bac5f2e283fee..5aa22997a06aed8816e4e05b48a36aa591067267 100644 --- a/Sample/Aggregate/InterferenceFunction2DParaCrystal.cpp +++ b/Sample/Aggregate/InterferenceFunction2DParaCrystal.cpp @@ -23,8 +23,7 @@ InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(const Latti double damping_length, double domain_size_1, double domain_size_2) - : IInterferenceFunction(0), m_integrate_xi(false), m_damping_length(damping_length) -{ + : IInterferenceFunction(0), m_integrate_xi(false), m_damping_length(damping_length) { setName("Interference2DParaCrystal"); m_lattice.reset(lattice.clone()); registerChild(m_lattice.get()); @@ -36,8 +35,7 @@ InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(const Latti InterferenceFunction2DParaCrystal::~InterferenceFunction2DParaCrystal() = default; -InterferenceFunction2DParaCrystal* InterferenceFunction2DParaCrystal::clone() const -{ +InterferenceFunction2DParaCrystal* InterferenceFunction2DParaCrystal::clone() const { auto* ret = new InterferenceFunction2DParaCrystal(*m_lattice, m_damping_length, m_domain_sizes[0], m_domain_sizes[1]); ret->setPositionVariance(m_position_var); @@ -51,9 +49,8 @@ InterferenceFunction2DParaCrystal* InterferenceFunction2DParaCrystal::clone() co //! @param pdf_1: probability distribution in first lattice direction //! @param pdf_2: probability distribution in second lattice direction -void InterferenceFunction2DParaCrystal::setProbabilityDistributions(const IFTDistribution2D& pdf_1, - const IFTDistribution2D& pdf_2) -{ +void InterferenceFunction2DParaCrystal::setProbabilityDistributions( + const IFTDistribution2D& pdf_1, const IFTDistribution2D& pdf_2) { m_pdf1.reset(pdf_1.clone()); registerChild(m_pdf1.get()); m_pdf2.reset(pdf_2.clone()); @@ -63,24 +60,20 @@ void InterferenceFunction2DParaCrystal::setProbabilityDistributions(const IFTDis //! Sets the damping length. //! @param damping_length: the damping (coherence) length of the paracrystal in nanometers -void InterferenceFunction2DParaCrystal::setDampingLength(double damping_length) -{ +void InterferenceFunction2DParaCrystal::setDampingLength(double damping_length) { m_damping_length = damping_length; } -double InterferenceFunction2DParaCrystal::getParticleDensity() const -{ +double InterferenceFunction2DParaCrystal::getParticleDensity() const { double area = m_lattice->unitCellArea(); return area == 0.0 ? 0.0 : 1.0 / area; } -std::vector<const INode*> InterferenceFunction2DParaCrystal::getChildren() const -{ +std::vector<const INode*> InterferenceFunction2DParaCrystal::getChildren() const { return std::vector<const INode*>() << m_pdf1 << m_pdf2 << m_lattice; } -double InterferenceFunction2DParaCrystal::iff_without_dw(const kvector_t q) const -{ +double InterferenceFunction2DParaCrystal::iff_without_dw(const kvector_t q) const { m_qx = q.x(); m_qy = q.y(); if (!m_integrate_xi) @@ -94,23 +87,20 @@ double InterferenceFunction2DParaCrystal::iff_without_dw(const kvector_t q) cons //! @param size_1: coherence domain size along the first basis vector in nanometers //! @param size_2: coherence domain size along the second basis vector in nanometers -void InterferenceFunction2DParaCrystal::setDomainSizes(double size_1, double size_2) -{ +void InterferenceFunction2DParaCrystal::setDomainSizes(double size_1, double size_2) { m_domain_sizes[0] = size_1; m_domain_sizes[1] = size_2; } void InterferenceFunction2DParaCrystal::transformToPrincipalAxes(double qx, double qy, double gamma, double delta, double& q_pa_1, - double& q_pa_2) const -{ + double& q_pa_2) const { q_pa_1 = qx * std::cos(gamma) + qy * std::sin(gamma); q_pa_2 = qx * std::cos(gamma + delta) + qy * std::sin(gamma + delta); } //! Returns interference function for fixed angle xi. -double InterferenceFunction2DParaCrystal::interferenceForXi(double xi) const -{ +double InterferenceFunction2DParaCrystal::interferenceForXi(double xi) const { // don't touch order of computation; problems under Windows double rx = interference1D(m_qx, m_qy, xi, 0); double ry = interference1D(m_qx, m_qy, xi + m_lattice->latticeAngle(), 1); @@ -119,8 +109,7 @@ double InterferenceFunction2DParaCrystal::interferenceForXi(double xi) const //! Returns interference function for fixed xi in the dimension determined by the given index. double InterferenceFunction2DParaCrystal::interference1D(double qx, double qy, double xi, - size_t index) const -{ + size_t index) const { if (index > 1) throw Exceptions::OutOfBoundsException( "InterferenceFunction2DParaCrystal::" @@ -158,8 +147,7 @@ double InterferenceFunction2DParaCrystal::interference1D(double qx, double qy, d } complex_t InterferenceFunction2DParaCrystal::FTPDF(double qx, double qy, double xi, - size_t index) const -{ + size_t index) const { double length = (index ? m_lattice->length2() : m_lattice->length1()); const IFTDistribution2D* pdf = (index ? m_pdf2.get() : m_pdf1.get()); @@ -177,22 +165,19 @@ complex_t InterferenceFunction2DParaCrystal::FTPDF(double qx, double qy, double return result; } -std::vector<double> InterferenceFunction2DParaCrystal::domainSizes() const -{ +std::vector<double> InterferenceFunction2DParaCrystal::domainSizes() const { return {m_domain_sizes[0], m_domain_sizes[1]}; } //! Enables/disables averaging over the lattice rotation angle. //! @param integrate_xi: integration flag -void InterferenceFunction2DParaCrystal::setIntegrationOverXi(bool integrate_xi) -{ +void InterferenceFunction2DParaCrystal::setIntegrationOverXi(bool integrate_xi) { m_integrate_xi = integrate_xi; m_lattice->setRotationEnabled(!m_integrate_xi); // deregister Xi in the case of integration } -const Lattice2D& InterferenceFunction2DParaCrystal::lattice() const -{ +const Lattice2D& InterferenceFunction2DParaCrystal::lattice() const { if (!m_lattice) throw std::runtime_error("InterferenceFunction2DParaCrystal::lattice() -> Error. " "No lattice defined."); diff --git a/Sample/Aggregate/InterferenceFunction2DParaCrystal.h b/Sample/Aggregate/InterferenceFunction2DParaCrystal.h index 101c2cf928d39fd84f63955b0db773ef603fb9d4..f8ffb2870b9d69e98698baac61c437837cac18a1 100644 --- a/Sample/Aggregate/InterferenceFunction2DParaCrystal.h +++ b/Sample/Aggregate/InterferenceFunction2DParaCrystal.h @@ -26,8 +26,7 @@ class IFTDistribution2D; //! Interference function of a 2D paracrystal. //! @ingroup interference -class InterferenceFunction2DParaCrystal : public IInterferenceFunction -{ +class InterferenceFunction2DParaCrystal : public IInterferenceFunction { public: InterferenceFunction2DParaCrystal(const Lattice2D& lattice, double damping_length, double domain_size_1, double domain_size_2); diff --git a/Sample/Aggregate/InterferenceFunction2DSuperLattice.cpp b/Sample/Aggregate/InterferenceFunction2DSuperLattice.cpp index a49252cafc93a88342169f363b7f2c1573af6838..727eff9b5d50e341b4c72ce79c7fbf090f977d14 100644 --- a/Sample/Aggregate/InterferenceFunction2DSuperLattice.cpp +++ b/Sample/Aggregate/InterferenceFunction2DSuperLattice.cpp @@ -29,8 +29,7 @@ InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(const Lat , m_integrate_xi(false) , m_substructure(nullptr) , m_size_1(size_1) - , m_size_2(size_2) -{ + , m_size_2(size_2) { setName("Interference2DSuperLattice"); m_lattice.reset(lattice.clone()); registerChild(m_lattice.get()); @@ -47,14 +46,11 @@ InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(const Lat InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice( double length_1, double length_2, double alpha, double xi, unsigned size_1, unsigned size_2) : InterferenceFunction2DSuperLattice(BasicLattice2D(length_1, length_2, alpha, xi), size_1, - size_2) -{ -} + size_2) {} InterferenceFunction2DSuperLattice::~InterferenceFunction2DSuperLattice() = default; -InterferenceFunction2DSuperLattice* InterferenceFunction2DSuperLattice::clone() const -{ +InterferenceFunction2DSuperLattice* InterferenceFunction2DSuperLattice::clone() const { auto* ret = new InterferenceFunction2DSuperLattice(*m_lattice, m_size_1, m_size_2); ret->setPositionVariance(m_position_var); ret->setSubstructureIFF(*m_substructure); @@ -62,19 +58,16 @@ InterferenceFunction2DSuperLattice* InterferenceFunction2DSuperLattice::clone() return ret; } -void InterferenceFunction2DSuperLattice::setSubstructureIFF(const IInterferenceFunction& sub_iff) -{ +void InterferenceFunction2DSuperLattice::setSubstructureIFF(const IInterferenceFunction& sub_iff) { m_substructure.reset(sub_iff.clone()); registerChild(m_substructure.get()); } -const IInterferenceFunction& InterferenceFunction2DSuperLattice::substructureIFF() const -{ +const IInterferenceFunction& InterferenceFunction2DSuperLattice::substructureIFF() const { return *m_substructure; } -double InterferenceFunction2DSuperLattice::evaluate(const kvector_t q, double outer_iff) const -{ +double InterferenceFunction2DSuperLattice::evaluate(const kvector_t q, double outer_iff) const { m_outer_iff = outer_iff; m_qx = q.x(); m_qy = q.y(); @@ -85,27 +78,23 @@ double InterferenceFunction2DSuperLattice::evaluate(const kvector_t q, double ou / M_TWOPI; } -void InterferenceFunction2DSuperLattice::setIntegrationOverXi(bool integrate_xi) -{ +void InterferenceFunction2DSuperLattice::setIntegrationOverXi(bool integrate_xi) { m_integrate_xi = integrate_xi; m_lattice->setRotationEnabled(!m_integrate_xi); // deregister Xi in the case of integration } -const Lattice2D& InterferenceFunction2DSuperLattice::lattice() const -{ +const Lattice2D& InterferenceFunction2DSuperLattice::lattice() const { if (!m_lattice) throw std::runtime_error("InterferenceFunctionFinite2DLattice::lattice() -> Error. " "No lattice defined."); return *m_lattice; } -std::vector<const INode*> InterferenceFunction2DSuperLattice::getChildren() const -{ +std::vector<const INode*> InterferenceFunction2DSuperLattice::getChildren() const { return std::vector<const INode*>() << m_lattice << m_substructure; } -double InterferenceFunction2DSuperLattice::iff_without_dw(const kvector_t q) const -{ +double InterferenceFunction2DSuperLattice::iff_without_dw(const kvector_t q) const { using Math::Laue; const double a = m_lattice->length1(); @@ -118,8 +107,7 @@ double InterferenceFunction2DSuperLattice::iff_without_dw(const kvector_t q) con return ampl * ampl / (m_size_1 * m_size_2); } -double InterferenceFunction2DSuperLattice::interferenceForXi(double xi) const -{ +double InterferenceFunction2DSuperLattice::interferenceForXi(double xi) const { m_xi = xi; // TODO ASAP don't set as collateratel effect; rm mutable const kvector_t q = kvector_t(m_qx, m_qy, 0.0); const double outer_iff = iff_no_inner(q, m_outer_iff); diff --git a/Sample/Aggregate/InterferenceFunction2DSuperLattice.h b/Sample/Aggregate/InterferenceFunction2DSuperLattice.h index 8e13781638f28a239d1002083b05502b3154a727..3fe7516236b67f8465c4fbeb768480124798caec 100644 --- a/Sample/Aggregate/InterferenceFunction2DSuperLattice.h +++ b/Sample/Aggregate/InterferenceFunction2DSuperLattice.h @@ -22,8 +22,7 @@ //! each lattice site. //! @ingroup interference -class InterferenceFunction2DSuperLattice : public IInterferenceFunction -{ +class InterferenceFunction2DSuperLattice : public IInterferenceFunction { public: InterferenceFunction2DSuperLattice(const Lattice2D& lattice, unsigned size_1, unsigned size_2); InterferenceFunction2DSuperLattice(double length_1, double length_2, double alpha, double xi, diff --git a/Sample/Aggregate/InterferenceFunction3DLattice.cpp b/Sample/Aggregate/InterferenceFunction3DLattice.cpp index 48dde3758d825f44deef9339bbc38a9544082d95..ef6c6388df30810f2cb3a96c5a4aed62783c927e 100644 --- a/Sample/Aggregate/InterferenceFunction3DLattice.cpp +++ b/Sample/Aggregate/InterferenceFunction3DLattice.cpp @@ -18,16 +18,14 @@ #include <algorithm> InterferenceFunction3DLattice::InterferenceFunction3DLattice(const Lattice3D& lattice) - : IInterferenceFunction(0), m_lattice(lattice), m_peak_shape(nullptr), m_rec_radius(0.0) -{ + : IInterferenceFunction(0), m_lattice(lattice), m_peak_shape(nullptr), m_rec_radius(0.0) { setName("Interference3DLattice"); initRecRadius(); } InterferenceFunction3DLattice::~InterferenceFunction3DLattice() = default; -InterferenceFunction3DLattice* InterferenceFunction3DLattice::clone() const -{ +InterferenceFunction3DLattice* InterferenceFunction3DLattice::clone() const { auto* ret = new InterferenceFunction3DLattice(m_lattice); ret->setPositionVariance(m_position_var); if (m_peak_shape) @@ -35,28 +33,23 @@ InterferenceFunction3DLattice* InterferenceFunction3DLattice::clone() const return ret; } -void InterferenceFunction3DLattice::setPeakShape(const IPeakShape& peak_shape) -{ +void InterferenceFunction3DLattice::setPeakShape(const IPeakShape& peak_shape) { m_peak_shape.reset(peak_shape.clone()); } -const Lattice3D& InterferenceFunction3DLattice::lattice() const -{ +const Lattice3D& InterferenceFunction3DLattice::lattice() const { return m_lattice; } -std::vector<const INode*> InterferenceFunction3DLattice::getChildren() const -{ +std::vector<const INode*> InterferenceFunction3DLattice::getChildren() const { return {}; } -void InterferenceFunction3DLattice::onChange() -{ +void InterferenceFunction3DLattice::onChange() { initRecRadius(); } -double InterferenceFunction3DLattice::iff_without_dw(const kvector_t q) const -{ +double InterferenceFunction3DLattice::iff_without_dw(const kvector_t q) const { ASSERT(m_peak_shape); kvector_t center = q; double radius = 2.1 * m_rec_radius; @@ -75,8 +68,7 @@ double InterferenceFunction3DLattice::iff_without_dw(const kvector_t q) const return result; } -void InterferenceFunction3DLattice::initRecRadius() -{ +void InterferenceFunction3DLattice::initRecRadius() { kvector_t a1 = m_lattice.getBasisVectorA(); kvector_t a2 = m_lattice.getBasisVectorB(); kvector_t a3 = m_lattice.getBasisVectorC(); diff --git a/Sample/Aggregate/InterferenceFunction3DLattice.h b/Sample/Aggregate/InterferenceFunction3DLattice.h index 16a7aae43f795dcd56da2d819d3d2ef98fc82c9e..7765aff1acc2f265c694f1b5e3011570f1f9ee9a 100644 --- a/Sample/Aggregate/InterferenceFunction3DLattice.h +++ b/Sample/Aggregate/InterferenceFunction3DLattice.h @@ -23,8 +23,7 @@ class IPeakShape; //! Interference function of a 3D lattice. //! @ingroup interference -class InterferenceFunction3DLattice : public IInterferenceFunction -{ +class InterferenceFunction3DLattice : public IInterferenceFunction { public: InterferenceFunction3DLattice(const Lattice3D& lattice); ~InterferenceFunction3DLattice() override; diff --git a/Sample/Aggregate/InterferenceFunctionFinite2DLattice.cpp b/Sample/Aggregate/InterferenceFunctionFinite2DLattice.cpp index 670417de96da5125113a3b7b0284c74dc5608f66..5306dcecb74351faa590f8434dbfe4d26113daf1 100644 --- a/Sample/Aggregate/InterferenceFunctionFinite2DLattice.cpp +++ b/Sample/Aggregate/InterferenceFunctionFinite2DLattice.cpp @@ -29,8 +29,7 @@ using Math::Laue; //! @param N_2: number of lattice cells in the second lattice direction InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(const Lattice2D& lattice, unsigned N_1, unsigned N_2) - : IInterferenceFunction(0), m_integrate_xi(false), m_N_1(N_1), m_N_2(N_2) -{ + : IInterferenceFunction(0), m_integrate_xi(false), m_N_1(N_1), m_N_2(N_2) { setName("InterferenceFinite2DLattice"); m_lattice.reset(lattice.clone()); registerChild(m_lattice.get()); @@ -38,41 +37,35 @@ InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(const L InterferenceFunctionFinite2DLattice::~InterferenceFunctionFinite2DLattice() = default; -InterferenceFunctionFinite2DLattice* InterferenceFunctionFinite2DLattice::clone() const -{ +InterferenceFunctionFinite2DLattice* InterferenceFunctionFinite2DLattice::clone() const { auto* ret = new InterferenceFunctionFinite2DLattice(*m_lattice, m_N_1, m_N_2); ret->setPositionVariance(m_position_var); ret->setIntegrationOverXi(integrationOverXi()); return ret; } -void InterferenceFunctionFinite2DLattice::setIntegrationOverXi(bool integrate_xi) -{ +void InterferenceFunctionFinite2DLattice::setIntegrationOverXi(bool integrate_xi) { m_integrate_xi = integrate_xi; m_lattice->setRotationEnabled(!m_integrate_xi); // deregister Xi in the case of integration } -const Lattice2D& InterferenceFunctionFinite2DLattice::lattice() const -{ +const Lattice2D& InterferenceFunctionFinite2DLattice::lattice() const { if (!m_lattice) throw std::runtime_error("InterferenceFunctionFinite2DLattice::lattice() -> Error. " "No lattice defined."); return *m_lattice; } -double InterferenceFunctionFinite2DLattice::getParticleDensity() const -{ +double InterferenceFunctionFinite2DLattice::getParticleDensity() const { double area = m_lattice->unitCellArea(); return area == 0.0 ? 0.0 : 1.0 / area; } -std::vector<const INode*> InterferenceFunctionFinite2DLattice::getChildren() const -{ +std::vector<const INode*> InterferenceFunctionFinite2DLattice::getChildren() const { return std::vector<const INode*>() << m_lattice; } -double InterferenceFunctionFinite2DLattice::iff_without_dw(const kvector_t q) const -{ +double InterferenceFunctionFinite2DLattice::iff_without_dw(const kvector_t q) const { m_qx = q.x(); m_qy = q.y(); if (!m_integrate_xi) @@ -82,8 +75,7 @@ double InterferenceFunctionFinite2DLattice::iff_without_dw(const kvector_t q) co / M_TWOPI; } -double InterferenceFunctionFinite2DLattice::interferenceForXi(double xi) const -{ +double InterferenceFunctionFinite2DLattice::interferenceForXi(double xi) const { double a = m_lattice->length1(); double b = m_lattice->length2(); double xialpha = xi + m_lattice->latticeAngle(); diff --git a/Sample/Aggregate/InterferenceFunctionFinite2DLattice.h b/Sample/Aggregate/InterferenceFunctionFinite2DLattice.h index 5afdf23f79808e5f74c90bb90044231745f73e95..484603310cac8949f53b6f45fd4ff3ebcc737da3 100644 --- a/Sample/Aggregate/InterferenceFunctionFinite2DLattice.h +++ b/Sample/Aggregate/InterferenceFunctionFinite2DLattice.h @@ -21,8 +21,7 @@ //! Interference function of a finite 2D lattice. //! @ingroup interference -class InterferenceFunctionFinite2DLattice : public IInterferenceFunction -{ +class InterferenceFunctionFinite2DLattice : public IInterferenceFunction { public: InterferenceFunctionFinite2DLattice(const Lattice2D& lattice, unsigned N_1, unsigned N_2); ~InterferenceFunctionFinite2DLattice() override; diff --git a/Sample/Aggregate/InterferenceFunctionFinite3DLattice.cpp b/Sample/Aggregate/InterferenceFunctionFinite3DLattice.cpp index b93b361ae705eea886eeea665968fbbbd6c70361..269fc462badb42435beb17711269c551d3f870eb 100644 --- a/Sample/Aggregate/InterferenceFunctionFinite3DLattice.cpp +++ b/Sample/Aggregate/InterferenceFunctionFinite3DLattice.cpp @@ -23,36 +23,31 @@ InterferenceFunctionFinite3DLattice::InterferenceFunctionFinite3DLattice(const Lattice3D& lattice, unsigned N_1, unsigned N_2, unsigned N_3) - : IInterferenceFunction(0), m_N_1(N_1), m_N_2(N_2), m_N_3(N_3) -{ + : IInterferenceFunction(0), m_N_1(N_1), m_N_2(N_2), m_N_3(N_3) { setName("InterferenceFinite3DLattice"); setLattice(lattice); } InterferenceFunctionFinite3DLattice::~InterferenceFunctionFinite3DLattice() = default; -InterferenceFunctionFinite3DLattice* InterferenceFunctionFinite3DLattice::clone() const -{ +InterferenceFunctionFinite3DLattice* InterferenceFunctionFinite3DLattice::clone() const { auto* ret = new InterferenceFunctionFinite3DLattice(*m_lattice, m_N_1, m_N_2, m_N_3); ret->setPositionVariance(m_position_var); return ret; } -const Lattice3D& InterferenceFunctionFinite3DLattice::lattice() const -{ +const Lattice3D& InterferenceFunctionFinite3DLattice::lattice() const { if (!m_lattice) throw std::runtime_error("InterferenceFunctionFinite3DLattice::lattice() -> Error. " "No lattice defined."); return *m_lattice; } -std::vector<const INode*> InterferenceFunctionFinite3DLattice::getChildren() const -{ +std::vector<const INode*> InterferenceFunctionFinite3DLattice::getChildren() const { return std::vector<const INode*>() << m_lattice; } -double InterferenceFunctionFinite3DLattice::iff_without_dw(const kvector_t q) const -{ +double InterferenceFunctionFinite3DLattice::iff_without_dw(const kvector_t q) const { using Math::Laue; const double qadiv2 = q.dot(m_lattice->getBasisVectorA()) / 2.0; const double qbdiv2 = q.dot(m_lattice->getBasisVectorB()) / 2.0; @@ -61,8 +56,7 @@ double InterferenceFunctionFinite3DLattice::iff_without_dw(const kvector_t q) co return ampl * ampl / (m_N_1 * m_N_2 * m_N_3); } -void InterferenceFunctionFinite3DLattice::setLattice(const Lattice3D& lattice) -{ +void InterferenceFunctionFinite3DLattice::setLattice(const Lattice3D& lattice) { m_lattice = std::make_unique<Lattice3D>(lattice); registerChild(m_lattice.get()); } diff --git a/Sample/Aggregate/InterferenceFunctionFinite3DLattice.h b/Sample/Aggregate/InterferenceFunctionFinite3DLattice.h index 93d535f3190b2067d6168152f8ff5485d0ece87e..85719d3198f5749faa99f68c1dcb4331fd7bf3f1 100644 --- a/Sample/Aggregate/InterferenceFunctionFinite3DLattice.h +++ b/Sample/Aggregate/InterferenceFunctionFinite3DLattice.h @@ -21,8 +21,7 @@ //! Interference function of a finite 3D lattice. //! @ingroup interference -class InterferenceFunctionFinite3DLattice : public IInterferenceFunction -{ +class InterferenceFunctionFinite3DLattice : public IInterferenceFunction { public: InterferenceFunctionFinite3DLattice(const Lattice3D& lattice, unsigned N_1, unsigned N_2, unsigned N_3); diff --git a/Sample/Aggregate/InterferenceFunctionHardDisk.cpp b/Sample/Aggregate/InterferenceFunctionHardDisk.cpp index 946ed73145f45d6e23f0ff4316e54aef8ede6b02..049b750f30dd8c43abdca36910748052e27a73fb 100644 --- a/Sample/Aggregate/InterferenceFunctionHardDisk.cpp +++ b/Sample/Aggregate/InterferenceFunctionHardDisk.cpp @@ -18,8 +18,7 @@ #include "Param/Base/RealParameter.h" #include <cmath> -namespace -{ +namespace { const double p = 7.0 / 3.0 - 4.0 * std::sqrt(3.0) / M_PI; double Czero(double packing); // TODO ASAP why these variables? double S2(double packing); @@ -28,8 +27,7 @@ double W2(double x); InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(double radius, double density, double position_var) - : IInterferenceFunction(position_var), m_radius(radius), m_density(density) -{ + : IInterferenceFunction(position_var), m_radius(radius), m_density(density) { setName("InterferenceHardDisk"); if (m_radius < 0.0 || m_density < 0.0 || packingRatio() > 0.65) throw std::runtime_error("InterferenceFunctionHardDisk::validateParameters: " @@ -39,29 +37,24 @@ InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(double radius, double registerParameter("TotalParticleDensity", &m_density).setUnit("nm").setNonnegative(); } -InterferenceFunctionHardDisk* InterferenceFunctionHardDisk::clone() const -{ +InterferenceFunctionHardDisk* InterferenceFunctionHardDisk::clone() const { auto* ret = new InterferenceFunctionHardDisk(m_radius, m_density, m_position_var); return ret; } -double InterferenceFunctionHardDisk::getParticleDensity() const -{ +double InterferenceFunctionHardDisk::getParticleDensity() const { return m_density; } -double InterferenceFunctionHardDisk::radius() const -{ +double InterferenceFunctionHardDisk::radius() const { return m_radius; } -double InterferenceFunctionHardDisk::density() const -{ +double InterferenceFunctionHardDisk::density() const { return m_density; } -double InterferenceFunctionHardDisk::iff_without_dw(const kvector_t q) const -{ +double InterferenceFunctionHardDisk::iff_without_dw(const kvector_t q) const { double qx = q.x(); double qy = q.y(); m_q = 2.0 * std::sqrt(qx * qx + qy * qy) * m_radius; @@ -75,28 +68,23 @@ double InterferenceFunctionHardDisk::iff_without_dw(const kvector_t q) const return 1.0 / (1.0 - rho * c_q); } -double InterferenceFunctionHardDisk::packingRatio() const -{ +double InterferenceFunctionHardDisk::packingRatio() const { return M_PI * m_radius * m_radius * m_density; } -double InterferenceFunctionHardDisk::integrand(double x) const -{ +double InterferenceFunctionHardDisk::integrand(double x) const { double cx = m_c_zero * (1.0 + 4.0 * m_packing * (W2(x / 2.0) - 1.0) + m_s2 * x); return x * cx * Math::Bessel::J0(m_q * x); } -namespace -{ -double Czero(double packing) -{ +namespace { +double Czero(double packing) { double numerator = 1.0 + packing + 3.0 * p * packing * packing - p * std::pow(packing, 3); double denominator = std::pow(1.0 - packing, 3); return -numerator / denominator; } -double S2(double packing) -{ +double S2(double packing) { double factor = 3.0 * packing * packing / 8.0; double numerator = 8.0 * (1.0 - 2.0 * p) + (25.0 - 9.0 * p) * p * packing - (7.0 - 3.0 * p) * p * packing * packing; @@ -104,8 +92,7 @@ double S2(double packing) return factor * numerator / denominator; } -double W2(double x) -{ +double W2(double x) { return 2.0 * (std::acos(x) - x * std::sqrt(1.0 - x * x)) / M_PI; } } // namespace diff --git a/Sample/Aggregate/InterferenceFunctionHardDisk.h b/Sample/Aggregate/InterferenceFunctionHardDisk.h index 4d3c29998f4e2fb25ab0a955895910d2b8950128..09965829e1c6617c72630aab3b272825e42e670b 100644 --- a/Sample/Aggregate/InterferenceFunctionHardDisk.h +++ b/Sample/Aggregate/InterferenceFunctionHardDisk.h @@ -24,8 +24,7 @@ //! DOI: 10.1080/00268979500101211 //! @ingroup interference -class InterferenceFunctionHardDisk : public IInterferenceFunction -{ +class InterferenceFunctionHardDisk : public IInterferenceFunction { public: InterferenceFunctionHardDisk(double radius, double density, double position_var = 0); ~InterferenceFunctionHardDisk() override = default; diff --git a/Sample/Aggregate/InterferenceFunctionNone.cpp b/Sample/Aggregate/InterferenceFunctionNone.cpp index 843a06b7161aad8472fd1636832972266a392680..2f575de7bcd32bb68ff9617af4cd189334e09c54 100644 --- a/Sample/Aggregate/InterferenceFunctionNone.cpp +++ b/Sample/Aggregate/InterferenceFunctionNone.cpp @@ -14,19 +14,16 @@ #include "Sample/Aggregate/InterferenceFunctionNone.h" -InterferenceFunctionNone::InterferenceFunctionNone() : IInterferenceFunction(0) -{ +InterferenceFunctionNone::InterferenceFunctionNone() : IInterferenceFunction(0) { setName("InterferenceNone"); } -InterferenceFunctionNone* InterferenceFunctionNone::clone() const -{ +InterferenceFunctionNone* InterferenceFunctionNone::clone() const { auto* ret = new InterferenceFunctionNone(); ret->setPositionVariance(m_position_var); return ret; } -double InterferenceFunctionNone::iff_without_dw(const kvector_t) const -{ +double InterferenceFunctionNone::iff_without_dw(const kvector_t) const { return 1.0; } diff --git a/Sample/Aggregate/InterferenceFunctionNone.h b/Sample/Aggregate/InterferenceFunctionNone.h index 231f8d157401d671ef42f8472dfe07a1fa8e6772..3ca2ec2dbf6e8fee96ccb1dfcc7a122e1f8708fc 100644 --- a/Sample/Aggregate/InterferenceFunctionNone.h +++ b/Sample/Aggregate/InterferenceFunctionNone.h @@ -20,8 +20,7 @@ //! Default interference function (i.e. absence of any interference). //! @ingroup interference -class InterferenceFunctionNone : public IInterferenceFunction -{ +class InterferenceFunctionNone : public IInterferenceFunction { public: InterferenceFunctionNone(); diff --git a/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.cpp b/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.cpp index 1bdf0001379b2c12a528f807245ab958c4081117..1119a8909744605ba6e510f0eb1a3aecd8ce9f25 100644 --- a/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.cpp +++ b/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.cpp @@ -28,8 +28,7 @@ InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(dou , m_damping_length(damping_length) , m_use_damping_length(true) , m_kappa(0.0) - , m_domain_size(0.0) -{ + , m_domain_size(0.0) { setName("InterferenceRadialParaCrystal"); if (m_damping_length == 0.0) m_use_damping_length = false; @@ -39,8 +38,7 @@ InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(dou registerParameter("DomainSize", &m_domain_size).setUnit("nm").setNonnegative(); } -InterferenceFunctionRadialParaCrystal* InterferenceFunctionRadialParaCrystal::clone() const -{ +InterferenceFunctionRadialParaCrystal* InterferenceFunctionRadialParaCrystal::clone() const { auto* ret = new InterferenceFunctionRadialParaCrystal(m_peak_distance, m_damping_length); ret->setPositionVariance(m_position_var); if (m_pdf) @@ -51,26 +49,22 @@ InterferenceFunctionRadialParaCrystal* InterferenceFunctionRadialParaCrystal::cl } //! Sets size spacing coupling parameter of the Size Spacing Correlation Approximation. -void InterferenceFunctionRadialParaCrystal::setKappa(double kappa) -{ +void InterferenceFunctionRadialParaCrystal::setKappa(double kappa) { m_kappa = kappa; } -double InterferenceFunctionRadialParaCrystal::kappa() const -{ +double InterferenceFunctionRadialParaCrystal::kappa() const { return m_kappa; } //! Sets domain size (finite size corrections). //! @param size: size of coherence domain along the lattice main axis in nanometers -void InterferenceFunctionRadialParaCrystal::setDomainSize(double size) -{ +void InterferenceFunctionRadialParaCrystal::setDomainSize(double size) { m_domain_size = size; } -complex_t InterferenceFunctionRadialParaCrystal::FTPDF(double qpar) const -{ +complex_t InterferenceFunctionRadialParaCrystal::FTPDF(double qpar) const { complex_t phase = exp_I(qpar * m_peak_distance); double amplitude = m_pdf->evaluate(qpar); complex_t result = phase * amplitude; @@ -82,19 +76,17 @@ complex_t InterferenceFunctionRadialParaCrystal::FTPDF(double qpar) const //! Sets one-dimensional probability distribution. //! @param pdf: probability distribution (Fourier transform of probability density) -void InterferenceFunctionRadialParaCrystal::setProbabilityDistribution(const IFTDistribution1D& pdf) -{ +void InterferenceFunctionRadialParaCrystal::setProbabilityDistribution( + const IFTDistribution1D& pdf) { m_pdf.reset(pdf.clone()); registerChild(m_pdf.get()); } -std::vector<const INode*> InterferenceFunctionRadialParaCrystal::getChildren() const -{ +std::vector<const INode*> InterferenceFunctionRadialParaCrystal::getChildren() const { return std::vector<const INode*>() << m_pdf; } -double InterferenceFunctionRadialParaCrystal::iff_without_dw(const kvector_t q) const -{ +double InterferenceFunctionRadialParaCrystal::iff_without_dw(const kvector_t q) const { if (!m_pdf) throw Exceptions::NullPointerException("InterferenceFunctionRadialParaCrystal::" "evaluate() -> Error! Probability distribution for " diff --git a/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.h b/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.h index e9f4a8e7245bbf9e76f9a6f2e41701a05f6c4598..9c19494a47cdcdd718a453d018134c74fcb69d85 100644 --- a/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.h +++ b/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.h @@ -23,8 +23,7 @@ //! Interference function of radial paracrystal. //! @ingroup interference -class InterferenceFunctionRadialParaCrystal : public IInterferenceFunction -{ +class InterferenceFunctionRadialParaCrystal : public IInterferenceFunction { public: InterferenceFunctionRadialParaCrystal(double peak_distance, double damping_length); InterferenceFunctionRadialParaCrystal* clone() const final; diff --git a/Sample/Aggregate/InterferenceFunctionTwin.cpp b/Sample/Aggregate/InterferenceFunctionTwin.cpp index f0b807a2d91875d5bdbb4084fd3a9a58d9d1d22f..952c054375cd7cb3b1009a4ffe54c4d4c405bfe3 100644 --- a/Sample/Aggregate/InterferenceFunctionTwin.cpp +++ b/Sample/Aggregate/InterferenceFunctionTwin.cpp @@ -21,8 +21,7 @@ InterferenceFunctionTwin::InterferenceFunctionTwin(const kvector_t& direction, d : IInterferenceFunction(0) , m_direction(direction) , m_distance(mean_distance) - , m_std_dev(std_dev) -{ + , m_std_dev(std_dev) { setName("InterferenceTwin"); if (m_direction.mag2() <= 0.0 || m_distance < 0.0 || m_std_dev < 0.0) throw std::runtime_error( @@ -33,30 +32,25 @@ InterferenceFunctionTwin::InterferenceFunctionTwin(const kvector_t& direction, d registerParameter("StdDev", &m_std_dev).setUnit("nm").setNonnegative(); } -InterferenceFunctionTwin* InterferenceFunctionTwin::clone() const -{ +InterferenceFunctionTwin* InterferenceFunctionTwin::clone() const { auto* ret = new InterferenceFunctionTwin(m_direction, m_distance, m_std_dev); ret->setPositionVariance(m_position_var); return ret; } -kvector_t InterferenceFunctionTwin::direction() const -{ +kvector_t InterferenceFunctionTwin::direction() const { return m_direction; } -double InterferenceFunctionTwin::meanDistance() const -{ +double InterferenceFunctionTwin::meanDistance() const { return m_distance; } -double InterferenceFunctionTwin::stdDev() const -{ +double InterferenceFunctionTwin::stdDev() const { return m_std_dev; } -double InterferenceFunctionTwin::iff_without_dw(const kvector_t q) const -{ +double InterferenceFunctionTwin::iff_without_dw(const kvector_t q) const { double q_proj = q.dot(m_direction.unit()); return 1.0 + std::exp(-q_proj * q_proj * m_std_dev * m_std_dev / 2.0) diff --git a/Sample/Aggregate/InterferenceFunctionTwin.h b/Sample/Aggregate/InterferenceFunctionTwin.h index a8ab69e36dd8b8760e4b58087bdf4053f33b6258..2adb9bcc97df9d9e6e96e942604ca02a71138e41 100644 --- a/Sample/Aggregate/InterferenceFunctionTwin.h +++ b/Sample/Aggregate/InterferenceFunctionTwin.h @@ -21,8 +21,7 @@ //! from each other in a given direction. //! @ingroup interference -class InterferenceFunctionTwin : public IInterferenceFunction -{ +class InterferenceFunctionTwin : public IInterferenceFunction { public: InterferenceFunctionTwin(const kvector_t& direction, double mean_distance, double std_dev); diff --git a/Sample/Aggregate/ParticleLayout.cpp b/Sample/Aggregate/ParticleLayout.cpp index e3c88601e2ce222a8e207b029cc2347b479363ff..3bd52a674ba9071f781929bbb828481f9285b79f 100644 --- a/Sample/Aggregate/ParticleLayout.cpp +++ b/Sample/Aggregate/ParticleLayout.cpp @@ -20,13 +20,11 @@ #include "Sample/Particle/Particle.h" #include "Sample/Particle/ParticleDistribution.h" -namespace -{ +namespace { //! Returns true if interference function is able to calculate particle density automatically, //! which is the case for 2D functions. -bool particleDensityIsProvidedByInterference(const IInterferenceFunction& iff) -{ +bool particleDensityIsProvidedByInterference(const IInterferenceFunction& iff) { return iff.getName() == "Interference2DLattice" || iff.getName() == "Interference2DParaCrystal" || iff.getName() == "Interference2DSuperLattice" || iff.getName() == "InterferenceFinite2DLattice" @@ -35,16 +33,14 @@ bool particleDensityIsProvidedByInterference(const IInterferenceFunction& iff) } // namespace ParticleLayout::ParticleLayout() - : m_weight(1.0), m_total_particle_density(0.01), m_interference_function(nullptr) -{ + : m_weight(1.0), m_total_particle_density(0.01), m_interference_function(nullptr) { setName("ParticleLayout"); registerParticleDensity(); registerWeight(); } ParticleLayout::ParticleLayout(const IAbstractParticle& particle, double abundance) - : m_weight(1.0), m_total_particle_density(0.01), m_interference_function(nullptr) -{ + : m_weight(1.0), m_total_particle_density(0.01), m_interference_function(nullptr) { setName("ParticleLayout"); addParticle(particle, abundance); registerParticleDensity(); @@ -53,8 +49,7 @@ ParticleLayout::ParticleLayout(const IAbstractParticle& particle, double abundan ParticleLayout::~ParticleLayout() = default; // needs member class definitions => don't move to .h -ParticleLayout* ParticleLayout::clone() const -{ +ParticleLayout* ParticleLayout::clone() const { ParticleLayout* p_result = new ParticleLayout(); for (auto p_particle : m_particles) @@ -75,8 +70,7 @@ ParticleLayout* ParticleLayout::clone() const //! @param position Particle position //! @param rotation Particle rotation void ParticleLayout::addParticle(const IAbstractParticle& particle, double abundance, - const kvector_t position, const IRotation& rotation) -{ + const kvector_t position, const IRotation& rotation) { IAbstractParticle* particle_clone = particle.clone(); if (abundance >= 0.0) particle_clone->setAbundance(abundance); @@ -89,8 +83,7 @@ void ParticleLayout::addParticle(const IAbstractParticle& particle, double abund //! Returns information on all particles (type and abundance) //! and generates new particles if an IAbstractParticle denotes a collection -SafePointerVector<IParticle> ParticleLayout::particles() const -{ +SafePointerVector<IParticle> ParticleLayout::particles() const { SafePointerVector<IParticle> particle_vector; for (auto particle : m_particles) { if (const auto* p_part_distr = dynamic_cast<const ParticleDistribution*>(particle)) { @@ -104,13 +97,11 @@ SafePointerVector<IParticle> ParticleLayout::particles() const return particle_vector; } -const IInterferenceFunction* ParticleLayout::interferenceFunction() const -{ +const IInterferenceFunction* ParticleLayout::interferenceFunction() const { return m_interference_function.get(); } -double ParticleLayout::getTotalAbundance() const -{ +double ParticleLayout::getTotalAbundance() const { double result = 0.0; for (auto p_particle : m_particles) result += p_particle->abundance(); @@ -118,13 +109,11 @@ double ParticleLayout::getTotalAbundance() const } //! Adds interference functions -void ParticleLayout::setInterferenceFunction(const IInterferenceFunction& interference_function) -{ +void ParticleLayout::setInterferenceFunction(const IInterferenceFunction& interference_function) { setAndRegisterInterferenceFunction(interference_function.clone()); } -double ParticleLayout::totalParticleSurfaceDensity() const -{ +double ParticleLayout::totalParticleSurfaceDensity() const { double iff_density = m_interference_function ? m_interference_function->getParticleDensity() : 0.0; return iff_density > 0.0 ? iff_density : m_total_particle_density; @@ -132,13 +121,11 @@ double ParticleLayout::totalParticleSurfaceDensity() const //! Sets total particle surface density. //! @param particle_density: number of particles per square nanometer -void ParticleLayout::setTotalParticleSurfaceDensity(double particle_density) -{ +void ParticleLayout::setTotalParticleSurfaceDensity(double particle_density) { m_total_particle_density = particle_density; } -std::vector<const INode*> ParticleLayout::getChildren() const -{ +std::vector<const INode*> ParticleLayout::getChildren() const { std::vector<const INode*> result; for (auto particle : m_particles) result.push_back(particle); @@ -147,15 +134,13 @@ std::vector<const INode*> ParticleLayout::getChildren() const } //! Adds particle information with simultaneous registration in parent class. -void ParticleLayout::addAndRegisterAbstractParticle(IAbstractParticle* child) -{ +void ParticleLayout::addAndRegisterAbstractParticle(IAbstractParticle* child) { m_particles.push_back(child); registerChild(child); } //! Sets interference function with simultaneous registration in parent class -void ParticleLayout::setAndRegisterInterferenceFunction(IInterferenceFunction* child) -{ +void ParticleLayout::setAndRegisterInterferenceFunction(IInterferenceFunction* child) { m_interference_function.reset(child); registerChild(child); @@ -165,8 +150,7 @@ void ParticleLayout::setAndRegisterInterferenceFunction(IInterferenceFunction* c registerParticleDensity(true); } -void ParticleLayout::registerParticleDensity(bool make_registered) -{ +void ParticleLayout::registerParticleDensity(bool make_registered) { if (make_registered) { if (!parameter("TotalParticleDensity")) registerParameter("TotalParticleDensity", &m_total_particle_density); @@ -175,7 +159,6 @@ void ParticleLayout::registerParticleDensity(bool make_registered) } } -void ParticleLayout::registerWeight() -{ +void ParticleLayout::registerWeight() { registerParameter("Weight", &m_weight); } diff --git a/Sample/Aggregate/ParticleLayout.h b/Sample/Aggregate/ParticleLayout.h index 14c50667438d041b9ed7451e41f05065888402e4..95c8ace181fce2731c49c06ac11bbaecedae95bb 100644 --- a/Sample/Aggregate/ParticleLayout.h +++ b/Sample/Aggregate/ParticleLayout.h @@ -27,8 +27,7 @@ class IParticle; //! Decorator class that adds particles to ISample objects. //! @ingroup samples -class ParticleLayout : public ISample -{ +class ParticleLayout : public ISample { public: ParticleLayout(); ParticleLayout(const IAbstractParticle& particle, double abundance = -1.0); diff --git a/Sample/Correlations/FTDecay1D.cpp b/Sample/Correlations/FTDecay1D.cpp index a27e4ffe18ced361c083fe0e1ded578c850b6cc9..6bc2daf704a3edfd7e46b46c08222580be3c2b87 100644 --- a/Sample/Correlations/FTDecay1D.cpp +++ b/Sample/Correlations/FTDecay1D.cpp @@ -22,31 +22,23 @@ IFTDecayFunction1D::IFTDecayFunction1D(const NodeMeta& meta, const std::vector<double>& PValues) : INode(nodeMetaUnion({{"DecayLength", "nm", "half width", 0, INF, 1.}}, meta), PValues) - , m_decay_length(m_P[0]) -{ -} + , m_decay_length(m_P[0]) {} // ************************************************************************************************ // class FTDecayFunction1DCauchy // ************************************************************************************************ FTDecayFunction1DCauchy::FTDecayFunction1DCauchy(const std::vector<double> P) - : IFTDecayFunction1D({"FTDecayFunction1DCauchy", "class_tooltip", {}}, P) -{ -} + : IFTDecayFunction1D({"FTDecayFunction1DCauchy", "class_tooltip", {}}, P) {} FTDecayFunction1DCauchy::FTDecayFunction1DCauchy(double decay_length) - : FTDecayFunction1DCauchy(std::vector<double>{decay_length}) -{ -} + : FTDecayFunction1DCauchy(std::vector<double>{decay_length}) {} -FTDecayFunction1DCauchy* FTDecayFunction1DCauchy::clone() const -{ +FTDecayFunction1DCauchy* FTDecayFunction1DCauchy::clone() const { return new FTDecayFunction1DCauchy(m_decay_length); } -double FTDecayFunction1DCauchy::evaluate(double q) const -{ +double FTDecayFunction1DCauchy::evaluate(double q) const { double sum_sq = q * q * m_decay_length * m_decay_length; return m_decay_length * 2.0 / (1.0 + sum_sq); } @@ -56,22 +48,16 @@ double FTDecayFunction1DCauchy::evaluate(double q) const // ************************************************************************************************ FTDecayFunction1DGauss::FTDecayFunction1DGauss(const std::vector<double> P) - : IFTDecayFunction1D({"FTDecayFunction1DGauss", "class_tooltip", {}}, P) -{ -} + : IFTDecayFunction1D({"FTDecayFunction1DGauss", "class_tooltip", {}}, P) {} FTDecayFunction1DGauss::FTDecayFunction1DGauss(double decay_length) - : FTDecayFunction1DGauss(std::vector<double>{decay_length}) -{ -} + : FTDecayFunction1DGauss(std::vector<double>{decay_length}) {} -FTDecayFunction1DGauss* FTDecayFunction1DGauss::clone() const -{ +FTDecayFunction1DGauss* FTDecayFunction1DGauss::clone() const { return new FTDecayFunction1DGauss(m_decay_length); } -double FTDecayFunction1DGauss::evaluate(double q) const -{ +double FTDecayFunction1DGauss::evaluate(double q) const { double sum_sq = q * q * m_decay_length * m_decay_length; return m_decay_length * std::sqrt(M_TWOPI) * std::exp(-sum_sq / 2.0); } @@ -81,22 +67,16 @@ double FTDecayFunction1DGauss::evaluate(double q) const // ************************************************************************************************ FTDecayFunction1DTriangle::FTDecayFunction1DTriangle(const std::vector<double> P) - : IFTDecayFunction1D({"FTDecayFunction1DTriangle", "class_tooltip", {}}, P) -{ -} + : IFTDecayFunction1D({"FTDecayFunction1DTriangle", "class_tooltip", {}}, P) {} FTDecayFunction1DTriangle::FTDecayFunction1DTriangle(double decay_length) - : FTDecayFunction1DTriangle(std::vector<double>{decay_length}) -{ -} + : FTDecayFunction1DTriangle(std::vector<double>{decay_length}) {} -FTDecayFunction1DTriangle* FTDecayFunction1DTriangle::clone() const -{ +FTDecayFunction1DTriangle* FTDecayFunction1DTriangle::clone() const { return new FTDecayFunction1DTriangle(m_decay_length); } -double FTDecayFunction1DTriangle::evaluate(double q) const -{ +double FTDecayFunction1DTriangle::evaluate(double q) const { double sincqw2 = Math::sinc(q * m_decay_length / 2.0); return m_decay_length * sincqw2 * sincqw2; } @@ -112,22 +92,16 @@ FTDecayFunction1DVoigt::FTDecayFunction1DVoigt(const std::vector<double> P) {{"Eta", "", "balances between Gauss (eta=0) and Cauchy (eta=1) limiting cases", -INF, +INF, 0}}}, P) - , m_eta(m_P[0]) -{ -} + , m_eta(m_P[0]) {} FTDecayFunction1DVoigt::FTDecayFunction1DVoigt(double decay_length, double eta) - : FTDecayFunction1DVoigt(std::vector<double>{decay_length, eta}) -{ -} + : FTDecayFunction1DVoigt(std::vector<double>{decay_length, eta}) {} -FTDecayFunction1DVoigt* FTDecayFunction1DVoigt::clone() const -{ +FTDecayFunction1DVoigt* FTDecayFunction1DVoigt::clone() const { return new FTDecayFunction1DVoigt(m_decay_length, m_eta); } -double FTDecayFunction1DVoigt::evaluate(double q) const -{ +double FTDecayFunction1DVoigt::evaluate(double q) const { double sum_sq = q * q * m_decay_length * m_decay_length; return m_eta * m_decay_length * std::sqrt(M_TWOPI) * std::exp(-sum_sq / 2.0) + (1.0 - m_eta) * m_decay_length * 2.0 / (1.0 + sum_sq); diff --git a/Sample/Correlations/FTDecay1D.h b/Sample/Correlations/FTDecay1D.h index 470e1e7f3cf33a95ce30aa57e18d8b1ee9edbb6f..4b0ba58d857150fc772d046f8446ec6fc420383f 100644 --- a/Sample/Correlations/FTDecay1D.h +++ b/Sample/Correlations/FTDecay1D.h @@ -24,8 +24,7 @@ //! with evaluate(q) returning the Fourier transform, //! normalized to \f$\int dq\; {\rm evaluate}(q) = 1\f$. //! @ingroup distribution_internal -class IFTDecayFunction1D : public ICloneable, public INode -{ +class IFTDecayFunction1D : public ICloneable, public INode { public: IFTDecayFunction1D(const NodeMeta& meta, const std::vector<double>& PValues); @@ -40,8 +39,7 @@ protected: //! One-dimensional Cauchy decay function in reciprocal space; //! corresponds to exp(-|x|/decay_length) in real space. //! @ingroup decayFT -class FTDecayFunction1DCauchy : public IFTDecayFunction1D -{ +class FTDecayFunction1DCauchy : public IFTDecayFunction1D { public: FTDecayFunction1DCauchy(const std::vector<double> P); FTDecayFunction1DCauchy(double decay_length); @@ -54,8 +52,7 @@ public: //! One-dimensional Gauss decay function in reciprocal space; //! corresponds to exp[-x^2/(2*decay_length^2)] in real space. //! @ingroup decayFT -class FTDecayFunction1DGauss : public IFTDecayFunction1D -{ +class FTDecayFunction1DGauss : public IFTDecayFunction1D { public: FTDecayFunction1DGauss(const std::vector<double> P); FTDecayFunction1DGauss(double decay_length); @@ -68,8 +65,7 @@ public: //! One-dimensional triangle decay function in reciprocal space; //! corresponds to 1-|x|/decay_length if |x|<decay_length (and 0 otherwise) in real space. //! @ingroup decayFT -class FTDecayFunction1DTriangle : public IFTDecayFunction1D -{ +class FTDecayFunction1DTriangle : public IFTDecayFunction1D { public: FTDecayFunction1DTriangle(const std::vector<double> P); FTDecayFunction1DTriangle(double decay_length); @@ -82,8 +78,7 @@ public: //! One-dimensional pseudo-Voigt decay function in reciprocal space; //! corresponds to eta*Gauss + (1-eta)*Cauchy. //! @ingroup decayFT -class FTDecayFunction1DVoigt : public IFTDecayFunction1D -{ +class FTDecayFunction1DVoigt : public IFTDecayFunction1D { public: FTDecayFunction1DVoigt(const std::vector<double> P); FTDecayFunction1DVoigt(double decay_length, double eta); diff --git a/Sample/Correlations/FTDecay2D.cpp b/Sample/Correlations/FTDecay2D.cpp index be20712ed9092b32444c5e561697975c680e0100..a80f7bde64e98556e1916f94134a4e802a58d67b 100644 --- a/Sample/Correlations/FTDecay2D.cpp +++ b/Sample/Correlations/FTDecay2D.cpp @@ -29,16 +29,13 @@ IFTDecayFunction2D::IFTDecayFunction2D(const NodeMeta& meta, const std::vector<d PValues) , m_decay_length_x(m_P[0]) , m_decay_length_y(m_P[1]) - , m_gamma(m_P[2]) -{ -} + , m_gamma(m_P[2]) {} //! Calculates bounding values of reciprocal lattice coordinates that contain the centered //! rectangle with a corner defined by qX and qY std::pair<double, double> IFTDecayFunction2D::boundingReciprocalLatticeCoordinates(double qX, double qY, double a, double b, - double alpha) const -{ + double alpha) const { auto q_bounds_1 = transformToRecLatticeCoordinates(qX, qY, a, b, alpha); auto q_bounds_2 = transformToRecLatticeCoordinates(qX, -qY, a, b, alpha); double qa_max = std::max(std::abs(q_bounds_1.first), std::abs(q_bounds_2.first)); @@ -48,8 +45,7 @@ IFTDecayFunction2D::boundingReciprocalLatticeCoordinates(double qX, double qY, d std::pair<double, double> IFTDecayFunction2D::transformToRecLatticeCoordinates(double qX, double qY, double a, double b, - double alpha) const -{ + double alpha) const { double qa = (a * qX * std::cos(m_gamma) - a * qY * std::sin(m_gamma)) / M_TWOPI; double qb = (b * qX * std::cos(alpha - m_gamma) + b * qY * std::sin(alpha - m_gamma)) / M_TWOPI; return {qa, qb}; @@ -60,23 +56,17 @@ std::pair<double, double> IFTDecayFunction2D::transformToRecLatticeCoordinates(d // ************************************************************************************************ FTDecayFunction2DCauchy::FTDecayFunction2DCauchy(const std::vector<double> P) - : IFTDecayFunction2D({"FTDecayFunction2DCauchy", "class_tooltip", {}}, P) -{ -} + : IFTDecayFunction2D({"FTDecayFunction2DCauchy", "class_tooltip", {}}, P) {} FTDecayFunction2DCauchy::FTDecayFunction2DCauchy(double decay_length_x, double decay_length_y, double gamma) - : FTDecayFunction2DCauchy(std::vector<double>{decay_length_x, decay_length_y, gamma}) -{ -} + : FTDecayFunction2DCauchy(std::vector<double>{decay_length_x, decay_length_y, gamma}) {} -FTDecayFunction2DCauchy* FTDecayFunction2DCauchy::clone() const -{ +FTDecayFunction2DCauchy* FTDecayFunction2DCauchy::clone() const { return new FTDecayFunction2DCauchy(m_decay_length_x, m_decay_length_y, m_gamma); } -double FTDecayFunction2DCauchy::evaluate(double qx, double qy) const -{ +double FTDecayFunction2DCauchy::evaluate(double qx, double qy) const { double sum_sq = qx * qx * m_decay_length_x * m_decay_length_x + qy * qy * m_decay_length_y * m_decay_length_y; return M_TWOPI * m_decay_length_x * m_decay_length_y * std::pow(1.0 + sum_sq, -1.5); @@ -87,23 +77,17 @@ double FTDecayFunction2DCauchy::evaluate(double qx, double qy) const // ************************************************************************************************ FTDecayFunction2DGauss::FTDecayFunction2DGauss(const std::vector<double> P) - : IFTDecayFunction2D({"FTDecayFunction2DGauss", "class_tooltip", {}}, P) -{ -} + : IFTDecayFunction2D({"FTDecayFunction2DGauss", "class_tooltip", {}}, P) {} FTDecayFunction2DGauss::FTDecayFunction2DGauss(double decay_length_x, double decay_length_y, double gamma) - : FTDecayFunction2DGauss(std::vector<double>{decay_length_x, decay_length_y, gamma}) -{ -} + : FTDecayFunction2DGauss(std::vector<double>{decay_length_x, decay_length_y, gamma}) {} -FTDecayFunction2DGauss* FTDecayFunction2DGauss::clone() const -{ +FTDecayFunction2DGauss* FTDecayFunction2DGauss::clone() const { return new FTDecayFunction2DGauss(m_decay_length_x, m_decay_length_y, m_gamma); } -double FTDecayFunction2DGauss::evaluate(double qx, double qy) const -{ +double FTDecayFunction2DGauss::evaluate(double qx, double qy) const { double sum_sq = qx * qx * m_decay_length_x * m_decay_length_x + qy * qy * m_decay_length_y * m_decay_length_y; return M_TWOPI * m_decay_length_x * m_decay_length_y * std::exp(-sum_sq / 2.0); @@ -120,23 +104,17 @@ FTDecayFunction2DVoigt::FTDecayFunction2DVoigt(const std::vector<double> P) {{"Eta", "", "balances between Gauss (eta=0) and Cauchy (eta=1) limiting cases", -INF, +INF, 0}}}, P) - , m_eta(m_P[0]) -{ -} + , m_eta(m_P[0]) {} FTDecayFunction2DVoigt::FTDecayFunction2DVoigt(double decay_length_x, double decay_length_y, double gamma, double eta) - : FTDecayFunction2DVoigt(std::vector<double>{decay_length_x, decay_length_y, gamma, eta}) -{ -} + : FTDecayFunction2DVoigt(std::vector<double>{decay_length_x, decay_length_y, gamma, eta}) {} -FTDecayFunction2DVoigt* FTDecayFunction2DVoigt::clone() const -{ +FTDecayFunction2DVoigt* FTDecayFunction2DVoigt::clone() const { return new FTDecayFunction2DVoigt(m_decay_length_x, m_decay_length_y, m_eta, m_gamma); } -double FTDecayFunction2DVoigt::evaluate(double qx, double qy) const -{ +double FTDecayFunction2DVoigt::evaluate(double qx, double qy) const { double sum_sq = qx * qx * m_decay_length_x * m_decay_length_x + qy * qy * m_decay_length_y * m_decay_length_y; return M_TWOPI * m_decay_length_x * m_decay_length_y diff --git a/Sample/Correlations/FTDecay2D.h b/Sample/Correlations/FTDecay2D.h index 69fe065c71149bced4e0c7caee50012b36ffef27..ef5a266cd330c8f598c061970e68efd4dd828231 100644 --- a/Sample/Correlations/FTDecay2D.h +++ b/Sample/Correlations/FTDecay2D.h @@ -22,8 +22,7 @@ //! Interface for two-dimensional decay function in reciprocal space. //! @ingroup decayFT_internal -class IFTDecayFunction2D : public ICloneable, public INode -{ +class IFTDecayFunction2D : public ICloneable, public INode { public: IFTDecayFunction2D(const NodeMeta& meta, const std::vector<double>& PValues); @@ -59,8 +58,7 @@ private: //! corresponds to exp(-r) in real space, //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$. //! @ingroup decayFT -class FTDecayFunction2DCauchy : public IFTDecayFunction2D -{ +class FTDecayFunction2DCauchy : public IFTDecayFunction2D { public: FTDecayFunction2DCauchy(const std::vector<double> P); FTDecayFunction2DCauchy(double decay_length_x, double decay_length_y, double gamma); @@ -74,8 +72,7 @@ public: //! corresponds to exp(-r^2/2) in real space, //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$. //! @ingroup decayFT -class FTDecayFunction2DGauss : public IFTDecayFunction2D -{ +class FTDecayFunction2DGauss : public IFTDecayFunction2D { public: FTDecayFunction2DGauss(const std::vector<double> P); FTDecayFunction2DGauss(double decay_length_x, double decay_length_y, double gamma); @@ -88,8 +85,7 @@ public: //! Two-dimensional pseudo-Voigt decay function in reciprocal space; //! corresponds to eta*Gauss + (1-eta)*Cauchy. //! @ingroup decayFT -class FTDecayFunction2DVoigt : public IFTDecayFunction2D -{ +class FTDecayFunction2DVoigt : public IFTDecayFunction2D { public: FTDecayFunction2DVoigt(const std::vector<double> P); FTDecayFunction2DVoigt(double decay_length_x, double decay_length_y, double gamma, double eta); diff --git a/Sample/Correlations/FTDistributions1D.cpp b/Sample/Correlations/FTDistributions1D.cpp index 873b4f92a7207efdd49b650f0fdd3e90421fa61f..08b2c9c47e7586327905091791641d77b7e48886 100644 --- a/Sample/Correlations/FTDistributions1D.cpp +++ b/Sample/Correlations/FTDistributions1D.cpp @@ -18,8 +18,7 @@ #include "Base/Types/Exceptions.h" #include <limits> -namespace -{ +namespace { const double CosineDistributionFactor = 1.0 / 3.0 - 2.0 / M_PI / M_PI; } @@ -29,42 +28,32 @@ const double CosineDistributionFactor = 1.0 / 3.0 - 2.0 / M_PI / M_PI; IFTDistribution1D::IFTDistribution1D(const NodeMeta& meta, const std::vector<double>& PValues) : INode(nodeMetaUnion({{"Omega", "nm", "Half-width", 0, INF, 1.}}, meta), PValues) - , m_omega(m_P[0]) -{ -} + , m_omega(m_P[0]) {} // ************************************************************************************************ // class FTDistribution1DCauchy // ************************************************************************************************ FTDistribution1DCauchy::FTDistribution1DCauchy(const std::vector<double> P) - : IFTDistribution1D({"FTDistribution1DCauchy", "class_tooltip", {}}, P) -{ -} + : IFTDistribution1D({"FTDistribution1DCauchy", "class_tooltip", {}}, P) {} FTDistribution1DCauchy::FTDistribution1DCauchy(double omega) - : FTDistribution1DCauchy(std::vector<double>{omega}) -{ -} + : FTDistribution1DCauchy(std::vector<double>{omega}) {} -FTDistribution1DCauchy* FTDistribution1DCauchy::clone() const -{ +FTDistribution1DCauchy* FTDistribution1DCauchy::clone() const { return new FTDistribution1DCauchy(m_omega); } -double FTDistribution1DCauchy::evaluate(double q) const -{ +double FTDistribution1DCauchy::evaluate(double q) const { double sum_sq = q * q * m_omega * m_omega; return 1.0 / (1.0 + sum_sq); } -double FTDistribution1DCauchy::qSecondDerivative() const -{ +double FTDistribution1DCauchy::qSecondDerivative() const { return 2.0 * m_omega * m_omega; } -std::unique_ptr<IDistribution1DSampler> FTDistribution1DCauchy::createSampler() const -{ +std::unique_ptr<IDistribution1DSampler> FTDistribution1DCauchy::createSampler() const { return std::make_unique<Distribution1DCauchySampler>(1 / m_omega); } @@ -73,33 +62,25 @@ std::unique_ptr<IDistribution1DSampler> FTDistribution1DCauchy::createSampler() // ************************************************************************************************ FTDistribution1DGauss::FTDistribution1DGauss(const std::vector<double> P) - : IFTDistribution1D({"FTDistribution1DGauss", "class_tooltip", {}}, P) -{ -} + : IFTDistribution1D({"FTDistribution1DGauss", "class_tooltip", {}}, P) {} FTDistribution1DGauss::FTDistribution1DGauss(double omega) - : FTDistribution1DGauss(std::vector<double>{omega}) -{ -} + : FTDistribution1DGauss(std::vector<double>{omega}) {} -FTDistribution1DGauss* FTDistribution1DGauss::clone() const -{ +FTDistribution1DGauss* FTDistribution1DGauss::clone() const { return new FTDistribution1DGauss(m_omega); } -double FTDistribution1DGauss::evaluate(double q) const -{ +double FTDistribution1DGauss::evaluate(double q) const { double sum_sq = q * q * m_omega * m_omega; return std::exp(-sum_sq / 2.0); } -double FTDistribution1DGauss::qSecondDerivative() const -{ +double FTDistribution1DGauss::qSecondDerivative() const { return m_omega * m_omega; } -std::unique_ptr<IDistribution1DSampler> FTDistribution1DGauss::createSampler() const -{ +std::unique_ptr<IDistribution1DSampler> FTDistribution1DGauss::createSampler() const { return std::make_unique<Distribution1DGaussSampler>(0.0, m_omega); } @@ -108,32 +89,24 @@ std::unique_ptr<IDistribution1DSampler> FTDistribution1DGauss::createSampler() c // ************************************************************************************************ FTDistribution1DGate::FTDistribution1DGate(const std::vector<double> P) - : IFTDistribution1D({"FTDistribution1DGate", "class_tooltip", {}}, P) -{ -} + : IFTDistribution1D({"FTDistribution1DGate", "class_tooltip", {}}, P) {} FTDistribution1DGate::FTDistribution1DGate(double omega) - : FTDistribution1DGate(std::vector<double>{omega}) -{ -} + : FTDistribution1DGate(std::vector<double>{omega}) {} -FTDistribution1DGate* FTDistribution1DGate::clone() const -{ +FTDistribution1DGate* FTDistribution1DGate::clone() const { return new FTDistribution1DGate(m_omega); } -double FTDistribution1DGate::evaluate(double q) const -{ +double FTDistribution1DGate::evaluate(double q) const { return Math::sinc(q * m_omega); } -double FTDistribution1DGate::qSecondDerivative() const -{ +double FTDistribution1DGate::qSecondDerivative() const { return m_omega * m_omega / 3.0; } -std::unique_ptr<IDistribution1DSampler> FTDistribution1DGate::createSampler() const -{ +std::unique_ptr<IDistribution1DSampler> FTDistribution1DGate::createSampler() const { return std::make_unique<Distribution1DGateSampler>(-m_omega, m_omega); } @@ -142,33 +115,25 @@ std::unique_ptr<IDistribution1DSampler> FTDistribution1DGate::createSampler() co // ************************************************************************************************ FTDistribution1DTriangle::FTDistribution1DTriangle(const std::vector<double> P) - : IFTDistribution1D({"FTDistribution1DTriangle", "class_tooltip", {}}, P) -{ -} + : IFTDistribution1D({"FTDistribution1DTriangle", "class_tooltip", {}}, P) {} FTDistribution1DTriangle::FTDistribution1DTriangle(double omega) - : FTDistribution1DTriangle(std::vector<double>{omega}) -{ -} + : FTDistribution1DTriangle(std::vector<double>{omega}) {} -FTDistribution1DTriangle* FTDistribution1DTriangle::clone() const -{ +FTDistribution1DTriangle* FTDistribution1DTriangle::clone() const { return new FTDistribution1DTriangle(m_omega); } -double FTDistribution1DTriangle::evaluate(double q) const -{ +double FTDistribution1DTriangle::evaluate(double q) const { double sincqw2 = Math::sinc(q * m_omega / 2.0); return sincqw2 * sincqw2; } -double FTDistribution1DTriangle::qSecondDerivative() const -{ +double FTDistribution1DTriangle::qSecondDerivative() const { return m_omega * m_omega / 6.0; } -std::unique_ptr<IDistribution1DSampler> FTDistribution1DTriangle::createSampler() const -{ +std::unique_ptr<IDistribution1DSampler> FTDistribution1DTriangle::createSampler() const { return std::make_unique<Distribution1DTriangleSampler>(m_omega); } @@ -177,35 +142,27 @@ std::unique_ptr<IDistribution1DSampler> FTDistribution1DTriangle::createSampler( // ************************************************************************************************ FTDistribution1DCosine::FTDistribution1DCosine(const std::vector<double> P) - : IFTDistribution1D({"FTDistribution1DCosine", "class_tooltip", {}}, P) -{ -} + : IFTDistribution1D({"FTDistribution1DCosine", "class_tooltip", {}}, P) {} FTDistribution1DCosine::FTDistribution1DCosine(double omega) - : FTDistribution1DCosine(std::vector<double>{omega}) -{ -} + : FTDistribution1DCosine(std::vector<double>{omega}) {} -FTDistribution1DCosine* FTDistribution1DCosine::clone() const -{ +FTDistribution1DCosine* FTDistribution1DCosine::clone() const { return new FTDistribution1DCosine(m_omega); } -double FTDistribution1DCosine::evaluate(double q) const -{ +double FTDistribution1DCosine::evaluate(double q) const { double qw = std::abs(q * m_omega); if (std::abs(1.0 - qw * qw / M_PI / M_PI) < std::numeric_limits<double>::epsilon()) return 0.5; return Math::sinc(qw) / (1.0 - qw * qw / M_PI / M_PI); } -double FTDistribution1DCosine::qSecondDerivative() const -{ +double FTDistribution1DCosine::qSecondDerivative() const { return CosineDistributionFactor * m_omega * m_omega; } -std::unique_ptr<IDistribution1DSampler> FTDistribution1DCosine::createSampler() const -{ +std::unique_ptr<IDistribution1DSampler> FTDistribution1DCosine::createSampler() const { return std::make_unique<Distribution1DCosineSampler>(m_omega); } @@ -220,33 +177,25 @@ FTDistribution1DVoigt::FTDistribution1DVoigt(const std::vector<double> P) {{"Eta", "", "balances between Gauss (eta=0) and Cauchy (eta=1) limiting cases", -INF, +INF, 0}}}, P) - , m_eta(m_P[1]) -{ -} + , m_eta(m_P[1]) {} FTDistribution1DVoigt::FTDistribution1DVoigt(double omega, double eta) - : FTDistribution1DVoigt(std::vector<double>{omega, eta}) -{ -} + : FTDistribution1DVoigt(std::vector<double>{omega, eta}) {} -FTDistribution1DVoigt* FTDistribution1DVoigt::clone() const -{ +FTDistribution1DVoigt* FTDistribution1DVoigt::clone() const { return new FTDistribution1DVoigt(m_omega, m_eta); } -double FTDistribution1DVoigt::evaluate(double q) const -{ +double FTDistribution1DVoigt::evaluate(double q) const { double sum_sq = q * q * m_omega * m_omega; return m_eta * std::exp(-sum_sq / 2.0) + (1.0 - m_eta) * 1.0 / (1.0 + sum_sq); } -double FTDistribution1DVoigt::qSecondDerivative() const -{ +double FTDistribution1DVoigt::qSecondDerivative() const { return (2.0 - m_eta) * m_omega * m_omega; } -std::unique_ptr<IDistribution1DSampler> FTDistribution1DVoigt::createSampler() const -{ +std::unique_ptr<IDistribution1DSampler> FTDistribution1DVoigt::createSampler() const { // TODO Need to implement 1D Voigt std::ostringstream ostr; diff --git a/Sample/Correlations/FTDistributions1D.h b/Sample/Correlations/FTDistributions1D.h index e5a54116031365f084c678c14bd162d219479d25..f69dd293fac4f332f0251e5a6d0c88b2204b5e7a 100644 --- a/Sample/Correlations/FTDistributions1D.h +++ b/Sample/Correlations/FTDistributions1D.h @@ -23,8 +23,7 @@ //! the Fourier transform evaluate(q) is a decay function that starts at evaluate(0)=1. //! @ingroup distribution_internal -class IFTDistribution1D : public ICloneable, public INode -{ +class IFTDistribution1D : public ICloneable, public INode { public: IFTDistribution1D(const NodeMeta& meta, const std::vector<double>& PValues); @@ -51,8 +50,7 @@ protected: //! its Fourier transform evaluate(q) is a Cauchy-Lorentzian starting at evaluate(0)=1. //! @ingroup distributionFT -class FTDistribution1DCauchy : public IFTDistribution1D -{ +class FTDistribution1DCauchy : public IFTDistribution1D { public: FTDistribution1DCauchy(const std::vector<double> P); FTDistribution1DCauchy(double omega); @@ -71,8 +69,7 @@ public: //! its Fourier transform evaluate(q) is a Gaussian starting at evaluate(0)=1. //! @ingroup distributionFT -class FTDistribution1DGauss : public IFTDistribution1D -{ +class FTDistribution1DGauss : public IFTDistribution1D { public: FTDistribution1DGauss(const std::vector<double> P); FTDistribution1DGauss(double omega); @@ -91,8 +88,7 @@ public: //! its Fourier transform evaluate(q) is a sinc function starting at evaluate(0)=1. //! @ingroup distributionFT -class FTDistribution1DGate : public IFTDistribution1D -{ +class FTDistribution1DGate : public IFTDistribution1D { public: FTDistribution1DGate(const std::vector<double> P); FTDistribution1DGate(double omega); @@ -111,8 +107,7 @@ public: //! its Fourier transform evaluate(q) is a squared sinc function starting at evaluate(0)=1. //! @ingroup distributionFT -class FTDistribution1DTriangle : public IFTDistribution1D -{ +class FTDistribution1DTriangle : public IFTDistribution1D { public: FTDistribution1DTriangle(const std::vector<double> P); FTDistribution1DTriangle(double omega); @@ -132,8 +127,7 @@ public: //! its Fourier transform evaluate(q) starts at evaluate(0)=1. //! @ingroup distributionFT -class FTDistribution1DCosine : public IFTDistribution1D -{ +class FTDistribution1DCosine : public IFTDistribution1D { public: FTDistribution1DCosine(const std::vector<double> P); FTDistribution1DCosine(double omega); @@ -153,8 +147,7 @@ public: //! starting at 1 for q=0. //! @ingroup distributionFT -class FTDistribution1DVoigt : public IFTDistribution1D -{ +class FTDistribution1DVoigt : public IFTDistribution1D { public: FTDistribution1DVoigt(const std::vector<double> P); FTDistribution1DVoigt(double omega, double eta); diff --git a/Sample/Correlations/FTDistributions2D.cpp b/Sample/Correlations/FTDistributions2D.cpp index 1cedc77fd00165b9f55a10c58374a191d501d9fb..ba1d270443ce3c5d31aefa96ed5ace36b5f9555d 100644 --- a/Sample/Correlations/FTDistributions2D.cpp +++ b/Sample/Correlations/FTDistributions2D.cpp @@ -32,12 +32,9 @@ IFTDistribution2D::IFTDistribution2D(const NodeMeta& meta, const std::vector<dou PValues) , m_omega_x(m_P[0]) , m_omega_y(m_P[1]) - , m_gamma(m_P[2]) -{ -} + , m_gamma(m_P[2]) {} -double IFTDistribution2D::sumsq(double qx, double qy) const -{ +double IFTDistribution2D::sumsq(double qx, double qy) const { return qx * qx * m_omega_x * m_omega_x + qy * qy * m_omega_y * m_omega_y; } @@ -46,27 +43,20 @@ double IFTDistribution2D::sumsq(double qx, double qy) const // ************************************************************************************************ FTDistribution2DCauchy::FTDistribution2DCauchy(const std::vector<double> P) - : IFTDistribution2D({"FTDistribution2DCauchy", "class_tooltip", {}}, P) -{ -} + : IFTDistribution2D({"FTDistribution2DCauchy", "class_tooltip", {}}, P) {} FTDistribution2DCauchy::FTDistribution2DCauchy(double omega_x, double omega_y, double gamma) - : FTDistribution2DCauchy(std::vector<double>{omega_x, omega_y, gamma}) -{ -} + : FTDistribution2DCauchy(std::vector<double>{omega_x, omega_y, gamma}) {} -FTDistribution2DCauchy* FTDistribution2DCauchy::clone() const -{ +FTDistribution2DCauchy* FTDistribution2DCauchy::clone() const { return new FTDistribution2DCauchy(m_omega_x, m_omega_y, m_gamma); } -double FTDistribution2DCauchy::evaluate(double qx, double qy) const -{ +double FTDistribution2DCauchy::evaluate(double qx, double qy) const { return std::pow(1.0 + sumsq(qx, qy), -1.5); } -std::unique_ptr<IDistribution2DSampler> FTDistribution2DCauchy::createSampler() const -{ +std::unique_ptr<IDistribution2DSampler> FTDistribution2DCauchy::createSampler() const { return std::make_unique<Distribution2DCauchySampler>(m_omega_x, m_omega_y); } @@ -75,27 +65,20 @@ std::unique_ptr<IDistribution2DSampler> FTDistribution2DCauchy::createSampler() // ************************************************************************************************ FTDistribution2DGauss::FTDistribution2DGauss(const std::vector<double> P) - : IFTDistribution2D({"FTDistribution2DGauss", "class_tooltip", {}}, P) -{ -} + : IFTDistribution2D({"FTDistribution2DGauss", "class_tooltip", {}}, P) {} FTDistribution2DGauss::FTDistribution2DGauss(double omega_x, double omega_y, double gamma) - : FTDistribution2DGauss(std::vector<double>{omega_x, omega_y, gamma}) -{ -} + : FTDistribution2DGauss(std::vector<double>{omega_x, omega_y, gamma}) {} -FTDistribution2DGauss* FTDistribution2DGauss::clone() const -{ +FTDistribution2DGauss* FTDistribution2DGauss::clone() const { return new FTDistribution2DGauss(m_omega_x, m_omega_y, m_gamma); } -double FTDistribution2DGauss::evaluate(double qx, double qy) const -{ +double FTDistribution2DGauss::evaluate(double qx, double qy) const { return std::exp(-sumsq(qx, qy) / 2); } -std::unique_ptr<IDistribution2DSampler> FTDistribution2DGauss::createSampler() const -{ +std::unique_ptr<IDistribution2DSampler> FTDistribution2DGauss::createSampler() const { return std::make_unique<Distribution2DGaussSampler>(m_omega_x, m_omega_y); } @@ -104,28 +87,21 @@ std::unique_ptr<IDistribution2DSampler> FTDistribution2DGauss::createSampler() c // ************************************************************************************************ FTDistribution2DGate::FTDistribution2DGate(const std::vector<double> P) - : IFTDistribution2D({"FTDistribution2DGate", "class_tooltip", {}}, P) -{ -} + : IFTDistribution2D({"FTDistribution2DGate", "class_tooltip", {}}, P) {} FTDistribution2DGate::FTDistribution2DGate(double omega_x, double omega_y, double gamma) - : FTDistribution2DGate(std::vector<double>{omega_x, omega_y, gamma}) -{ -} + : FTDistribution2DGate(std::vector<double>{omega_x, omega_y, gamma}) {} -FTDistribution2DGate* FTDistribution2DGate::clone() const -{ +FTDistribution2DGate* FTDistribution2DGate::clone() const { return new FTDistribution2DGate(m_omega_x, m_omega_y, m_gamma); } -double FTDistribution2DGate::evaluate(double qx, double qy) const -{ +double FTDistribution2DGate::evaluate(double qx, double qy) const { double scaled_q = std::sqrt(sumsq(qx, qy)); return Math::Bessel::J1c(scaled_q) * 2.0; } -std::unique_ptr<IDistribution2DSampler> FTDistribution2DGate::createSampler() const -{ +std::unique_ptr<IDistribution2DSampler> FTDistribution2DGate::createSampler() const { return std::make_unique<Distribution2DGateSampler>(m_omega_x, m_omega_y); } @@ -134,22 +110,16 @@ std::unique_ptr<IDistribution2DSampler> FTDistribution2DGate::createSampler() co // ************************************************************************************************ FTDistribution2DCone::FTDistribution2DCone(const std::vector<double> P) - : IFTDistribution2D({"FTDistribution2DCone", "class_tooltip", {}}, P) -{ -} + : IFTDistribution2D({"FTDistribution2DCone", "class_tooltip", {}}, P) {} FTDistribution2DCone::FTDistribution2DCone(double omega_x, double omega_y, double gamma) - : FTDistribution2DCone(std::vector<double>{omega_x, omega_y, gamma}) -{ -} + : FTDistribution2DCone(std::vector<double>{omega_x, omega_y, gamma}) {} -FTDistribution2DCone* FTDistribution2DCone::clone() const -{ +FTDistribution2DCone* FTDistribution2DCone::clone() const { return new FTDistribution2DCone(m_omega_x, m_omega_y, m_gamma); } -double FTDistribution2DCone::evaluate(double qx, double qy) const -{ +double FTDistribution2DCone::evaluate(double qx, double qy) const { double scaled_q = std::sqrt(sumsq(qx, qy)); if (scaled_q < std::numeric_limits<double>::epsilon()) return 1.0 - 3.0 * scaled_q * scaled_q / 40.0; @@ -159,8 +129,7 @@ double FTDistribution2DCone::evaluate(double qx, double qy) const return 6.0 * (Math::Bessel::J1c(scaled_q) - integral / scaled_q / scaled_q / scaled_q); } -std::unique_ptr<IDistribution2DSampler> FTDistribution2DCone::createSampler() const -{ +std::unique_ptr<IDistribution2DSampler> FTDistribution2DCone::createSampler() const { return std::make_unique<Distribution2DConeSampler>(m_omega_x, m_omega_y); } @@ -175,29 +144,22 @@ FTDistribution2DVoigt::FTDistribution2DVoigt(const std::vector<double> P) {{"Eta", "", "balances between Gauss (eta=0) and Cauchy (eta=1) limiting cases", -INF, +INF, 0}}}, P) - , m_eta(m_P[3]) -{ -} + , m_eta(m_P[3]) {} FTDistribution2DVoigt::FTDistribution2DVoigt(double omega_x, double omega_y, double gamma, double eta) - : FTDistribution2DVoigt(std::vector<double>{omega_x, omega_y, gamma, eta}) -{ -} + : FTDistribution2DVoigt(std::vector<double>{omega_x, omega_y, gamma, eta}) {} -FTDistribution2DVoigt* FTDistribution2DVoigt::clone() const -{ +FTDistribution2DVoigt* FTDistribution2DVoigt::clone() const { return new FTDistribution2DVoigt(m_omega_x, m_omega_y, m_gamma, m_eta); } -double FTDistribution2DVoigt::evaluate(double qx, double qy) const -{ +double FTDistribution2DVoigt::evaluate(double qx, double qy) const { double sum_sq = sumsq(qx, qy); return m_eta * std::exp(-sum_sq / 2) + (1.0 - m_eta) * std::pow(1.0 + sum_sq, -1.5); } -std::unique_ptr<IDistribution2DSampler> FTDistribution2DVoigt::createSampler() const -{ +std::unique_ptr<IDistribution2DSampler> FTDistribution2DVoigt::createSampler() const { // TODO Need to implement 2D Voigt std::ostringstream ostr; diff --git a/Sample/Correlations/FTDistributions2D.h b/Sample/Correlations/FTDistributions2D.h index 623d856b099c9f294819aa7dd5101204ad5a27e7..4e6f1405c376034e520baeddbd0c84284fce815b 100644 --- a/Sample/Correlations/FTDistributions2D.h +++ b/Sample/Correlations/FTDistributions2D.h @@ -23,8 +23,7 @@ //! Interface for two-dimensional distributions in Fourier space. //! @ingroup distribution_internal -class IFTDistribution2D : public ICloneable, public INode -{ +class IFTDistribution2D : public ICloneable, public INode { public: IFTDistribution2D(const NodeMeta& meta, const std::vector<double>& PValues); @@ -59,8 +58,7 @@ protected: //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$. //! @ingroup distributionFT -class FTDistribution2DCauchy : public IFTDistribution2D -{ +class FTDistribution2DCauchy : public IFTDistribution2D { public: FTDistribution2DCauchy(const std::vector<double> P); FTDistribution2DCauchy(double omega_x, double omega_y, double gamma); @@ -78,8 +76,7 @@ public: //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$. //! @ingroup distributionFT -class FTDistribution2DGauss : public IFTDistribution2D -{ +class FTDistribution2DGauss : public IFTDistribution2D { public: FTDistribution2DGauss(const std::vector<double> P); FTDistribution2DGauss(double omega_x, double omega_y, double gamma); @@ -97,8 +94,7 @@ public: //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$. //! @ingroup distributionFT -class FTDistribution2DGate : public IFTDistribution2D -{ +class FTDistribution2DGate : public IFTDistribution2D { public: FTDistribution2DGate(const std::vector<double> P); FTDistribution2DGate(double omega_x, double omega_y, double gamma); @@ -116,8 +112,7 @@ public: //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$. //! @ingroup distributionFT -class FTDistribution2DCone : public IFTDistribution2D -{ +class FTDistribution2DCone : public IFTDistribution2D { public: FTDistribution2DCone(const std::vector<double> P); FTDistribution2DCone(double omega_x, double omega_y, double gamma); @@ -134,8 +129,7 @@ public: //! corresponds to eta*Gauss + (1-eta)*Cauchy //! @ingroup distributionFT -class FTDistribution2DVoigt : public IFTDistribution2D -{ +class FTDistribution2DVoigt : public IFTDistribution2D { public: FTDistribution2DVoigt(const std::vector<double> P); FTDistribution2DVoigt(double omega_x, double omega_y, double gamma, double eta); diff --git a/Sample/Correlations/IDistribution1DSampler.cpp b/Sample/Correlations/IDistribution1DSampler.cpp index e107407add478141cf50367b846ebad6a89d81ff..fe4a6057c4e1f148b9df3419753847355b6452cd 100644 --- a/Sample/Correlations/IDistribution1DSampler.cpp +++ b/Sample/Correlations/IDistribution1DSampler.cpp @@ -17,8 +17,7 @@ IDistribution1DSampler::~IDistribution1DSampler() = default; -double Distribution1DCauchySampler::randomSample() const -{ +double Distribution1DCauchySampler::randomSample() const { // BornAgain Cauchy Distribution = std library Exponential distribution std::random_device rd; // random device class instance std::mt19937 gen(rd()); // Standard mersenne_twister_engine seeded with rd() @@ -34,8 +33,7 @@ double Distribution1DCauchySampler::randomSample() const return -value; } -double Distribution1DGaussSampler::randomSample() const -{ +double Distribution1DGaussSampler::randomSample() const { // BornAgain Gauss Distribution = std library Normal distribution std::random_device rd; std::mt19937 gen(rd()); @@ -44,8 +42,7 @@ double Distribution1DGaussSampler::randomSample() const return normalDist(gen); } -double Distribution1DGateSampler::randomSample() const -{ +double Distribution1DGateSampler::randomSample() const { // BornAgain Gate Distribution = std library Uniform distribution std::random_device rd; std::mt19937 gen(rd()); @@ -54,8 +51,7 @@ double Distribution1DGateSampler::randomSample() const return uniformDist(gen); } -double Distribution1DTriangleSampler::randomSample() const -{ +double Distribution1DTriangleSampler::randomSample() const { std::random_device rd; std::mt19937 gen(rd()); @@ -70,8 +66,7 @@ double Distribution1DTriangleSampler::randomSample() const return (m_omega - m_omega * std::sqrt(2 * (1 - cdf_value))); } -double Distribution1DCosineSampler::randomSample() const -{ +double Distribution1DCosineSampler::randomSample() const { std::random_device rd; std::mt19937 gen(rd()); diff --git a/Sample/Correlations/IDistribution1DSampler.h b/Sample/Correlations/IDistribution1DSampler.h index 2ac6b700d74839159d25c765af1995466e7c5c4f..5b5efd5a26a7aa6bf7f105f298d4632a52ad5bd2 100644 --- a/Sample/Correlations/IDistribution1DSampler.h +++ b/Sample/Correlations/IDistribution1DSampler.h @@ -15,8 +15,7 @@ #ifndef BORNAGAIN_SAMPLE_CORRELATIONS_IDISTRIBUTION1DSAMPLER_H #define BORNAGAIN_SAMPLE_CORRELATIONS_IDISTRIBUTION1DSAMPLER_H -class IDistribution1DSampler -{ +class IDistribution1DSampler { public: IDistribution1DSampler() {} virtual ~IDistribution1DSampler(); @@ -24,8 +23,7 @@ public: virtual double randomSample() const = 0; }; -class Distribution1DCauchySampler : public IDistribution1DSampler -{ +class Distribution1DCauchySampler : public IDistribution1DSampler { public: Distribution1DCauchySampler(double lambda) : m_lambda(lambda) {} double randomSample() const final; @@ -34,8 +32,7 @@ private: double m_lambda; }; -class Distribution1DGaussSampler : public IDistribution1DSampler -{ +class Distribution1DGaussSampler : public IDistribution1DSampler { public: Distribution1DGaussSampler(double mean, double stddev) : m_mean(mean), m_stddev(stddev) {} double randomSample() const final; @@ -44,8 +41,7 @@ private: double m_mean, m_stddev; }; -class Distribution1DGateSampler : public IDistribution1DSampler -{ +class Distribution1DGateSampler : public IDistribution1DSampler { public: Distribution1DGateSampler(double a, double b) : m_a(a), m_b(b) {} double randomSample() const final; @@ -54,8 +50,7 @@ private: double m_a, m_b; // the left and right limits of the Gate (Uniform) distribution }; -class Distribution1DTriangleSampler : public IDistribution1DSampler -{ +class Distribution1DTriangleSampler : public IDistribution1DSampler { public: Distribution1DTriangleSampler(double omega) : m_omega(omega) {} double randomSample() const final; @@ -64,8 +59,7 @@ private: double m_omega; // half the base of the symmetrical Triangle distribution }; -class Distribution1DCosineSampler : public IDistribution1DSampler -{ +class Distribution1DCosineSampler : public IDistribution1DSampler { public: Distribution1DCosineSampler(double omega) : m_omega(omega) {} double randomSample() const final; diff --git a/Sample/Correlations/IDistribution2DSampler.cpp b/Sample/Correlations/IDistribution2DSampler.cpp index f148d248e16f5ede9c0ec2dffd2310fe7b82d18c..6f8dff63a69e89901b1daf5f68a0be6841142ea9 100644 --- a/Sample/Correlations/IDistribution2DSampler.cpp +++ b/Sample/Correlations/IDistribution2DSampler.cpp @@ -15,16 +15,13 @@ #include "Sample/Correlations/IDistribution2DSampler.h" #include <random> -namespace -{ +namespace { double sigma_scale = 3.0; size_t n_boxes = 256; // number of boxes for Ziggurat sampling struct ZigguratBox { ZigguratBox(double x_min, double x_max, double y_max, double y_lower) - : m_x_min(x_min), m_x_max(x_max), m_y_max(y_max), m_y_lower(y_lower) - { - } + : m_x_min(x_min), m_x_max(x_max), m_y_max(y_max), m_y_lower(y_lower) {} double m_x_min; // left edge of the box double m_x_max; // right edge of the box @@ -34,8 +31,8 @@ struct ZigguratBox { // are located below the density function curve in the box }; -std::pair<double, double> samplingZiggurat(double r, double x_func_max, double (*func_phi)(double)) -{ +std::pair<double, double> samplingZiggurat(double r, double x_func_max, + double (*func_phi)(double)) { // This sampling is based on vertical boxes instead of the conventional // Ziggurat sampling that is done with horizontal boxes @@ -111,14 +108,12 @@ std::pair<double, double> samplingZiggurat(double r, double x_func_max, double ( return std::make_pair(phi, alpha); } -double func_phi_Cauchy(double phi) -{ +double func_phi_Cauchy(double phi) { // The independent "phi" density function of the 2D Cauchy distribution return phi * std::exp(-phi); } -double func_phi_Cone(double phi) -{ +double func_phi_Cone(double phi) { // The independent "phi" density function of the 2D Cone distribution return 6 * (1 - phi) * phi; } @@ -126,8 +121,7 @@ double func_phi_Cone(double phi) IDistribution2DSampler::~IDistribution2DSampler() = default; -std::pair<double, double> Distribution2DCauchySampler::randomSample() const -{ +std::pair<double, double> Distribution2DCauchySampler::randomSample() const { // Use Ziggurat sampling instead of Inverse Transform Sampling (ITS requires numerical solver) double phi_max_Cauchy = 1.0; @@ -138,8 +132,7 @@ std::pair<double, double> Distribution2DCauchySampler::randomSample() const m_omega_y * samples.first * std::sin(samples.second)); } -std::pair<double, double> Distribution2DGaussSampler::randomSample() const -{ +std::pair<double, double> Distribution2DGaussSampler::randomSample() const { std::random_device rd; // random device class instance std::mt19937 gen(rd()); // Standard mersenne_twister_engine seeded with rd() std::uniform_real_distribution<double> uniformDist(0.0, 1.0); @@ -152,8 +145,7 @@ std::pair<double, double> Distribution2DGaussSampler::randomSample() const return std::make_pair(m_omega_x * phi * std::cos(alpha), m_omega_y * phi * std::sin(alpha)); } -std::pair<double, double> Distribution2DGateSampler::randomSample() const -{ +std::pair<double, double> Distribution2DGateSampler::randomSample() const { std::random_device rd; // random device class instance std::mt19937 gen(rd()); // Standard mersenne_twister_engine seeded with rd() std::uniform_real_distribution<double> uniformDist(0.0, 1.0); @@ -166,8 +158,7 @@ std::pair<double, double> Distribution2DGateSampler::randomSample() const return std::make_pair(m_omega_x * phi * std::cos(alpha), m_omega_y * phi * std::sin(alpha)); } -std::pair<double, double> Distribution2DConeSampler::randomSample() const -{ +std::pair<double, double> Distribution2DConeSampler::randomSample() const { // Use Ziggurat sampling instead of Inverse Transform Sampling (ITS requires numerical solver) double phi_max_Cone = 0.5; diff --git a/Sample/Correlations/IDistribution2DSampler.h b/Sample/Correlations/IDistribution2DSampler.h index e2b6a8e3f3502f5712cfbc3f47c5aadabde1e717..c83e6f7322be099a84a6a62f0bdd0c782eeb3d1d 100644 --- a/Sample/Correlations/IDistribution2DSampler.h +++ b/Sample/Correlations/IDistribution2DSampler.h @@ -17,8 +17,7 @@ #include <utility> -class IDistribution2DSampler -{ +class IDistribution2DSampler { public: IDistribution2DSampler() {} virtual ~IDistribution2DSampler(); @@ -26,52 +25,40 @@ public: virtual std::pair<double, double> randomSample() const = 0; }; -class Distribution2DCauchySampler : public IDistribution2DSampler -{ +class Distribution2DCauchySampler : public IDistribution2DSampler { public: Distribution2DCauchySampler(double omega_x, double omega_y) - : m_omega_x(omega_x), m_omega_y(omega_y) - { - } + : m_omega_x(omega_x), m_omega_y(omega_y) {} std::pair<double, double> randomSample() const final; private: double m_omega_x, m_omega_y; }; -class Distribution2DGaussSampler : public IDistribution2DSampler -{ +class Distribution2DGaussSampler : public IDistribution2DSampler { public: Distribution2DGaussSampler(double omega_x, double omega_y) - : m_omega_x(omega_x), m_omega_y(omega_y) - { - } + : m_omega_x(omega_x), m_omega_y(omega_y) {} std::pair<double, double> randomSample() const final; private: double m_omega_x, m_omega_y; }; -class Distribution2DGateSampler : public IDistribution2DSampler -{ +class Distribution2DGateSampler : public IDistribution2DSampler { public: Distribution2DGateSampler(double omega_x, double omega_y) - : m_omega_x(omega_x), m_omega_y(omega_y) - { - } + : m_omega_x(omega_x), m_omega_y(omega_y) {} std::pair<double, double> randomSample() const final; private: double m_omega_x, m_omega_y; }; -class Distribution2DConeSampler : public IDistribution2DSampler -{ +class Distribution2DConeSampler : public IDistribution2DSampler { public: Distribution2DConeSampler(double omega_x, double omega_y) - : m_omega_x(omega_x), m_omega_y(omega_y) - { - } + : m_omega_x(omega_x), m_omega_y(omega_y) {} std::pair<double, double> randomSample() const final; private: diff --git a/Sample/Correlations/IPeakShape.cpp b/Sample/Correlations/IPeakShape.cpp index 0e48f6b72f6279da6e4268b53f1e13198083582a..2380d0eb998852b62bdb163fe46d8cc2b932236d 100644 --- a/Sample/Correlations/IPeakShape.cpp +++ b/Sample/Correlations/IPeakShape.cpp @@ -18,14 +18,12 @@ #include "Base/Math/Integrator.h" #include <limits> -namespace -{ +namespace { const double maxkappa = std::log(1.0 / std::numeric_limits<double>::epsilon()) / 2.0; const double maxkappa2 = std::log(std::numeric_limits<double>::max()); -double FisherDistribution(double x, double kappa) -{ +double FisherDistribution(double x, double kappa) { if (kappa <= 0.0) { return 1.0 / (4.0 * M_PI); } @@ -36,8 +34,7 @@ double FisherDistribution(double x, double kappa) return prefactor * std::exp(kappa * x) / std::sinh(kappa); } -double FisherPrefactor(double kappa) -{ +double FisherPrefactor(double kappa) { if (kappa <= 0.0) { return 1.0 / (4.0 * M_PI); } @@ -48,8 +45,7 @@ double FisherPrefactor(double kappa) } } -double MisesPrefactor(double kappa) -{ +double MisesPrefactor(double kappa) { if (kappa <= 0.0) { return 1.0 / (2.0 * M_PI); } @@ -60,15 +56,13 @@ double MisesPrefactor(double kappa) } } -double Gauss3D(double q2, double domainsize) -{ +double Gauss3D(double q2, double domainsize) { double norm_factor = std::pow(domainsize / std::sqrt(M_TWOPI), 3.0); double exponent = -q2 * domainsize * domainsize / 2.0; return norm_factor * std::exp(exponent); } -double Cauchy3D(double q2, double domainsize) -{ +double Cauchy3D(double q2, double domainsize) { double lorentz1 = domainsize / (1.0 + q2 * domainsize * domainsize) / M_PI; return domainsize * lorentz1 * lorentz1; } @@ -80,9 +74,7 @@ double Cauchy3D(double q2, double domainsize) // ************************************************************************************************ IPeakShape::IPeakShape(const NodeMeta& meta, const std::vector<double>& PValues) - : ISample(meta, PValues) -{ -} + : ISample(meta, PValues) {} IPeakShape::~IPeakShape() = default; @@ -91,25 +83,20 @@ IPeakShape::~IPeakShape() = default; // ************************************************************************************************ IsotropicGaussPeakShape::IsotropicGaussPeakShape(double max_intensity, double domainsize) - : m_max_intensity(max_intensity), m_domainsize(domainsize) -{ -} + : m_max_intensity(max_intensity), m_domainsize(domainsize) {} IsotropicGaussPeakShape::~IsotropicGaussPeakShape() = default; -IsotropicGaussPeakShape* IsotropicGaussPeakShape::clone() const -{ +IsotropicGaussPeakShape* IsotropicGaussPeakShape::clone() const { return new IsotropicGaussPeakShape(m_max_intensity, m_domainsize); } -double IsotropicGaussPeakShape::evaluate(const kvector_t q) const -{ +double IsotropicGaussPeakShape::evaluate(const kvector_t q) const { double q_norm = q.mag2(); return m_max_intensity * Gauss3D(q_norm, m_domainsize); } -double IsotropicGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_lattice_point) const -{ +double IsotropicGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_lattice_point) const { return evaluate(q - q_lattice_point); } @@ -118,25 +105,21 @@ double IsotropicGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_la // ************************************************************************************************ IsotropicLorentzPeakShape::IsotropicLorentzPeakShape(double max_intensity, double domainsize) - : m_max_intensity(max_intensity), m_domainsize(domainsize) -{ -} + : m_max_intensity(max_intensity), m_domainsize(domainsize) {} IsotropicLorentzPeakShape::~IsotropicLorentzPeakShape() = default; -IsotropicLorentzPeakShape* IsotropicLorentzPeakShape::clone() const -{ +IsotropicLorentzPeakShape* IsotropicLorentzPeakShape::clone() const { return new IsotropicLorentzPeakShape(m_max_intensity, m_domainsize); } -double IsotropicLorentzPeakShape::evaluate(const kvector_t q) const -{ +double IsotropicLorentzPeakShape::evaluate(const kvector_t q) const { double q_norm = q.mag2(); return m_max_intensity * Cauchy3D(q_norm, m_domainsize); } -double IsotropicLorentzPeakShape::evaluate(const kvector_t q, const kvector_t q_lattice_point) const -{ +double IsotropicLorentzPeakShape::evaluate(const kvector_t q, + const kvector_t q_lattice_point) const { return evaluate(q - q_lattice_point); } @@ -145,19 +128,15 @@ double IsotropicLorentzPeakShape::evaluate(const kvector_t q, const kvector_t q_ // ************************************************************************************************ GaussFisherPeakShape::GaussFisherPeakShape(double max_intensity, double radial_size, double kappa) - : m_max_intensity(max_intensity), m_radial_size(radial_size), m_kappa(kappa) -{ -} + : m_max_intensity(max_intensity), m_radial_size(radial_size), m_kappa(kappa) {} GaussFisherPeakShape::~GaussFisherPeakShape() = default; -GaussFisherPeakShape* GaussFisherPeakShape::clone() const -{ +GaussFisherPeakShape* GaussFisherPeakShape::clone() const { return new GaussFisherPeakShape(m_max_intensity, m_radial_size, m_kappa); } -double GaussFisherPeakShape::evaluate(const kvector_t q, const kvector_t q_lattice_point) const -{ +double GaussFisherPeakShape::evaluate(const kvector_t q, const kvector_t q_lattice_point) const { const double q_r = q.mag(); const double q_lat_r = q_lattice_point.mag(); const double dq2 = (q_r - q_lat_r) * (q_r - q_lat_r); @@ -179,19 +158,15 @@ double GaussFisherPeakShape::evaluate(const kvector_t q, const kvector_t q_latti LorentzFisherPeakShape::LorentzFisherPeakShape(double max_intensity, double radial_size, double kappa) - : m_max_intensity(max_intensity), m_radial_size(radial_size), m_kappa(kappa) -{ -} + : m_max_intensity(max_intensity), m_radial_size(radial_size), m_kappa(kappa) {} LorentzFisherPeakShape::~LorentzFisherPeakShape() = default; -LorentzFisherPeakShape* LorentzFisherPeakShape::clone() const -{ +LorentzFisherPeakShape* LorentzFisherPeakShape::clone() const { return new LorentzFisherPeakShape(m_max_intensity, m_radial_size, m_kappa); } -double LorentzFisherPeakShape::evaluate(const kvector_t q, const kvector_t q_lattice_point) const -{ +double LorentzFisherPeakShape::evaluate(const kvector_t q, const kvector_t q_lattice_point) const { const double q_r = q.mag(); const double q_lat_r = q_lattice_point.mag(); const double dq2 = (q_r - q_lat_r) * (q_r - q_lat_r); @@ -217,20 +192,17 @@ MisesFisherGaussPeakShape::MisesFisherGaussPeakShape(double max_intensity, doubl , m_radial_size(radial_size) , m_zenith(zenith.unit()) , m_kappa_1(kappa_1) - , m_kappa_2(kappa_2) -{ -} + , m_kappa_2(kappa_2) {} MisesFisherGaussPeakShape::~MisesFisherGaussPeakShape() = default; -MisesFisherGaussPeakShape* MisesFisherGaussPeakShape::clone() const -{ +MisesFisherGaussPeakShape* MisesFisherGaussPeakShape::clone() const { return new MisesFisherGaussPeakShape(m_max_intensity, m_radial_size, m_zenith, m_kappa_1, m_kappa_2); } -double MisesFisherGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_lattice_point) const -{ +double MisesFisherGaussPeakShape::evaluate(const kvector_t q, + const kvector_t q_lattice_point) const { // radial part const double q_r = q.mag(); const double q_lat_r = q_lattice_point.mag(); @@ -260,8 +232,7 @@ double MisesFisherGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_ return m_max_intensity * radial_part * pre_1 * pre_2 * integral; } -double MisesFisherGaussPeakShape::integrand(double phi) const -{ +double MisesFisherGaussPeakShape::integrand(double phi) const { kvector_t u_q = std::sin(m_theta) * std::cos(phi) * m_ux + std::sin(m_theta) * std::sin(phi) * m_uy + std::cos(m_theta) * m_zenith; const double fisher = std::exp(m_kappa_1 * (u_q.dot(m_up) - 1.0)); @@ -278,19 +249,15 @@ MisesGaussPeakShape::MisesGaussPeakShape(double max_intensity, double radial_siz : m_max_intensity(max_intensity) , m_radial_size(radial_size) , m_zenith(zenith.unit()) - , m_kappa(kappa) -{ -} + , m_kappa(kappa) {} MisesGaussPeakShape::~MisesGaussPeakShape() = default; -MisesGaussPeakShape* MisesGaussPeakShape::clone() const -{ +MisesGaussPeakShape* MisesGaussPeakShape::clone() const { return new MisesGaussPeakShape(m_max_intensity, m_radial_size, m_zenith, m_kappa); } -double MisesGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_lattice_point) const -{ +double MisesGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_lattice_point) const { m_uy = m_zenith.cross(q_lattice_point); kvector_t zxq = m_zenith.cross(q); if (m_uy.mag2() <= 0.0 || zxq.mag2() <= 0.0) { @@ -310,8 +277,7 @@ double MisesGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_lattic return m_max_intensity * pre * integral; } -double MisesGaussPeakShape::integrand(double phi) const -{ +double MisesGaussPeakShape::integrand(double phi) const { kvector_t q_rot = m_qr * (std::sin(m_theta) * std::cos(phi) * m_ux + std::sin(m_theta) * std::sin(phi) * m_uy + std::cos(m_theta) * m_zenith); diff --git a/Sample/Correlations/IPeakShape.h b/Sample/Correlations/IPeakShape.h index f1508050face1d30bf5feb47aa15d14eb9a46a8d..650acd67c0653e2469976d056e0b5945d478964b 100644 --- a/Sample/Correlations/IPeakShape.h +++ b/Sample/Correlations/IPeakShape.h @@ -21,8 +21,7 @@ //! //! @ingroup samples_internal -class IPeakShape : public ISample -{ +class IPeakShape : public ISample { public: IPeakShape() = default; IPeakShape(const NodeMeta& meta, const std::vector<double>& PValues); @@ -43,8 +42,7 @@ public: //! //! @ingroup samples_internal -class IsotropicGaussPeakShape : public IPeakShape -{ +class IsotropicGaussPeakShape : public IPeakShape { public: IsotropicGaussPeakShape(double max_intensity, double domainsize); ~IsotropicGaussPeakShape() override; @@ -65,8 +63,7 @@ private: //! //! @ingroup samples_internal -class IsotropicLorentzPeakShape : public IPeakShape -{ +class IsotropicLorentzPeakShape : public IPeakShape { public: IsotropicLorentzPeakShape(double max_intensity, double domainsize); ~IsotropicLorentzPeakShape() override; @@ -88,8 +85,7 @@ private: //! //! @ingroup samples_internal -class GaussFisherPeakShape : public IPeakShape -{ +class GaussFisherPeakShape : public IPeakShape { public: GaussFisherPeakShape(double max_intensity, double radial_size, double kappa); ~GaussFisherPeakShape() override; @@ -113,8 +109,7 @@ private: //! //! @ingroup samples_internal -class LorentzFisherPeakShape : public IPeakShape -{ +class LorentzFisherPeakShape : public IPeakShape { public: LorentzFisherPeakShape(double max_intensity, double radial_size, double kappa); ~LorentzFisherPeakShape() override; @@ -138,8 +133,7 @@ private: //! //! @ingroup samples_internal -class MisesFisherGaussPeakShape : public IPeakShape -{ +class MisesFisherGaussPeakShape : public IPeakShape { public: MisesFisherGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith, double kappa_1, double kappa_2); @@ -168,8 +162,7 @@ private: //! //! @ingroup samples_internal -class MisesGaussPeakShape : public IPeakShape -{ +class MisesGaussPeakShape : public IPeakShape { public: MisesGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith, double kappa); ~MisesGaussPeakShape() override; diff --git a/Sample/FFCompute/ComputeBA.cpp b/Sample/FFCompute/ComputeBA.cpp index 7442bca021f0de1df70aa48030e486da9ec570f3..13c98d3b60a323a861652158f5b8427d02c53c9d 100644 --- a/Sample/FFCompute/ComputeBA.cpp +++ b/Sample/FFCompute/ComputeBA.cpp @@ -20,12 +20,10 @@ ComputeBA::ComputeBA(const IFormFactor& ff) : IComputeFF(ff) {} ComputeBA::~ComputeBA() = default; -ComputeBA* ComputeBA::clone() const -{ +ComputeBA* ComputeBA::clone() const { return new ComputeBA(*m_ff); } -complex_t ComputeBA::evaluate(const WavevectorInfo& wavevectors) const -{ +complex_t ComputeBA::evaluate(const WavevectorInfo& wavevectors) const { return m_ff->evaluate(wavevectors); } diff --git a/Sample/FFCompute/ComputeBA.h b/Sample/FFCompute/ComputeBA.h index 182b36727e180ce4ece3c7e894e64d375849f748..cf2166459b96df3843952db3ac0ca958695bd4cd 100644 --- a/Sample/FFCompute/ComputeBA.h +++ b/Sample/FFCompute/ComputeBA.h @@ -22,8 +22,7 @@ //! @ingroup formfactors_internal -class ComputeBA : public IComputeFF -{ +class ComputeBA : public IComputeFF { public: ComputeBA(const IFormFactor& ff); ~ComputeBA() override; diff --git a/Sample/FFCompute/ComputeBAPol.cpp b/Sample/FFCompute/ComputeBAPol.cpp index c92155e462e0990c50dcfb386ed78f3d3e8fab3f..f36ae5f7588176e9b683299a863297eed18a684d 100644 --- a/Sample/FFCompute/ComputeBAPol.cpp +++ b/Sample/FFCompute/ComputeBAPol.cpp @@ -20,19 +20,16 @@ ComputeBAPol::ComputeBAPol(const IFormFactor& ff) : IComputeFF(ff) {} ComputeBAPol::~ComputeBAPol() = default; -ComputeBAPol* ComputeBAPol::clone() const -{ +ComputeBAPol* ComputeBAPol::clone() const { return new ComputeBAPol(*m_ff); } -complex_t ComputeBAPol::evaluate(const WavevectorInfo&) const -{ +complex_t ComputeBAPol::evaluate(const WavevectorInfo&) const { throw std::runtime_error("ComputeBAPol::evaluate: " "should never be called for matrix interactions"); } -Eigen::Matrix2cd ComputeBAPol::evaluatePol(const WavevectorInfo& wavevectors) const -{ +Eigen::Matrix2cd ComputeBAPol::evaluatePol(const WavevectorInfo& wavevectors) const { Eigen::Matrix2cd ff_BA = m_ff->evaluatePol(wavevectors); Eigen::Matrix2cd result; result(0, 0) = -ff_BA(1, 0); diff --git a/Sample/FFCompute/ComputeBAPol.h b/Sample/FFCompute/ComputeBAPol.h index 39e97a99ef1a6fc0d884f3116f4c89e1d11e9a18..669161b67c60d205035043eee25c59c7387c0a4a 100644 --- a/Sample/FFCompute/ComputeBAPol.h +++ b/Sample/FFCompute/ComputeBAPol.h @@ -23,8 +23,7 @@ //! @ingroup formfactors_internal -class ComputeBAPol : public IComputeFF -{ +class ComputeBAPol : public IComputeFF { public: ComputeBAPol(const IFormFactor& ff); ~ComputeBAPol() override; diff --git a/Sample/FFCompute/ComputeDWBA.cpp b/Sample/FFCompute/ComputeDWBA.cpp index 57142fa8ecc1dd46b8ff3dae647883abe592c13a..d7c6630535c2ed326a84ff8cb5dae206807aae4c 100644 --- a/Sample/FFCompute/ComputeDWBA.cpp +++ b/Sample/FFCompute/ComputeDWBA.cpp @@ -21,8 +21,7 @@ ComputeDWBA::ComputeDWBA(const IFormFactor& ff) : IComputeFF(ff) {} ComputeDWBA::~ComputeDWBA() = default; -ComputeDWBA* ComputeDWBA::clone() const -{ +ComputeDWBA* ComputeDWBA::clone() const { ComputeDWBA* result = new ComputeDWBA(*m_ff); std::unique_ptr<const ILayerRTCoefficients> p_in_coefs = m_in_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(m_in_coeffs->clone()) : nullptr; @@ -32,8 +31,7 @@ ComputeDWBA* ComputeDWBA::clone() const return result; } -complex_t ComputeDWBA::evaluate(const WavevectorInfo& wavevectors) const -{ +complex_t ComputeDWBA::evaluate(const WavevectorInfo& wavevectors) const { // Retrieve the two different incoming wavevectors in the layer cvector_t k_i_T = wavevectors.getKi(); k_i_T.setZ(-m_in_coeffs->getScalarKz()); @@ -70,8 +68,7 @@ complex_t ComputeDWBA::evaluate(const WavevectorInfo& wavevectors) const } void ComputeDWBA::setSpecularInfo(std::unique_ptr<const ILayerRTCoefficients> p_in_coeffs, - std::unique_ptr<const ILayerRTCoefficients> p_out_coeffs) -{ + std::unique_ptr<const ILayerRTCoefficients> p_out_coeffs) { m_in_coeffs = std::move(p_in_coeffs); m_out_coeffs = std::move(p_out_coeffs); } diff --git a/Sample/FFCompute/ComputeDWBA.h b/Sample/FFCompute/ComputeDWBA.h index 439b4c877ff0971fb13d3fb2bf2be2175fede373..6742fbfe3753db3ffda5bc00388ec4a9df276ddb 100644 --- a/Sample/FFCompute/ComputeDWBA.h +++ b/Sample/FFCompute/ComputeDWBA.h @@ -24,8 +24,7 @@ class ILayerRTCoefficients; //! @ingroup formfactors_internal -class ComputeDWBA : public IComputeFF -{ +class ComputeDWBA : public IComputeFF { public: ComputeDWBA(const IFormFactor& ff); ~ComputeDWBA() override; diff --git a/Sample/FFCompute/ComputeDWBAPol.cpp b/Sample/FFCompute/ComputeDWBAPol.cpp index 9313b12eb6c07614a1f9b0a7cc6716255cec637b..7ba4e8ed7cbd18571c77f1e68aa930141156a096 100644 --- a/Sample/FFCompute/ComputeDWBAPol.cpp +++ b/Sample/FFCompute/ComputeDWBAPol.cpp @@ -17,11 +17,9 @@ #include "Sample/RT/ILayerRTCoefficients.h" #include "Sample/Scattering/IFormFactor.h" -namespace -{ +namespace { std::complex<double> VecMatVecProduct(const Eigen::Vector2cd& vec1, const Eigen::Matrix2cd& ff, - const Eigen::Vector2cd& vec2) -{ + const Eigen::Vector2cd& vec2) { return vec1.transpose() * ff * vec2; } } // namespace @@ -30,8 +28,7 @@ ComputeDWBAPol::ComputeDWBAPol(const IFormFactor& ff) : IComputeFF(ff) {} ComputeDWBAPol::~ComputeDWBAPol() = default; -ComputeDWBAPol* ComputeDWBAPol::clone() const -{ +ComputeDWBAPol* ComputeDWBAPol::clone() const { ComputeDWBAPol* p_result = new ComputeDWBAPol(*m_ff); std::unique_ptr<const ILayerRTCoefficients> p_in_coefs = m_in_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(m_in_coeffs->clone()) : nullptr; @@ -41,13 +38,11 @@ ComputeDWBAPol* ComputeDWBAPol::clone() const return p_result; } -complex_t ComputeDWBAPol::evaluate(const WavevectorInfo&) const -{ +complex_t ComputeDWBAPol::evaluate(const WavevectorInfo&) const { throw std::runtime_error("Bug: forbidden call of ComputeDWBAPol::evaluate"); } -Eigen::Matrix2cd ComputeDWBAPol::evaluatePol(const WavevectorInfo& wavevectors) const -{ +Eigen::Matrix2cd ComputeDWBAPol::evaluatePol(const WavevectorInfo& wavevectors) const { // the required wavevectors inside the layer for // different eigenmodes and in- and outgoing wavevector; complex_t kix = wavevectors.getKi().x(); @@ -192,8 +187,7 @@ Eigen::Matrix2cd ComputeDWBAPol::evaluatePol(const WavevectorInfo& wavevectors) } void ComputeDWBAPol::setSpecularInfo(std::unique_ptr<const ILayerRTCoefficients> p_in_coeffs, - std::unique_ptr<const ILayerRTCoefficients> p_out_coeffs) -{ + std::unique_ptr<const ILayerRTCoefficients> p_out_coeffs) { m_in_coeffs = std::move(p_in_coeffs); m_out_coeffs = std::move(p_out_coeffs); } diff --git a/Sample/FFCompute/ComputeDWBAPol.h b/Sample/FFCompute/ComputeDWBAPol.h index 34133adc2f1b5c57113030baa84bbc40e81a23e8..513b03388a86bede5a022b588f2055de5a9dba40 100644 --- a/Sample/FFCompute/ComputeDWBAPol.h +++ b/Sample/FFCompute/ComputeDWBAPol.h @@ -24,8 +24,7 @@ class ILayerRTCoefficients; //! @ingroup formfactors_internal -class ComputeDWBAPol : public IComputeFF -{ +class ComputeDWBAPol : public IComputeFF { public: ComputeDWBAPol(const IFormFactor& ff); ~ComputeDWBAPol() override; diff --git a/Sample/FFCompute/IComputeFF.cpp b/Sample/FFCompute/IComputeFF.cpp index e372996967a91b3b270225d09f56933815835406..95160c6d7545d84801a4bd484234f53876dc9d67 100644 --- a/Sample/FFCompute/IComputeFF.cpp +++ b/Sample/FFCompute/IComputeFF.cpp @@ -21,37 +21,29 @@ IComputeFF::IComputeFF(const IFormFactor& ff) : m_ff(ff.clone()) {} IComputeFF::~IComputeFF() = default; -void IComputeFF::setAmbientMaterial(const Material& material) -{ +void IComputeFF::setAmbientMaterial(const Material& material) { m_ff->setAmbientMaterial(material); } -double IComputeFF::volume() const -{ +double IComputeFF::volume() const { return m_ff->volume(); } -double IComputeFF::radialExtension() const -{ +double IComputeFF::radialExtension() const { return m_ff->radialExtension(); } -double IComputeFF::bottomZ(const IRotation& rotation) const -{ +double IComputeFF::bottomZ(const IRotation& rotation) const { return m_ff->bottomZ(rotation); } -double IComputeFF::topZ(const IRotation& rotation) const -{ +double IComputeFF::topZ(const IRotation& rotation) const { return m_ff->topZ(rotation); } -Eigen::Matrix2cd IComputeFF::evaluatePol(const WavevectorInfo&) const -{ +Eigen::Matrix2cd IComputeFF::evaluatePol(const WavevectorInfo&) const { throw std::runtime_error("Bug: impossible call to FFCompute::evaluatePol"); } void IComputeFF::setSpecularInfo(std::unique_ptr<const ILayerRTCoefficients>, - std::unique_ptr<const ILayerRTCoefficients>) -{ -} + std::unique_ptr<const ILayerRTCoefficients>) {} diff --git a/Sample/FFCompute/IComputeFF.h b/Sample/FFCompute/IComputeFF.h index d5d70f3f16540b2e3733d9186906d547a1e0a6c9..2f6c13b0bdb08851e010370a954573deddc7eece 100644 --- a/Sample/FFCompute/IComputeFF.h +++ b/Sample/FFCompute/IComputeFF.h @@ -31,8 +31,7 @@ class WavevectorInfo; //! @ingroup formfactors_internal -class IComputeFF -{ +class IComputeFF { public: IComputeFF() = delete; diff --git a/Sample/Fresnel/FormFactorCoherentPart.cpp b/Sample/Fresnel/FormFactorCoherentPart.cpp index a5466c8173fd9f68b4d0edf5dc235f9cc489e146..0bf2b7d823e5600caeb6e0067298137e90f956d9 100644 --- a/Sample/Fresnel/FormFactorCoherentPart.cpp +++ b/Sample/Fresnel/FormFactorCoherentPart.cpp @@ -24,12 +24,9 @@ FormFactorCoherentPart::FormFactorCoherentPart(IComputeFF* ff) : m_ff(ff) {} FormFactorCoherentPart::FormFactorCoherentPart(const FormFactorCoherentPart& other) : m_ff(std::unique_ptr<IComputeFF>(other.m_ff->clone())) , m_fresnel_map(other.m_fresnel_map) - , m_layer_index(other.m_layer_index) -{ -} + , m_layer_index(other.m_layer_index) {} -FormFactorCoherentPart& FormFactorCoherentPart::operator=(const FormFactorCoherentPart& other) -{ +FormFactorCoherentPart& FormFactorCoherentPart::operator=(const FormFactorCoherentPart& other) { m_ff.reset(other.m_ff->clone()); m_fresnel_map = other.m_fresnel_map; m_layer_index = other.m_layer_index; @@ -42,8 +39,7 @@ FormFactorCoherentPart::FormFactorCoherentPart(FormFactorCoherentPart&&) = defau FormFactorCoherentPart::~FormFactorCoherentPart() = default; -complex_t FormFactorCoherentPart::evaluate(const SimulationElement& sim_element) const -{ +complex_t FormFactorCoherentPart::evaluate(const SimulationElement& sim_element) const { WavevectorInfo wavevectors(sim_element.getKi(), sim_element.getMeanKf(), sim_element.getWavelength()); @@ -53,8 +49,7 @@ complex_t FormFactorCoherentPart::evaluate(const SimulationElement& sim_element) return m_ff->evaluate(wavevectors); } -Eigen::Matrix2cd FormFactorCoherentPart::evaluatePol(const SimulationElement& sim_element) const -{ +Eigen::Matrix2cd FormFactorCoherentPart::evaluatePol(const SimulationElement& sim_element) const { WavevectorInfo wavevectors(sim_element.getKi(), sim_element.getMeanKf(), sim_element.getWavelength()); @@ -64,13 +59,11 @@ Eigen::Matrix2cd FormFactorCoherentPart::evaluatePol(const SimulationElement& si return m_ff->evaluatePol(wavevectors); } -void FormFactorCoherentPart::setSpecularInfo(const IFresnelMap* fresnel_map, size_t layer_index) -{ +void FormFactorCoherentPart::setSpecularInfo(const IFresnelMap* fresnel_map, size_t layer_index) { m_fresnel_map = fresnel_map; m_layer_index = layer_index; } -double FormFactorCoherentPart::radialExtension() const -{ +double FormFactorCoherentPart::radialExtension() const { return m_ff->radialExtension(); } diff --git a/Sample/Fresnel/FormFactorCoherentPart.h b/Sample/Fresnel/FormFactorCoherentPart.h index 4019fa0b09271f58a028088bab09d4b283020458..445bab2fe78824e5aec7d070dc26b957d1eac149 100644 --- a/Sample/Fresnel/FormFactorCoherentPart.h +++ b/Sample/Fresnel/FormFactorCoherentPart.h @@ -26,8 +26,7 @@ class SimulationElement; //! Information about single particle form factor and specular info of the embedding layer. //! @ingroup formfactors_internal -class FormFactorCoherentPart -{ +class FormFactorCoherentPart { public: FormFactorCoherentPart(IComputeFF* ff); FormFactorCoherentPart(const FormFactorCoherentPart& other); diff --git a/Sample/Fresnel/FormFactorCoherentSum.cpp b/Sample/Fresnel/FormFactorCoherentSum.cpp index 11765e8e3606ca6db30b13cb0d8eed4522f2621c..0be1b223b5bf7564f5fa89f72e432c431743434e 100644 --- a/Sample/Fresnel/FormFactorCoherentSum.cpp +++ b/Sample/Fresnel/FormFactorCoherentSum.cpp @@ -18,42 +18,35 @@ FormFactorCoherentSum::FormFactorCoherentSum(double abundance) : m_abundance(abundance) {} -void FormFactorCoherentSum::addCoherentPart(const FormFactorCoherentPart& part) -{ +void FormFactorCoherentSum::addCoherentPart(const FormFactorCoherentPart& part) { m_parts.push_back(part); } -complex_t FormFactorCoherentSum::evaluate(const SimulationElement& sim_element) const -{ +complex_t FormFactorCoherentSum::evaluate(const SimulationElement& sim_element) const { complex_t result{}; for (auto& part : m_parts) result += part.evaluate(sim_element); return result; } -Eigen::Matrix2cd FormFactorCoherentSum::evaluatePol(const SimulationElement& sim_element) const -{ +Eigen::Matrix2cd FormFactorCoherentSum::evaluatePol(const SimulationElement& sim_element) const { Eigen::Matrix2cd result = Eigen::Matrix2cd::Zero(); for (auto& part : m_parts) result += part.evaluatePol(sim_element); return result; } -void FormFactorCoherentSum::scaleRelativeAbundance(double total_abundance) -{ +void FormFactorCoherentSum::scaleRelativeAbundance(double total_abundance) { if (total_abundance <= 0.0) throw Exceptions::LogicErrorException("FormFactorCoherentSum::scaleRelativeAbundance: " "Trying to scale with non strictly positive factor."); m_abundance /= total_abundance; } -double FormFactorCoherentSum::radialExtension() const -{ +double FormFactorCoherentSum::radialExtension() const { return m_parts[0].radialExtension(); } FormFactorCoherentSum::FormFactorCoherentSum(const std::vector<FormFactorCoherentPart>& parts, double abundance) - : m_parts(parts), m_abundance(abundance) -{ -} + : m_parts(parts), m_abundance(abundance) {} diff --git a/Sample/Fresnel/FormFactorCoherentSum.h b/Sample/Fresnel/FormFactorCoherentSum.h index 0510df9869c2f52940ce3b0947246e034275e694..678f62cd9adc413f0d38a445f8f1e55b6c57e066 100644 --- a/Sample/Fresnel/FormFactorCoherentSum.h +++ b/Sample/Fresnel/FormFactorCoherentSum.h @@ -23,8 +23,7 @@ class SimulationElement; //! Information about particle form factor and abundance. //! @ingroup formfactors_internal -class FormFactorCoherentSum -{ +class FormFactorCoherentSum { public: FormFactorCoherentSum(double abundance); diff --git a/Sample/Fresnel/IFresnelMap.cpp b/Sample/Fresnel/IFresnelMap.cpp index e5a9fc0414f75968a942408fdc9da4d26c843238..e090f8f2ec48a6e7e308b36e6fdbbfb3325492c8 100644 --- a/Sample/Fresnel/IFresnelMap.cpp +++ b/Sample/Fresnel/IFresnelMap.cpp @@ -16,23 +16,18 @@ #include "Sample/Slice/Slice.h" IFresnelMap::IFresnelMap(std::unique_ptr<ISpecularStrategy> strategy) - : m_use_cache(true), m_Strategy(std::move(strategy)) -{ -} + : m_use_cache(true), m_Strategy(std::move(strategy)) {} -void IFresnelMap::setSlices(const std::vector<Slice>& slices) -{ +void IFresnelMap::setSlices(const std::vector<Slice>& slices) { m_slices = slices; } -const std::vector<Slice>& IFresnelMap::slices() const -{ +const std::vector<Slice>& IFresnelMap::slices() const { return m_slices; } IFresnelMap::~IFresnelMap() = default; -void IFresnelMap::disableCaching() -{ +void IFresnelMap::disableCaching() { m_use_cache = false; } diff --git a/Sample/Fresnel/IFresnelMap.h b/Sample/Fresnel/IFresnelMap.h index d3b94ef629fb31ecd0ec566f4793626209374669..95dd80776d47d892ff65c49579702be534e6cee9 100644 --- a/Sample/Fresnel/IFresnelMap.h +++ b/Sample/Fresnel/IFresnelMap.h @@ -26,8 +26,7 @@ class SimulationElement; //! (these amplitudes correspond to the specular part of the wavefunction). //! @ingroup algorithms_internal -class IFresnelMap -{ +class IFresnelMap { public: IFresnelMap(std::unique_ptr<ISpecularStrategy> strategy); virtual ~IFresnelMap(); @@ -39,8 +38,7 @@ public: //! Retrieves the amplitude coefficients for an incoming wavevector. template <typename T> std::unique_ptr<const ILayerRTCoefficients> getInCoefficients(const T& sim_element, - size_t layer_index) const - { + size_t layer_index) const { return getCoefficients(sim_element.getKi(), layer_index); } diff --git a/Sample/Fresnel/MatrixFresnelMap.cpp b/Sample/Fresnel/MatrixFresnelMap.cpp index d5b5ac4cb2427eed956f353074ce0e2f192dad91..4004bbbf5c0d23a1d65ec92c23702c3169b8fa10 100644 --- a/Sample/Fresnel/MatrixFresnelMap.cpp +++ b/Sample/Fresnel/MatrixFresnelMap.cpp @@ -24,21 +24,19 @@ MatrixFresnelMap::MatrixFresnelMap(std::unique_ptr<ISpecularStrategy> strategy) MatrixFresnelMap::~MatrixFresnelMap() = default; //! Returns hash value of a 3-vector, computed by exclusive-or of the component hash values. -size_t MatrixFresnelMap::HashKVector::operator()(const kvector_t& kvec) const noexcept -{ +size_t MatrixFresnelMap::HashKVector::operator()(const kvector_t& kvec) const noexcept { return std::hash<double>{}(kvec.x()) ^ std::hash<double>{}(kvec.y()) ^ std::hash<double>{}(kvec.z()); } std::unique_ptr<const ILayerRTCoefficients> -MatrixFresnelMap::getOutCoefficients(const SimulationElement& sim_element, size_t layer_index) const -{ +MatrixFresnelMap::getOutCoefficients(const SimulationElement& sim_element, + size_t layer_index) const { return getCoefficients(-sim_element.getMeanKf(), layer_index, m_inverted_slices, m_hash_table_out); } -void MatrixFresnelMap::setSlices(const std::vector<Slice>& slices) -{ +void MatrixFresnelMap::setSlices(const std::vector<Slice>& slices) { IFresnelMap::setSlices(slices); m_inverted_slices.clear(); for (auto slice : slices) { @@ -48,16 +46,14 @@ void MatrixFresnelMap::setSlices(const std::vector<Slice>& slices) } std::unique_ptr<const ILayerRTCoefficients> -MatrixFresnelMap::getCoefficients(const kvector_t& kvec, size_t layer_index) const -{ +MatrixFresnelMap::getCoefficients(const kvector_t& kvec, size_t layer_index) const { return getCoefficients(kvec, layer_index, m_slices, m_hash_table_in); } std::unique_ptr<const ILayerRTCoefficients> MatrixFresnelMap::getCoefficients(const kvector_t& kvec, size_t layer_index, const std::vector<Slice>& slices, - CoefficientHash& hash_table) const -{ + CoefficientHash& hash_table) const { if (!m_use_cache) { auto coeffs = m_Strategy->Execute(slices, kvec); return std::unique_ptr<const ILayerRTCoefficients>(coeffs[layer_index]->clone()); @@ -68,8 +64,7 @@ MatrixFresnelMap::getCoefficients(const kvector_t& kvec, size_t layer_index, const ISpecularStrategy::coeffs_t& MatrixFresnelMap::getCoefficientsFromCache(kvector_t kvec, const std::vector<Slice>& slices, - MatrixFresnelMap::CoefficientHash& hash_table) const -{ + MatrixFresnelMap::CoefficientHash& hash_table) const { auto it = hash_table.find(kvec); if (it == hash_table.end()) it = hash_table.emplace(kvec, m_Strategy->Execute(slices, kvec)).first; diff --git a/Sample/Fresnel/MatrixFresnelMap.h b/Sample/Fresnel/MatrixFresnelMap.h index 0e641400d28ccf5c5d8b8a9ec59113a035ded91a..2616af9f5b8fb1915c51c999054a99a0816659f5 100644 --- a/Sample/Fresnel/MatrixFresnelMap.h +++ b/Sample/Fresnel/MatrixFresnelMap.h @@ -31,8 +31,7 @@ class SimulationElement; //! Implementation of IFresnelMap for matrix valued reflection/transmission coefficients. //! @ingroup algorithms_internal -class MatrixFresnelMap : public IFresnelMap -{ +class MatrixFresnelMap : public IFresnelMap { public: MatrixFresnelMap(std::unique_ptr<ISpecularStrategy> strategy); ~MatrixFresnelMap() override; @@ -47,8 +46,7 @@ public: private: //! Provides a hash function for a 3-vector of doubles, for use in MatrixFresnelMap. - class HashKVector - { + class HashKVector { public: size_t operator()(const kvector_t& kvec) const noexcept; }; diff --git a/Sample/Fresnel/ScalarFresnelMap.cpp b/Sample/Fresnel/ScalarFresnelMap.cpp index ced1cd39f0916571bcce1e6997166a958edc0275..ea36b4137884c86e4d7f1bb1590f9047a29d9a45 100644 --- a/Sample/Fresnel/ScalarFresnelMap.cpp +++ b/Sample/Fresnel/ScalarFresnelMap.cpp @@ -17,28 +17,24 @@ #include <functional> ScalarFresnelMap::ScalarFresnelMap(std::unique_ptr<ISpecularStrategy> strategy) - : IFresnelMap(std::move(strategy)) -{ -} + : IFresnelMap(std::move(strategy)) {} ScalarFresnelMap::~ScalarFresnelMap() = default; //! Returns hash value of a pair of doubles, computed by exclusive-or of the component hash values. -size_t -ScalarFresnelMap::Hash2Doubles::operator()(const std::pair<double, double>& doubles) const noexcept -{ +size_t ScalarFresnelMap::Hash2Doubles::operator()( + const std::pair<double, double>& doubles) const noexcept { return std::hash<double>{}(doubles.first) ^ std::hash<double>{}(doubles.second); } std::unique_ptr<const ILayerRTCoefficients> -ScalarFresnelMap::getOutCoefficients(const SimulationElement& sim_element, size_t layer_index) const -{ +ScalarFresnelMap::getOutCoefficients(const SimulationElement& sim_element, + size_t layer_index) const { return getCoefficients(-sim_element.getMeanKf(), layer_index); } std::unique_ptr<const ILayerRTCoefficients> -ScalarFresnelMap::getCoefficients(const kvector_t& kvec, size_t layer_index) const -{ +ScalarFresnelMap::getCoefficients(const kvector_t& kvec, size_t layer_index) const { if (!m_use_cache) { auto coeffs = m_Strategy->Execute(m_slices, kvec); return std::unique_ptr<const ILayerRTCoefficients>(coeffs[layer_index]->clone()); @@ -47,8 +43,8 @@ ScalarFresnelMap::getCoefficients(const kvector_t& kvec, size_t layer_index) con return std::unique_ptr<const ILayerRTCoefficients>(coef_vector[layer_index]->clone()); } -const ISpecularStrategy::coeffs_t& ScalarFresnelMap::getCoefficientsFromCache(kvector_t kvec) const -{ +const ISpecularStrategy::coeffs_t& +ScalarFresnelMap::getCoefficientsFromCache(kvector_t kvec) const { std::pair<double, double> k2_theta(kvec.mag2(), kvec.theta()); auto it = m_cache.find(k2_theta); if (it == m_cache.end()) { diff --git a/Sample/Fresnel/ScalarFresnelMap.h b/Sample/Fresnel/ScalarFresnelMap.h index b1ad3b98b13b234696828dabfe2d5a43012e1f64..4740d3f99bec25bbbfa4dfbf2275aa789f57b219 100644 --- a/Sample/Fresnel/ScalarFresnelMap.h +++ b/Sample/Fresnel/ScalarFresnelMap.h @@ -29,8 +29,7 @@ class Slice; //! Implementation of IFresnelMap for scalar valued reflection/transmission coefficients. //! @ingroup algorithms_internal -class ScalarFresnelMap : public IFresnelMap -{ +class ScalarFresnelMap : public IFresnelMap { public: ScalarFresnelMap(std::unique_ptr<ISpecularStrategy> strategy); ~ScalarFresnelMap() override; @@ -43,8 +42,7 @@ public: private: //! Provides a hash function for a pair of doubles. - class Hash2Doubles - { + class Hash2Doubles { public: size_t operator()(const std::pair<double, double>& doubles) const noexcept; }; diff --git a/Sample/HardParticle/FormFactorAnisoPyramid.cpp b/Sample/HardParticle/FormFactorAnisoPyramid.cpp index 3dae72e12afae83ee61bb5baf1518d57f5f9c035..4081b3884634f2f87400fa97faa0feab1192eed8 100644 --- a/Sample/HardParticle/FormFactorAnisoPyramid.cpp +++ b/Sample/HardParticle/FormFactorAnisoPyramid.cpp @@ -37,20 +37,16 @@ FormFactorAnisoPyramid::FormFactorAnisoPyramid(const std::vector<double> P) , m_length(m_P[0]) , m_width(m_P[1]) , m_height(m_P[2]) - , m_alpha(m_P[3]) -{ + , m_alpha(m_P[3]) { onChange(); } FormFactorAnisoPyramid::FormFactorAnisoPyramid(double length, double width, double height, double alpha) - : FormFactorAnisoPyramid(std::vector<double>{length, width, height, alpha}) -{ -} + : FormFactorAnisoPyramid(std::vector<double>{length, width, height, alpha}) {} IFormFactor* FormFactorAnisoPyramid::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); double dbase_edge = 2 * effects.dz_bottom * Math::cot(m_alpha); FormFactorAnisoPyramid slicedff(m_length - dbase_edge, m_width - dbase_edge, @@ -58,8 +54,7 @@ IFormFactor* FormFactorAnisoPyramid::sliceFormFactor(ZLimits limits, const IRota return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorAnisoPyramid::onChange() -{ +void FormFactorAnisoPyramid::onChange() { double cot_alpha = Math::cot(m_alpha); if (!std::isfinite(cot_alpha) || cot_alpha < 0) throw Exceptions::OutOfBoundsException("AnisoPyramid: angle alpha out of bounds"); diff --git a/Sample/HardParticle/FormFactorAnisoPyramid.h b/Sample/HardParticle/FormFactorAnisoPyramid.h index f136a31f2c67b57132331d72b00cdc808584fd9d..86db3efd1a4f5bf56e756f09e08dc0528a3c173e 100644 --- a/Sample/HardParticle/FormFactorAnisoPyramid.h +++ b/Sample/HardParticle/FormFactorAnisoPyramid.h @@ -20,14 +20,12 @@ //! A frustum (truncated pyramid) with rectangular base. //! @ingroup hardParticle -class FormFactorAnisoPyramid : public IFormFactorPolyhedron -{ +class FormFactorAnisoPyramid : public IFormFactorPolyhedron { public: FormFactorAnisoPyramid(const std::vector<double> P); FormFactorAnisoPyramid(double length, double width, double height, double alpha); - FormFactorAnisoPyramid* clone() const final - { + FormFactorAnisoPyramid* clone() const final { return new FormFactorAnisoPyramid(m_length, m_width, m_height, m_alpha); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorBar.cpp b/Sample/HardParticle/FormFactorBar.cpp index 51bba8576a9524f8a8f954f081a37f3efb939f49..7301f15039995b590f482487b301f7309856ae3b 100644 --- a/Sample/HardParticle/FormFactorBar.cpp +++ b/Sample/HardParticle/FormFactorBar.cpp @@ -20,27 +20,20 @@ // ************************************************************************************************ FormFactorBarGauss::FormFactorBarGauss(const std::vector<double> P) - : IProfileRectangularRipple({"BarGauss", "class_tooltip", {}}, P) -{ -} + : IProfileRectangularRipple({"BarGauss", "class_tooltip", {}}, P) {} FormFactorBarGauss::FormFactorBarGauss(double length, double width, double height) - : FormFactorBarGauss(std::vector<double>{length, width, height}) -{ -} + : FormFactorBarGauss(std::vector<double>{length, width, height}) {} -FormFactorBarGauss* FormFactorBarGauss::clone() const -{ +FormFactorBarGauss* FormFactorBarGauss::clone() const { return new FormFactorBarGauss(m_length, m_width, m_height); } -void FormFactorBarGauss::accept(INodeVisitor* visitor) const -{ +void FormFactorBarGauss::accept(INodeVisitor* visitor) const { visitor->visit(this); } -complex_t FormFactorBarGauss::factor_x(complex_t qx) const -{ +complex_t FormFactorBarGauss::factor_x(complex_t qx) const { return ripples::factor_x_Gauss(qx, m_length); } @@ -49,26 +42,19 @@ complex_t FormFactorBarGauss::factor_x(complex_t qx) const // ************************************************************************************************ FormFactorBarLorentz::FormFactorBarLorentz(const std::vector<double> P) - : IProfileRectangularRipple({"BarLorentz", "class_tooltip", {}}, P) -{ -} + : IProfileRectangularRipple({"BarLorentz", "class_tooltip", {}}, P) {} FormFactorBarLorentz::FormFactorBarLorentz(double length, double width, double height) - : FormFactorBarLorentz(std::vector<double>{length, width, height}) -{ -} + : FormFactorBarLorentz(std::vector<double>{length, width, height}) {} -FormFactorBarLorentz* FormFactorBarLorentz::clone() const -{ +FormFactorBarLorentz* FormFactorBarLorentz::clone() const { return new FormFactorBarLorentz(m_length, m_width, m_height); } -void FormFactorBarLorentz::accept(INodeVisitor* visitor) const -{ +void FormFactorBarLorentz::accept(INodeVisitor* visitor) const { visitor->visit(this); } -complex_t FormFactorBarLorentz::factor_x(complex_t qx) const -{ +complex_t FormFactorBarLorentz::factor_x(complex_t qx) const { return ripples::factor_x_Lorentz(qx, m_length); } diff --git a/Sample/HardParticle/FormFactorBar.h b/Sample/HardParticle/FormFactorBar.h index 2f0fee07bc0725595d410196c47d197d6b2e10e0..66c386942373d42b46af76f1e8dcfe21916b7b5f 100644 --- a/Sample/HardParticle/FormFactorBar.h +++ b/Sample/HardParticle/FormFactorBar.h @@ -19,8 +19,7 @@ //! The form factor of an elongated bar, with Gaussian profile in elongation direction. //! @ingroup legacyGrating -class FormFactorBarGauss : public IProfileRectangularRipple -{ +class FormFactorBarGauss : public IProfileRectangularRipple { public: FormFactorBarGauss(const std::vector<double> P); FormFactorBarGauss(double length, double width, double height); @@ -33,8 +32,7 @@ private: //! The form factor of an elongated, with Lorentz form factor in elongation direction. //! @ingroup legacyGrating -class FormFactorBarLorentz : public IProfileRectangularRipple -{ +class FormFactorBarLorentz : public IProfileRectangularRipple { public: FormFactorBarLorentz(const std::vector<double> P); FormFactorBarLorentz(double length, double width, double height); diff --git a/Sample/HardParticle/FormFactorBox.cpp b/Sample/HardParticle/FormFactorBox.cpp index 5e3743a22c59f6f5413b591cc2a4d4e65c9727dc..77e3634cb0fa6ef461b2daae729c1e784100ab9a 100644 --- a/Sample/HardParticle/FormFactorBox.cpp +++ b/Sample/HardParticle/FormFactorBox.cpp @@ -24,33 +24,27 @@ FormFactorBox::FormFactorBox(const std::vector<double> P) P) , m_length(m_P[0]) , m_width(m_P[1]) - , m_height(m_P[2]) -{ + , m_height(m_P[2]) { onChange(); } FormFactorBox::FormFactorBox(double length, double width, double height) - : FormFactorBox(std::vector<double>{length, width, height}) -{ -} + : FormFactorBox(std::vector<double>{length, width, height}) {} -complex_t FormFactorBox::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorBox::evaluate_for_q(cvector_t q) const { complex_t qzHdiv2 = m_height / 2 * q.z(); return m_length * m_width * m_height * Math::sinc(m_length / 2 * q.x()) * Math::sinc(m_width / 2 * q.y()) * Math::sinc(qzHdiv2) * exp_I(qzHdiv2); } IFormFactor* FormFactorBox::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); FormFactorBox slicedff(m_length, m_width, m_height - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorBox::onChange() -{ +void FormFactorBox::onChange() { double a = m_length / 2; double b = m_width / 2; std::vector<kvector_t> V{{a, b, 0.}, {-a, b, 0.}, {-a, -b, 0.}, {a, -b, 0}}; diff --git a/Sample/HardParticle/FormFactorBox.h b/Sample/HardParticle/FormFactorBox.h index 4319d64b0d5595e50de6d2dc63b05391d1dc7fc5..59ca1ba8f289e67f47801520f272617b960a264a 100644 --- a/Sample/HardParticle/FormFactorBox.h +++ b/Sample/HardParticle/FormFactorBox.h @@ -20,8 +20,7 @@ //! A rectangular prism (parallelepiped). //! @ingroup hardParticle -class FormFactorBox : public IFormFactorPrism -{ +class FormFactorBox : public IFormFactorPrism { public: FormFactorBox(const std::vector<double> P); FormFactorBox(double length, double width, double height); diff --git a/Sample/HardParticle/FormFactorCantellatedCube.cpp b/Sample/HardParticle/FormFactorCantellatedCube.cpp index 0ba87444f66ec1fcc83c469cc00eb65d2609fd3b..1364302b5e8c8c90d7e531f0a2e40dba6e3bc369 100644 --- a/Sample/HardParticle/FormFactorCantellatedCube.cpp +++ b/Sample/HardParticle/FormFactorCantellatedCube.cpp @@ -55,18 +55,14 @@ FormFactorCantellatedCube::FormFactorCantellatedCube(const std::vector<double> P "side length of the trirectangular tetrahedron removed one corner", 0, +INF, 0}}}, P) , m_length(m_P[0]) - , m_removed_length(m_P[1]) -{ + , m_removed_length(m_P[1]) { onChange(); } FormFactorCantellatedCube::FormFactorCantellatedCube(double length, double removed_length) - : FormFactorCantellatedCube(std::vector<double>{length, removed_length}) -{ -} + : FormFactorCantellatedCube(std::vector<double>{length, removed_length}) {} -void FormFactorCantellatedCube::onChange() -{ +void FormFactorCantellatedCube::onChange() { if (m_removed_length > 0.5 * m_length) { std::ostringstream ostr; ostr << "::FormFactorCantellatedCube() -> Error in class initialization "; diff --git a/Sample/HardParticle/FormFactorCantellatedCube.h b/Sample/HardParticle/FormFactorCantellatedCube.h index bdb15d69a7e4efaf0f4859d5067bbf36541fc5d8..0c1e5b84c5c4493a7168263cb9351cfbd01f46f9 100644 --- a/Sample/HardParticle/FormFactorCantellatedCube.h +++ b/Sample/HardParticle/FormFactorCantellatedCube.h @@ -20,14 +20,12 @@ //! A cube, with truncation of all edges and corners, as in Croset (2017) Fig 7 //! @ingroup hardParticle -class FormFactorCantellatedCube : public IFormFactorPolyhedron -{ +class FormFactorCantellatedCube : public IFormFactorPolyhedron { public: FormFactorCantellatedCube(const std::vector<double> P); FormFactorCantellatedCube(double length, double removed_length); - FormFactorCantellatedCube* clone() const final - { + FormFactorCantellatedCube* clone() const final { return new FormFactorCantellatedCube(m_length, m_removed_length); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorCone.cpp b/Sample/HardParticle/FormFactorCone.cpp index c08da1b31ff77f84b3a6a508236086a1a4e9cfb5..2ff6a874e2e75f1a1f5bd34a13af453e505e1796 100644 --- a/Sample/HardParticle/FormFactorCone.cpp +++ b/Sample/HardParticle/FormFactorCone.cpp @@ -30,8 +30,7 @@ FormFactorCone::FormFactorCone(const std::vector<double> P) P) , m_radius(m_P[0]) , m_height(m_P[1]) - , m_alpha(m_P[2]) -{ + , m_alpha(m_P[2]) { m_cot_alpha = Math::cot(m_alpha); if (!std::isfinite(m_cot_alpha) || m_cot_alpha < 0) throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds"); @@ -48,20 +47,16 @@ FormFactorCone::FormFactorCone(const std::vector<double> P) } FormFactorCone::FormFactorCone(double radius, double height, double alpha) - : FormFactorCone(std::vector<double>{radius, height, alpha}) -{ -} + : FormFactorCone(std::vector<double>{radius, height, alpha}) {} //! Integrand for complex form factor. -complex_t FormFactorCone::Integrand(double Z) const -{ +complex_t FormFactorCone::Integrand(double Z) const { double Rz = m_radius - Z * m_cot_alpha; complex_t q_p = std::sqrt(m_q.x() * m_q.x() + m_q.y() * m_q.y()); // sqrt(x*x + y*y) return Rz * Rz * Math::Bessel::J1c(q_p * Rz) * exp_I(m_q.z() * Z); } -complex_t FormFactorCone::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorCone::evaluate_for_q(cvector_t q) const { m_q = q; if (std::abs(m_q.mag()) < std::numeric_limits<double>::epsilon()) { double R = m_radius; @@ -79,8 +74,7 @@ complex_t FormFactorCone::evaluate_for_q(cvector_t q) const } IFormFactor* FormFactorCone::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); double dradius = effects.dz_bottom * m_cot_alpha; FormFactorCone slicedff(m_radius - dradius, m_height - effects.dz_bottom - effects.dz_top, @@ -88,8 +82,7 @@ IFormFactor* FormFactorCone::sliceFormFactor(ZLimits limits, const IRotation& ro return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorCone::onChange() -{ +void FormFactorCone::onChange() { m_cot_alpha = Math::cot(m_alpha); double radius2 = m_radius - m_height * m_cot_alpha; m_shape = std::make_unique<DoubleEllipse>(m_radius, m_radius, m_height, radius2, radius2); diff --git a/Sample/HardParticle/FormFactorCone.h b/Sample/HardParticle/FormFactorCone.h index ac8715fda159eb999671a89dfdd55a1361117114..011ac2fc8526ef14106e1334dde148c25060a0ff 100644 --- a/Sample/HardParticle/FormFactorCone.h +++ b/Sample/HardParticle/FormFactorCone.h @@ -20,8 +20,7 @@ //! A conical frustum (cone truncated parallel to the base) with circular base. //! @ingroup hardParticle -class FormFactorCone : public IBornFF -{ +class FormFactorCone : public IBornFF { public: FormFactorCone(const std::vector<double> P); FormFactorCone(double radius, double height, double alpha); diff --git a/Sample/HardParticle/FormFactorCone6.cpp b/Sample/HardParticle/FormFactorCone6.cpp index a65d6fc4a3a64236c63cf13f7627b68c32514013..bb17ab17fd66ff90ccaf558148a1760c28c6defd 100644 --- a/Sample/HardParticle/FormFactorCone6.cpp +++ b/Sample/HardParticle/FormFactorCone6.cpp @@ -37,19 +37,15 @@ FormFactorCone6::FormFactorCone6(const std::vector<double> P) P) , m_base_edge(m_P[0]) , m_height(m_P[1]) - , m_alpha(m_P[2]) -{ + , m_alpha(m_P[2]) { onChange(); } FormFactorCone6::FormFactorCone6(double base_edge, double height, double alpha) - : FormFactorCone6(std::vector<double>{base_edge, height, alpha}) -{ -} + : FormFactorCone6(std::vector<double>{base_edge, height, alpha}) {} IFormFactor* FormFactorCone6::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); double dbase_edge = effects.dz_bottom * Math::cot(m_alpha); FormFactorCone6 slicedff(m_base_edge - dbase_edge, @@ -57,8 +53,7 @@ IFormFactor* FormFactorCone6::sliceFormFactor(ZLimits limits, const IRotation& r return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorCone6::onChange() -{ +void FormFactorCone6::onChange() { double cot_alpha = Math::cot(m_alpha); if (!std::isfinite(cot_alpha) || cot_alpha < 0) throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds"); diff --git a/Sample/HardParticle/FormFactorCone6.h b/Sample/HardParticle/FormFactorCone6.h index 9af35b57d7bc0c54c75c3ad8320e2ccb381afd45..1d4c3164e3db7629e4fbe0733430989151e0ff1a 100644 --- a/Sample/HardParticle/FormFactorCone6.h +++ b/Sample/HardParticle/FormFactorCone6.h @@ -20,14 +20,12 @@ //! A frustum (truncated pyramid) with regular hexagonal base. //! @ingroup hardParticle -class FormFactorCone6 : public IFormFactorPolyhedron -{ +class FormFactorCone6 : public IFormFactorPolyhedron { public: FormFactorCone6(const std::vector<double> P); FormFactorCone6(double base_edge, double height, double alpha); - FormFactorCone6* clone() const final - { + FormFactorCone6* clone() const final { return new FormFactorCone6(m_base_edge, m_height, m_alpha); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorCosineRipple.cpp b/Sample/HardParticle/FormFactorCosineRipple.cpp index 00048ec1de1b8c39ebd6a114eee854f42dae5bc5..24fc6e542c3b1862c9e7a1463f4c37d9ebaaa097 100644 --- a/Sample/HardParticle/FormFactorCosineRipple.cpp +++ b/Sample/HardParticle/FormFactorCosineRipple.cpp @@ -20,27 +20,20 @@ // ************************************************************************************************ FormFactorCosineRippleBox::FormFactorCosineRippleBox(const std::vector<double> P) - : ICosineRipple({"CosineRippleBox", "class_tooltip", {}}, P) -{ -} + : ICosineRipple({"CosineRippleBox", "class_tooltip", {}}, P) {} FormFactorCosineRippleBox::FormFactorCosineRippleBox(double length, double width, double height) - : FormFactorCosineRippleBox(std::vector<double>{length, width, height}) -{ -} + : FormFactorCosineRippleBox(std::vector<double>{length, width, height}) {} -FormFactorCosineRippleBox* FormFactorCosineRippleBox::clone() const -{ +FormFactorCosineRippleBox* FormFactorCosineRippleBox::clone() const { return new FormFactorCosineRippleBox(m_length, m_width, m_height); } -void FormFactorCosineRippleBox::accept(INodeVisitor* visitor) const -{ +void FormFactorCosineRippleBox::accept(INodeVisitor* visitor) const { visitor->visit(this); } -complex_t FormFactorCosineRippleBox::factor_x(complex_t qx) const -{ +complex_t FormFactorCosineRippleBox::factor_x(complex_t qx) const { return ripples::factor_x_box(qx, m_length); } @@ -49,27 +42,20 @@ complex_t FormFactorCosineRippleBox::factor_x(complex_t qx) const // ************************************************************************************************ FormFactorCosineRippleGauss::FormFactorCosineRippleGauss(const std::vector<double> P) - : ICosineRipple({"CosineRippleGauss", "class_tooltip", {}}, P) -{ -} + : ICosineRipple({"CosineRippleGauss", "class_tooltip", {}}, P) {} FormFactorCosineRippleGauss::FormFactorCosineRippleGauss(double length, double width, double height) - : FormFactorCosineRippleGauss(std::vector<double>{length, width, height}) -{ -} + : FormFactorCosineRippleGauss(std::vector<double>{length, width, height}) {} -FormFactorCosineRippleGauss* FormFactorCosineRippleGauss::clone() const -{ +FormFactorCosineRippleGauss* FormFactorCosineRippleGauss::clone() const { return new FormFactorCosineRippleGauss(m_length, m_width, m_height); } -void FormFactorCosineRippleGauss::accept(INodeVisitor* visitor) const -{ +void FormFactorCosineRippleGauss::accept(INodeVisitor* visitor) const { visitor->visit(this); } -complex_t FormFactorCosineRippleGauss::factor_x(complex_t qx) const -{ +complex_t FormFactorCosineRippleGauss::factor_x(complex_t qx) const { return ripples::factor_x_Gauss(qx, m_length); } @@ -78,27 +64,20 @@ complex_t FormFactorCosineRippleGauss::factor_x(complex_t qx) const // ************************************************************************************************ FormFactorCosineRippleLorentz::FormFactorCosineRippleLorentz(const std::vector<double> P) - : ICosineRipple({"CosineRippleLorentz", "class_tooltip", {}}, P) -{ -} + : ICosineRipple({"CosineRippleLorentz", "class_tooltip", {}}, P) {} FormFactorCosineRippleLorentz::FormFactorCosineRippleLorentz(double length, double width, double height) - : FormFactorCosineRippleLorentz(std::vector<double>{length, width, height}) -{ -} + : FormFactorCosineRippleLorentz(std::vector<double>{length, width, height}) {} -FormFactorCosineRippleLorentz* FormFactorCosineRippleLorentz::clone() const -{ +FormFactorCosineRippleLorentz* FormFactorCosineRippleLorentz::clone() const { return new FormFactorCosineRippleLorentz(m_length, m_width, m_height); } -void FormFactorCosineRippleLorentz::accept(INodeVisitor* visitor) const -{ +void FormFactorCosineRippleLorentz::accept(INodeVisitor* visitor) const { visitor->visit(this); } -complex_t FormFactorCosineRippleLorentz::factor_x(complex_t qx) const -{ +complex_t FormFactorCosineRippleLorentz::factor_x(complex_t qx) const { return ripples::factor_x_Lorentz(qx, m_length); } diff --git a/Sample/HardParticle/FormFactorCosineRipple.h b/Sample/HardParticle/FormFactorCosineRipple.h index 945900c33d9214e1c5d516e8ce498e1ee3f69c4c..6bdc5e92ff2a2621cf6fea92bea40dbe4481fce2 100644 --- a/Sample/HardParticle/FormFactorCosineRipple.h +++ b/Sample/HardParticle/FormFactorCosineRipple.h @@ -19,8 +19,7 @@ //! The form factor for a cosine ripple, with box profile in elongation direction. //! @ingroup legacyGrating -class FormFactorCosineRippleBox : public ICosineRipple -{ +class FormFactorCosineRippleBox : public ICosineRipple { public: FormFactorCosineRippleBox(const std::vector<double> P); FormFactorCosineRippleBox(double length, double width, double height); @@ -33,8 +32,7 @@ private: //! The form factor for a cosine ripple, with Gaussian profile in elongation direction. //! @ingroup legacyGrating -class FormFactorCosineRippleGauss : public ICosineRipple -{ +class FormFactorCosineRippleGauss : public ICosineRipple { public: FormFactorCosineRippleGauss(const std::vector<double> P); FormFactorCosineRippleGauss(double length, double width, double height); @@ -47,8 +45,7 @@ private: //! The form factor for a cosine ripple, with Lorentz form factor in elongation direction. //! @ingroup legacyGrating -class FormFactorCosineRippleLorentz : public ICosineRipple -{ +class FormFactorCosineRippleLorentz : public ICosineRipple { public: FormFactorCosineRippleLorentz(const std::vector<double> P); FormFactorCosineRippleLorentz(double length, double width, double height); diff --git a/Sample/HardParticle/FormFactorCuboctahedron.cpp b/Sample/HardParticle/FormFactorCuboctahedron.cpp index 8b7911ec3b874a304d2c55bbe4004e17db06f6e3..0dbf65df380f142744ec880e59d4d1c3e37f7b65 100644 --- a/Sample/HardParticle/FormFactorCuboctahedron.cpp +++ b/Sample/HardParticle/FormFactorCuboctahedron.cpp @@ -42,20 +42,16 @@ FormFactorCuboctahedron::FormFactorCuboctahedron(const std::vector<double> P) , m_length(m_P[0]) , m_height(m_P[1]) , m_height_ratio(m_P[2]) - , m_alpha(m_P[3]) -{ + , m_alpha(m_P[3]) { onChange(); } FormFactorCuboctahedron::FormFactorCuboctahedron(double length, double height, double height_ratio, double alpha) - : FormFactorCuboctahedron(std::vector<double>{length, height, height_ratio, alpha}) -{ -} + : FormFactorCuboctahedron(std::vector<double>{length, height, height_ratio, alpha}) {} IFormFactor* FormFactorCuboctahedron::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height * (1 + m_height_ratio)); if (effects.dz_bottom > m_height) { double dbase_edge = 2 * (effects.dz_bottom - m_height) * Math::cot(m_alpha); @@ -76,8 +72,7 @@ IFormFactor* FormFactorCuboctahedron::sliceFormFactor(ZLimits limits, const IRot } } -void FormFactorCuboctahedron::onChange() -{ +void FormFactorCuboctahedron::onChange() { double cot_alpha = Math::cot(m_alpha); if (!std::isfinite(cot_alpha) || cot_alpha < 0) throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds"); diff --git a/Sample/HardParticle/FormFactorCuboctahedron.h b/Sample/HardParticle/FormFactorCuboctahedron.h index cc4e18760e55d78336369fd880581da122454dbe..55eaee8e42fbe6ec8dc6180c2481fbfb6063b79c 100644 --- a/Sample/HardParticle/FormFactorCuboctahedron.h +++ b/Sample/HardParticle/FormFactorCuboctahedron.h @@ -20,14 +20,12 @@ //! A truncated bifrustum with quadratic base. //! @ingroup hardParticle -class FormFactorCuboctahedron : public IFormFactorPolyhedron -{ +class FormFactorCuboctahedron : public IFormFactorPolyhedron { public: FormFactorCuboctahedron(const std::vector<double> P); FormFactorCuboctahedron(double length, double height, double height_ratio, double alpha); - FormFactorCuboctahedron* clone() const final - { + FormFactorCuboctahedron* clone() const final { return new FormFactorCuboctahedron(m_length, m_height, m_height_ratio, m_alpha); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorCylinder.cpp b/Sample/HardParticle/FormFactorCylinder.cpp index 6d9f8ca773767e71462a7a0ea59c4d29ec88fdd4..5994062d63bf840ac35cd708495fac72bdb448c0 100644 --- a/Sample/HardParticle/FormFactorCylinder.cpp +++ b/Sample/HardParticle/FormFactorCylinder.cpp @@ -25,18 +25,14 @@ FormFactorCylinder::FormFactorCylinder(const std::vector<double> P) {{"Radius", "nm", "radius of base", 0, +INF, 0}, {"Height", "nm", "height", 0, +INF, 0}}}, P) , m_radius(m_P[0]) - , m_height(m_P[1]) -{ + , m_height(m_P[1]) { onChange(); } FormFactorCylinder::FormFactorCylinder(double radius, double height) - : FormFactorCylinder(std::vector<double>{radius, height}) -{ -} + : FormFactorCylinder(std::vector<double>{radius, height}) {} -complex_t FormFactorCylinder::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorCylinder::evaluate_for_q(cvector_t q) const { double R = m_radius; double H = m_height; @@ -50,14 +46,12 @@ complex_t FormFactorCylinder::evaluate_for_q(cvector_t q) const } IFormFactor* FormFactorCylinder::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); FormFactorCylinder slicedff(m_radius, m_height - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorCylinder::onChange() -{ +void FormFactorCylinder::onChange() { m_shape = std::make_unique<DoubleEllipse>(m_radius, m_radius, m_height, m_radius, m_radius); } diff --git a/Sample/HardParticle/FormFactorCylinder.h b/Sample/HardParticle/FormFactorCylinder.h index ef0bda1d4ad4a355de6e1ebcf2065dc783c81c5e..e6008d5358f5b972f34418b911169c84a21389a8 100644 --- a/Sample/HardParticle/FormFactorCylinder.h +++ b/Sample/HardParticle/FormFactorCylinder.h @@ -20,8 +20,7 @@ //! A circular cylinder. //! @ingroup hardParticle -class FormFactorCylinder : public IBornFF -{ +class FormFactorCylinder : public IBornFF { public: FormFactorCylinder(const std::vector<double> P); FormFactorCylinder(double radius, double height); diff --git a/Sample/HardParticle/FormFactorDodecahedron.cpp b/Sample/HardParticle/FormFactorDodecahedron.cpp index fa5ca933ebe1f7261e7fe443d00bc8b3111991d5..00c289fdb0da15a9e1eec9d49b62b40edb048e00 100644 --- a/Sample/HardParticle/FormFactorDodecahedron.cpp +++ b/Sample/HardParticle/FormFactorDodecahedron.cpp @@ -35,18 +35,14 @@ const PolyhedralTopology FormFactorDodecahedron::topology = {{// bottom: FormFactorDodecahedron::FormFactorDodecahedron(const std::vector<double> P) : IFormFactorPolyhedron( {"Dodecahedron", "regular dodecahedron", {{"Edge", "nm", "edge length", 0, +INF, 0}}}, P) - , m_edge(m_P[0]) -{ + , m_edge(m_P[0]) { onChange(); } FormFactorDodecahedron::FormFactorDodecahedron(double edge) - : FormFactorDodecahedron(std::vector<double>{edge}) -{ -} + : FormFactorDodecahedron(std::vector<double>{edge}) {} -void FormFactorDodecahedron::onChange() -{ +void FormFactorDodecahedron::onChange() { double a = m_edge; setPolyhedron(topology, -1.113516364411607 * a, {{0.8506508083520399 * a, 0 * a, -1.113516364411607 * a}, diff --git a/Sample/HardParticle/FormFactorDodecahedron.h b/Sample/HardParticle/FormFactorDodecahedron.h index 47ac41c9ab3ffd00da898018d2f34dbd425d3899..bd1815fc8bb46f58410f97dd40ba7811404efa50 100644 --- a/Sample/HardParticle/FormFactorDodecahedron.h +++ b/Sample/HardParticle/FormFactorDodecahedron.h @@ -20,8 +20,7 @@ //! A regular dodecahedron. //! @ingroup hardParticle -class FormFactorDodecahedron : public IFormFactorPolyhedron -{ +class FormFactorDodecahedron : public IFormFactorPolyhedron { public: FormFactorDodecahedron(const std::vector<double> P); FormFactorDodecahedron(double edge); diff --git a/Sample/HardParticle/FormFactorDot.cpp b/Sample/HardParticle/FormFactorDot.cpp index 33898dbb642abc9e80b2899cde81cc4f2d5e6044..7416cc4ff38ab5911500552b8f89ec80d9babe62 100644 --- a/Sample/HardParticle/FormFactorDot.cpp +++ b/Sample/HardParticle/FormFactorDot.cpp @@ -19,14 +19,12 @@ FormFactorDot::FormFactorDot(const std::vector<double> P) "dot, with scattering power of a sphere of given radius", {{"Radius", "nm", "radius of sphere that defines scattering power", 0, +INF, 0}}}, P) - , m_radius(m_P[0]) -{ + , m_radius(m_P[0]) { onChange(); } FormFactorDot::FormFactorDot(double radius) : FormFactorDot(std::vector<double>{radius}) {} -complex_t FormFactorDot::evaluate_for_q(cvector_t) const -{ +complex_t FormFactorDot::evaluate_for_q(cvector_t) const { return 4 * M_PI / 3 * pow(m_radius, 3); } diff --git a/Sample/HardParticle/FormFactorDot.h b/Sample/HardParticle/FormFactorDot.h index 60b51546d87cb5eeea0d329f4686cee59c9f5000..e14d372a171b49e001f8d08087dab3598fe80162 100644 --- a/Sample/HardParticle/FormFactorDot.h +++ b/Sample/HardParticle/FormFactorDot.h @@ -20,8 +20,7 @@ //! A dot, with scattering power as a sphere of radius rscat, but with F(q)=const. //! @ingroup hardParticle -class FormFactorDot : public IBornFF -{ +class FormFactorDot : public IBornFF { public: FormFactorDot(const std::vector<double> P); FormFactorDot(double radius); diff --git a/Sample/HardParticle/FormFactorEllipsoidalCylinder.cpp b/Sample/HardParticle/FormFactorEllipsoidalCylinder.cpp index d405fb744788587759233a8654e70ae6b62ab608..0a14ca25bfcfbcaa464aab8728386020092326df 100644 --- a/Sample/HardParticle/FormFactorEllipsoidalCylinder.cpp +++ b/Sample/HardParticle/FormFactorEllipsoidalCylinder.cpp @@ -27,24 +27,19 @@ FormFactorEllipsoidalCylinder::FormFactorEllipsoidalCylinder(const std::vector<d P) , m_radius_x(m_P[0]) , m_radius_y(m_P[1]) - , m_height(m_P[2]) -{ + , m_height(m_P[2]) { onChange(); } FormFactorEllipsoidalCylinder::FormFactorEllipsoidalCylinder(double radius_x, double radius_y, double height) - : FormFactorEllipsoidalCylinder(std::vector<double>{radius_x, radius_y, height}) -{ -} + : FormFactorEllipsoidalCylinder(std::vector<double>{radius_x, radius_y, height}) {} -double FormFactorEllipsoidalCylinder::radialExtension() const -{ +double FormFactorEllipsoidalCylinder::radialExtension() const { return (m_radius_x + m_radius_y) / 2.0; } -complex_t FormFactorEllipsoidalCylinder::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorEllipsoidalCylinder::evaluate_for_q(cvector_t q) const { complex_t qxRa = q.x() * m_radius_x; complex_t qyRb = q.y() * m_radius_y; complex_t qzHdiv2 = m_height / 2 * q.z(); @@ -57,16 +52,14 @@ complex_t FormFactorEllipsoidalCylinder::evaluate_for_q(cvector_t q) const } IFormFactor* FormFactorEllipsoidalCylinder::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); FormFactorEllipsoidalCylinder slicedff(m_radius_x, m_radius_y, m_height - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorEllipsoidalCylinder::onChange() -{ +void FormFactorEllipsoidalCylinder::onChange() { m_shape = std::make_unique<DoubleEllipse>(m_radius_x, m_radius_y, m_height, m_radius_x, m_radius_y); } diff --git a/Sample/HardParticle/FormFactorEllipsoidalCylinder.h b/Sample/HardParticle/FormFactorEllipsoidalCylinder.h index db7117ed8e2920a4f9dcddb23f952290ee79ba06..4ecac90e2824b35f457db12224eed26804768ec2 100644 --- a/Sample/HardParticle/FormFactorEllipsoidalCylinder.h +++ b/Sample/HardParticle/FormFactorEllipsoidalCylinder.h @@ -20,14 +20,12 @@ //! A cylinder with elliptical base. //! @ingroup hardParticle -class FormFactorEllipsoidalCylinder : public IBornFF -{ +class FormFactorEllipsoidalCylinder : public IBornFF { public: FormFactorEllipsoidalCylinder(const std::vector<double> P); FormFactorEllipsoidalCylinder(double radius_x, double radius_y, double height); - FormFactorEllipsoidalCylinder* clone() const final - { + FormFactorEllipsoidalCylinder* clone() const final { return new FormFactorEllipsoidalCylinder(m_radius_x, m_radius_y, m_height); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorFullSphere.cpp b/Sample/HardParticle/FormFactorFullSphere.cpp index 200dd17178ecbbb1f5e7aef40f758df80cee9c6d..2a36b026ec3e33418448a0ceb7ef863b168fa2fa 100644 --- a/Sample/HardParticle/FormFactorFullSphere.cpp +++ b/Sample/HardParticle/FormFactorFullSphere.cpp @@ -21,18 +21,14 @@ FormFactorFullSphere::FormFactorFullSphere(const std::vector<double> P, bool position_at_center) : IBornFF({"FullSphere", "sphere", {{"Radius", "nm", "radius", 0, +INF, 0}}}, P) , m_radius(m_P[0]) - , m_position_at_center(position_at_center) -{ + , m_position_at_center(position_at_center) { onChange(); } FormFactorFullSphere::FormFactorFullSphere(double radius, bool position_at_center) - : FormFactorFullSphere(std::vector<double>{radius}, position_at_center) -{ -} + : FormFactorFullSphere(std::vector<double>{radius}, position_at_center) {} -double FormFactorFullSphere::bottomZ(const IRotation& rotation) const -{ +double FormFactorFullSphere::bottomZ(const IRotation& rotation) const { if (m_position_at_center) return -m_radius; kvector_t centre(0.0, 0.0, m_radius); @@ -40,8 +36,7 @@ double FormFactorFullSphere::bottomZ(const IRotation& rotation) const return new_centre.z() - m_radius; } -double FormFactorFullSphere::topZ(const IRotation& rotation) const -{ +double FormFactorFullSphere::topZ(const IRotation& rotation) const { if (m_position_at_center) return m_radius; kvector_t centre(0.0, 0.0, m_radius); @@ -49,8 +44,7 @@ double FormFactorFullSphere::topZ(const IRotation& rotation) const return new_centre.z() + m_radius; } -complex_t FormFactorFullSphere::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorFullSphere::evaluate_for_q(cvector_t q) const { complex_t ret = someff::ffSphere(q, m_radius); if (!m_position_at_center) ret *= exp_I(q.z() * m_radius); @@ -58,8 +52,7 @@ complex_t FormFactorFullSphere::evaluate_for_q(cvector_t q) const } IFormFactor* FormFactorFullSphere::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { kvector_t center(0.0, 0.0, m_radius); kvector_t rotation_offset = m_position_at_center ? kvector_t(0.0, 0.0, 0.0) : rot.transformed(center) - center; diff --git a/Sample/HardParticle/FormFactorFullSphere.h b/Sample/HardParticle/FormFactorFullSphere.h index df6e0c2f426104d9b02801e76f41738fcdda3737..618e398af96569582a1511eaecc9c2ae8fb33219 100644 --- a/Sample/HardParticle/FormFactorFullSphere.h +++ b/Sample/HardParticle/FormFactorFullSphere.h @@ -20,14 +20,12 @@ //! A full sphere. //! @ingroup hardParticle -class FormFactorFullSphere : public IBornFF -{ +class FormFactorFullSphere : public IBornFF { public: FormFactorFullSphere(const std::vector<double> P, bool position_at_center = false); FormFactorFullSphere(double radius, bool position_at_center = false); - FormFactorFullSphere* clone() const final - { + FormFactorFullSphere* clone() const final { return new FormFactorFullSphere(m_radius, m_position_at_center); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorFullSpheroid.cpp b/Sample/HardParticle/FormFactorFullSpheroid.cpp index 2744216aabb7129f77646227afc65c5702f62557..db87d8dd5ac4f4d3348bb3205f3e6c9d3cad01a3 100644 --- a/Sample/HardParticle/FormFactorFullSpheroid.cpp +++ b/Sample/HardParticle/FormFactorFullSpheroid.cpp @@ -27,18 +27,14 @@ FormFactorFullSpheroid::FormFactorFullSpheroid(const std::vector<double> P) {"Height", "nm", "height = twice the radius in non-revolution direction", 0, +INF, 0}}}, P) , m_radius(m_P[0]) - , m_height(m_P[1]) -{ + , m_height(m_P[1]) { onChange(); } FormFactorFullSpheroid::FormFactorFullSpheroid(double radius, double height) - : FormFactorFullSpheroid(std::vector<double>{radius, height}) -{ -} + : FormFactorFullSpheroid(std::vector<double>{radius, height}) {} -complex_t FormFactorFullSpheroid::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorFullSpheroid::evaluate_for_q(cvector_t q) const { double h = m_height / 2; double R = m_radius; @@ -56,8 +52,7 @@ complex_t FormFactorFullSpheroid::evaluate_for_q(cvector_t q) const } IFormFactor* FormFactorFullSpheroid::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { double flattening = m_height / (2.0 * m_radius); auto effects = computeSlicingEffects(limits, translation, m_height); FormFactorTruncatedSpheroid slicedff(m_radius, m_height - effects.dz_bottom, flattening, @@ -65,8 +60,7 @@ IFormFactor* FormFactorFullSpheroid::sliceFormFactor(ZLimits limits, const IRota return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorFullSpheroid::onChange() -{ +void FormFactorFullSpheroid::onChange() { m_shape = std::make_unique<TruncatedEllipsoid>(m_radius, m_radius, m_height / 2.0, m_height, 0.0); } diff --git a/Sample/HardParticle/FormFactorFullSpheroid.h b/Sample/HardParticle/FormFactorFullSpheroid.h index c2598ed0590f7906a982d47158b9895eb3bd6f92..f151c6e560f3aeedf569c1883a25a8eb44149bda 100644 --- a/Sample/HardParticle/FormFactorFullSpheroid.h +++ b/Sample/HardParticle/FormFactorFullSpheroid.h @@ -20,14 +20,12 @@ //! A full spheroid (an ellipsoid with two equal axes, hence with circular cross section) //! @ingroup hardParticle -class FormFactorFullSpheroid : public IBornFF -{ +class FormFactorFullSpheroid : public IBornFF { public: FormFactorFullSpheroid(const std::vector<double> P); FormFactorFullSpheroid(double radius, double height); - FormFactorFullSpheroid* clone() const final - { + FormFactorFullSpheroid* clone() const final { return new FormFactorFullSpheroid(m_radius, m_height); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorHemiEllipsoid.cpp b/Sample/HardParticle/FormFactorHemiEllipsoid.cpp index e7f9b0e6b2b54c6350eda03fecd563ebf4184462..648f15c7d02e3442143a2d0f79744d8341fb2120 100644 --- a/Sample/HardParticle/FormFactorHemiEllipsoid.cpp +++ b/Sample/HardParticle/FormFactorHemiEllipsoid.cpp @@ -28,24 +28,19 @@ FormFactorHemiEllipsoid::FormFactorHemiEllipsoid(const std::vector<double> P) P) , m_radius_x(m_P[0]) , m_radius_y(m_P[1]) - , m_height(m_P[2]) -{ + , m_height(m_P[2]) { onChange(); } FormFactorHemiEllipsoid::FormFactorHemiEllipsoid(double radius_x, double radius_y, double height) - : FormFactorHemiEllipsoid(std::vector<double>{radius_x, radius_y, height}) -{ -} + : FormFactorHemiEllipsoid(std::vector<double>{radius_x, radius_y, height}) {} -double FormFactorHemiEllipsoid::radialExtension() const -{ +double FormFactorHemiEllipsoid::radialExtension() const { return (m_radius_x + m_radius_y) / 2.0; } //! Integrand for complex form factor. -complex_t FormFactorHemiEllipsoid::Integrand(double Z) const -{ +complex_t FormFactorHemiEllipsoid::Integrand(double Z) const { double R = m_radius_x; double W = m_radius_y; double H = m_height; @@ -62,8 +57,7 @@ complex_t FormFactorHemiEllipsoid::Integrand(double Z) const return Rz * Wz * J1_gamma_div_gamma * exp_I(m_q.z() * Z); } -complex_t FormFactorHemiEllipsoid::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorHemiEllipsoid::evaluate_for_q(cvector_t q) const { m_q = q; double R = m_radius_x; double W = m_radius_y; @@ -74,7 +68,6 @@ complex_t FormFactorHemiEllipsoid::evaluate_for_q(cvector_t q) const return M_TWOPI * ComplexIntegrator().integrate([&](double Z) { return Integrand(Z); }, 0., H); } -void FormFactorHemiEllipsoid::onChange() -{ +void FormFactorHemiEllipsoid::onChange() { m_shape = std::make_unique<TruncatedEllipsoid>(m_radius_x, m_radius_x, m_height, m_height, 0.0); } diff --git a/Sample/HardParticle/FormFactorHemiEllipsoid.h b/Sample/HardParticle/FormFactorHemiEllipsoid.h index 09f2473ff957c82bbbb8fa3f9123f4efdfcedd10..93ea373a8786236d16fb7c19b0ed679c7b4eccea 100644 --- a/Sample/HardParticle/FormFactorHemiEllipsoid.h +++ b/Sample/HardParticle/FormFactorHemiEllipsoid.h @@ -21,15 +21,13 @@ //! obtained by truncating a full ellipsoid in the middle plane spanned by two principal axes. //! @ingroup hardParticle -class FormFactorHemiEllipsoid : public IBornFF -{ +class FormFactorHemiEllipsoid : public IBornFF { public: FormFactorHemiEllipsoid(const std::vector<double> P); FormFactorHemiEllipsoid(double radius_x, double radius_y, double height); virtual ~FormFactorHemiEllipsoid() {} - FormFactorHemiEllipsoid* clone() const final - { + FormFactorHemiEllipsoid* clone() const final { return new FormFactorHemiEllipsoid(m_radius_x, m_radius_y, m_height); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorHollowSphere.cpp b/Sample/HardParticle/FormFactorHollowSphere.cpp index b231f60d2dfd8b183023690a338620ee680157c0..df8894bb9c9e0fdd460d4140982c586fa0fb83e6 100644 --- a/Sample/HardParticle/FormFactorHollowSphere.cpp +++ b/Sample/HardParticle/FormFactorHollowSphere.cpp @@ -25,8 +25,7 @@ FormFactorHollowSphere::FormFactorHollowSphere(const std::vector<double> P) {"FullWidth", "nm", "para_tooltip", 0, +INF, 0}}}, P) , m_mean(m_P[0]) - , m_full_width(m_P[1]) -{ + , m_full_width(m_P[1]) { if (!checkParameters()) throw Exceptions::ClassInitializationException( "FormFactorHollowSphere::FormFactorHollowSphere:" @@ -35,12 +34,9 @@ FormFactorHollowSphere::FormFactorHollowSphere(const std::vector<double> P) } FormFactorHollowSphere::FormFactorHollowSphere(double mean, double full_width) - : FormFactorHollowSphere(std::vector<double>{mean, full_width}) -{ -} + : FormFactorHollowSphere(std::vector<double>{mean, full_width}) {} -complex_t FormFactorHollowSphere::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorHollowSphere::evaluate_for_q(cvector_t q) const { double R = m_mean; double W = m_full_width; double q2 = std::norm(q.x()) + std::norm(q.y()) + std::norm(q.z()); @@ -56,13 +52,11 @@ complex_t FormFactorHollowSphere::evaluate_for_q(cvector_t q) const return nominator / (q2 * q2 * W); } -void FormFactorHollowSphere::onChange() -{ +void FormFactorHollowSphere::onChange() { m_shape = std::make_unique<TruncatedEllipsoid>(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0); } -bool FormFactorHollowSphere::checkParameters() const -{ +bool FormFactorHollowSphere::checkParameters() const { if (m_full_width <= 0.0) return false; if (2.0 * m_mean < m_full_width) diff --git a/Sample/HardParticle/FormFactorHollowSphere.h b/Sample/HardParticle/FormFactorHollowSphere.h index 03000cade08dbbd2868db083dab49ef65a324a7a..bacecea56815e8febe658b291e467a67db646feb 100644 --- a/Sample/HardParticle/FormFactorHollowSphere.h +++ b/Sample/HardParticle/FormFactorHollowSphere.h @@ -20,14 +20,12 @@ //! Integrated full sphere form factor over a uniform distribution of radii. //! @ingroup softParticle -class FormFactorHollowSphere : public IBornFF -{ +class FormFactorHollowSphere : public IBornFF { public: FormFactorHollowSphere(const std::vector<double> P); FormFactorHollowSphere(double mean, double full_width); - FormFactorHollowSphere* clone() const final - { + FormFactorHollowSphere* clone() const final { return new FormFactorHollowSphere(m_mean, m_full_width); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorIcosahedron.cpp b/Sample/HardParticle/FormFactorIcosahedron.cpp index e17083b9decc3059000849f79700a9787a9d5f92..979015a14bd72547234ec2a7ac4c1a1b11c73e3f 100644 --- a/Sample/HardParticle/FormFactorIcosahedron.cpp +++ b/Sample/HardParticle/FormFactorIcosahedron.cpp @@ -45,18 +45,14 @@ const PolyhedralTopology FormFactorIcosahedron::topology = {{// bottom: FormFactorIcosahedron::FormFactorIcosahedron(const std::vector<double> P) : IFormFactorPolyhedron( {"Icosahedron", "regular icosahedron", {{"Edge", "nm", "edge length", 0, +INF, 0}}}, P) - , m_edge(m_P[0]) -{ + , m_edge(m_P[0]) { onChange(); } FormFactorIcosahedron::FormFactorIcosahedron(double edge) - : FormFactorIcosahedron(std::vector<double>{edge}) -{ -} + : FormFactorIcosahedron(std::vector<double>{edge}) {} -void FormFactorIcosahedron::onChange() -{ +void FormFactorIcosahedron::onChange() { double a = m_edge; setPolyhedron(topology, -0.7557613140761708 * a, {{0.5773502691896258 * a, 0 * a, -0.7557613140761708 * a}, diff --git a/Sample/HardParticle/FormFactorIcosahedron.h b/Sample/HardParticle/FormFactorIcosahedron.h index 30d95f03e98047ef44b7534bd75951e3ffbec9b3..4f9f656c3632b5200e48c396d4a451964801e4b5 100644 --- a/Sample/HardParticle/FormFactorIcosahedron.h +++ b/Sample/HardParticle/FormFactorIcosahedron.h @@ -20,8 +20,7 @@ //! A regular icosahedron. //! @ingroup hardParticle -class FormFactorIcosahedron : public IFormFactorPolyhedron -{ +class FormFactorIcosahedron : public IFormFactorPolyhedron { public: FormFactorIcosahedron(const std::vector<double> P); FormFactorIcosahedron(double edge); diff --git a/Sample/HardParticle/FormFactorLongBoxGauss.cpp b/Sample/HardParticle/FormFactorLongBoxGauss.cpp index 8f10a894aaacd254c90e9fe7129b17a7b85664cc..2af68ed22b57947c39f0ea2892b2bf8b9047d041 100644 --- a/Sample/HardParticle/FormFactorLongBoxGauss.cpp +++ b/Sample/HardParticle/FormFactorLongBoxGauss.cpp @@ -25,18 +25,14 @@ FormFactorLongBoxGauss::FormFactorLongBoxGauss(const std::vector<double> P) P) , m_length(m_P[0]) , m_width(m_P[1]) - , m_height(m_P[2]) -{ + , m_height(m_P[2]) { onChange(); } FormFactorLongBoxGauss::FormFactorLongBoxGauss(double length, double width, double height) - : FormFactorLongBoxGauss(std::vector<double>{length, width, height}) -{ -} + : FormFactorLongBoxGauss(std::vector<double>{length, width, height}) {} -complex_t FormFactorLongBoxGauss::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorLongBoxGauss::evaluate_for_q(cvector_t q) const { complex_t qxL2 = std::pow(m_length * q.x(), 2) / 2.0; complex_t qyWdiv2 = m_width * q.y() / 2.0; complex_t qzHdiv2 = m_height * q.z() / 2.0; @@ -46,15 +42,13 @@ complex_t FormFactorLongBoxGauss::evaluate_for_q(cvector_t q) const } IFormFactor* FormFactorLongBoxGauss::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); FormFactorLongBoxGauss slicedff(m_length, m_width, m_height - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorLongBoxGauss::onChange() -{ +void FormFactorLongBoxGauss::onChange() { m_shape = std::make_unique<Box>(m_length, m_width, m_height); } diff --git a/Sample/HardParticle/FormFactorLongBoxGauss.h b/Sample/HardParticle/FormFactorLongBoxGauss.h index 972091a682a75845e7abd9f14f9c7dd6d0237871..9113eb5cb24b297c542fe1fb8af5850953d1caf6 100644 --- a/Sample/HardParticle/FormFactorLongBoxGauss.h +++ b/Sample/HardParticle/FormFactorLongBoxGauss.h @@ -20,14 +20,12 @@ //! The form factor for a long rectangular box. //! @ingroup legacyGrating -class FormFactorLongBoxGauss : public IBornFF -{ +class FormFactorLongBoxGauss : public IBornFF { public: FormFactorLongBoxGauss(const std::vector<double> P); FormFactorLongBoxGauss(double length, double width, double height); - FormFactorLongBoxGauss* clone() const final - { + FormFactorLongBoxGauss* clone() const final { return new FormFactorLongBoxGauss(m_length, m_width, m_height); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorLongBoxLorentz.cpp b/Sample/HardParticle/FormFactorLongBoxLorentz.cpp index 5b0fbd6bd9c6b144ea8d5f9968fd83ac74132d03..e6d87568d30a85941146e76737756398f90c8251 100644 --- a/Sample/HardParticle/FormFactorLongBoxLorentz.cpp +++ b/Sample/HardParticle/FormFactorLongBoxLorentz.cpp @@ -25,18 +25,14 @@ FormFactorLongBoxLorentz::FormFactorLongBoxLorentz(const std::vector<double> P) P) , m_length(m_P[0]) , m_width(m_P[1]) - , m_height(m_P[2]) -{ + , m_height(m_P[2]) { onChange(); } FormFactorLongBoxLorentz::FormFactorLongBoxLorentz(double length, double width, double height) - : FormFactorLongBoxLorentz(std::vector<double>{length, width, height}) -{ -} + : FormFactorLongBoxLorentz(std::vector<double>{length, width, height}) {} -complex_t FormFactorLongBoxLorentz::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorLongBoxLorentz::evaluate_for_q(cvector_t q) const { complex_t qxL2 = 2.5 * std::pow(m_length * q.x(), 2); complex_t qyWdiv2 = m_width * q.y() / 2.0; complex_t qzHdiv2 = m_height * q.z() / 2.0; @@ -46,15 +42,13 @@ complex_t FormFactorLongBoxLorentz::evaluate_for_q(cvector_t q) const } IFormFactor* FormFactorLongBoxLorentz::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); FormFactorLongBoxLorentz slicedff(m_length, m_width, m_height - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorLongBoxLorentz::onChange() -{ +void FormFactorLongBoxLorentz::onChange() { m_shape = std::make_unique<Box>(m_length, m_width, m_height); } diff --git a/Sample/HardParticle/FormFactorLongBoxLorentz.h b/Sample/HardParticle/FormFactorLongBoxLorentz.h index 32cea60893ed4e6498beff7a2c83679a9f8548c0..8e44e78886a3faa40f2927a447000c389cf12f1f 100644 --- a/Sample/HardParticle/FormFactorLongBoxLorentz.h +++ b/Sample/HardParticle/FormFactorLongBoxLorentz.h @@ -20,14 +20,12 @@ //! The form factor for a long rectangular box. //! @ingroup legacyGrating -class FormFactorLongBoxLorentz : public IBornFF -{ +class FormFactorLongBoxLorentz : public IBornFF { public: FormFactorLongBoxLorentz(const std::vector<double> P); FormFactorLongBoxLorentz(double length, double width, double height); - FormFactorLongBoxLorentz* clone() const final - { + FormFactorLongBoxLorentz* clone() const final { return new FormFactorLongBoxLorentz(m_length, m_width, m_height); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorPrism3.cpp b/Sample/HardParticle/FormFactorPrism3.cpp index ddb39a7cc278222f888d90e52d630bd3d366cd95..d9b9968a59d73b38fe3033c35dcc3fd03b508f04 100644 --- a/Sample/HardParticle/FormFactorPrism3.cpp +++ b/Sample/HardParticle/FormFactorPrism3.cpp @@ -22,26 +22,21 @@ FormFactorPrism3::FormFactorPrism3(const std::vector<double> P) {"Height", "nm", "height", 0, +INF, 0}}}, P) , m_base_edge(m_P[0]) - , m_height(m_P[1]) -{ + , m_height(m_P[1]) { onChange(); } FormFactorPrism3::FormFactorPrism3(double base_edge, double height) - : FormFactorPrism3(std::vector<double>{base_edge, height}) -{ -} + : FormFactorPrism3(std::vector<double>{base_edge, height}) {} IFormFactor* FormFactorPrism3::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); FormFactorPrism3 slicedff(m_base_edge, m_height - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorPrism3::onChange() -{ +void FormFactorPrism3::onChange() { double a = m_base_edge; double as = a / 2; double ac = a / sqrt(3) / 2; diff --git a/Sample/HardParticle/FormFactorPrism3.h b/Sample/HardParticle/FormFactorPrism3.h index 34778434c6b8a2d8dbf0d3fcbf351faf96119143..39bc0ace77e5fd26b8a117a9bd84e56e7bd41020 100644 --- a/Sample/HardParticle/FormFactorPrism3.h +++ b/Sample/HardParticle/FormFactorPrism3.h @@ -20,8 +20,7 @@ //! A prism based on an equilateral triangle. //! @ingroup hardParticle -class FormFactorPrism3 : public IFormFactorPrism -{ +class FormFactorPrism3 : public IFormFactorPrism { public: FormFactorPrism3(const std::vector<double> P); FormFactorPrism3(double base_edge, double height); diff --git a/Sample/HardParticle/FormFactorPrism6.cpp b/Sample/HardParticle/FormFactorPrism6.cpp index d135d4bd610be4ffd21cdc7800f9b8db2146d580..0212ba7644cef4e38655ee18ec066cf4f7f983d2 100644 --- a/Sample/HardParticle/FormFactorPrism6.cpp +++ b/Sample/HardParticle/FormFactorPrism6.cpp @@ -21,26 +21,21 @@ FormFactorPrism6::FormFactorPrism6(const std::vector<double> P) {"Height", "nm", "height", 0, +INF, 0}}}, P) , m_base_edge(m_P[0]) - , m_height(m_P[1]) -{ + , m_height(m_P[1]) { onChange(); } FormFactorPrism6::FormFactorPrism6(double base_edge, double height) - : FormFactorPrism6(std::vector<double>{base_edge, height}) -{ -} + : FormFactorPrism6(std::vector<double>{base_edge, height}) {} IFormFactor* FormFactorPrism6::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); FormFactorPrism6 slicedff(m_base_edge, m_height - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorPrism6::onChange() -{ +void FormFactorPrism6::onChange() { double a = m_base_edge; double as = a * sqrt(3) / 2; double ac = a / 2; diff --git a/Sample/HardParticle/FormFactorPrism6.h b/Sample/HardParticle/FormFactorPrism6.h index 79e9c816ef0517f172cb1b96dbdfdf6d55b8f097..09708d07c81b0628e3998908e342cd73351ecf2c 100644 --- a/Sample/HardParticle/FormFactorPrism6.h +++ b/Sample/HardParticle/FormFactorPrism6.h @@ -20,8 +20,7 @@ //! A prism based on a regular hexagonal. //! @ingroup hardParticle -class FormFactorPrism6 : public IFormFactorPrism -{ +class FormFactorPrism6 : public IFormFactorPrism { public: FormFactorPrism6(const std::vector<double> P); FormFactorPrism6(double base_edge, double height); diff --git a/Sample/HardParticle/FormFactorPyramid.cpp b/Sample/HardParticle/FormFactorPyramid.cpp index 305adcce7d75b72cfb0ddaee94cf04edf35c76f3..febf03f9a3bf551dae5febb460bf868a409c3ef0 100644 --- a/Sample/HardParticle/FormFactorPyramid.cpp +++ b/Sample/HardParticle/FormFactorPyramid.cpp @@ -36,19 +36,15 @@ FormFactorPyramid::FormFactorPyramid(const std::vector<double> P) P) , m_base_edge(m_P[0]) , m_height(m_P[1]) - , m_alpha(m_P[2]) -{ + , m_alpha(m_P[2]) { onChange(); } FormFactorPyramid::FormFactorPyramid(double base_edge, double height, double alpha) - : FormFactorPyramid(std::vector<double>{base_edge, height, alpha}) -{ -} + : FormFactorPyramid(std::vector<double>{base_edge, height, alpha}) {} IFormFactor* FormFactorPyramid::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); double dbase_edge = 2 * effects.dz_bottom * Math::cot(m_alpha); FormFactorPyramid slicedff(m_base_edge - dbase_edge, @@ -56,8 +52,7 @@ IFormFactor* FormFactorPyramid::sliceFormFactor(ZLimits limits, const IRotation& return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorPyramid::onChange() -{ +void FormFactorPyramid::onChange() { double cot_alpha = Math::cot(m_alpha); if (!std::isfinite(cot_alpha)) throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds"); diff --git a/Sample/HardParticle/FormFactorPyramid.h b/Sample/HardParticle/FormFactorPyramid.h index 92529980f5e6613ea1dcca06563a1a1cdc86bdb6..6550c10bf59ae991cac823ad81916aba56dcfd82 100644 --- a/Sample/HardParticle/FormFactorPyramid.h +++ b/Sample/HardParticle/FormFactorPyramid.h @@ -20,14 +20,12 @@ //! A frustum with a quadratic base. //! @ingroup hardParticle -class FormFactorPyramid : public IFormFactorPolyhedron -{ +class FormFactorPyramid : public IFormFactorPolyhedron { public: FormFactorPyramid(const std::vector<double> P); FormFactorPyramid(double base_edge, double height, double alpha); - FormFactorPyramid* clone() const final - { + FormFactorPyramid* clone() const final { return new FormFactorPyramid(m_base_edge, m_height, m_alpha); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorSawtoothRipple.cpp b/Sample/HardParticle/FormFactorSawtoothRipple.cpp index c9272daae68d1eaf3f295e79a34b8c5f9ecda73a..72debca32006147a8dab2474a16a56ffc501398e 100644 --- a/Sample/HardParticle/FormFactorSawtoothRipple.cpp +++ b/Sample/HardParticle/FormFactorSawtoothRipple.cpp @@ -20,28 +20,21 @@ // ************************************************************************************************ FormFactorSawtoothRippleBox::FormFactorSawtoothRippleBox(const std::vector<double> P) - : ISawtoothRipple({"SawtoothRippleBox", "class_tooltip", {}}, P) -{ -} + : ISawtoothRipple({"SawtoothRippleBox", "class_tooltip", {}}, P) {} FormFactorSawtoothRippleBox::FormFactorSawtoothRippleBox(double length, double width, double height, double asymmetry) - : FormFactorSawtoothRippleBox(std::vector<double>{length, width, height, asymmetry}) -{ -} + : FormFactorSawtoothRippleBox(std::vector<double>{length, width, height, asymmetry}) {} -FormFactorSawtoothRippleBox* FormFactorSawtoothRippleBox::clone() const -{ +FormFactorSawtoothRippleBox* FormFactorSawtoothRippleBox::clone() const { return new FormFactorSawtoothRippleBox(m_length, m_width, m_height, m_asymmetry); } -void FormFactorSawtoothRippleBox::accept(INodeVisitor* visitor) const -{ +void FormFactorSawtoothRippleBox::accept(INodeVisitor* visitor) const { visitor->visit(this); } -complex_t FormFactorSawtoothRippleBox::factor_x(complex_t qx) const -{ +complex_t FormFactorSawtoothRippleBox::factor_x(complex_t qx) const { return ripples::factor_x_box(qx, m_length); } @@ -50,28 +43,21 @@ complex_t FormFactorSawtoothRippleBox::factor_x(complex_t qx) const // ************************************************************************************************ FormFactorSawtoothRippleGauss::FormFactorSawtoothRippleGauss(const std::vector<double> P) - : ISawtoothRipple({"SawtoothRippleGauss", "class_tooltip", {}}, P) -{ -} + : ISawtoothRipple({"SawtoothRippleGauss", "class_tooltip", {}}, P) {} FormFactorSawtoothRippleGauss::FormFactorSawtoothRippleGauss(double length, double width, double height, double asymmetry) - : FormFactorSawtoothRippleGauss(std::vector<double>{length, width, height, asymmetry}) -{ -} + : FormFactorSawtoothRippleGauss(std::vector<double>{length, width, height, asymmetry}) {} -FormFactorSawtoothRippleGauss* FormFactorSawtoothRippleGauss::clone() const -{ +FormFactorSawtoothRippleGauss* FormFactorSawtoothRippleGauss::clone() const { return new FormFactorSawtoothRippleGauss(m_length, m_width, m_height, m_asymmetry); } -void FormFactorSawtoothRippleGauss::accept(INodeVisitor* visitor) const -{ +void FormFactorSawtoothRippleGauss::accept(INodeVisitor* visitor) const { visitor->visit(this); } -complex_t FormFactorSawtoothRippleGauss::factor_x(complex_t qx) const -{ +complex_t FormFactorSawtoothRippleGauss::factor_x(complex_t qx) const { return ripples::factor_x_Gauss(qx, m_length); } @@ -80,27 +66,20 @@ complex_t FormFactorSawtoothRippleGauss::factor_x(complex_t qx) const // ************************************************************************************************ FormFactorSawtoothRippleLorentz::FormFactorSawtoothRippleLorentz(const std::vector<double> P) - : ISawtoothRipple({"SawtoothRippleLorentz", "class_tooltip", {}}, P) -{ -} + : ISawtoothRipple({"SawtoothRippleLorentz", "class_tooltip", {}}, P) {} FormFactorSawtoothRippleLorentz::FormFactorSawtoothRippleLorentz(double length, double width, double height, double asymmetry) - : FormFactorSawtoothRippleLorentz(std::vector<double>{length, width, height, asymmetry}) -{ -} + : FormFactorSawtoothRippleLorentz(std::vector<double>{length, width, height, asymmetry}) {} -FormFactorSawtoothRippleLorentz* FormFactorSawtoothRippleLorentz::clone() const -{ +FormFactorSawtoothRippleLorentz* FormFactorSawtoothRippleLorentz::clone() const { return new FormFactorSawtoothRippleLorentz(m_length, m_width, m_height, m_asymmetry); } -void FormFactorSawtoothRippleLorentz::accept(INodeVisitor* visitor) const -{ +void FormFactorSawtoothRippleLorentz::accept(INodeVisitor* visitor) const { visitor->visit(this); } -complex_t FormFactorSawtoothRippleLorentz::factor_x(complex_t qx) const -{ +complex_t FormFactorSawtoothRippleLorentz::factor_x(complex_t qx) const { return ripples::factor_x_Lorentz(qx, m_length); } diff --git a/Sample/HardParticle/FormFactorSawtoothRipple.h b/Sample/HardParticle/FormFactorSawtoothRipple.h index 33b4399ebb912e696cf2cac315b457f431dfcce5..44c352614e918a1cfe467827fa158154470ab6b6 100644 --- a/Sample/HardParticle/FormFactorSawtoothRipple.h +++ b/Sample/HardParticle/FormFactorSawtoothRipple.h @@ -19,8 +19,7 @@ //! The form factor for a cosine ripple, with box profile in elongation direction. //! @ingroup legacyGrating -class FormFactorSawtoothRippleBox : public ISawtoothRipple -{ +class FormFactorSawtoothRippleBox : public ISawtoothRipple { public: FormFactorSawtoothRippleBox(const std::vector<double> P); FormFactorSawtoothRippleBox(double length, double width, double height, double asymmetry); @@ -33,8 +32,7 @@ private: //! The form factor for a cosine ripple, with Gaussian profile in elongation direction. //! @ingroup legacyGrating -class FormFactorSawtoothRippleGauss : public ISawtoothRipple -{ +class FormFactorSawtoothRippleGauss : public ISawtoothRipple { public: FormFactorSawtoothRippleGauss(const std::vector<double> P); FormFactorSawtoothRippleGauss(double length, double width, double height, double asymmetry); @@ -47,8 +45,7 @@ private: //! The form factor for a cosine ripple, with Lorentz form factor in elongation direction. //! @ingroup legacyGrating -class FormFactorSawtoothRippleLorentz : public ISawtoothRipple -{ +class FormFactorSawtoothRippleLorentz : public ISawtoothRipple { public: FormFactorSawtoothRippleLorentz(const std::vector<double> P); FormFactorSawtoothRippleLorentz(double length, double width, double height, double asymmetry); diff --git a/Sample/HardParticle/FormFactorTetrahedron.cpp b/Sample/HardParticle/FormFactorTetrahedron.cpp index d1756f136b7993032ff0ac7259725a0cdd7aa4f2..030e4bb0d6f8b1bc7d9550ea1cf25ebf5b529c8d 100644 --- a/Sample/HardParticle/FormFactorTetrahedron.cpp +++ b/Sample/HardParticle/FormFactorTetrahedron.cpp @@ -34,19 +34,15 @@ FormFactorTetrahedron::FormFactorTetrahedron(const std::vector<double> P) P) , m_base_edge(m_P[0]) , m_height(m_P[1]) - , m_alpha(m_P[2]) -{ + , m_alpha(m_P[2]) { onChange(); } FormFactorTetrahedron::FormFactorTetrahedron(double base_edge, double height, double alpha) - : FormFactorTetrahedron(std::vector<double>{base_edge, height, alpha}) -{ -} + : FormFactorTetrahedron(std::vector<double>{base_edge, height, alpha}) {} IFormFactor* FormFactorTetrahedron::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { auto effects = computeSlicingEffects(limits, translation, m_height); double dbase_edge = 2 * sqrt(3) * effects.dz_bottom * Math::cot(m_alpha); FormFactorTetrahedron slicedff(m_base_edge - dbase_edge, @@ -54,8 +50,7 @@ IFormFactor* FormFactorTetrahedron::sliceFormFactor(ZLimits limits, const IRotat return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorTetrahedron::onChange() -{ +void FormFactorTetrahedron::onChange() { double cot_alpha = Math::cot(m_alpha); if (!std::isfinite(cot_alpha) || cot_alpha < 0) throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds"); diff --git a/Sample/HardParticle/FormFactorTetrahedron.h b/Sample/HardParticle/FormFactorTetrahedron.h index 822aff2218aa3728b8d1daee0b2b37d0016148db..d4ffbc86b88c14611c2e4edea8b941f98a675fb5 100644 --- a/Sample/HardParticle/FormFactorTetrahedron.h +++ b/Sample/HardParticle/FormFactorTetrahedron.h @@ -20,14 +20,12 @@ //! A frustum with equilateral trigonal base. //! @ingroup hardParticle -class FormFactorTetrahedron : public IFormFactorPolyhedron -{ +class FormFactorTetrahedron : public IFormFactorPolyhedron { public: FormFactorTetrahedron(const std::vector<double> P); FormFactorTetrahedron(double base_edge, double height, double alpha); - FormFactorTetrahedron* clone() const final - { + FormFactorTetrahedron* clone() const final { return new FormFactorTetrahedron(m_base_edge, m_height, m_alpha); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorTruncatedCube.cpp b/Sample/HardParticle/FormFactorTruncatedCube.cpp index dea3293c224e7318399bf40b190c11d3617cac19..7d55bd80d3548861eb21961e7132a836b835985b 100644 --- a/Sample/HardParticle/FormFactorTruncatedCube.cpp +++ b/Sample/HardParticle/FormFactorTruncatedCube.cpp @@ -40,18 +40,14 @@ FormFactorTruncatedCube::FormFactorTruncatedCube(const std::vector<double> P) {"RemovedLength", "nm", "edge length removed from one corner", 0, +INF, 0}}}, P) , m_length(m_P[0]) - , m_removed_length(m_P[1]) -{ + , m_removed_length(m_P[1]) { onChange(); } FormFactorTruncatedCube::FormFactorTruncatedCube(double length, double removed_length) - : FormFactorTruncatedCube(std::vector<double>{length, removed_length}) -{ -} + : FormFactorTruncatedCube(std::vector<double>{length, removed_length}) {} -void FormFactorTruncatedCube::onChange() -{ +void FormFactorTruncatedCube::onChange() { if (m_removed_length > 0.5 * m_length) { std::ostringstream ostr; ostr << "::FormFactorTruncatedCube() -> Error in class initialization "; diff --git a/Sample/HardParticle/FormFactorTruncatedCube.h b/Sample/HardParticle/FormFactorTruncatedCube.h index f0acaaecc66882b299507df23687556acb2dd8cf..9fc02fdc91d77535e8347beee21dafef9ce69d09 100644 --- a/Sample/HardParticle/FormFactorTruncatedCube.h +++ b/Sample/HardParticle/FormFactorTruncatedCube.h @@ -20,14 +20,12 @@ //! A cube, with tetrahedral truncation of all corners //! @ingroup hardParticle -class FormFactorTruncatedCube : public IFormFactorPolyhedron -{ +class FormFactorTruncatedCube : public IFormFactorPolyhedron { public: FormFactorTruncatedCube(const std::vector<double> P); FormFactorTruncatedCube(double length, double removed_length); - FormFactorTruncatedCube* clone() const final - { + FormFactorTruncatedCube* clone() const final { return new FormFactorTruncatedCube(m_length, m_removed_length); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorTruncatedSphere.cpp b/Sample/HardParticle/FormFactorTruncatedSphere.cpp index bb192cf2b665b674173eb1604c94e5877c573d1d..0d8033c7e385c6a72f9f46d664b3810b89759350 100644 --- a/Sample/HardParticle/FormFactorTruncatedSphere.cpp +++ b/Sample/HardParticle/FormFactorTruncatedSphere.cpp @@ -29,19 +29,15 @@ FormFactorTruncatedSphere::FormFactorTruncatedSphere(const std::vector<double> P P) , m_radius(m_P[0]) , m_height(m_P[1]) - , m_dh(m_P[2]) -{ + , m_dh(m_P[2]) { check_initialization(); onChange(); } FormFactorTruncatedSphere::FormFactorTruncatedSphere(double radius, double height, double dh) - : FormFactorTruncatedSphere(std::vector<double>{radius, height, dh}) -{ -} + : FormFactorTruncatedSphere(std::vector<double>{radius, height, dh}) {} -bool FormFactorTruncatedSphere::check_initialization() const -{ +bool FormFactorTruncatedSphere::check_initialization() const { bool result(true); if (m_height > 2. * m_radius || m_dh > m_height) { std::ostringstream ostr; @@ -55,8 +51,7 @@ bool FormFactorTruncatedSphere::check_initialization() const } //! Integrand for complex form factor. -complex_t FormFactorTruncatedSphere::Integrand(double Z) const -{ +complex_t FormFactorTruncatedSphere::Integrand(double Z) const { double Rz = std::sqrt(m_radius * m_radius - Z * Z); complex_t qx = m_q.x(); complex_t qy = m_q.y(); @@ -65,8 +60,7 @@ complex_t FormFactorTruncatedSphere::Integrand(double Z) const } //! Complex form factor. -complex_t FormFactorTruncatedSphere::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorTruncatedSphere::evaluate_for_q(cvector_t q) const { m_q = q; if (std::abs(q.mag()) < std::numeric_limits<double>::epsilon()) { return M_PI / 3. @@ -80,8 +74,7 @@ complex_t FormFactorTruncatedSphere::evaluate_for_q(cvector_t q) const } IFormFactor* FormFactorTruncatedSphere::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { double height = m_height - m_dh; auto effects = computeSlicingEffects(limits, translation, height); FormFactorTruncatedSphere slicedff(m_radius, m_height - effects.dz_bottom, @@ -89,7 +82,6 @@ IFormFactor* FormFactorTruncatedSphere::sliceFormFactor(ZLimits limits, const IR return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorTruncatedSphere::onChange() -{ +void FormFactorTruncatedSphere::onChange() { m_shape = std::make_unique<TruncatedEllipsoid>(m_radius, m_radius, m_radius, m_height, m_dh); } diff --git a/Sample/HardParticle/FormFactorTruncatedSphere.h b/Sample/HardParticle/FormFactorTruncatedSphere.h index b3a375c493acff9f865cc395aeb9694157fc92ec..7416a6ee51403d5e9892455b9472dbfbe1dd2978 100644 --- a/Sample/HardParticle/FormFactorTruncatedSphere.h +++ b/Sample/HardParticle/FormFactorTruncatedSphere.h @@ -20,14 +20,12 @@ //! A truncated Sphere. //! @ingroup hardParticle -class FormFactorTruncatedSphere : public IBornFF -{ +class FormFactorTruncatedSphere : public IBornFF { public: FormFactorTruncatedSphere(const std::vector<double> P); FormFactorTruncatedSphere(double radius, double height, double dh); - FormFactorTruncatedSphere* clone() const final - { + FormFactorTruncatedSphere* clone() const final { return new FormFactorTruncatedSphere(m_radius, m_height, m_dh); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/FormFactorTruncatedSpheroid.cpp b/Sample/HardParticle/FormFactorTruncatedSpheroid.cpp index 20ab716ecc43bb19e1e4a8bf8dca6454c3ba4e9e..d6627d3f7325236fe4dea8bfef40233749e8fdca 100644 --- a/Sample/HardParticle/FormFactorTruncatedSpheroid.cpp +++ b/Sample/HardParticle/FormFactorTruncatedSpheroid.cpp @@ -31,20 +31,16 @@ FormFactorTruncatedSpheroid::FormFactorTruncatedSpheroid(const std::vector<doubl , m_radius(m_P[0]) , m_height(m_P[1]) , m_height_flattening(m_P[2]) - , m_dh(m_P[3]) -{ + , m_dh(m_P[3]) { check_initialization(); onChange(); } FormFactorTruncatedSpheroid::FormFactorTruncatedSpheroid(double radius, double height, double height_flattening, double dh) - : FormFactorTruncatedSpheroid(std::vector<double>{radius, height, height_flattening, dh}) -{ -} + : FormFactorTruncatedSpheroid(std::vector<double>{radius, height, height_flattening, dh}) {} -bool FormFactorTruncatedSpheroid::check_initialization() const -{ +bool FormFactorTruncatedSpheroid::check_initialization() const { bool result(true); if (m_height > 2. * m_radius * m_height_flattening || m_dh > m_height) { std::ostringstream ostr; @@ -59,8 +55,7 @@ bool FormFactorTruncatedSpheroid::check_initialization() const } //! Integrand for complex form factor. -complex_t FormFactorTruncatedSpheroid::Integrand(double Z) const -{ +complex_t FormFactorTruncatedSpheroid::Integrand(double Z) const { double R = m_radius; double fp = m_height_flattening; @@ -71,8 +66,7 @@ complex_t FormFactorTruncatedSpheroid::Integrand(double Z) const return Rz * Rz * J1_qrRz_div_qrRz * exp_I(m_q.z() * Z); } -complex_t FormFactorTruncatedSpheroid::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorTruncatedSpheroid::evaluate_for_q(cvector_t q) const { double H = m_height; double R = m_radius; double fp = m_height_flattening; @@ -87,8 +81,7 @@ complex_t FormFactorTruncatedSpheroid::evaluate_for_q(cvector_t q) const } IFormFactor* FormFactorTruncatedSpheroid::sliceFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { double height = m_height - m_dh; auto effects = computeSlicingEffects(limits, translation, height); FormFactorTruncatedSpheroid slicedff(m_radius, height - effects.dz_bottom, m_height_flattening, @@ -96,8 +89,7 @@ IFormFactor* FormFactorTruncatedSpheroid::sliceFormFactor(ZLimits limits, const return createTransformedFormFactor(slicedff, rot, effects.position); } -void FormFactorTruncatedSpheroid::onChange() -{ +void FormFactorTruncatedSpheroid::onChange() { m_shape.reset( new TruncatedEllipsoid(m_radius, m_radius, m_height_flattening * m_radius, m_height, m_dh)); } diff --git a/Sample/HardParticle/FormFactorTruncatedSpheroid.h b/Sample/HardParticle/FormFactorTruncatedSpheroid.h index ffae06204a8ff16e08bc8a86bf370f1e2e5c6009..7b11c53813311495c3b2ec361805152c98f0ecbe 100644 --- a/Sample/HardParticle/FormFactorTruncatedSpheroid.h +++ b/Sample/HardParticle/FormFactorTruncatedSpheroid.h @@ -21,14 +21,12 @@ //! An ellipsoid with two equal axis, truncated by a plane perpendicular to the third axis. //! @ingroup hardParticle -class FormFactorTruncatedSpheroid : public IBornFF -{ +class FormFactorTruncatedSpheroid : public IBornFF { public: FormFactorTruncatedSpheroid(const std::vector<double> P); FormFactorTruncatedSpheroid(double radius, double height, double height_flattening, double dh); - FormFactorTruncatedSpheroid* clone() const final - { + FormFactorTruncatedSpheroid* clone() const final { return new FormFactorTruncatedSpheroid(m_radius, m_height, m_height_flattening, m_dh); } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Sample/HardParticle/IFormFactorPolyhedron.cpp b/Sample/HardParticle/IFormFactorPolyhedron.cpp index 41895138eaf0f0098f64b2b0aa556a6aa6458b0b..0cc4f747892105c025198841e0801e384b82027f 100644 --- a/Sample/HardParticle/IFormFactorPolyhedron.cpp +++ b/Sample/HardParticle/IFormFactorPolyhedron.cpp @@ -20,8 +20,7 @@ #include "Sample/HardParticle/Polyhedron.h" #ifdef POLYHEDRAL_DIAGNOSTIC // TODO restore -void IFormFactorPolyhedron::setLimits(double _q, int _n) -{ +void IFormFactorPolyhedron::setLimits(double _q, int _n) { q_limit_series = _q; n_limit_series = _n; } @@ -29,52 +28,42 @@ void IFormFactorPolyhedron::setLimits(double _q, int _n) IFormFactorPolyhedron::IFormFactorPolyhedron(const NodeMeta& meta, const std::vector<double>& PValues) - : IBornFF(meta, PValues) -{ -} + : IBornFF(meta, PValues) {} IFormFactorPolyhedron::~IFormFactorPolyhedron() = default; //! Called by child classes to set faces and other internal variables. void IFormFactorPolyhedron::setPolyhedron(const PolyhedralTopology& topology, double z_bottom, - const std::vector<kvector_t>& vertices) -{ + const std::vector<kvector_t>& vertices) { pimpl = std::make_unique<Polyhedron>(topology, z_bottom, vertices); } -double IFormFactorPolyhedron::bottomZ(const IRotation& rotation) const -{ +double IFormFactorPolyhedron::bottomZ(const IRotation& rotation) const { return BottomZ(pimpl->vertices(), rotation); } -double IFormFactorPolyhedron::topZ(const IRotation& rotation) const -{ +double IFormFactorPolyhedron::topZ(const IRotation& rotation) const { return TopZ(pimpl->vertices(), rotation); } -complex_t IFormFactorPolyhedron::evaluate_for_q(cvector_t q) const -{ +complex_t IFormFactorPolyhedron::evaluate_for_q(cvector_t q) const { return pimpl->evaluate_for_q(q); } -complex_t IFormFactorPolyhedron::evaluate_centered(cvector_t q) const -{ +complex_t IFormFactorPolyhedron::evaluate_centered(cvector_t q) const { return pimpl->evaluate_centered(q); } -double IFormFactorPolyhedron::volume() const -{ +double IFormFactorPolyhedron::volume() const { return pimpl->volume(); } -double IFormFactorPolyhedron::radialExtension() const -{ +double IFormFactorPolyhedron::radialExtension() const { return pimpl->radius(); } //! Assertions for Platonic solid. -void IFormFactorPolyhedron::assert_platonic() const -{ +void IFormFactorPolyhedron::assert_platonic() const { pimpl->assert_platonic(); } diff --git a/Sample/HardParticle/IFormFactorPolyhedron.h b/Sample/HardParticle/IFormFactorPolyhedron.h index 7aaa460d50a9e59f2492a1231a21ae41a8cd95ed..9ac8dc0c94cf6daec31a486a232d104682c67a40 100644 --- a/Sample/HardParticle/IFormFactorPolyhedron.h +++ b/Sample/HardParticle/IFormFactorPolyhedron.h @@ -23,8 +23,7 @@ class Polyhedron; //! A polyhedron, for form factor computation. -class IFormFactorPolyhedron : public IBornFF -{ +class IFormFactorPolyhedron : public IBornFF { public: #ifdef POLYHEDRAL_DIAGNOSTIC static void setLimits(double _q, int _n); diff --git a/Sample/HardParticle/IFormFactorPrism.cpp b/Sample/HardParticle/IFormFactorPrism.cpp index ef987ce525ad8c81290648d617035af2dfcd217d..dc7c1d5a9b1aea3ac13909091f5783430a01b39b 100644 --- a/Sample/HardParticle/IFormFactorPrism.cpp +++ b/Sample/HardParticle/IFormFactorPrism.cpp @@ -16,45 +16,36 @@ #include "Sample/HardParticle/Prism.h" IFormFactorPrism::IFormFactorPrism(const NodeMeta& meta, const std::vector<double>& PValues) - : IBornFF(meta, PValues) -{ -} + : IBornFF(meta, PValues) {} IFormFactorPrism::~IFormFactorPrism() = default; -void IFormFactorPrism::setPrism(bool symmetry_Ci, const std::vector<kvector_t>& vertices) -{ +void IFormFactorPrism::setPrism(bool symmetry_Ci, const std::vector<kvector_t>& vertices) { pimpl = std::make_unique<Prism>(symmetry_Ci, height(), vertices); } -double IFormFactorPrism::bottomZ(const IRotation& rotation) const -{ +double IFormFactorPrism::bottomZ(const IRotation& rotation) const { return BottomZ(pimpl->vertices(), rotation); } -double IFormFactorPrism::topZ(const IRotation& rotation) const -{ +double IFormFactorPrism::topZ(const IRotation& rotation) const { return TopZ(pimpl->vertices(), rotation); } //! Returns the volume of this prism. -double IFormFactorPrism::volume() const -{ +double IFormFactorPrism::volume() const { return height() * pimpl->area(); } -double IFormFactorPrism::getHeight() const -{ +double IFormFactorPrism::getHeight() const { return height(); } -double IFormFactorPrism::radialExtension() const -{ +double IFormFactorPrism::radialExtension() const { return std::sqrt(pimpl->area()); } //! Returns the form factor F(q) of this polyhedron, respecting the offset height/2. -complex_t IFormFactorPrism::evaluate_for_q(cvector_t q) const -{ +complex_t IFormFactorPrism::evaluate_for_q(cvector_t q) const { return pimpl->evaluate_for_q(q); } diff --git a/Sample/HardParticle/IFormFactorPrism.h b/Sample/HardParticle/IFormFactorPrism.h index e3d01082f5de01724eb852e602f7252f0a2a6870..701fb7d0f234551bf7ef306955e2b8871a07a619 100644 --- a/Sample/HardParticle/IFormFactorPrism.h +++ b/Sample/HardParticle/IFormFactorPrism.h @@ -22,8 +22,7 @@ class Prism; //! A prism with a polygonal base, for form factor computation. -class IFormFactorPrism : public IBornFF -{ +class IFormFactorPrism : public IBornFF { public: IFormFactorPrism(const NodeMeta& meta, const std::vector<double>& PValues); ~IFormFactorPrism(); diff --git a/Sample/HardParticle/IProfileRipple.cpp b/Sample/HardParticle/IProfileRipple.cpp index f00db73ad6a403d0630305dda7d0ca19dadd5ac2..60fb7f0fa304afecf01765c3b89731be50731297 100644 --- a/Sample/HardParticle/IProfileRipple.cpp +++ b/Sample/HardParticle/IProfileRipple.cpp @@ -30,17 +30,13 @@ IProfileRipple::IProfileRipple(const NodeMeta& meta, const std::vector<double>& PValues) , m_length(m_P[0]) , m_width(m_P[1]) - , m_height(m_P[2]) -{ -} + , m_height(m_P[2]) {} -double IProfileRipple::radialExtension() const -{ +double IProfileRipple::radialExtension() const { return (m_width + m_length) / 4.0; } -complex_t IProfileRipple::evaluate_for_q(cvector_t q) const -{ +complex_t IProfileRipple::evaluate_for_q(cvector_t q) const { return factor_x(q.x()) * factor_yz(q.y(), q.z()); } @@ -50,19 +46,16 @@ complex_t IProfileRipple::evaluate_for_q(cvector_t q) const IProfileRectangularRipple::IProfileRectangularRipple(const NodeMeta& meta, const std::vector<double>& PValues) - : IProfileRipple(meta, PValues) -{ + : IProfileRipple(meta, PValues) { onChange(); } //! Complex form factor. -complex_t IProfileRectangularRipple::factor_yz(complex_t qy, complex_t qz) const -{ +complex_t IProfileRectangularRipple::factor_yz(complex_t qy, complex_t qz) const { return ripples::profile_yz_bar(qy, qz, m_width, m_height); } -void IProfileRectangularRipple::onChange() -{ +void IProfileRectangularRipple::onChange() { m_shape = std::make_unique<Box>(m_length, m_width, m_height); } @@ -71,19 +64,16 @@ void IProfileRectangularRipple::onChange() // ************************************************************************************************ ICosineRipple::ICosineRipple(const NodeMeta& meta, const std::vector<double>& PValues) - : IProfileRipple(meta, PValues) -{ + : IProfileRipple(meta, PValues) { onChange(); } //! Complex form factor. -complex_t ICosineRipple::factor_yz(complex_t qy, complex_t qz) const -{ +complex_t ICosineRipple::factor_yz(complex_t qy, complex_t qz) const { return ripples::profile_yz_cosine(qy, qz, m_width, m_height); } -void ICosineRipple::onChange() -{ +void ICosineRipple::onChange() { m_shape = std::make_unique<RippleCosine>(m_length, m_width, m_height); } @@ -95,18 +85,15 @@ ISawtoothRipple::ISawtoothRipple(const NodeMeta& meta, const std::vector<double> : IProfileRipple( nodeMetaUnion({{"AsymmetryLength", "nm", "Asymmetry of width", -INF, INF, 0.}}, meta), PValues) - , m_asymmetry(m_P[3]) -{ + , m_asymmetry(m_P[3]) { onChange(); } //! Complex form factor. -complex_t ISawtoothRipple::factor_yz(complex_t qy, complex_t qz) const -{ +complex_t ISawtoothRipple::factor_yz(complex_t qy, complex_t qz) const { return ripples::profile_yz_triangular(qy, qz, m_width, m_height, m_asymmetry); } -void ISawtoothRipple::onChange() -{ +void ISawtoothRipple::onChange() { m_shape = std::make_unique<RippleSawtooth>(m_length, m_width, m_height, m_asymmetry); } diff --git a/Sample/HardParticle/IProfileRipple.h b/Sample/HardParticle/IProfileRipple.h index d221a9bf010f176cd2466b50c6ce613068707a81..26f6e09c59f84e7ffb478f82fb180589ce85da68 100644 --- a/Sample/HardParticle/IProfileRipple.h +++ b/Sample/HardParticle/IProfileRipple.h @@ -19,8 +19,7 @@ //! Base class for form factors with a cosine ripple profile in the yz plane. -class IProfileRipple : public IBornFF -{ +class IProfileRipple : public IBornFF { public: IProfileRipple(const NodeMeta& meta, const std::vector<double>& PValues); @@ -44,8 +43,7 @@ protected: //! Base class for form factors with a rectangular ripple (bar) profile in the yz plane. -class IProfileRectangularRipple : public IProfileRipple -{ +class IProfileRectangularRipple : public IProfileRipple { public: IProfileRectangularRipple(const NodeMeta& meta, const std::vector<double>& PValues); @@ -56,8 +54,7 @@ private: //! Base class for form factors with a cosine ripple profile in the yz plane. -class ICosineRipple : public IProfileRipple -{ +class ICosineRipple : public IProfileRipple { public: ICosineRipple(const NodeMeta& meta, const std::vector<double>& PValues); @@ -68,8 +65,7 @@ private: //! Base class for form factors with a triangular ripple profile in the yz plane. -class ISawtoothRipple : public IProfileRipple -{ +class ISawtoothRipple : public IProfileRipple { public: ISawtoothRipple(const NodeMeta& meta, const std::vector<double>& PValues); diff --git a/Sample/HardParticle/PolyhedralComponents.cpp b/Sample/HardParticle/PolyhedralComponents.cpp index 50f59f63beba1036e3a5174c18b1b7edaa8bfacf..ba5b5570275ce7cc639934e2bbe93fff79fe55d1 100644 --- a/Sample/HardParticle/PolyhedralComponents.cpp +++ b/Sample/HardParticle/PolyhedralComponents.cpp @@ -18,8 +18,7 @@ #include <iomanip> #include <stdexcept> // need overlooked by g++ 5.4 -namespace -{ +namespace { const double eps = 2e-16; constexpr auto ReciprocalFactorialArray = Math::generateReciprocalFactorialArray<171>(); } // namespace @@ -29,16 +28,14 @@ constexpr auto ReciprocalFactorialArray = Math::generateReciprocalFactorialArray // ************************************************************************************************ PolyhedralEdge::PolyhedralEdge(kvector_t _Vlow, kvector_t _Vhig) - : m_E((_Vhig - _Vlow) / 2), m_R((_Vhig + _Vlow) / 2) -{ + : m_E((_Vhig - _Vlow) / 2), m_R((_Vhig + _Vlow) / 2) { if (m_E.mag2() == 0) throw std::invalid_argument("At least one edge has zero length"); }; //! Returns sum_l=0^M/2 u^2l v^(M-2l) / (2l+1)!(M-2l)! - vperp^M/M! -complex_t PolyhedralEdge::contrib(int M, cvector_t qpa, complex_t qrperp) const -{ +complex_t PolyhedralEdge::contrib(int M, cvector_t qpa, complex_t qrperp) const { complex_t u = qE(qpa); complex_t v2 = m_R.dot(qpa); complex_t v1 = qrperp; @@ -95,8 +92,7 @@ int PolyhedralFace::n_limit_series = 20; //! Static method, returns diameter of circle that contains all vertices. -double PolyhedralFace::diameter(const std::vector<kvector_t>& V) -{ +double PolyhedralFace::diameter(const std::vector<kvector_t>& V) { double diameterFace = 0; for (size_t j = 0; j < V.size(); ++j) for (size_t jj = j + 1; jj < V.size(); ++jj) @@ -105,8 +101,7 @@ double PolyhedralFace::diameter(const std::vector<kvector_t>& V) } #ifdef POLYHEDRAL_DIAGNOSTIC -void PolyhedralFace::setLimits(double _qpa, int _n) -{ +void PolyhedralFace::setLimits(double _qpa, int _n) { qpa_limit_series = _qpa; n_limit_series = _n; } @@ -117,8 +112,7 @@ void PolyhedralFace::setLimits(double _qpa, int _n) //! @param V oriented vertex list //! @param _sym_S2 true if face has a perpedicular two-fold symmetry axis -PolyhedralFace::PolyhedralFace(const std::vector<kvector_t>& V, bool _sym_S2) : sym_S2(_sym_S2) -{ +PolyhedralFace::PolyhedralFace(const std::vector<kvector_t>& V, bool _sym_S2) : sym_S2(_sym_S2) { size_t NV = V.size(); if (!NV) throw std::logic_error("Face with no edges"); @@ -191,8 +185,7 @@ PolyhedralFace::PolyhedralFace(const std::vector<kvector_t>& V, bool _sym_S2) : //! Sets qperp and qpa according to argument q and to this polygon's normal. -void PolyhedralFace::decompose_q(cvector_t q, complex_t& qperp, cvector_t& qpa) const -{ +void PolyhedralFace::decompose_q(cvector_t q, complex_t& qperp, cvector_t& qpa) const { qperp = m_normal.dot(q); qpa = q - qperp * m_normal; // improve numeric accuracy: @@ -203,8 +196,7 @@ void PolyhedralFace::decompose_q(cvector_t q, complex_t& qperp, cvector_t& qpa) //! Returns core contribution to f_n -complex_t PolyhedralFace::ff_n_core(int m, cvector_t qpa, complex_t qperp) const -{ +complex_t PolyhedralFace::ff_n_core(int m, cvector_t qpa, complex_t qperp) const { cvector_t prevec = 2. * m_normal.cross(qpa); // complex conjugation will take place in .dot complex_t ret = 0; complex_t vfacsum = 0; @@ -232,8 +224,7 @@ complex_t PolyhedralFace::ff_n_core(int m, cvector_t qpa, complex_t qperp) const //! Returns contribution qn*f_n [of order q^(n+1)] from this face to the polyhedral form factor. -complex_t PolyhedralFace::ff_n(int n, cvector_t q) const -{ +complex_t PolyhedralFace::ff_n(int n, cvector_t q) const { complex_t qn = q.dot(m_normal); // conj(q)*normal (dot is antilinear in 'this' argument) if (std::abs(qn) < eps * q.mag()) return 0.; @@ -258,8 +249,7 @@ complex_t PolyhedralFace::ff_n(int n, cvector_t q) const //! Returns sum of n>=1 terms of qpa expansion of 2d form factor complex_t PolyhedralFace::expansion(complex_t fac_even, complex_t fac_odd, cvector_t qpa, - double abslevel) const -{ + double abslevel) const { #ifdef POLYHEDRAL_DIAGNOSTIC diagnosis.nExpandedFaces += 1; #endif @@ -293,8 +283,7 @@ complex_t PolyhedralFace::expansion(complex_t fac_even, complex_t fac_odd, cvect //! Returns core contribution to analytic 2d form factor. -complex_t PolyhedralFace::edge_sum_ff(cvector_t q, cvector_t qpa, bool sym_Ci) const -{ +complex_t PolyhedralFace::edge_sum_ff(cvector_t q, cvector_t qpa, bool sym_Ci) const { cvector_t prevec = m_normal.cross(qpa); // complex conjugation will take place in .dot complex_t sum = 0; complex_t vfacsum = 0; @@ -324,8 +313,7 @@ complex_t PolyhedralFace::edge_sum_ff(cvector_t q, cvector_t qpa, bool sym_Ci) c //! Returns the contribution ff(q) of this face to the polyhedral form factor. -complex_t PolyhedralFace::ff(cvector_t q, bool sym_Ci) const -{ +complex_t PolyhedralFace::ff(cvector_t q, bool sym_Ci) const { complex_t qperp; cvector_t qpa; decompose_q(q, qperp, qpa); @@ -363,8 +351,7 @@ complex_t PolyhedralFace::ff(cvector_t q, bool sym_Ci) const //! Returns the two-dimensional form factor of this face, for use in a prism. -complex_t PolyhedralFace::ff_2D(cvector_t qpa) const -{ +complex_t PolyhedralFace::ff_2D(cvector_t qpa) const { if (std::abs(qpa.dot(m_normal)) > eps * qpa.mag()) throw std::logic_error("ff_2D called with perpendicular q component"); double qpa_red = m_radius_2d * qpa.mag(); @@ -387,8 +374,7 @@ complex_t PolyhedralFace::ff_2D(cvector_t qpa) const //! Throws if deviation from inversion symmetry is detected. Does not check vertices. -void PolyhedralFace::assert_Ci(const PolyhedralFace& other) const -{ +void PolyhedralFace::assert_Ci(const PolyhedralFace& other) const { if (std::abs(m_rperp - other.m_rperp) > 1e-15 * (m_rperp + other.m_rperp)) throw std::logic_error("Faces with different distance from origin violate symmetry Ci"); if (std::abs(m_area - other.m_area) > 1e-15 * (m_area + other.m_area)) diff --git a/Sample/HardParticle/PolyhedralComponents.h b/Sample/HardParticle/PolyhedralComponents.h index 1180bf15e2a2dffb470aa267ab57a2f56a91a5ba..5f47a9c6864faf98f0f1b112d8a94a1117e421db 100644 --- a/Sample/HardParticle/PolyhedralComponents.h +++ b/Sample/HardParticle/PolyhedralComponents.h @@ -21,8 +21,7 @@ //! One edge of a polygon, for form factor computation. -class PolyhedralEdge -{ +class PolyhedralEdge { public: PolyhedralEdge(const kvector_t _Vlow, const kvector_t _Vhig); @@ -40,8 +39,7 @@ private: //! A polygon, for form factor computation. -class PolyhedralFace -{ +class PolyhedralFace { public: static double diameter(const std::vector<kvector_t>& V); #ifdef POLYHEDRAL_DIAGNOSTIC diff --git a/Sample/HardParticle/PolyhedralTopology.h b/Sample/HardParticle/PolyhedralTopology.h index 377b7de1eb1b104588fb0b8258478752e8802db0..25505ed80815224a956453aa671e3052e5f79ca2 100644 --- a/Sample/HardParticle/PolyhedralTopology.h +++ b/Sample/HardParticle/PolyhedralTopology.h @@ -18,16 +18,14 @@ #include <vector> //! For internal use in PolyhedralFace. -class PolygonalTopology -{ +class PolygonalTopology { public: std::vector<int> vertexIndices; bool symmetry_S2; }; //! For internal use in IFormFactorPolyhedron. -class PolyhedralTopology -{ +class PolyhedralTopology { public: std::vector<PolygonalTopology> faces; bool symmetry_Ci; diff --git a/Sample/HardParticle/Polyhedron.cpp b/Sample/HardParticle/Polyhedron.cpp index 909b86c39662be9369bff82d3a6458efc8239330..0061fded19b6a1c5383af9179cbdd5511f658f12 100644 --- a/Sample/HardParticle/Polyhedron.cpp +++ b/Sample/HardParticle/Polyhedron.cpp @@ -22,16 +22,14 @@ #include <iostream> #include <stdexcept> // need overlooked by g++ 5.4 -namespace -{ +namespace { const double eps = 2e-16; const double q_limit_series = 1e-2; const int n_limit_series = 20; } // namespace Polyhedron::Polyhedron(const PolyhedralTopology& topology, double z_bottom, - const std::vector<kvector_t>& vertices) -{ + const std::vector<kvector_t>& vertices) { m_vertices.clear(); for (const kvector_t& vertex : vertices) @@ -88,8 +86,7 @@ Polyhedron::Polyhedron(const PolyhedralTopology& topology, double z_bottom, Polyhedron::~Polyhedron() = default; -void Polyhedron::assert_platonic() const -{ +void Polyhedron::assert_platonic() const { // just one test; one could do much more ... double pyramidal_volume = 0; for (const auto& Gk : m_faces) @@ -104,24 +101,20 @@ void Polyhedron::assert_platonic() const } } -double Polyhedron::volume() const -{ +double Polyhedron::volume() const { return m_volume; } -double Polyhedron::radius() const -{ +double Polyhedron::radius() const { return m_radius; } -const std::vector<kvector_t>& Polyhedron::vertices() -{ +const std::vector<kvector_t>& Polyhedron::vertices() { return m_vertices; } //! Returns the form factor F(q) of this polyhedron, respecting the offset z_bottom. -complex_t Polyhedron::evaluate_for_q(const cvector_t& q) const -{ +complex_t Polyhedron::evaluate_for_q(const cvector_t& q) const { try { return exp_I(-m_z_bottom * q.z()) * evaluate_centered(q); } catch (std::logic_error& e) { @@ -138,8 +131,7 @@ complex_t Polyhedron::evaluate_for_q(const cvector_t& q) const //! Returns the form factor F(q) of this polyhedron, with origin at z=0. -complex_t Polyhedron::evaluate_centered(const cvector_t& q) const -{ +complex_t Polyhedron::evaluate_centered(const cvector_t& q) const { double q_red = m_radius * q.mag(); #ifdef POLYHEDRAL_DIAGNOSTIC diagnosis.maxOrder = 0; diff --git a/Sample/HardParticle/Polyhedron.h b/Sample/HardParticle/Polyhedron.h index 9a26f2e5844f77cebb3512ea36fcb2bf93748ca0..3db9972c01d7d7655b228acfb204da3a52aa8eec 100644 --- a/Sample/HardParticle/Polyhedron.h +++ b/Sample/HardParticle/Polyhedron.h @@ -21,8 +21,7 @@ //! A polyhedron, implementation class for use in IFormFactorPolyhedron -class Polyhedron -{ +class Polyhedron { public: Polyhedron() = delete; Polyhedron(const Polyhedron&) = delete; diff --git a/Sample/HardParticle/Prism.cpp b/Sample/HardParticle/Prism.cpp index 83fac4e24b5fe03053a0a0b40e54455333a0867d..5b19e80e95f8cae8bafec3483645d8cd2694df3c 100644 --- a/Sample/HardParticle/Prism.cpp +++ b/Sample/HardParticle/Prism.cpp @@ -20,8 +20,7 @@ #include "Base/Math/Functions.h" #include <stdexcept> // need overlooked by g++ 5.4 -Prism::Prism(bool symmetry_Ci, double height, const std::vector<kvector_t>& vertices) -{ +Prism::Prism(bool symmetry_Ci, double height, const std::vector<kvector_t>& vertices) { m_height = height; m_vertices.clear(); for (const kvector_t& vertex : vertices) { @@ -42,18 +41,15 @@ Prism::Prism(bool symmetry_Ci, double height, const std::vector<kvector_t>& vert } } -double Prism::area() const -{ +double Prism::area() const { return m_base->area(); } -const std::vector<kvector_t>& Prism::vertices() -{ +const std::vector<kvector_t>& Prism::vertices() { return m_vertices; } -complex_t Prism::evaluate_for_q(const cvector_t& q) const -{ +complex_t Prism::evaluate_for_q(const cvector_t& q) const { try { #ifdef POLYHEDRAL_DIAGNOSTIC diagnosis.maxOrder = 0; diff --git a/Sample/HardParticle/Prism.h b/Sample/HardParticle/Prism.h index a431790f5e00d64a33d4b74f65160e9807ad69cf..957513cff59486270929b8dea3930aa00c9f866c 100644 --- a/Sample/HardParticle/Prism.h +++ b/Sample/HardParticle/Prism.h @@ -19,8 +19,7 @@ #include "Sample/HardParticle/PolyhedralTopology.h" #include <memory> -class Prism -{ +class Prism { public: Prism() = delete; Prism(const Prism&) = delete; diff --git a/Sample/HardParticle/Ripples.cpp b/Sample/HardParticle/Ripples.cpp index c08579edea73a69ce6d4db13af99dafcdfe18ebb..98d108066c9068534b484e138b71b8ceb61a4fa1 100644 --- a/Sample/HardParticle/Ripples.cpp +++ b/Sample/HardParticle/Ripples.cpp @@ -17,24 +17,20 @@ #include "Base/Math/Functions.h" #include "Base/Math/Integrator.h" -complex_t ripples::factor_x_box(complex_t q, double r) -{ +complex_t ripples::factor_x_box(complex_t q, double r) { return r * Math::sinc(q * r / 2.0); } -complex_t ripples::factor_x_Gauss(complex_t q, double r) -{ +complex_t ripples::factor_x_Gauss(complex_t q, double r) { return r * exp(-q * r / 8.0); } -complex_t ripples::factor_x_Lorentz(complex_t q, double r) -{ +complex_t ripples::factor_x_Lorentz(complex_t q, double r) { return r / (1.0 + (q * r) * (q * r)); } //! Complex form factor of rectangular ripple (bar). -complex_t ripples::profile_yz_bar(complex_t qy, complex_t qz, double width, double height) -{ +complex_t ripples::profile_yz_bar(complex_t qy, complex_t qz, double width, double height) { const complex_t qyWdiv2 = width * qy / 2.0; const complex_t qzHdiv2 = height * qz / 2.0; @@ -42,8 +38,7 @@ complex_t ripples::profile_yz_bar(complex_t qy, complex_t qz, double width, doub } //! Complex form factor of triangular ripple. -complex_t ripples::profile_yz_cosine(complex_t qy, complex_t qz, double width, double height) -{ +complex_t ripples::profile_yz_cosine(complex_t qy, complex_t qz, double width, double height) { complex_t factor = width / M_PI; // analytical expressions for some particular cases @@ -70,8 +65,7 @@ complex_t ripples::profile_yz_cosine(complex_t qy, complex_t qz, double width, d //! Complex form factor of triangular ripple. complex_t ripples::profile_yz_triangular(complex_t qy, complex_t qz, double width, double height, - double asymmetry) -{ + double asymmetry) { complex_t result; const complex_t factor = height * width; const complex_t qyW2 = qy * width * 0.5; diff --git a/Sample/HardParticle/Ripples.h b/Sample/HardParticle/Ripples.h index fbbabfb1ce0bf1a9d0e0b874aaecaccd2a1c9f33..dafdee9d6365ddbaf3e0ed66996304c411e6ad18 100644 --- a/Sample/HardParticle/Ripples.h +++ b/Sample/HardParticle/Ripples.h @@ -18,8 +18,7 @@ #include "Base/Types/Complex.h" //! Computations for elongated particles. -namespace ripples -{ +namespace ripples { complex_t factor_x_box(complex_t q, double l); complex_t factor_x_Gauss(complex_t q, double l); diff --git a/Sample/Interference/DecouplingApproximationStrategy.cpp b/Sample/Interference/DecouplingApproximationStrategy.cpp index fa556ff62281f3645be250453b262a53d767f67c..6d3200eb141dc57117f1a0dfc3f8ff4b3a1417bc 100644 --- a/Sample/Interference/DecouplingApproximationStrategy.cpp +++ b/Sample/Interference/DecouplingApproximationStrategy.cpp @@ -26,15 +26,13 @@ DecouplingApproximationStrategy::DecouplingApproximationStrategy( : IInterferenceFunctionStrategy(weighted_formfactors, sim_params, polarized) , m_iff(iff ? iff->clone() : new InterferenceFunctionNone()) -{ -} +{} //! Returns the total incoherent and coherent scattering intensity for given kf and //! for one particle layout (implied by the given particle form factors). //! This is the scalar version double -DecouplingApproximationStrategy::scalarCalculation(const SimulationElement& sim_element) const -{ +DecouplingApproximationStrategy::scalarCalculation(const SimulationElement& sim_element) const { double intensity = 0.0; complex_t amplitude = complex_t(0.0, 0.0); for (const auto& ffw : m_weighted_formfactors) { @@ -53,8 +51,7 @@ DecouplingApproximationStrategy::scalarCalculation(const SimulationElement& sim_ //! This is the polarized version double -DecouplingApproximationStrategy::polarizedCalculation(const SimulationElement& sim_element) const -{ +DecouplingApproximationStrategy::polarizedCalculation(const SimulationElement& sim_element) const { Eigen::Matrix2cd mean_intensity = Eigen::Matrix2cd::Zero(); Eigen::Matrix2cd mean_amplitude = Eigen::Matrix2cd::Zero(); diff --git a/Sample/Interference/DecouplingApproximationStrategy.h b/Sample/Interference/DecouplingApproximationStrategy.h index 1e2ea6692297c77d7acc12a80ede4f4b765a7835..e884ed3b3f42c0128a1e4e004ad76d3b3188d1e6 100644 --- a/Sample/Interference/DecouplingApproximationStrategy.h +++ b/Sample/Interference/DecouplingApproximationStrategy.h @@ -23,8 +23,7 @@ class SimulationElement; //! in the decoupling approximation. //! @ingroup algorithms_internal -class DecouplingApproximationStrategy : public IInterferenceFunctionStrategy -{ +class DecouplingApproximationStrategy : public IInterferenceFunctionStrategy { public: DecouplingApproximationStrategy(const std::vector<FormFactorCoherentSum>& weighted_formfactors, const IInterferenceFunction* iff, SimulationOptions sim_params, diff --git a/Sample/Interference/FormFactorPrecompute.cpp b/Sample/Interference/FormFactorPrecompute.cpp index a1aa31812d39b2d7d41a7bf052373421eee7f0cf..a9689ac950eadae8607a783179d6e6e9205e9495 100644 --- a/Sample/Interference/FormFactorPrecompute.cpp +++ b/Sample/Interference/FormFactorPrecompute.cpp @@ -17,8 +17,7 @@ std::vector<complex_t> FormFactorPrecompute::scalar(const SimulationElement& sim_element, - const std::vector<FormFactorCoherentSum>& ff_wrappers) -{ + const std::vector<FormFactorCoherentSum>& ff_wrappers) { std::vector<complex_t> result; for (auto& ffw : ff_wrappers) { result.push_back(ffw.evaluate(sim_element)); @@ -28,8 +27,7 @@ FormFactorPrecompute::scalar(const SimulationElement& sim_element, FormFactorPrecompute::matrixFFVector_t FormFactorPrecompute::polarized(const SimulationElement& sim_element, - const std::vector<FormFactorCoherentSum>& ff_wrappers) -{ + const std::vector<FormFactorCoherentSum>& ff_wrappers) { FormFactorPrecompute::matrixFFVector_t result; for (auto& ffw : ff_wrappers) { result.push_back(ffw.evaluatePol(sim_element)); diff --git a/Sample/Interference/FormFactorPrecompute.h b/Sample/Interference/FormFactorPrecompute.h index 606594a0deae1534fdb403051642ba69ee67f30f..7101d478dba5620bfe968e9bfc68790393673531 100644 --- a/Sample/Interference/FormFactorPrecompute.h +++ b/Sample/Interference/FormFactorPrecompute.h @@ -22,8 +22,7 @@ class FormFactorCoherentSum; class SimulationElement; -namespace FormFactorPrecompute -{ +namespace FormFactorPrecompute { using matrixFFVector_t = std::vector<Eigen::Matrix2cd, Eigen::aligned_allocator<Eigen::Matrix2cd>>; std::vector<complex_t> scalar(const SimulationElement& sim_element, diff --git a/Sample/Interference/IInterferenceFunctionStrategy.cpp b/Sample/Interference/IInterferenceFunctionStrategy.cpp index cbf87afdbc0b526a47e62def2640d2b38464eb54..e88799e061467d9363125df9aa5da79db62a3a20 100644 --- a/Sample/Interference/IInterferenceFunctionStrategy.cpp +++ b/Sample/Interference/IInterferenceFunctionStrategy.cpp @@ -25,24 +25,21 @@ IInterferenceFunctionStrategy::IInterferenceFunctionStrategy( : m_weighted_formfactors(weighted_formfactors) , m_options(sim_params) , m_polarized(polarized) - , m_integrator( - make_integrator_miser(this, &IInterferenceFunctionStrategy::evaluate_for_fixed_angles, 2)) -{ + , m_integrator(make_integrator_miser( + this, &IInterferenceFunctionStrategy::evaluate_for_fixed_angles, 2)) { ASSERT(!m_weighted_formfactors.empty()); } IInterferenceFunctionStrategy::~IInterferenceFunctionStrategy() = default; -double IInterferenceFunctionStrategy::evaluate(const SimulationElement& sim_element) const -{ +double IInterferenceFunctionStrategy::evaluate(const SimulationElement& sim_element) const { if (m_options.isIntegrate() && (sim_element.solidAngle() > 0.0)) return MCIntegratedEvaluate(sim_element); return evaluateSinglePoint(sim_element); } double -IInterferenceFunctionStrategy::evaluateSinglePoint(const SimulationElement& sim_element) const -{ +IInterferenceFunctionStrategy::evaluateSinglePoint(const SimulationElement& sim_element) const { if (!m_polarized) return scalarCalculation(sim_element); return polarizedCalculation(sim_element); @@ -50,8 +47,7 @@ IInterferenceFunctionStrategy::evaluateSinglePoint(const SimulationElement& sim_ //! Performs a Monte Carlo integration over the bin for the evaluation of the intensity. double -IInterferenceFunctionStrategy::MCIntegratedEvaluate(const SimulationElement& sim_element) const -{ +IInterferenceFunctionStrategy::MCIntegratedEvaluate(const SimulationElement& sim_element) const { double min_array[] = {0.0, 0.0}; double max_array[] = {1.0, 1.0}; return m_integrator->integrate(min_array, max_array, (void*)&sim_element, @@ -59,8 +55,7 @@ IInterferenceFunctionStrategy::MCIntegratedEvaluate(const SimulationElement& sim } double IInterferenceFunctionStrategy::evaluate_for_fixed_angles(double* fractions, size_t, - void* params) const -{ + void* params) const { double par0 = fractions[0]; double par1 = fractions[1]; diff --git a/Sample/Interference/IInterferenceFunctionStrategy.h b/Sample/Interference/IInterferenceFunctionStrategy.h index 2bd62404ed35051a8b21db7cae5868203b3ee6e7..a8d8ce5af4dd282bebf9823a03608248b8663c12 100644 --- a/Sample/Interference/IInterferenceFunctionStrategy.h +++ b/Sample/Interference/IInterferenceFunctionStrategy.h @@ -38,8 +38,7 @@ class SimulationElement; //! //! @ingroup algorithms_internal -class IInterferenceFunctionStrategy -{ +class IInterferenceFunctionStrategy { public: IInterferenceFunctionStrategy(const std::vector<FormFactorCoherentSum>& weighted_formfactors, const SimulationOptions& sim_params, bool polarized); diff --git a/Sample/Interference/SSCApproximationStrategy.cpp b/Sample/Interference/SSCApproximationStrategy.cpp index fa773f64d86422250117a03ba45b1f52cd12ba15..08865ac5217c8c1dad10c57e8d1ce173d66e755b 100644 --- a/Sample/Interference/SSCApproximationStrategy.cpp +++ b/Sample/Interference/SSCApproximationStrategy.cpp @@ -24,8 +24,7 @@ SSCApproximationStrategy::SSCApproximationStrategy( double kappa) : IInterferenceFunctionStrategy(weighted_formfactors, sim_params, polarized) , m_iff(iff->clone()) - , m_kappa(kappa) -{ + , m_kappa(kappa) { m_mean_radius = 0.0; for (const auto& ffw : m_weighted_formfactors) m_mean_radius += ffw.relativeAbundance() * ffw.radialExtension(); @@ -34,8 +33,7 @@ SSCApproximationStrategy::SSCApproximationStrategy( //! Returns the total scattering intensity for given kf and //! for one particle layout (implied by the given particle form factors). //! This is the scalar version -double SSCApproximationStrategy::scalarCalculation(const SimulationElement& sim_element) const -{ +double SSCApproximationStrategy::scalarCalculation(const SimulationElement& sim_element) const { const double qp = sim_element.meanQ().magxy(); double diffuse_intensity = 0.0; complex_t ff_orig = 0., ff_conj = 0.; // original and conjugated mean formfactor @@ -58,8 +56,7 @@ double SSCApproximationStrategy::scalarCalculation(const SimulationElement& sim_ } //! This is the polarized version -double SSCApproximationStrategy::polarizedCalculation(const SimulationElement& sim_element) const -{ +double SSCApproximationStrategy::polarizedCalculation(const SimulationElement& sim_element) const { const double qp = sim_element.meanQ().magxy(); Eigen::Matrix2cd diffuse_matrix = Eigen::Matrix2cd::Zero(); const auto& polarization_handler = sim_element.polarizationHandler(); @@ -89,8 +86,7 @@ double SSCApproximationStrategy::polarizedCalculation(const SimulationElement& s } complex_t SSCApproximationStrategy::getCharacteristicSizeCoupling( - double qp, const std::vector<FormFactorCoherentSum>& ff_wrappers) const -{ + double qp, const std::vector<FormFactorCoherentSum>& ff_wrappers) const { complex_t result = 0; for (const auto& ffw : ff_wrappers) result += @@ -99,7 +95,6 @@ complex_t SSCApproximationStrategy::getCharacteristicSizeCoupling( } complex_t SSCApproximationStrategy::calculatePositionOffsetPhase(double qp, - double radial_extension) const -{ + double radial_extension) const { return exp_I(m_kappa * qp * (radial_extension - m_mean_radius)); } diff --git a/Sample/Interference/SSCApproximationStrategy.h b/Sample/Interference/SSCApproximationStrategy.h index b818c52e862480354adc44b79ed055bdcc11cb72..33b29b0b708bcac80554c8d8fcc5fabdfb0b3462 100644 --- a/Sample/Interference/SSCApproximationStrategy.h +++ b/Sample/Interference/SSCApproximationStrategy.h @@ -25,8 +25,7 @@ class SimulationElement; //! in the size-spacing correlation approximation. //! @ingroup algorithms_internal -class SSCApproximationStrategy : public IInterferenceFunctionStrategy -{ +class SSCApproximationStrategy : public IInterferenceFunctionStrategy { public: SSCApproximationStrategy(const std::vector<FormFactorCoherentSum>& weighted_formfactors, const InterferenceFunctionRadialParaCrystal* iff, diff --git a/Sample/Lattice/BakeLattice.cpp b/Sample/Lattice/BakeLattice.cpp index 963acfd02801b0b52c4647f78f902c2d53dafca4..4301b28c32715084ea4508aac0800d19147bbfd9 100644 --- a/Sample/Lattice/BakeLattice.cpp +++ b/Sample/Lattice/BakeLattice.cpp @@ -15,16 +15,14 @@ #include "Sample/Lattice/BakeLattice.h" #include "Sample/Lattice/Lattice3D.h" -Lattice3D bake::CubicLattice(double a) -{ +Lattice3D bake::CubicLattice(double a) { kvector_t a1(a, 0.0, 0.0); kvector_t a2(0.0, a, 0.0); kvector_t a3(0.0, 0.0, a); return Lattice3D(a1, a2, a3); } -Lattice3D bake::FCCLattice(double a) -{ +Lattice3D bake::FCCLattice(double a) { double b = a / 2.0; kvector_t a1(0.0, b, b); kvector_t a2(b, 0.0, b); @@ -32,32 +30,28 @@ Lattice3D bake::FCCLattice(double a) return Lattice3D(a1, a2, a3); } -Lattice3D bake::HexagonalLattice(double a, double c) -{ +Lattice3D bake::HexagonalLattice(double a, double c) { kvector_t a1(a, 0.0, 0.0); kvector_t a2(-a / 2.0, std::sqrt(3.0) * a / 2.0, 0.0); kvector_t a3(0.0, 0.0, c); return Lattice3D(a1, a2, a3); } -Lattice3D bake::HCPLattice(double a, double c) -{ +Lattice3D bake::HCPLattice(double a, double c) { kvector_t a1(a, 0.0, 0.0); kvector_t a2(-a / 2.0, std::sqrt(3.0) * a / 2.0, 0); kvector_t a3(a / 2.0, a / std::sqrt(3.0) / 2.0, c / 2.0); return Lattice3D(a1, a2, a3); } -Lattice3D bake::TetragonalLattice(double a, double c) -{ +Lattice3D bake::TetragonalLattice(double a, double c) { kvector_t a1(a, 0.0, 0.0); kvector_t a2(0.0, a, 0.0); kvector_t a3(0.0, 0.0, c); return Lattice3D(a1, a2, a3); } -Lattice3D bake::BCTLattice(double a, double c) -{ +Lattice3D bake::BCTLattice(double a, double c) { kvector_t a1(a, 0.0, 0.0); kvector_t a2(0.0, a, 0.0); kvector_t a3(a / 2.0, a / 2.0, c / 2.0); diff --git a/Sample/Lattice/BakeLattice.h b/Sample/Lattice/BakeLattice.h index 4ebbf577cc7157bb21af91002ed8028f75fcd5cb..7be194b692efee8284fcfcad261129c127fdfe2f 100644 --- a/Sample/Lattice/BakeLattice.h +++ b/Sample/Lattice/BakeLattice.h @@ -19,8 +19,7 @@ class Lattice3D; //! Functions that instantiate objects. To be used like constructors. -namespace bake -{ +namespace bake { //! Returns a primitive cubic (cP) lattice with edge length a. Lattice3D CubicLattice(double a); diff --git a/Sample/Lattice/ISelectionRule.h b/Sample/Lattice/ISelectionRule.h index 3b712c00fce46daba40f84ccdbe0809d8bf65cef..b4bcbf708c2e5cf1e4a8f4ec395f5122c604e583 100644 --- a/Sample/Lattice/ISelectionRule.h +++ b/Sample/Lattice/ISelectionRule.h @@ -20,8 +20,7 @@ //! Abstract base class for selection rules. //! @ingroup samples_internal -class ISelectionRule -{ +class ISelectionRule { public: virtual ~ISelectionRule() {} @@ -33,8 +32,7 @@ public: //! Selection rule (v*q)%modulus!=0, defined by vector v(a,b,c) and modulus. //! @ingroup samples_internal -class SimpleSelectionRule : public ISelectionRule -{ +class SimpleSelectionRule : public ISelectionRule { public: SimpleSelectionRule(int a, int b, int c, int modulus); virtual ~SimpleSelectionRule() {} @@ -49,17 +47,13 @@ private: }; inline SimpleSelectionRule::SimpleSelectionRule(int a, int b, int c, int modulus) - : m_a(a), m_b(b), m_c(c), m_mod(modulus) -{ -} + : m_a(a), m_b(b), m_c(c), m_mod(modulus) {} -inline SimpleSelectionRule* SimpleSelectionRule::clone() const -{ +inline SimpleSelectionRule* SimpleSelectionRule::clone() const { return new SimpleSelectionRule(m_a, m_b, m_c, m_mod); } -inline bool SimpleSelectionRule::coordinateSelected(const ivector_t& coordinate) const -{ +inline bool SimpleSelectionRule::coordinateSelected(const ivector_t& coordinate) const { return (m_a * coordinate[0] + m_b * coordinate[1] + m_c * coordinate[2]) % m_mod == 0; } diff --git a/Sample/Lattice/Lattice2D.cpp b/Sample/Lattice/Lattice2D.cpp index 56c32fc1b79a8a29b2fd639aa1d45a7482e4ee4d..5f76f397593277e0865bf48cb12ed21ddcc8c0cc 100644 --- a/Sample/Lattice/Lattice2D.cpp +++ b/Sample/Lattice/Lattice2D.cpp @@ -23,17 +23,13 @@ // ************************************************************************************************ Lattice2D::Lattice2D(const NodeMeta& meta, const std::vector<double>& PValues) - : INode(meta, PValues) -{ -} + : INode(meta, PValues) {} -Lattice2D::Lattice2D(double xi) : m_xi(xi) -{ +Lattice2D::Lattice2D(double xi) : m_xi(xi) { registerParameter("Xi", &m_xi).setUnit("rad"); } -Lattice2D::ReciprocalBases Lattice2D::reciprocalBases() const -{ +Lattice2D::ReciprocalBases Lattice2D::reciprocalBases() const { const double sinalpha = std::sin(latticeAngle()); const double ainv = M_TWOPI / length1() / sinalpha; const double binv = M_TWOPI / length2() / sinalpha; @@ -44,8 +40,7 @@ Lattice2D::ReciprocalBases Lattice2D::reciprocalBases() const +binv * std::cos(xi)}; } -void Lattice2D::onChange() -{ +void Lattice2D::onChange() { if (parent()) parent()->onChange(); } @@ -66,8 +61,7 @@ void Lattice2D::setRotationEnabled(bool enabled) // TODO ASAP replace by generic // ************************************************************************************************ BasicLattice2D::BasicLattice2D(double length1, double length2, double angle, double xi) - : Lattice2D(xi), m_length1(length1), m_length2(length2), m_angle(angle) -{ + : Lattice2D(xi), m_length1(length1), m_length2(length2), m_angle(angle) { if (m_length1 <= 0.0 || m_length2 <= 0.0) throw std::runtime_error( "BasicLattice2D::BasicLattice2D() -> Error. Lattice length can't be " @@ -79,13 +73,11 @@ BasicLattice2D::BasicLattice2D(double length1, double length2, double angle, dou registerParameter("Alpha", &m_angle).setUnit("rad"); } -BasicLattice2D* BasicLattice2D::clone() const -{ +BasicLattice2D* BasicLattice2D::clone() const { return new BasicLattice2D(m_length1, m_length2, m_angle, m_xi); } -double BasicLattice2D::unitCellArea() const -{ +double BasicLattice2D::unitCellArea() const { return std::abs(m_length1 * m_length2 * std::sin(m_angle)); } @@ -93,8 +85,7 @@ double BasicLattice2D::unitCellArea() const // class SquareLattice2D // ************************************************************************************************ -SquareLattice2D::SquareLattice2D(double length, double xi) : Lattice2D(xi), m_length(length) -{ +SquareLattice2D::SquareLattice2D(double length, double xi) : Lattice2D(xi), m_length(length) { if (m_length <= 0.0) throw std::runtime_error( "SquareLattice2D::SquareLattice2D() -> Error. Lattice length can't be " @@ -104,18 +95,15 @@ SquareLattice2D::SquareLattice2D(double length, double xi) : Lattice2D(xi), m_le registerParameter("LatticeLength", &m_length).setUnit("nm").setPositive(); } -SquareLattice2D* SquareLattice2D::clone() const -{ +SquareLattice2D* SquareLattice2D::clone() const { return new SquareLattice2D(m_length, m_xi); } -double SquareLattice2D::latticeAngle() const -{ +double SquareLattice2D::latticeAngle() const { return M_PI / 2.0; } -double SquareLattice2D::unitCellArea() const -{ +double SquareLattice2D::unitCellArea() const { return std::abs(m_length * m_length); } @@ -123,8 +111,7 @@ double SquareLattice2D::unitCellArea() const // class HexagonalLattice2D // ************************************************************************************************ -HexagonalLattice2D::HexagonalLattice2D(double length, double xi) : Lattice2D(xi), m_length(length) -{ +HexagonalLattice2D::HexagonalLattice2D(double length, double xi) : Lattice2D(xi), m_length(length) { if (m_length <= 0.0) throw std::runtime_error("HexagonalLattice2D::HexagonalLattice2D() -> Error. " "Lattice length can't be negative or zero."); @@ -133,18 +120,15 @@ HexagonalLattice2D::HexagonalLattice2D(double length, double xi) : Lattice2D(xi) registerParameter("LatticeLength", &m_length).setUnit("nm").setPositive(); } -HexagonalLattice2D* HexagonalLattice2D::clone() const -{ +HexagonalLattice2D* HexagonalLattice2D::clone() const { return new HexagonalLattice2D(m_length, m_xi); } -double HexagonalLattice2D::latticeAngle() const -{ +double HexagonalLattice2D::latticeAngle() const { return M_TWOPI / 3.0; } -double HexagonalLattice2D::unitCellArea() const -{ +double HexagonalLattice2D::unitCellArea() const { static const double sinval = std::sin(latticeAngle()); return std::abs(m_length * m_length * sinval); } diff --git a/Sample/Lattice/Lattice2D.h b/Sample/Lattice/Lattice2D.h index 0da154635ec87998ce7c12cabc5a3eec4e49d5a2..77a3685ecc98ba283ced69cb6882ab4b12d6feb3 100644 --- a/Sample/Lattice/Lattice2D.h +++ b/Sample/Lattice/Lattice2D.h @@ -18,8 +18,7 @@ #include "Base/Types/ICloneable.h" #include "Param/Node/INode.h" -class Lattice2D : public ICloneable, public INode -{ +class Lattice2D : public ICloneable, public INode { public: Lattice2D(const NodeMeta& meta, const std::vector<double>& PValues); explicit Lattice2D(double xi); @@ -47,8 +46,7 @@ protected: double m_xi; }; -class BasicLattice2D : public Lattice2D -{ +class BasicLattice2D : public Lattice2D { public: BasicLattice2D(double length1, double length2, double angle, double xi); @@ -66,8 +64,7 @@ private: double m_angle; }; -class SquareLattice2D : public Lattice2D -{ +class SquareLattice2D : public Lattice2D { public: SquareLattice2D(double length, double xi = 0.0); @@ -84,8 +81,7 @@ private: double m_length; }; -class HexagonalLattice2D : public Lattice2D -{ +class HexagonalLattice2D : public Lattice2D { public: HexagonalLattice2D(double length, double xi); diff --git a/Sample/Lattice/Lattice3D.cpp b/Sample/Lattice/Lattice3D.cpp index a5d77314de7ee25e9d2576f440dbbc14c7d247de..f9462f76ab1e31c887f858345893ba420664c4e0 100644 --- a/Sample/Lattice/Lattice3D.cpp +++ b/Sample/Lattice/Lattice3D.cpp @@ -20,15 +20,13 @@ #include <gsl/gsl_linalg.h> Lattice3D::Lattice3D(const kvector_t a, const kvector_t b, const kvector_t c) - : m_a(a), m_b(b), m_c(c) -{ + : m_a(a), m_b(b), m_c(c) { setName("Lattice"); initialize(); } Lattice3D::Lattice3D(const Lattice3D& lattice) - : INode(), m_a(lattice.m_a), m_b(lattice.m_b), m_c(lattice.m_c) -{ + : INode(), m_a(lattice.m_a), m_b(lattice.m_b), m_c(lattice.m_c) { setName("Lattice"); initialize(); if (lattice.m_selection_rule) @@ -37,8 +35,7 @@ Lattice3D::Lattice3D(const Lattice3D& lattice) Lattice3D::~Lattice3D() = default; -void Lattice3D::initialize() -{ +void Lattice3D::initialize() { computeReciprocalVectors(); if (!parameter(XComponentName("BasisA"))) { registerVector("BasisA", &m_a, "nm"); @@ -47,13 +44,11 @@ void Lattice3D::initialize() } } -void Lattice3D::onChange() -{ +void Lattice3D::onChange() { computeReciprocalVectors(); } -Lattice3D Lattice3D::transformed(const Transform3D& transform) const -{ +Lattice3D Lattice3D::transformed(const Transform3D& transform) const { kvector_t q1 = transform.transformed(m_a); kvector_t q2 = transform.transformed(m_b); kvector_t q3 = transform.transformed(m_c); @@ -64,34 +59,29 @@ Lattice3D Lattice3D::transformed(const Transform3D& transform) const } //! Currently unused but may be useful for checks -kvector_t Lattice3D::getMillerDirection(double h, double k, double l) const -{ +kvector_t Lattice3D::getMillerDirection(double h, double k, double l) const { kvector_t direction = h * m_ra + k * m_rb + l * m_rc; return direction.unit(); } -double Lattice3D::unitCellVolume() const -{ +double Lattice3D::unitCellVolume() const { return std::abs(m_a.dot(m_b.cross(m_c))); } //! Currently only used in tests -void Lattice3D::getReciprocalLatticeBasis(kvector_t& ra, kvector_t& rb, kvector_t& rc) const -{ +void Lattice3D::getReciprocalLatticeBasis(kvector_t& ra, kvector_t& rb, kvector_t& rc) const { ra = m_ra; rb = m_rb; rc = m_rc; } -ivector_t Lattice3D::getNearestReciprocalLatticeVectorCoordinates(const kvector_t q) const -{ +ivector_t Lattice3D::getNearestReciprocalLatticeVectorCoordinates(const kvector_t q) const { return {(int)std::lround(q.dot(m_a) / M_TWOPI), (int)std::lround(q.dot(m_b) / M_TWOPI), (int)std::lround(q.dot(m_c) / M_TWOPI)}; } std::vector<kvector_t> Lattice3D::reciprocalLatticeVectorsWithinRadius(const kvector_t q, - double dq) const -{ + double dq) const { ivector_t nearest_coords = getNearestReciprocalLatticeVectorCoordinates(q); int max_X = std::lround(m_a.mag() * dq / M_TWOPI); @@ -115,8 +105,7 @@ std::vector<kvector_t> Lattice3D::reciprocalLatticeVectorsWithinRadius(const kve return ret; } -void Lattice3D::computeReciprocalVectors() const -{ +void Lattice3D::computeReciprocalVectors() const { kvector_t q23 = m_b.cross(m_c); kvector_t q31 = m_c.cross(m_a); kvector_t q12 = m_a.cross(m_b); @@ -125,7 +114,6 @@ void Lattice3D::computeReciprocalVectors() const m_rc = M_TWOPI / m_c.dot(q12) * q12; } -void Lattice3D::setSelectionRule(const ISelectionRule& selection_rule) -{ +void Lattice3D::setSelectionRule(const ISelectionRule& selection_rule) { m_selection_rule.reset(selection_rule.clone()); } diff --git a/Sample/Lattice/Lattice3D.h b/Sample/Lattice/Lattice3D.h index 91574eb40586a3541fcb59b93028d14d3b87e433..950b738bf28b15c6cbd0e1ab8cb4d07a7f24aa49 100644 --- a/Sample/Lattice/Lattice3D.h +++ b/Sample/Lattice/Lattice3D.h @@ -26,8 +26,7 @@ class Transform3D; //! @ingroup samples -class Lattice3D : public INode -{ +class Lattice3D : public INode { public: Lattice3D() = delete; Lattice3D(const kvector_t a, const kvector_t b, const kvector_t c); diff --git a/Sample/LibFF/SomeFormFactors.cpp b/Sample/LibFF/SomeFormFactors.cpp index 90f4210fa425ce12dc1bf412f94c0361dc8417cd..6d84e5fcb5b5be9c798bb103b818c47de4f50666 100644 --- a/Sample/LibFF/SomeFormFactors.cpp +++ b/Sample/LibFF/SomeFormFactors.cpp @@ -18,8 +18,7 @@ //! //! Used by the hard sphere and by several soft sphere classes. -complex_t someff::ffSphere(cvector_t q, double R) -{ +complex_t someff::ffSphere(cvector_t q, double R) { complex_t q1 = sqrt(q.x() * q.x() + q.y() * q.y() + q.z() * q.z()); // NO sesquilinear dot product! complex_t qR = q1 * R; diff --git a/Sample/LibFF/SomeFormFactors.h b/Sample/LibFF/SomeFormFactors.h index d2a61f9c660a69803a95dde5db67d2da4fceea76..873effee4bbf53256788f05b9b21454e89b6bc00 100644 --- a/Sample/LibFF/SomeFormFactors.h +++ b/Sample/LibFF/SomeFormFactors.h @@ -20,8 +20,7 @@ //! Some form factor functions. -namespace someff -{ +namespace someff { complex_t ffSphere(cvector_t q, double R); diff --git a/Sample/Material/BaseMaterialImpl.h b/Sample/Material/BaseMaterialImpl.h index 423a92078237b2c52f2674d2d81acad2bea99e64..b9cc2b3d7366e4343248fd05c8dc5cc412534715 100644 --- a/Sample/Material/BaseMaterialImpl.h +++ b/Sample/Material/BaseMaterialImpl.h @@ -28,8 +28,7 @@ enum class MATERIAL_TYPES { InvalidMaterialType = -1, RefractiveMaterial = 0, Ma //! Inherited by MagneticMaterialImpl, which has further children. //! @ingroup materials -class BaseMaterialImpl -{ +class BaseMaterialImpl { public: //! Constructs basic material with name BaseMaterialImpl(const std::string& name) : m_name(name) {} diff --git a/Sample/Material/MagneticMaterialImpl.cpp b/Sample/Material/MagneticMaterialImpl.cpp index 619e0139a0836fd3477a754622264b6c4607544d..3e9a69a61ff7529ea6b3bd337356d929e196c554 100644 --- a/Sample/Material/MagneticMaterialImpl.cpp +++ b/Sample/Material/MagneticMaterialImpl.cpp @@ -25,10 +25,8 @@ using PhysConsts::r_e; // The factor 1e-18 is here to have unit: m/A*nm^-2 constexpr double magnetization_prefactor = (gamma_n * r_e / 2.0 / mu_B) * 1e-18; -namespace -{ -cvector_t OrthogonalToBaseVector(cvector_t base, const kvector_t vector) -{ +namespace { +cvector_t OrthogonalToBaseVector(cvector_t base, const kvector_t vector) { if (base.mag2() == 0.0) return cvector_t{}; cvector_t projection = (base.dot(vector) / base.mag2()) * base; @@ -37,42 +35,34 @@ cvector_t OrthogonalToBaseVector(cvector_t base, const kvector_t vector) } // namespace MagneticMaterialImpl::MagneticMaterialImpl(const std::string& name, kvector_t magnetization) - : BaseMaterialImpl(name), m_magnetization(magnetization) -{ -} + : BaseMaterialImpl(name), m_magnetization(magnetization) {} -MagneticMaterialImpl* MagneticMaterialImpl::inverted() const -{ +MagneticMaterialImpl* MagneticMaterialImpl::inverted() const { std::string name = isScalarMaterial() ? getName() : getName() + "_inv"; MagneticMaterialImpl* result = this->clone(); result->setMagnetization(-magnetization()); return result; } -bool MagneticMaterialImpl::isScalarMaterial() const -{ +bool MagneticMaterialImpl::isScalarMaterial() const { return m_magnetization == kvector_t{}; } -bool MagneticMaterialImpl::isMagneticMaterial() const -{ +bool MagneticMaterialImpl::isMagneticMaterial() const { return !isScalarMaterial(); } -kvector_t MagneticMaterialImpl::magnetization() const -{ +kvector_t MagneticMaterialImpl::magnetization() const { return m_magnetization; } -Eigen::Matrix2cd MagneticMaterialImpl::polarizedSubtrSLD(const WavevectorInfo& wavevectors) const -{ +Eigen::Matrix2cd MagneticMaterialImpl::polarizedSubtrSLD(const WavevectorInfo& wavevectors) const { cvector_t mag_ortho = OrthogonalToBaseVector(wavevectors.getQ(), m_magnetization); complex_t unit_factor = scalarSubtrSLD(wavevectors); return MaterialUtils::MagnetizationCorrection(unit_factor, magnetization_prefactor, mag_ortho); } -MagneticMaterialImpl* MagneticMaterialImpl::rotatedMaterial(const Transform3D& transform) const -{ +MagneticMaterialImpl* MagneticMaterialImpl::rotatedMaterial(const Transform3D& transform) const { kvector_t transformed_field = transform.transformed(m_magnetization); MagneticMaterialImpl* result = this->clone(); result->setMagnetization(transformed_field); diff --git a/Sample/Material/MagneticMaterialImpl.h b/Sample/Material/MagneticMaterialImpl.h index 6951b143ad8503c5cb366237a73c640a1d048bd9..830382dc85c13638d99b2da72684e81872a62591 100644 --- a/Sample/Material/MagneticMaterialImpl.h +++ b/Sample/Material/MagneticMaterialImpl.h @@ -25,8 +25,7 @@ class WavevectorInfo; //! Incorporates data and methods required to handle material magnetization. //! @ingroup materials -class MagneticMaterialImpl : public BaseMaterialImpl -{ +class MagneticMaterialImpl : public BaseMaterialImpl { public: //! Constructs basic material with name and magnetization MagneticMaterialImpl(const std::string& name, kvector_t magnetization); diff --git a/Sample/Material/Material.cpp b/Sample/Material/Material.cpp index b4e97f7113b45b4b4d46a4d1fe896d9941f05ab7..96aef5472e31a0d425f1c5ccb4849fe694264f44 100644 --- a/Sample/Material/Material.cpp +++ b/Sample/Material/Material.cpp @@ -19,20 +19,16 @@ #include <typeinfo> Material::Material(std::unique_ptr<BaseMaterialImpl> material_impl) - : m_material_impl(std::move(material_impl)) -{ -} + : m_material_impl(std::move(material_impl)) {} -Material::Material(const Material& material) -{ +Material::Material(const Material& material) { if (material.isEmpty()) throw Exceptions::NullPointerException( "Material: Error! Attempt to initialize material with nullptr."); m_material_impl.reset(material.m_material_impl->clone()); } -Material& Material::operator=(const Material& other) -{ +Material& Material::operator=(const Material& other) { if (other.isEmpty()) throw Exceptions::NullPointerException( "Material: Error! Attempt to assign nullptr to material."); @@ -40,64 +36,52 @@ Material& Material::operator=(const Material& other) return *this; } -Material Material::inverted() const -{ +Material Material::inverted() const { std::unique_ptr<BaseMaterialImpl> material_impl(m_material_impl->inverted()); return Material(std::move(material_impl)); } -complex_t Material::refractiveIndex(double wavelength) const -{ +complex_t Material::refractiveIndex(double wavelength) const { return m_material_impl->refractiveIndex(wavelength); } -complex_t Material::refractiveIndex2(double wavelength) const -{ +complex_t Material::refractiveIndex2(double wavelength) const { return m_material_impl->refractiveIndex2(wavelength); } -bool Material::isScalarMaterial() const -{ +bool Material::isScalarMaterial() const { return m_material_impl->isScalarMaterial(); } -bool Material::isMagneticMaterial() const -{ +bool Material::isMagneticMaterial() const { return m_material_impl->isMagneticMaterial(); } -std::string Material::getName() const -{ +std::string Material::getName() const { return m_material_impl->getName(); } -MATERIAL_TYPES Material::typeID() const -{ +MATERIAL_TYPES Material::typeID() const { return m_material_impl->typeID(); } -kvector_t Material::magnetization() const -{ +kvector_t Material::magnetization() const { return m_material_impl->magnetization(); } -complex_t Material::materialData() const -{ +complex_t Material::materialData() const { return m_material_impl->materialData(); } -bool Material::isDefaultMaterial() const -{ +bool Material::isDefaultMaterial() const { return materialData() == complex_t() && isScalarMaterial(); } -complex_t Material::scalarSubtrSLD(const WavevectorInfo& wavevectors) const -{ +complex_t Material::scalarSubtrSLD(const WavevectorInfo& wavevectors) const { return m_material_impl->scalarSubtrSLD(wavevectors); } -Eigen::Matrix2cd Material::polarizedSubtrSLD(const WavevectorInfo& wavevectors) const -{ +Eigen::Matrix2cd Material::polarizedSubtrSLD(const WavevectorInfo& wavevectors) const { return m_material_impl->polarizedSubtrSLD(wavevectors); } @@ -107,14 +91,12 @@ Material Material::rotatedMaterial(const Transform3D& transform) const // TODO p return Material(std::move(material_impl)); } -std::ostream& operator<<(std::ostream& ostr, const Material& m) -{ +std::ostream& operator<<(std::ostream& ostr, const Material& m) { m.m_material_impl->print(ostr); return ostr; } -bool operator==(const Material& left, const Material& right) -{ +bool operator==(const Material& left, const Material& right) { if (left.getName() != right.getName()) return false; if (left.magnetization() != right.magnetization()) @@ -126,7 +108,6 @@ bool operator==(const Material& left, const Material& right) return true; } -bool operator!=(const Material& left, const Material& right) -{ +bool operator!=(const Material& left, const Material& right) { return !(left == right); } diff --git a/Sample/Material/Material.h b/Sample/Material/Material.h index ef6774ee4066cbf7db3f257f283de8528ed916bd..8b272f7061c88133aadac2a2f795a4adb2ee0466 100644 --- a/Sample/Material/Material.h +++ b/Sample/Material/Material.h @@ -25,8 +25,7 @@ class WavevectorInfo; //! A wrapper for underlying material implementation //! @ingroup materials -class Material -{ +class Material { public: #ifndef SWIG //! Creates material with particular material implementation diff --git a/Sample/Material/MaterialBySLDImpl.cpp b/Sample/Material/MaterialBySLDImpl.cpp index b1da544a67c05e8d7e294af5851b94a6183374db..2424dca9bb8b6e859bc32983d4ad061224517ef9 100644 --- a/Sample/Material/MaterialBySLDImpl.cpp +++ b/Sample/Material/MaterialBySLDImpl.cpp @@ -16,12 +16,10 @@ #include "Base/Const/Units.h" #include "Sample/Material/WavevectorInfo.h" -namespace -{ +namespace { const double square_angstroms = Units::angstrom * Units::angstrom; -inline double getWlPrefactor(double wavelength) -{ +inline double getWlPrefactor(double wavelength) { return wavelength * wavelength / M_PI; } } // namespace @@ -32,44 +30,35 @@ MaterialBySLDImpl::MaterialBySLDImpl(const std::string& name, double sld_real, d , m_sld_real(sld_real) , m_sld_imag(sld_imag < 0. ? throw std::runtime_error( "The imaginary part of the SLD must be greater or equal zero") - : sld_imag) -{ -} + : sld_imag) {} -MaterialBySLDImpl* MaterialBySLDImpl::clone() const -{ +MaterialBySLDImpl* MaterialBySLDImpl::clone() const { return new MaterialBySLDImpl(*this); } -complex_t MaterialBySLDImpl::refractiveIndex(double wavelength) const -{ +complex_t MaterialBySLDImpl::refractiveIndex(double wavelength) const { return std::sqrt(refractiveIndex2(wavelength)); } -complex_t MaterialBySLDImpl::refractiveIndex2(double wavelength) const -{ +complex_t MaterialBySLDImpl::refractiveIndex2(double wavelength) const { return 1.0 - getWlPrefactor(wavelength) * sld(); } -complex_t MaterialBySLDImpl::materialData() const -{ +complex_t MaterialBySLDImpl::materialData() const { return complex_t(m_sld_real * square_angstroms, m_sld_imag * square_angstroms); } -complex_t MaterialBySLDImpl::scalarSubtrSLD(const WavevectorInfo& wavevectors) const -{ +complex_t MaterialBySLDImpl::scalarSubtrSLD(const WavevectorInfo& wavevectors) const { double wavelength = wavevectors.getWavelength(); return 1.0 / getWlPrefactor(wavelength) - sld(); } -void MaterialBySLDImpl::print(std::ostream& ostr) const -{ +void MaterialBySLDImpl::print(std::ostream& ostr) const { ostr << "MaterialBySLD:" << getName() << "<" << this << ">{ " << "sld_real=" << m_sld_real << ", sld_imag = " << m_sld_imag << ", B=" << magnetization() << "}"; } -complex_t MaterialBySLDImpl::sld() const -{ +complex_t MaterialBySLDImpl::sld() const { return complex_t(m_sld_real, -m_sld_imag); } diff --git a/Sample/Material/MaterialBySLDImpl.h b/Sample/Material/MaterialBySLDImpl.h index 0527328bab643c8c93bb37069443927216bbfeae..c67fb27a016b1ad041dc4d16dd6a99ff5797476b 100644 --- a/Sample/Material/MaterialBySLDImpl.h +++ b/Sample/Material/MaterialBySLDImpl.h @@ -21,8 +21,7 @@ //! Material implementation based on wavelength-independent data (valid for a range of wavelengths) //! @ingroup materials -class MaterialBySLDImpl : public MagneticMaterialImpl -{ +class MaterialBySLDImpl : public MagneticMaterialImpl { public: friend Material MaterialBySLD(const std::string& name, double sld_real, double sld_imag, kvector_t magnetization); diff --git a/Sample/Material/MaterialFactoryFuncs.cpp b/Sample/Material/MaterialFactoryFuncs.cpp index 9608f16721353581ef5b8a2a3a0f2af3a76ac919..0dea4f9bc8b55bbdcf721d379c9647d416ff3dff 100644 --- a/Sample/Material/MaterialFactoryFuncs.cpp +++ b/Sample/Material/MaterialFactoryFuncs.cpp @@ -19,34 +19,29 @@ #include <functional> Material HomogeneousMaterial(const std::string& name, complex_t refractive_index, - kvector_t magnetization) -{ + kvector_t magnetization) { const double delta = 1.0 - refractive_index.real(); const double beta = refractive_index.imag(); return HomogeneousMaterial(name, delta, beta, magnetization); } Material HomogeneousMaterial(const std::string& name, double delta, double beta, - kvector_t magnetization) -{ + kvector_t magnetization) { std::unique_ptr<RefractiveMaterialImpl> mat_impl( new RefractiveMaterialImpl(name, delta, beta, magnetization)); return Material(std::move(mat_impl)); } -Material HomogeneousMaterial() -{ +Material HomogeneousMaterial() { return HomogeneousMaterial("vacuum", 0.0, 0.0, kvector_t{}); } -Material MaterialBySLD() -{ +Material MaterialBySLD() { return MaterialBySLD("vacuum", 0.0, 0.0, kvector_t{}); } Material MaterialBySLD(const std::string& name, double sld_real, double sld_imag, - kvector_t magnetization) -{ + kvector_t magnetization) { constexpr double inv_sq_angstroms = 1.0 / (Units::angstrom * Units::angstrom); std::unique_ptr<MaterialBySLDImpl> mat_impl(new MaterialBySLDImpl( name, sld_real * inv_sq_angstroms, sld_imag * inv_sq_angstroms, magnetization)); diff --git a/Sample/Material/MaterialUtils.cpp b/Sample/Material/MaterialUtils.cpp index 6e4f896138b4ba362632b029a1a0873c00502cf2..60f6a2b76170a538204900507f5eac336f6255e7 100644 --- a/Sample/Material/MaterialUtils.cpp +++ b/Sample/Material/MaterialUtils.cpp @@ -25,8 +25,7 @@ constexpr double magnetic_prefactor = (m_n * g_factor_n * mu_N / h_bar / h_bar) // Unit 2x2 matrix const Eigen::Matrix2cd Unit_Matrix(Eigen::Matrix2cd::Identity()); -namespace -{ +namespace { // Pauli matrices const Eigen::Matrix2cd Pauli_X((Eigen::Matrix2cd() << 0, 1, 1, 0).finished()); const Eigen::Matrix2cd Pauli_Y((Eigen::Matrix2cd() << 0, -I, I, 0).finished()); @@ -36,8 +35,7 @@ const Eigen::Matrix2cd Pauli_Z((Eigen::Matrix2cd() << 1, 0, 0, -1).finished()); template <typename T> Eigen::Matrix2cd MaterialUtils::MagnetizationCorrection(complex_t unit_factor, double magnetic_factor, - BasicVector3D<T> polarization) -{ + BasicVector3D<T> polarization) { Eigen::Matrix2cd result = unit_factor * Unit_Matrix + magnetic_factor @@ -53,22 +51,19 @@ template Eigen::Matrix2cd MaterialUtils::MagnetizationCorrection(complex_t unit_ double magnetic_factor, cvector_t polarization); -complex_t MaterialUtils::ScalarReducedPotential(complex_t n, kvector_t k, double n_ref) -{ +complex_t MaterialUtils::ScalarReducedPotential(complex_t n, kvector_t k, double n_ref) { return n * n - n_ref * n_ref * k.sin2Theta(); } Eigen::Matrix2cd MaterialUtils::PolarizedReducedPotential(complex_t n, kvector_t b_field, - kvector_t k, double n_ref) -{ + kvector_t k, double n_ref) { Eigen::Matrix2cd result; double factor = magnetic_prefactor / k.mag2(); complex_t unit_factor = ScalarReducedPotential(n, k, n_ref); return MagnetizationCorrection(unit_factor, factor, b_field); } -MATERIAL_TYPES MaterialUtils::checkMaterialTypes(const std::vector<const Material*>& materials) -{ +MATERIAL_TYPES MaterialUtils::checkMaterialTypes(const std::vector<const Material*>& materials) { MATERIAL_TYPES result = MATERIAL_TYPES::RefractiveMaterial; bool isDefault = true; for (const Material* mat : materials) { diff --git a/Sample/Material/MaterialUtils.h b/Sample/Material/MaterialUtils.h index e257e95462f44698c785a3e59b441c3f4ad0d837..dfd3b6379916de45805660d42844f90e83608969 100644 --- a/Sample/Material/MaterialUtils.h +++ b/Sample/Material/MaterialUtils.h @@ -20,8 +20,7 @@ //! A number of materials-related helper functions for internal use //! @ingroup materials -namespace MaterialUtils -{ +namespace MaterialUtils { //! Function for calculating the reduced potential, used for obtaining the Fresnel coefficients //! (non-polarized material case) diff --git a/Sample/Material/RefractiveMaterialImpl.cpp b/Sample/Material/RefractiveMaterialImpl.cpp index d34dc6d3915016e2233734d352c602006a88f041..63eacacf2a1cc178226e311ce36214e2ec2cf68f 100644 --- a/Sample/Material/RefractiveMaterialImpl.cpp +++ b/Sample/Material/RefractiveMaterialImpl.cpp @@ -21,39 +21,31 @@ RefractiveMaterialImpl::RefractiveMaterialImpl(const std::string& name, double d , m_delta(delta) , m_beta(beta < 0. ? throw std::runtime_error( "The imaginary part of the refractive index must be greater or equal zero") - : beta) -{ -} + : beta) {} -RefractiveMaterialImpl* RefractiveMaterialImpl::clone() const -{ +RefractiveMaterialImpl* RefractiveMaterialImpl::clone() const { return new RefractiveMaterialImpl(*this); } -complex_t RefractiveMaterialImpl::refractiveIndex(double) const -{ +complex_t RefractiveMaterialImpl::refractiveIndex(double) const { return complex_t(1.0 - m_delta, m_beta); } -complex_t RefractiveMaterialImpl::refractiveIndex2(double) const -{ +complex_t RefractiveMaterialImpl::refractiveIndex2(double) const { complex_t result(1.0 - m_delta, m_beta); return result * result; } -complex_t RefractiveMaterialImpl::materialData() const -{ +complex_t RefractiveMaterialImpl::materialData() const { return complex_t(m_delta, m_beta); } -complex_t RefractiveMaterialImpl::scalarSubtrSLD(const WavevectorInfo& wavevectors) const -{ +complex_t RefractiveMaterialImpl::scalarSubtrSLD(const WavevectorInfo& wavevectors) const { double wavelength = wavevectors.getWavelength(); return M_PI / wavelength / wavelength * refractiveIndex2(wavelength); } -void RefractiveMaterialImpl::print(std::ostream& ostr) const -{ +void RefractiveMaterialImpl::print(std::ostream& ostr) const { ostr << "RefractiveMaterial:" << getName() << "<" << this << ">{ " << "delta=" << m_delta << ", beta=" << m_beta << ", B=" << magnetization() << "}"; } diff --git a/Sample/Material/RefractiveMaterialImpl.h b/Sample/Material/RefractiveMaterialImpl.h index 16b765c9e705d01252e6b8f6e749f967ffbc5929..0128614e02488302a63e90e70b5d62c045053bca 100644 --- a/Sample/Material/RefractiveMaterialImpl.h +++ b/Sample/Material/RefractiveMaterialImpl.h @@ -21,8 +21,7 @@ //! Material implementation based on refractive coefficiencts (valid for one wavelength value only) //! @ingroup materials -class RefractiveMaterialImpl : public MagneticMaterialImpl -{ +class RefractiveMaterialImpl : public MagneticMaterialImpl { public: friend Material HomogeneousMaterial(const std::string&, double, double, kvector_t); diff --git a/Sample/Material/WavevectorInfo.cpp b/Sample/Material/WavevectorInfo.cpp index b93b859d4a664b26549fdad8f40cf01175f1f768..0011243432ae534e98b765dc99ce9acef12c06c4 100644 --- a/Sample/Material/WavevectorInfo.cpp +++ b/Sample/Material/WavevectorInfo.cpp @@ -17,13 +17,11 @@ // TODO: can be removed when IFormFactor::volume() is refactored // (static function is provided to easily track usage of default constructor) -WavevectorInfo WavevectorInfo::GetZeroQ() -{ +WavevectorInfo WavevectorInfo::GetZeroQ() { return {}; } -WavevectorInfo WavevectorInfo::transformed(const Transform3D& transform) const -{ +WavevectorInfo WavevectorInfo::transformed(const Transform3D& transform) const { return WavevectorInfo(transform.transformed(m_ki), transform.transformed(m_kf), m_vacuum_wavelength); } diff --git a/Sample/Material/WavevectorInfo.h b/Sample/Material/WavevectorInfo.h index ec7ab405e1ac198cb8525bc0b2dbc40536427926..fa4eff86bd0e429f175b62e3d5e8635fd425a8e3 100644 --- a/Sample/Material/WavevectorInfo.h +++ b/Sample/Material/WavevectorInfo.h @@ -22,18 +22,13 @@ class Transform3D; //! Holds all wavevector information relevant for calculating form factors. //! @ingroup formfactors_internal -class WavevectorInfo -{ +class WavevectorInfo { public: static WavevectorInfo GetZeroQ(); WavevectorInfo(cvector_t ki, cvector_t kf, double wavelength) - : m_ki(ki), m_kf(kf), m_vacuum_wavelength(wavelength) - { - } + : m_ki(ki), m_kf(kf), m_vacuum_wavelength(wavelength) {} WavevectorInfo(kvector_t ki, kvector_t kf, double wavelength) - : m_ki(ki.complex()), m_kf(kf.complex()), m_vacuum_wavelength(wavelength) - { - } + : m_ki(ki.complex()), m_kf(kf.complex()), m_vacuum_wavelength(wavelength) {} WavevectorInfo transformed(const Transform3D& transform) const; cvector_t getKi() const { return m_ki; } diff --git a/Sample/Multilayer/Layer.cpp b/Sample/Multilayer/Layer.cpp index cec5985fb33d4e5c6451a0eb2a6ab3a859c719a8..111901edb6b5ae9d892cda8d236ded4ebd73875d 100644 --- a/Sample/Multilayer/Layer.cpp +++ b/Sample/Multilayer/Layer.cpp @@ -22,16 +22,14 @@ //! @param material: material the layer is made of //! @param thickness: thickness of a layer in nanometers Layer::Layer(Material material, double thickness) - : m_material(std::move(material)), m_thickness(thickness) -{ + : m_material(std::move(material)), m_thickness(thickness) { setName("Layer"); registerThickness(); } Layer::~Layer() = default; -Layer* Layer::clone() const -{ +Layer* Layer::clone() const { Layer* p_result = new Layer(m_material, m_thickness); p_result->setName(getName()); p_result->m_B_field = m_B_field; @@ -42,43 +40,37 @@ Layer* Layer::clone() const } //! Sets layer thickness in nanometers. -void Layer::setThickness(double thickness) -{ +void Layer::setThickness(double thickness) { if (thickness < 0.) throw Exceptions::DomainErrorException("Layer thickness cannot be negative"); m_thickness = thickness; } -void Layer::setMaterial(Material material) -{ +void Layer::setMaterial(Material material) { m_material = std::move(material); } -void Layer::addLayout(const ParticleLayout& layout) -{ +void Layer::addLayout(const ParticleLayout& layout) { ParticleLayout* clone = layout.clone(); m_layouts.push_back(clone); registerChild(clone); } -std::vector<const ParticleLayout*> Layer::layouts() const -{ +std::vector<const ParticleLayout*> Layer::layouts() const { std::vector<const ParticleLayout*> result; for (auto p_layout : m_layouts) result.push_back(p_layout); return result; } -std::vector<const INode*> Layer::getChildren() const -{ +std::vector<const INode*> Layer::getChildren() const { std::vector<const INode*> result; for (auto layout : m_layouts) result.push_back(layout); return result; } -void Layer::registerThickness(bool make_registered) -{ +void Layer::registerThickness(bool make_registered) { if (make_registered) { if (!parameter("Thickness")) registerParameter("Thickness", &m_thickness).setUnit("nm").setNonnegative(); diff --git a/Sample/Multilayer/Layer.h b/Sample/Multilayer/Layer.h index 7675e2ab5aa9265cd1b4858b25962aa46150f64b..e7f0602a5476065cbf4d232c671814b0afd22e28 100644 --- a/Sample/Multilayer/Layer.h +++ b/Sample/Multilayer/Layer.h @@ -24,8 +24,7 @@ class ParticleLayout; //! A layer, with thickness (in nanometer) and material. //! @ingroup samples -class Layer : public ISample -{ +class Layer : public ISample { public: Layer(Material material, double thickness = 0); diff --git a/Sample/Multilayer/MultiLayer.cpp b/Sample/Multilayer/MultiLayer.cpp index 34638408849e2e9af459c18bb7c2f062ed751c82..1e4d2711c27b4a508352a0041aa65724e4e2b19f 100644 --- a/Sample/Multilayer/MultiLayer.cpp +++ b/Sample/Multilayer/MultiLayer.cpp @@ -24,8 +24,7 @@ #include "Sample/Slice/LayerInterface.h" #include "Sample/Slice/LayerRoughness.h" -MultiLayer::MultiLayer() : m_crossCorrLength(0) -{ +MultiLayer::MultiLayer() : m_crossCorrLength(0) { setName("MultiLayer"); registerParameter("CrossCorrelationLength", &m_crossCorrLength).setUnit("nm").setNonnegative(); registerVector("ExternalField", &m_ext_field, ""); @@ -33,8 +32,7 @@ MultiLayer::MultiLayer() : m_crossCorrLength(0) MultiLayer::~MultiLayer() = default; -MultiLayer* MultiLayer::clone() const -{ +MultiLayer* MultiLayer::clone() const { auto* ret = new MultiLayer; ret->setCrossCorrLength(crossCorrLength()); ret->setExternalField(externalField()); @@ -51,15 +49,13 @@ MultiLayer* MultiLayer::clone() const } //! Adds layer with default (zero) roughness -void MultiLayer::addLayer(const Layer& layer) -{ +void MultiLayer::addLayer(const Layer& layer) { LayerRoughness zero_roughness; addLayerWithTopRoughness(layer, zero_roughness); } //! Adds layer with top roughness -void MultiLayer::addLayerWithTopRoughness(const Layer& layer, const LayerRoughness& roughness) -{ +void MultiLayer::addLayerWithTopRoughness(const Layer& layer, const LayerRoughness& roughness) { Layer* new_layer = layer.clone(); if (numberOfLayers()) { // not the top layer @@ -85,35 +81,29 @@ void MultiLayer::addLayerWithTopRoughness(const Layer& layer, const LayerRoughne addAndRegisterLayer(new_layer); } -const Layer* MultiLayer::layer(size_t i_layer) const -{ +const Layer* MultiLayer::layer(size_t i_layer) const { return m_layers[check_layer_index(i_layer)]; } -const LayerInterface* MultiLayer::layerInterface(size_t i_interface) const -{ +const LayerInterface* MultiLayer::layerInterface(size_t i_interface) const { return m_interfaces[check_interface_index(i_interface)]; } -void MultiLayer::setCrossCorrLength(double crossCorrLength) -{ +void MultiLayer::setCrossCorrLength(double crossCorrLength) { if (crossCorrLength < 0.0) throw Exceptions::LogicErrorException("Attempt to set crossCorrLength to negative value"); m_crossCorrLength = crossCorrLength; } -void MultiLayer::setExternalField(kvector_t ext_field) -{ +void MultiLayer::setExternalField(kvector_t ext_field) { m_ext_field = ext_field; } -void MultiLayer::setRoughnessModel(RoughnessModel roughnessModel) -{ +void MultiLayer::setRoughnessModel(RoughnessModel roughnessModel) { m_roughness_model = roughnessModel; } -std::vector<const INode*> MultiLayer::getChildren() const -{ +std::vector<const INode*> MultiLayer::getChildren() const { std::vector<const INode*> ret; const size_t N = m_layers.size(); ret.reserve(N + m_interfaces.size()); @@ -127,35 +117,30 @@ std::vector<const INode*> MultiLayer::getChildren() const return ret; } -void MultiLayer::addAndRegisterLayer(Layer* child) -{ +void MultiLayer::addAndRegisterLayer(Layer* child) { m_layers.push_back(child); handleLayerThicknessRegistration(); registerChild(child); } -void MultiLayer::addAndRegisterInterface(LayerInterface* child) -{ +void MultiLayer::addAndRegisterInterface(LayerInterface* child) { m_interfaces.push_back(child); registerChild(child); } -void MultiLayer::handleLayerThicknessRegistration() -{ +void MultiLayer::handleLayerThicknessRegistration() { size_t n_layers = numberOfLayers(); for (size_t i = 0; i < numberOfLayers(); ++i) m_layers[i]->registerThickness(i > 0 && i < n_layers - 1); } -size_t MultiLayer::check_layer_index(size_t i_layer) const -{ +size_t MultiLayer::check_layer_index(size_t i_layer) const { if (i_layer >= m_layers.size()) throw Exceptions::OutOfBoundsException("Layer index is out of bounds"); return i_layer; } -size_t MultiLayer::check_interface_index(size_t i_interface) const -{ +size_t MultiLayer::check_interface_index(size_t i_interface) const { if (i_interface >= m_interfaces.size()) throw Exceptions::OutOfBoundsException("Interface index is out of bounds"); return i_interface; diff --git a/Sample/Multilayer/MultiLayer.h b/Sample/Multilayer/MultiLayer.h index b0c991b1de89b6ea484e4cb783fbcac03a415b3e..26e5b2aa65d3110e70ba1a1ef2d0c12a41a8de4c 100644 --- a/Sample/Multilayer/MultiLayer.h +++ b/Sample/Multilayer/MultiLayer.h @@ -38,8 +38,7 @@ class LayerRoughness; //! --------- interface #2 z=-60.0 //! substrate layer #3 -class MultiLayer : public ISample -{ +class MultiLayer : public ISample { public: MultiLayer(); ~MultiLayer() override; diff --git a/Sample/Multilayer/MultiLayerUtils.cpp b/Sample/Multilayer/MultiLayerUtils.cpp index fb03291bb42717c0b8a7154a27ac134476ff527a..dd3b743153c00aebeede38dfe82cbc94f601d837 100644 --- a/Sample/Multilayer/MultiLayerUtils.cpp +++ b/Sample/Multilayer/MultiLayerUtils.cpp @@ -21,11 +21,9 @@ #include "Sample/Scattering/LayerFillLimits.h" #include "Sample/Slice/LayerInterface.h" -namespace -{ +namespace { -std::vector<double> BottomLayerCoordinates(const MultiLayer& multilayer) -{ +std::vector<double> BottomLayerCoordinates(const MultiLayer& multilayer) { auto n_layers = multilayer.numberOfLayers(); if (n_layers < 2) return {}; @@ -39,49 +37,43 @@ std::vector<double> BottomLayerCoordinates(const MultiLayer& multilayer) } // namespace -double MultiLayerUtils::LayerThickness(const MultiLayer& multilayer, size_t i) -{ +double MultiLayerUtils::LayerThickness(const MultiLayer& multilayer, size_t i) { return multilayer.layer(i)->thickness(); } -const LayerInterface* MultiLayerUtils::LayerTopInterface(const MultiLayer& multilayer, size_t i) -{ +const LayerInterface* MultiLayerUtils::LayerTopInterface(const MultiLayer& multilayer, size_t i) { if (i == 0) return nullptr; return multilayer.layerInterface(i - 1); } -const LayerInterface* MultiLayerUtils::LayerBottomInterface(const MultiLayer& multilayer, size_t i) -{ +const LayerInterface* MultiLayerUtils::LayerBottomInterface(const MultiLayer& multilayer, + size_t i) { if (i + 1 < multilayer.numberOfLayers()) return multilayer.layerInterface(i); return nullptr; } -const LayerRoughness* MultiLayerUtils::LayerTopRoughness(const MultiLayer& multilayer, size_t i) -{ +const LayerRoughness* MultiLayerUtils::LayerTopRoughness(const MultiLayer& multilayer, size_t i) { if (i == 0) return nullptr; return multilayer.layerInterface(i - 1)->getRoughness(); } -size_t MultiLayerUtils::IndexOfLayer(const MultiLayer& multilayer, const Layer* p_layer) -{ +size_t MultiLayerUtils::IndexOfLayer(const MultiLayer& multilayer, const Layer* p_layer) { for (size_t i = 0; i < multilayer.numberOfLayers(); ++i) if (p_layer == multilayer.layer(i)) return i; throw std::out_of_range("MultiLayerUtils::IndexOfLayer: layer not found"); } -bool MultiLayerUtils::ContainsCompatibleMaterials(const MultiLayer& multilayer) -{ +bool MultiLayerUtils::ContainsCompatibleMaterials(const MultiLayer& multilayer) { return MaterialUtils::checkMaterialTypes(multilayer.containedMaterials()) != MATERIAL_TYPES::InvalidMaterialType; } std::vector<ZLimits> MultiLayerUtils::ParticleRegions(const MultiLayer& multilayer, - bool use_slicing) -{ + bool use_slicing) { auto bottom_coords = BottomLayerCoordinates(multilayer); LayerFillLimits layer_fill_limits(bottom_coords); if (use_slicing) { @@ -97,8 +89,7 @@ std::vector<ZLimits> MultiLayerUtils::ParticleRegions(const MultiLayer& multilay return layer_fill_limits.layerZLimits(); } -bool MultiLayerUtils::hasRoughness(const MultiLayer& sample) -{ +bool MultiLayerUtils::hasRoughness(const MultiLayer& sample) { for (size_t i = 0; i < sample.numberOfLayers() - 1; i++) { if (sample.layerInterface(i)->getRoughness()) return true; diff --git a/Sample/Multilayer/MultiLayerUtils.h b/Sample/Multilayer/MultiLayerUtils.h index cc5ecccf79e69a1d03656090562bcabf865066f2..b05b46ae87b70a710b213ef7b8f27f97d192de77 100644 --- a/Sample/Multilayer/MultiLayerUtils.h +++ b/Sample/Multilayer/MultiLayerUtils.h @@ -24,8 +24,7 @@ class LayerRoughness; class MultiLayer; class ZLimits; -namespace MultiLayerUtils -{ +namespace MultiLayerUtils { //! Returns thickness of layer double LayerThickness(const MultiLayer& multilayer, size_t i); diff --git a/Sample/Multilayer/PyImport.cpp b/Sample/Multilayer/PyImport.cpp index 98001ed22c91d99228a54cd3a097a4ef0f22e4d7..a43c44732d6658679be4ef9213cd73a5ceb9a8b7 100644 --- a/Sample/Multilayer/PyImport.cpp +++ b/Sample/Multilayer/PyImport.cpp @@ -19,11 +19,9 @@ #include "Base/Utils/PythonCore.h" #include "Sample/Multilayer/MultiLayer.h" -namespace -{ +namespace { -std::string error_description(const std::string& title) -{ +std::string error_description(const std::string& title) { std::stringstream buf; buf << title << "\n"; buf << PyEmbeddedUtils::pythonStackTrace() << "\n"; @@ -34,8 +32,7 @@ std::string error_description(const std::string& title) std::unique_ptr<MultiLayer> PyImport::createFromPython(const std::string& script, const std::string& functionName, - const std::string& path) -{ + const std::string& path) { PyEmbeddedUtils::import_bornagain(path); PyObject* pCompiledFn = Py_CompileString(script.c_str(), "", Py_file_input); @@ -85,8 +82,7 @@ std::unique_ptr<MultiLayer> PyImport::createFromPython(const std::string& script } std::vector<std::string> PyImport::listOfFunctions(const std::string& script, - const std::string& path) -{ + const std::string& path) { PyEmbeddedUtils::import_bornagain(path); PyObject* pCompiledFn = Py_CompileString(script.c_str(), "", Py_file_input); diff --git a/Sample/Multilayer/PyImport.h b/Sample/Multilayer/PyImport.h index eaaecf06bb7315f0c349627ce790abf812f92b68..c040e65cc2e7f187b7c9c8491d59c5439d3d0cb0 100644 --- a/Sample/Multilayer/PyImport.h +++ b/Sample/Multilayer/PyImport.h @@ -23,8 +23,7 @@ class MultiLayer; -namespace PyImport -{ +namespace PyImport { ////! Returns directory name // std::string bornagainPythonDir(); diff --git a/Sample/Multilayer/RoughnessModels.cpp b/Sample/Multilayer/RoughnessModels.cpp index 7cdeb230ffa3f365407237952959b470998f1632..5346cfd3b50c7d7254fbbcc78e844fdfc19fb25e 100644 --- a/Sample/Multilayer/RoughnessModels.cpp +++ b/Sample/Multilayer/RoughnessModels.cpp @@ -16,15 +16,13 @@ #include <map> -namespace -{ +namespace { const std::map<RoughnessModel, std::string> roughnessModelNames = { {RoughnessModel::DEFAULT, "RoughnessModel::DEFAULT"}, {RoughnessModel::TANH, "RoughnessModel::TANH"}, {RoughnessModel::NEVOT_CROCE, "RoughnessModel::NEVOT_CROCE"}}; } -std::string RoughnessModelWrap::roughnessModelName(RoughnessModel model) -{ +std::string RoughnessModelWrap::roughnessModelName(RoughnessModel model) { return roughnessModelNames.at(model); } diff --git a/Sample/Particle/Crystal.cpp b/Sample/Particle/Crystal.cpp index ee138043debf9cf80db3eb189faf9bfe642756df..e036476541c4612872bba2c05ec68c361731f147 100644 --- a/Sample/Particle/Crystal.cpp +++ b/Sample/Particle/Crystal.cpp @@ -21,8 +21,7 @@ #include "Sample/Scattering/Rotations.h" Crystal::Crystal(const IParticle& basis, const Lattice3D& lattice, double position_variance) - : m_lattice(lattice), m_position_variance(position_variance) -{ + : m_lattice(lattice), m_position_variance(position_variance) { setName("Crystal"); m_basis.reset(basis.clone()); m_basis->registerAbundance(false); @@ -31,8 +30,7 @@ Crystal::Crystal(const IParticle& basis, const Lattice3D& lattice, double positi } Crystal::Crystal(IParticle* p_basis, const Lattice3D& lattice, double position_variance) - : m_lattice(lattice), m_position_variance(position_variance) -{ + : m_lattice(lattice), m_position_variance(position_variance) { setName("Crystal"); m_basis.reset(p_basis); registerChild(m_basis.get()); @@ -41,15 +39,13 @@ Crystal::Crystal(IParticle* p_basis, const Lattice3D& lattice, double position_v Crystal::~Crystal() = default; -Crystal* Crystal::clone() const -{ +Crystal* Crystal::clone() const { return new Crystal(*m_basis, m_lattice, m_position_variance); } IFormFactor* Crystal::createTotalFormFactor(const IFormFactor& meso_crystal_form_factor, const IRotation* p_rotation, - const kvector_t& translation) const -{ + const kvector_t& translation) const { Lattice3D transformed_lattice = transformedLattice(p_rotation); std::unique_ptr<IParticle> P_basis_clone{m_basis->clone()}; if (p_rotation) @@ -60,8 +56,7 @@ IFormFactor* Crystal::createTotalFormFactor(const IFormFactor& meso_crystal_form m_position_variance); } -std::vector<HomogeneousRegion> Crystal::homogeneousRegions() const -{ +std::vector<HomogeneousRegion> Crystal::homogeneousRegions() const { std::vector<HomogeneousRegion> result; double unit_cell_volume = m_lattice.unitCellVolume(); if (unit_cell_volume <= 0) @@ -78,14 +73,12 @@ std::vector<HomogeneousRegion> Crystal::homogeneousRegions() const return result; } -Lattice3D Crystal::transformedLattice(const IRotation* p_rotation) const -{ +Lattice3D Crystal::transformedLattice(const IRotation* p_rotation) const { if (!p_rotation) return m_lattice; return m_lattice.transformed(p_rotation->getTransform3D()); } -std::vector<const INode*> Crystal::getChildren() const -{ +std::vector<const INode*> Crystal::getChildren() const { return std::vector<const INode*>() << m_basis << &m_lattice; } diff --git a/Sample/Particle/Crystal.h b/Sample/Particle/Crystal.h index 6aeb6dbfe2ea46047eb4b7573c8a664315823c16..db69913108cb3906545785f0259689f1a7e6eeb3 100644 --- a/Sample/Particle/Crystal.h +++ b/Sample/Particle/Crystal.h @@ -32,8 +32,7 @@ struct HomogeneousRegion; //! //! @ingroup samples -class Crystal : public ISample -{ +class Crystal : public ISample { public: Crystal(const IParticle& basis, const Lattice3D& lattice, double position_variance = 0); ~Crystal(); diff --git a/Sample/Particle/FormFactorCoreShell.cpp b/Sample/Particle/FormFactorCoreShell.cpp index 14a6e9f04f5bb8a7af74a0ac4bddce9ec83fb0e7..eb1b51f1b411b9d979cbac8601b53958c89df488 100644 --- a/Sample/Particle/FormFactorCoreShell.cpp +++ b/Sample/Particle/FormFactorCoreShell.cpp @@ -15,44 +15,36 @@ #include "Sample/Particle/FormFactorCoreShell.h" FormFactorCoreShell::FormFactorCoreShell(IFormFactor* core, IFormFactor* shell) - : m_core(core), m_shell(shell) -{ + : m_core(core), m_shell(shell) { setName("FormFactorCoreShell"); } FormFactorCoreShell::~FormFactorCoreShell() = default; -FormFactorCoreShell* FormFactorCoreShell::clone() const -{ +FormFactorCoreShell* FormFactorCoreShell::clone() const { return new FormFactorCoreShell(m_core->clone(), m_shell->clone()); } -double FormFactorCoreShell::radialExtension() const -{ +double FormFactorCoreShell::radialExtension() const { return m_shell->radialExtension(); } -double FormFactorCoreShell::bottomZ(const IRotation& rotation) const -{ +double FormFactorCoreShell::bottomZ(const IRotation& rotation) const { return m_shell->bottomZ(rotation); } -double FormFactorCoreShell::topZ(const IRotation& rotation) const -{ +double FormFactorCoreShell::topZ(const IRotation& rotation) const { return m_shell->topZ(rotation); } -void FormFactorCoreShell::setAmbientMaterial(const Material& material) -{ +void FormFactorCoreShell::setAmbientMaterial(const Material& material) { m_shell->setAmbientMaterial(material); } -complex_t FormFactorCoreShell::evaluate(const WavevectorInfo& wavevectors) const -{ +complex_t FormFactorCoreShell::evaluate(const WavevectorInfo& wavevectors) const { return m_shell->evaluate(wavevectors) + m_core->evaluate(wavevectors); } -Eigen::Matrix2cd FormFactorCoreShell::evaluatePol(const WavevectorInfo& wavevectors) const -{ +Eigen::Matrix2cd FormFactorCoreShell::evaluatePol(const WavevectorInfo& wavevectors) const { return m_shell->evaluatePol(wavevectors) + m_core->evaluatePol(wavevectors); } diff --git a/Sample/Particle/FormFactorCoreShell.h b/Sample/Particle/FormFactorCoreShell.h index e52c10a1a75177f8c62003202bb844dc6b9f955c..f4fd15da1e3f11cddead5cfaf761fb11d3f91ccc 100644 --- a/Sample/Particle/FormFactorCoreShell.h +++ b/Sample/Particle/FormFactorCoreShell.h @@ -25,8 +25,7 @@ //! @ingroup formfactors_internal -class FormFactorCoreShell : public IFormFactor -{ +class FormFactorCoreShell : public IFormFactor { public: FormFactorCoreShell(IFormFactor* core, IFormFactor* shell); ~FormFactorCoreShell() override; diff --git a/Sample/Particle/FormFactorCrystal.cpp b/Sample/Particle/FormFactorCrystal.cpp index b5e892fb7c5925a43ecf0f0933e50a83abc82666..dcea5c98dff3c0f8d0a7a0f1a83cf4b1aa2f9771 100644 --- a/Sample/Particle/FormFactorCrystal.cpp +++ b/Sample/Particle/FormFactorCrystal.cpp @@ -22,30 +22,25 @@ FormFactorCrystal::FormFactorCrystal(const Lattice3D& lattice, const IFormFactor : m_lattice(lattice) , m_basis_form_factor(basis_form_factor.clone()) , m_meso_form_factor(meso_form_factor.clone()) - , m_position_variance(position_variance) -{ + , m_position_variance(position_variance) { setName("FormFactorCrystal"); calculateLargestReciprocalDistance(); } -FormFactorCrystal::~FormFactorCrystal() -{ +FormFactorCrystal::~FormFactorCrystal() { delete m_basis_form_factor; delete m_meso_form_factor; } -double FormFactorCrystal::bottomZ(const IRotation& rotation) const -{ +double FormFactorCrystal::bottomZ(const IRotation& rotation) const { return m_meso_form_factor->bottomZ(rotation); } -double FormFactorCrystal::topZ(const IRotation& rotation) const -{ +double FormFactorCrystal::topZ(const IRotation& rotation) const { return m_meso_form_factor->topZ(rotation); } -complex_t FormFactorCrystal::evaluate(const WavevectorInfo& wavevectors) const -{ +complex_t FormFactorCrystal::evaluate(const WavevectorInfo& wavevectors) const { // retrieve reciprocal lattice vectors within reasonable radius cvector_t q = wavevectors.getQ(); double radius = 2.1 * m_max_rec_length; @@ -68,8 +63,7 @@ complex_t FormFactorCrystal::evaluate(const WavevectorInfo& wavevectors) const return result / m_lattice.unitCellVolume(); } -Eigen::Matrix2cd FormFactorCrystal::evaluatePol(const WavevectorInfo& wavevectors) const -{ +Eigen::Matrix2cd FormFactorCrystal::evaluatePol(const WavevectorInfo& wavevectors) const { // retrieve reciprocal lattice vectors within reasonable radius cvector_t q = wavevectors.getQ(); double radius = 2.1 * m_max_rec_length; @@ -92,8 +86,7 @@ Eigen::Matrix2cd FormFactorCrystal::evaluatePol(const WavevectorInfo& wavevector return result / m_lattice.unitCellVolume(); } -void FormFactorCrystal::calculateLargestReciprocalDistance() -{ +void FormFactorCrystal::calculateLargestReciprocalDistance() { kvector_t a1 = m_lattice.getBasisVectorA(); kvector_t a2 = m_lattice.getBasisVectorB(); kvector_t a3 = m_lattice.getBasisVectorC(); @@ -102,8 +95,7 @@ void FormFactorCrystal::calculateLargestReciprocalDistance() m_max_rec_length = std::max(m_max_rec_length, M_PI / a3.mag()); } -complex_t FormFactorCrystal::debyeWallerFactor(const kvector_t& q_i) const -{ +complex_t FormFactorCrystal::debyeWallerFactor(const kvector_t& q_i) const { auto q2 = q_i.mag2(); return std::exp(-q2 * m_position_variance / 2.0); } diff --git a/Sample/Particle/FormFactorCrystal.h b/Sample/Particle/FormFactorCrystal.h index 36a6373656dc158873b2bf13fb0ed78713e262aa..2a3ce102eed33eb3ce31ea940ba927e92dfa3a73 100644 --- a/Sample/Particle/FormFactorCrystal.h +++ b/Sample/Particle/FormFactorCrystal.h @@ -21,23 +21,20 @@ //! The form factor of a MesoCrystal. //! @ingroup formfactors -class FormFactorCrystal : public IFormFactor -{ +class FormFactorCrystal : public IFormFactor { public: FormFactorCrystal(const Lattice3D& lattice, const IFormFactor& basis_form_factor, const IFormFactor& meso_form_factor, double position_variance = 0.0); ~FormFactorCrystal() override; - FormFactorCrystal* clone() const override - { + FormFactorCrystal* clone() const override { return new FormFactorCrystal(m_lattice, *m_basis_form_factor, *m_meso_form_factor, m_position_variance); } void accept(INodeVisitor* visitor) const override { visitor->visit(this); } - void setAmbientMaterial(const Material& material) override - { + void setAmbientMaterial(const Material& material) override { m_basis_form_factor->setAmbientMaterial(material); } diff --git a/Sample/Particle/FormFactorWeighted.cpp b/Sample/Particle/FormFactorWeighted.cpp index f8462cd17434407c92807c73425903bc23ff2f79..98b0b3a99a1d56deb92d215990851490394d2344 100644 --- a/Sample/Particle/FormFactorWeighted.cpp +++ b/Sample/Particle/FormFactorWeighted.cpp @@ -15,35 +15,30 @@ #include "Sample/Particle/FormFactorWeighted.h" #include "Base/Utils/Algorithms.h" -FormFactorWeighted::FormFactorWeighted() -{ +FormFactorWeighted::FormFactorWeighted() { setName("FormFactorWeighted"); } -FormFactorWeighted::~FormFactorWeighted() -{ +FormFactorWeighted::~FormFactorWeighted() { for (size_t index = 0; index < m_form_factors.size(); ++index) delete m_form_factors[index]; } -FormFactorWeighted* FormFactorWeighted::clone() const -{ +FormFactorWeighted* FormFactorWeighted::clone() const { FormFactorWeighted* result = new FormFactorWeighted(); for (size_t index = 0; index < m_form_factors.size(); ++index) result->addFormFactor(*m_form_factors[index], m_weights[index]); return result; } -double FormFactorWeighted::radialExtension() const -{ +double FormFactorWeighted::radialExtension() const { double result{0.0}; for (size_t index = 0; index < m_form_factors.size(); ++index) result += m_weights[index] * m_form_factors[index]->radialExtension(); return result; } -double FormFactorWeighted::bottomZ(const IRotation& rotation) const -{ +double FormFactorWeighted::bottomZ(const IRotation& rotation) const { if (m_form_factors.empty()) throw std::runtime_error("FormFactorWeighted::bottomZ() -> Error: " "'this' contains no form factors."); @@ -51,8 +46,7 @@ double FormFactorWeighted::bottomZ(const IRotation& rotation) const [&rotation](IFormFactor* ff) { return ff->bottomZ(rotation); }); } -double FormFactorWeighted::topZ(const IRotation& rotation) const -{ +double FormFactorWeighted::topZ(const IRotation& rotation) const { if (m_form_factors.empty()) throw std::runtime_error("FormFactorWeighted::topZ() -> Error: " "'this' contains no form factors."); @@ -60,28 +54,24 @@ double FormFactorWeighted::topZ(const IRotation& rotation) const [&rotation](IFormFactor* ff) { return ff->topZ(rotation); }); } -void FormFactorWeighted::addFormFactor(const IFormFactor& form_factor, double weight) -{ +void FormFactorWeighted::addFormFactor(const IFormFactor& form_factor, double weight) { m_form_factors.push_back(form_factor.clone()); m_weights.push_back(weight); } -void FormFactorWeighted::setAmbientMaterial(const Material& material) -{ +void FormFactorWeighted::setAmbientMaterial(const Material& material) { for (size_t index = 0; index < m_form_factors.size(); ++index) m_form_factors[index]->setAmbientMaterial(material); } -complex_t FormFactorWeighted::evaluate(const WavevectorInfo& wavevectors) const -{ +complex_t FormFactorWeighted::evaluate(const WavevectorInfo& wavevectors) const { complex_t result(0.0, 0.0); for (size_t index = 0; index < m_form_factors.size(); ++index) result += m_weights[index] * m_form_factors[index]->evaluate(wavevectors); return result; } -Eigen::Matrix2cd FormFactorWeighted::evaluatePol(const WavevectorInfo& wavevectors) const -{ +Eigen::Matrix2cd FormFactorWeighted::evaluatePol(const WavevectorInfo& wavevectors) const { Eigen::Matrix2cd result = Eigen::Matrix2cd::Zero(); for (size_t index = 0; index < m_form_factors.size(); ++index) result += m_weights[index] * m_form_factors[index]->evaluatePol(wavevectors); diff --git a/Sample/Particle/FormFactorWeighted.h b/Sample/Particle/FormFactorWeighted.h index ed70db2f6e5cb22032032acda534debe2bbfdd5b..85b1731ebe42f156fdcf907129c3626362b35bb1 100644 --- a/Sample/Particle/FormFactorWeighted.h +++ b/Sample/Particle/FormFactorWeighted.h @@ -25,8 +25,7 @@ //! @ingroup formfactors_internal -class FormFactorWeighted : public IFormFactor -{ +class FormFactorWeighted : public IFormFactor { public: FormFactorWeighted(); ~FormFactorWeighted() override; diff --git a/Sample/Particle/HomogeneousRegion.cpp b/Sample/Particle/HomogeneousRegion.cpp index a3a28074460bdaf36fc14cd5bfe60eb4115e48c4..1ff63def201fc2b5925b6ddf2b063a4e6f789d19 100644 --- a/Sample/Particle/HomogeneousRegion.cpp +++ b/Sample/Particle/HomogeneousRegion.cpp @@ -19,13 +19,11 @@ #include "Sample/Material/RefractiveMaterialImpl.h" #include <functional> -namespace -{ +namespace { template <class T> T averageData(const Material& layer_mat, const std::vector<HomogeneousRegion>& regions, - std::function<T(const Material&)> average) -{ + std::function<T(const Material&)> average) { const T layer_data = average(layer_mat); T averaged_data = layer_data; for (auto& region : regions) @@ -36,8 +34,7 @@ T averageData(const Material& layer_mat, const std::vector<HomogeneousRegion>& r } // namespace Material createAveragedMaterial(const Material& layer_mat, - const std::vector<HomogeneousRegion>& regions) -{ + const std::vector<HomogeneousRegion>& regions) { // determine the type of returned material std::vector<const Material*> materials(regions.size() + 1); materials[0] = &layer_mat; diff --git a/Sample/Particle/IAbstractParticle.cpp b/Sample/Particle/IAbstractParticle.cpp index f72309e5c0d8f0064b59254ab2458322fb18de17..06913eaf7e659d39f8b0184f9ce3cd11b941b1c1 100644 --- a/Sample/Particle/IAbstractParticle.cpp +++ b/Sample/Particle/IAbstractParticle.cpp @@ -15,11 +15,8 @@ #include "Sample/Particle/IAbstractParticle.h" IAbstractParticle::IAbstractParticle(const NodeMeta& meta, const std::vector<double>& PValues) - : ISample(meta, PValues) -{ -} + : ISample(meta, PValues) {} -void IAbstractParticle::accept(INodeVisitor* visitor) const -{ +void IAbstractParticle::accept(INodeVisitor* visitor) const { visitor->visit(this); } diff --git a/Sample/Particle/IAbstractParticle.h b/Sample/Particle/IAbstractParticle.h index 2a4ab752fd7899cee5d112b3a7f6e8a1f74d11c8..dd593ce337b44f6149f41e46769f3cf47d1d6153 100644 --- a/Sample/Particle/IAbstractParticle.h +++ b/Sample/Particle/IAbstractParticle.h @@ -25,8 +25,7 @@ class IRotation; //! @ingroup samples -class IAbstractParticle : public ISample -{ +class IAbstractParticle : public ISample { public: IAbstractParticle() = default; IAbstractParticle(const NodeMeta& meta, const std::vector<double>& PValues); diff --git a/Sample/Particle/IParticle.cpp b/Sample/Particle/IParticle.cpp index 884732d73db0fdef3438910a75cb42e1e00585a1..30ea1b4063e4aeaa739baeb00457eb26e1f4e42f 100644 --- a/Sample/Particle/IParticle.cpp +++ b/Sample/Particle/IParticle.cpp @@ -20,35 +20,29 @@ IParticle::~IParticle() = default; -IFormFactor* IParticle::createFormFactor() const -{ +IFormFactor* IParticle::createFormFactor() const { return createSlicedParticle(ZLimits{}).m_slicedff.release(); } -SlicedParticle IParticle::createSlicedParticle(ZLimits) const -{ +SlicedParticle IParticle::createSlicedParticle(ZLimits) const { throw std::runtime_error("IParticle::createSlicedParticle error: " "not implemented!"); } -void IParticle::translate(kvector_t translation) -{ +void IParticle::translate(kvector_t translation) { m_position += translation; } -const IRotation* IParticle::rotation() const -{ +const IRotation* IParticle::rotation() const { return m_rotation.get(); } -void IParticle::setRotation(const IRotation& rotation) -{ +void IParticle::setRotation(const IRotation& rotation) { m_rotation.reset(rotation.clone()); registerChild(m_rotation.get()); } -void IParticle::rotate(const IRotation& rotation) -{ +void IParticle::rotate(const IRotation& rotation) { if (m_rotation) { m_rotation.reset(createProduct(rotation, *m_rotation)); } else { @@ -58,13 +52,11 @@ void IParticle::rotate(const IRotation& rotation) registerChild(m_rotation.get()); } -std::vector<const INode*> IParticle::getChildren() const -{ +std::vector<const INode*> IParticle::getChildren() const { return std::vector<const INode*>() << m_rotation; } -void IParticle::registerAbundance(bool make_registered) -{ +void IParticle::registerAbundance(bool make_registered) { if (make_registered) { if (!parameter("Abundance")) registerParameter("Abundance", &m_abundance); @@ -73,8 +65,7 @@ void IParticle::registerAbundance(bool make_registered) } } -void IParticle::registerPosition(bool make_registered) -{ +void IParticle::registerPosition(bool make_registered) { if (make_registered) { if (!parameter(XComponentName("Position"))) { registerVector("Position", &m_position, "nm"); @@ -84,22 +75,19 @@ void IParticle::registerPosition(bool make_registered) } } -SafePointerVector<IParticle> IParticle::decompose() const -{ +SafePointerVector<IParticle> IParticle::decompose() const { SafePointerVector<IParticle> result; result.push_back(this->clone()); return result; } -ParticleLimits IParticle::bottomTopZ() const -{ +ParticleLimits IParticle::bottomTopZ() const { std::unique_ptr<IFormFactor> P_ff(createFormFactor()); std::unique_ptr<IRotation> P_rot(new IdentityRotation); return {P_ff->bottomZ(*P_rot), P_ff->topZ(*P_rot)}; } -IRotation* IParticle::createComposedRotation(const IRotation* p_rotation) const -{ +IRotation* IParticle::createComposedRotation(const IRotation* p_rotation) const { if (p_rotation) { if (m_rotation) return createProduct(*p_rotation, *m_rotation); @@ -113,8 +101,7 @@ IRotation* IParticle::createComposedRotation(const IRotation* p_rotation) const } } -kvector_t IParticle::composedTranslation(const IRotation* p_rotation, kvector_t translation) const -{ +kvector_t IParticle::composedTranslation(const IRotation* p_rotation, kvector_t translation) const { if (p_rotation) { return translation + p_rotation->transformed(m_position); } else { @@ -122,8 +109,7 @@ kvector_t IParticle::composedTranslation(const IRotation* p_rotation, kvector_t } } -void IParticle::registerParticleProperties() -{ +void IParticle::registerParticleProperties() { registerAbundance(); registerPosition(); } diff --git a/Sample/Particle/IParticle.h b/Sample/Particle/IParticle.h index 7a1d016ee0bff71fefb32b629d874d63c4af7ccb..1629dea65f5ab7711c7b2887776c027eb04c1de6 100644 --- a/Sample/Particle/IParticle.h +++ b/Sample/Particle/IParticle.h @@ -29,8 +29,7 @@ class ZLimits; //! //! @ingroup samples -class IParticle : public IAbstractParticle -{ +class IParticle : public IAbstractParticle { public: ~IParticle(); IParticle* clone() const override = 0; diff --git a/Sample/Particle/MesoCrystal.cpp b/Sample/Particle/MesoCrystal.cpp index 61ed79824fdb2e152329b233c48e77ca6286abc9..cf07b70faaa730e04ffd71d89f8ac7ca2ea35c74 100644 --- a/Sample/Particle/MesoCrystal.cpp +++ b/Sample/Particle/MesoCrystal.cpp @@ -20,15 +20,13 @@ #include "Sample/Scattering/Rotations.h" MesoCrystal::MesoCrystal(const Crystal& particle_structure, const IFormFactor& form_factor) - : m_particle_structure(particle_structure.clone()), m_meso_form_factor(form_factor.clone()) -{ + : m_particle_structure(particle_structure.clone()), m_meso_form_factor(form_factor.clone()) { initialize(); } MesoCrystal::~MesoCrystal() = default; -MesoCrystal* MesoCrystal::clone() const -{ +MesoCrystal* MesoCrystal::clone() const { MesoCrystal* p_result = new MesoCrystal(m_particle_structure->clone(), m_meso_form_factor->clone()); p_result->setAbundance(m_abundance); @@ -38,13 +36,11 @@ MesoCrystal* MesoCrystal::clone() const return p_result; } -void MesoCrystal::accept(INodeVisitor* visitor) const -{ +void MesoCrystal::accept(INodeVisitor* visitor) const { visitor->visit(this); } -SlicedParticle MesoCrystal::createSlicedParticle(ZLimits limits) const -{ +SlicedParticle MesoCrystal::createSlicedParticle(ZLimits limits) const { if (!m_particle_structure || !m_meso_form_factor) return {}; std::unique_ptr<IRotation> rotation(new IdentityRotation); @@ -64,20 +60,17 @@ SlicedParticle MesoCrystal::createSlicedParticle(ZLimits limits) const return result; } -std::vector<const INode*> MesoCrystal::getChildren() const -{ +std::vector<const INode*> MesoCrystal::getChildren() const { return std::vector<const INode*>() << IParticle::getChildren() << m_particle_structure << m_meso_form_factor; } MesoCrystal::MesoCrystal(Crystal* particle_structure, IFormFactor* form_factor) - : m_particle_structure(particle_structure), m_meso_form_factor(form_factor) -{ + : m_particle_structure(particle_structure), m_meso_form_factor(form_factor) { initialize(); } -void MesoCrystal::initialize() -{ +void MesoCrystal::initialize() { setName("MesoCrystal"); registerParticleProperties(); registerChild(m_particle_structure.get()); diff --git a/Sample/Particle/MesoCrystal.h b/Sample/Particle/MesoCrystal.h index 25cb9de906861476f075238a26a64cdc6be3de7f..989726a05950babddff417a58b04383c13f2ed2f 100644 --- a/Sample/Particle/MesoCrystal.h +++ b/Sample/Particle/MesoCrystal.h @@ -22,8 +22,7 @@ class Crystal; //! A particle with an internal structure of smaller particles. //! @ingroup samples -class MesoCrystal : public IParticle -{ +class MesoCrystal : public IParticle { public: MesoCrystal(const Crystal& particle_structure, const IFormFactor& form_factor); diff --git a/Sample/Particle/Particle.cpp b/Sample/Particle/Particle.cpp index 58df8bc919c4068166122f498b2907465fadfce4..d00b9e7a8a60d31bbf877a1b4677a0a630c8e387 100644 --- a/Sample/Particle/Particle.cpp +++ b/Sample/Particle/Particle.cpp @@ -22,28 +22,24 @@ Particle::~Particle() = default; -Particle::Particle(Material material) : m_material(std::move(material)) -{ +Particle::Particle(Material material) : m_material(std::move(material)) { initialize(); } Particle::Particle(Material material, const IFormFactor& form_factor) - : m_material(std::move(material)), m_form_factor(form_factor.clone()) -{ + : m_material(std::move(material)), m_form_factor(form_factor.clone()) { initialize(); registerChild(m_form_factor.get()); } Particle::Particle(Material material, const IFormFactor& form_factor, const IRotation& rotation) - : m_material(std::move(material)), m_form_factor(form_factor.clone()) -{ + : m_material(std::move(material)), m_form_factor(form_factor.clone()) { initialize(); setRotation(rotation); registerChild(m_form_factor.get()); } -Particle* Particle::clone() const -{ +Particle* Particle::clone() const { Particle* p_result = new Particle(m_material); p_result->setAbundance(m_abundance); if (m_form_factor) @@ -55,8 +51,7 @@ Particle* Particle::clone() const return p_result; } -SlicedParticle Particle::createSlicedParticle(ZLimits limits) const -{ +SlicedParticle Particle::createSlicedParticle(ZLimits limits) const { if (!m_form_factor) return {}; std::unique_ptr<IRotation> P_rotation(new IdentityRotation); @@ -76,26 +71,22 @@ SlicedParticle Particle::createSlicedParticle(ZLimits limits) const return result; } -void Particle::setMaterial(Material material) -{ +void Particle::setMaterial(Material material) { m_material = std::move(material); } -void Particle::setFormFactor(const IFormFactor& form_factor) -{ +void Particle::setFormFactor(const IFormFactor& form_factor) { if (&form_factor != m_form_factor.get()) { m_form_factor.reset(form_factor.clone()); registerChild(m_form_factor.get()); } } -std::vector<const INode*> Particle::getChildren() const -{ +std::vector<const INode*> Particle::getChildren() const { return std::vector<const INode*>() << IParticle::getChildren() << m_form_factor; } -void Particle::initialize() -{ +void Particle::initialize() { setName("Particle"); registerParticleProperties(); } diff --git a/Sample/Particle/Particle.h b/Sample/Particle/Particle.h index 819397472023c2cb269f209d25716aa893849e69..6e900cf48f7c563d44a8b90e71f28b72bde8309b 100644 --- a/Sample/Particle/Particle.h +++ b/Sample/Particle/Particle.h @@ -21,8 +21,7 @@ //! A particle with a form factor and refractive index. //! @ingroup samples -class Particle : public IParticle -{ +class Particle : public IParticle { public: Particle() = delete; ~Particle(); diff --git a/Sample/Particle/ParticleComposition.cpp b/Sample/Particle/ParticleComposition.cpp index 1eff66a7b6703abef8e0bbdbee02abd851b87422..f8feb238334b677837d5f796b1d3245fd695a149 100644 --- a/Sample/Particle/ParticleComposition.cpp +++ b/Sample/Particle/ParticleComposition.cpp @@ -18,22 +18,19 @@ #include "Sample/Particle/ParticleDistribution.h" #include "Sample/Scattering/Rotations.h" -ParticleComposition::ParticleComposition() -{ +ParticleComposition::ParticleComposition() { initialize(); } ParticleComposition::ParticleComposition(const IParticle& particle, - std::vector<kvector_t> positions) -{ + std::vector<kvector_t> positions) { initialize(); addParticles(particle, positions); } ParticleComposition::~ParticleComposition() = default; -ParticleComposition* ParticleComposition::clone() const -{ +ParticleComposition* ParticleComposition::clone() const { ParticleComposition* p_result = new ParticleComposition(); p_result->setAbundance(m_abundance); for (size_t index = 0; index < m_particles.size(); ++index) @@ -44,8 +41,7 @@ ParticleComposition* ParticleComposition::clone() const return p_result; } -IFormFactor* ParticleComposition::createFormFactor() const -{ +IFormFactor* ParticleComposition::createFormFactor() const { if (m_particles.empty()) return {}; auto* result = new FormFactorWeighted; @@ -57,14 +53,12 @@ IFormFactor* ParticleComposition::createFormFactor() const return result; } -void ParticleComposition::addParticle(const IParticle& particle) -{ +void ParticleComposition::addParticle(const IParticle& particle) { IParticle* np = particle.clone(); addParticlePointer(np); } -void ParticleComposition::addParticle(const IParticle& particle, kvector_t position) -{ +void ParticleComposition::addParticle(const IParticle& particle, kvector_t position) { IParticle* np = particle.clone(); np->translate(position); addParticlePointer(np); @@ -72,22 +66,20 @@ void ParticleComposition::addParticle(const IParticle& particle, kvector_t posit // Please note, that positions is not const reference here. This is intentional, to // enable python lists to std::vector conversion -void ParticleComposition::addParticles(const IParticle& particle, std::vector<kvector_t> positions) -{ +void ParticleComposition::addParticles(const IParticle& particle, + std::vector<kvector_t> positions) { for (size_t i = 0; i < positions.size(); ++i) addParticle(particle, positions[i]); } -std::vector<const INode*> ParticleComposition::getChildren() const -{ +std::vector<const INode*> ParticleComposition::getChildren() const { std::vector<const INode*> result = IParticle::getChildren(); for (auto& P_particle : m_particles) result.push_back(P_particle.get()); return result; } -SafePointerVector<IParticle> ParticleComposition::decompose() const -{ +SafePointerVector<IParticle> ParticleComposition::decompose() const { SafePointerVector<IParticle> result; auto p_rotation = rotation(); auto translation = position(); @@ -103,8 +95,7 @@ SafePointerVector<IParticle> ParticleComposition::decompose() const return result; } -ParticleLimits ParticleComposition::bottomTopZ() const -{ +ParticleLimits ParticleComposition::bottomTopZ() const { auto particles = decompose(); ParticleLimits result = particles[check_index(0)]->bottomTopZ(); for (auto& P_particle : particles) { @@ -115,23 +106,20 @@ ParticleLimits ParticleComposition::bottomTopZ() const return result; } -size_t ParticleComposition::check_index(size_t index) const -{ +size_t ParticleComposition::check_index(size_t index) const { return index < m_particles.size() ? index : throw Exceptions::OutOfBoundsException( "ParticleComposition::check_index() -> Index is out of bounds"); } -void ParticleComposition::addParticlePointer(IParticle* p_particle) -{ +void ParticleComposition::addParticlePointer(IParticle* p_particle) { p_particle->registerAbundance(false); registerChild(p_particle); m_particles.emplace_back(p_particle); } -void ParticleComposition::initialize() -{ +void ParticleComposition::initialize() { setName("ParticleComposition"); registerParticleProperties(); } diff --git a/Sample/Particle/ParticleComposition.h b/Sample/Particle/ParticleComposition.h index d0549b61a8b8f1a8a92fa3423e3e170f9bc95645..1bff5f1fdd3e26c8151feac75432f42698789c07 100644 --- a/Sample/Particle/ParticleComposition.h +++ b/Sample/Particle/ParticleComposition.h @@ -21,8 +21,7 @@ //! A composition of particles at fixed positions //! @ingroup samples -class ParticleComposition : public IParticle -{ +class ParticleComposition : public IParticle { public: ParticleComposition(); ParticleComposition(const IParticle& particle, std::vector<kvector_t> positions); diff --git a/Sample/Particle/ParticleCoreShell.cpp b/Sample/Particle/ParticleCoreShell.cpp index 5db9cfa93de2d2dcc79d5cfcdb11d2c27d2498cb..c60061c781f8743f52c2a5b1b25660dd17fa047a 100644 --- a/Sample/Particle/ParticleCoreShell.cpp +++ b/Sample/Particle/ParticleCoreShell.cpp @@ -19,8 +19,7 @@ #include "Sample/Scattering/Rotations.h" ParticleCoreShell::ParticleCoreShell(const Particle& shell, const Particle& core, - kvector_t relative_core_position) -{ + kvector_t relative_core_position) { setName("ParticleCoreShell"); registerParticleProperties(); addAndRegisterCore(core, relative_core_position); @@ -29,8 +28,7 @@ ParticleCoreShell::ParticleCoreShell(const Particle& shell, const Particle& core ParticleCoreShell::~ParticleCoreShell() = default; -ParticleCoreShell* ParticleCoreShell::clone() const -{ +ParticleCoreShell* ParticleCoreShell::clone() const { ParticleCoreShell* p_result = new ParticleCoreShell(*m_shell, *m_core); p_result->setAbundance(m_abundance); if (m_rotation) @@ -39,8 +37,7 @@ ParticleCoreShell* ParticleCoreShell::clone() const return p_result; } -SlicedParticle ParticleCoreShell::createSlicedParticle(ZLimits limits) const -{ +SlicedParticle ParticleCoreShell::createSlicedParticle(ZLimits limits) const { if (!m_core || !m_shell) return {}; std::unique_ptr<IRotation> P_rotation(new IdentityRotation); @@ -85,28 +82,24 @@ SlicedParticle ParticleCoreShell::createSlicedParticle(ZLimits limits) const return result; } -std::vector<const INode*> ParticleCoreShell::getChildren() const -{ +std::vector<const INode*> ParticleCoreShell::getChildren() const { return std::vector<const INode*>() << IParticle::getChildren() << m_core << m_shell; } -void ParticleCoreShell::addAndRegisterCore(const Particle& core, kvector_t relative_core_position) -{ +void ParticleCoreShell::addAndRegisterCore(const Particle& core, kvector_t relative_core_position) { m_core.reset(core.clone()); m_core->translate(relative_core_position); registerChild(m_core.get()); m_core->registerAbundance(false); } -void ParticleCoreShell::addAndRegisterShell(const Particle& shell) -{ +void ParticleCoreShell::addAndRegisterShell(const Particle& shell) { m_shell.reset(shell.clone()); registerChild(m_shell.get()); m_shell->registerAbundance(false); m_shell->registerPosition(false); } -ParticleCoreShell::ParticleCoreShell() : m_shell{nullptr}, m_core{nullptr} -{ +ParticleCoreShell::ParticleCoreShell() : m_shell{nullptr}, m_core{nullptr} { setName("ParticleCoreShell"); } diff --git a/Sample/Particle/ParticleCoreShell.h b/Sample/Particle/ParticleCoreShell.h index a854bcf0fb58b15da87a1118cef9517baaa693f1..1dd8c93eb3266ae39932d7db4f1404a832658a09 100644 --- a/Sample/Particle/ParticleCoreShell.h +++ b/Sample/Particle/ParticleCoreShell.h @@ -22,8 +22,7 @@ class Particle; //! A particle with a core/shell geometry. //! @ingroup samples -class ParticleCoreShell : public IParticle -{ +class ParticleCoreShell : public IParticle { public: ParticleCoreShell(const Particle& shell, const Particle& core, kvector_t relative_core_position = kvector_t(0.0, 0.0, 0.0)); @@ -50,13 +49,11 @@ protected: std::unique_ptr<Particle> m_core; }; -inline const Particle* ParticleCoreShell::coreParticle() const -{ +inline const Particle* ParticleCoreShell::coreParticle() const { return m_core.get(); } -inline const Particle* ParticleCoreShell::shellParticle() const -{ +inline const Particle* ParticleCoreShell::shellParticle() const { return m_shell.get(); } diff --git a/Sample/Particle/ParticleDistribution.cpp b/Sample/Particle/ParticleDistribution.cpp index 0cfe90219c6a9bb69b07a37eab3cc5f6064cd0af..26b79a8fae323bb54dbab9b7750a63840624e503 100644 --- a/Sample/Particle/ParticleDistribution.cpp +++ b/Sample/Particle/ParticleDistribution.cpp @@ -23,8 +23,7 @@ ParticleDistribution::ParticleDistribution(const IParticle& prototype, const ParameterDistribution& par_distr) - : m_par_distribution(par_distr) -{ + : m_par_distribution(par_distr) { setName("ParticleDistribution"); m_particle.reset(prototype.clone()); registerChild(m_particle.get()); @@ -34,27 +33,23 @@ ParticleDistribution::ParticleDistribution(const IParticle& prototype, registerParameter("Abundance", &m_abundance); } -ParticleDistribution* ParticleDistribution::clone() const -{ +ParticleDistribution* ParticleDistribution::clone() const { ParticleDistribution* p_result = new ParticleDistribution(*m_particle, m_par_distribution); p_result->setAbundance(m_abundance); return p_result; } -void ParticleDistribution::translate(kvector_t translation) -{ +void ParticleDistribution::translate(kvector_t translation) { m_particle->translate(translation); } -void ParticleDistribution::rotate(const IRotation& rotation) -{ +void ParticleDistribution::rotate(const IRotation& rotation) { m_particle->rotate(rotation); } //! Returns particle clones with parameter values drawn from distribution. -SafePointerVector<IParticle> ParticleDistribution::generateParticles() const -{ +SafePointerVector<IParticle> ParticleDistribution::generateParticles() const { std::unique_ptr<ParameterPool> P_pool{m_particle->createParameterTree()}; std::string main_par_name = m_par_distribution.getMainParameterName(); double main_par_value = P_pool->getUniqueMatch(main_par_name)->value(); @@ -80,16 +75,14 @@ SafePointerVector<IParticle> ParticleDistribution::generateParticles() const return result; } -std::vector<const INode*> ParticleDistribution::getChildren() const -{ +std::vector<const INode*> ParticleDistribution::getChildren() const { std::vector<const INode*> result = std::vector<const INode*>() << m_particle; if (auto dist = m_par_distribution.getDistribution()) result.push_back(dist); return result; } -std::string ParticleDistribution::mainUnits() const -{ +std::string ParticleDistribution::mainUnits() const { return ParameterUtils::poolParameterUnits(prototype(), parameterDistribution().getMainParameterName()); } diff --git a/Sample/Particle/ParticleDistribution.h b/Sample/Particle/ParticleDistribution.h index 8bbf7b2a0d0756409cb166b038a318aee8993dac..2c710c7417549b9264a3dd6c84c5179f49a1f8a8 100644 --- a/Sample/Particle/ParticleDistribution.h +++ b/Sample/Particle/ParticleDistribution.h @@ -24,8 +24,7 @@ class IParticle; //! A particle type that is a parametric distribution of IParticle's. //! @ingroup samples -class ParticleDistribution : public IAbstractParticle -{ +class ParticleDistribution : public IAbstractParticle { public: ParticleDistribution(const IParticle& prototype, const ParameterDistribution& par_distr); diff --git a/Sample/Particle/TRange.h b/Sample/Particle/TRange.h index 7c3a9867df88ebf06075dc9a4fa77dc9c8e6c385..afed9188b3c86cba6471f3abca24ebac916633d8 100644 --- a/Sample/Particle/TRange.h +++ b/Sample/Particle/TRange.h @@ -20,8 +20,7 @@ //! An interval [lowerBound..upperBound[. //! @ingroup tools_internal -template <class T> class TRange -{ +template <class T> class TRange { public: TRange(T lowerBound, T upperBound) : m_lower_bound(lowerBound), m_upper_bound(upperBound) {} virtual ~TRange() {} @@ -38,13 +37,10 @@ private: //! An interval [lowerBound..upperBound[, and a number of samples. -template <class T> class TSampledRange : public TRange<T> -{ +template <class T> class TSampledRange : public TRange<T> { public: TSampledRange(size_t n_samples, T lowerBound, T upperBound) - : TRange<T>(lowerBound, upperBound), m_n_samples(n_samples) - { - } + : TRange<T>(lowerBound, upperBound), m_n_samples(n_samples) {} size_t getNSamples() const { return m_n_samples; } diff --git a/Sample/Processed/MultiLayerFuncs.cpp b/Sample/Processed/MultiLayerFuncs.cpp index 1c13fc901114649d6c5e07872a21db020ee21862..3b338f57f7f971fb11c11419ddd9ce45af37ddee 100644 --- a/Sample/Processed/MultiLayerFuncs.cpp +++ b/Sample/Processed/MultiLayerFuncs.cpp @@ -18,8 +18,7 @@ #include "Sample/RT/SimulationOptions.h" std::vector<complex_t> MaterialProfile(const MultiLayer& multilayer, int n_points, double z_min, - double z_max) -{ + double z_max) { SimulationOptions options; options.setUseAvgMaterials(true); ProcessedSample sample(multilayer, options); @@ -28,8 +27,7 @@ std::vector<complex_t> MaterialProfile(const MultiLayer& multilayer, int n_point return helper.calculateProfile(z_values); } -std::pair<double, double> DefaultMaterialProfileLimits(const MultiLayer& multilayer) -{ +std::pair<double, double> DefaultMaterialProfileLimits(const MultiLayer& multilayer) { SimulationOptions options; options.setUseAvgMaterials(true); ProcessedSample sample(multilayer, options); @@ -37,8 +35,7 @@ std::pair<double, double> DefaultMaterialProfileLimits(const MultiLayer& multila return helper.defaultLimits(); } -std::vector<double> GenerateZValues(int n_points, double z_min, double z_max) -{ +std::vector<double> GenerateZValues(int n_points, double z_min, double z_max) { std::vector<double> result; if (n_points < 1) return result; diff --git a/Sample/Processed/ProcessedLayout.cpp b/Sample/Processed/ProcessedLayout.cpp index ff4eb557166f496a723cf3a03eb4e6a5754c8219..1fd77581e760dbcafbdaaff47c028315fc811426 100644 --- a/Sample/Processed/ProcessedLayout.cpp +++ b/Sample/Processed/ProcessedLayout.cpp @@ -24,10 +24,8 @@ #include "Sample/Slice/Slice.h" #include "Sample/Slice/SlicedFormFactorList.h" -namespace -{ -void ScaleRegionMap(std::map<size_t, std::vector<HomogeneousRegion>>& region_map, double factor) -{ +namespace { +void ScaleRegionMap(std::map<size_t, std::vector<HomogeneousRegion>>& region_map, double factor) { for (auto& entry : region_map) { for (auto& region : entry.second) { region.m_volume *= factor; @@ -42,16 +40,14 @@ void ScaleRegionMap(std::map<size_t, std::vector<HomogeneousRegion>>& region_map ProcessedLayout::ProcessedLayout(const ParticleLayout& layout, const std::vector<Slice>& slices, double z_ref, const IFresnelMap* p_fresnel_map, bool polarized) - : m_fresnel_map(p_fresnel_map), m_polarized(polarized) -{ + : m_fresnel_map(p_fresnel_map), m_polarized(polarized) { m_n_slices = slices.size(); collectFormFactors(layout, slices, z_ref); if (auto p_iff = layout.interferenceFunction()) m_iff.reset(p_iff->clone()); } -ProcessedLayout::ProcessedLayout(ProcessedLayout&& other) -{ +ProcessedLayout::ProcessedLayout(ProcessedLayout&& other) { m_fresnel_map = other.m_fresnel_map; m_polarized = other.m_polarized; m_n_slices = other.m_n_slices; @@ -61,36 +57,30 @@ ProcessedLayout::ProcessedLayout(ProcessedLayout&& other) m_region_map = std::move(other.m_region_map); } -size_t ProcessedLayout::numberOfSlices() const -{ +size_t ProcessedLayout::numberOfSlices() const { return m_n_slices; } -double ProcessedLayout::surfaceDensity() const -{ +double ProcessedLayout::surfaceDensity() const { return m_surface_density; } -const std::vector<FormFactorCoherentSum>& ProcessedLayout::formFactorList() const -{ +const std::vector<FormFactorCoherentSum>& ProcessedLayout::formFactorList() const { return m_formfactors; } -const IInterferenceFunction* ProcessedLayout::interferenceFunction() const -{ +const IInterferenceFunction* ProcessedLayout::interferenceFunction() const { return m_iff.get(); } -std::map<size_t, std::vector<HomogeneousRegion>> ProcessedLayout::regionMap() const -{ +std::map<size_t, std::vector<HomogeneousRegion>> ProcessedLayout::regionMap() const { return m_region_map; } ProcessedLayout::~ProcessedLayout() = default; void ProcessedLayout::collectFormFactors(const ParticleLayout& layout, - const std::vector<Slice>& slices, double z_ref) -{ + const std::vector<Slice>& slices, double z_ref) { double layout_abundance = layout.getTotalAbundance(); for (const auto* particle : layout.particles()) { FormFactorCoherentSum ff_coh = processParticle(*particle, slices, z_ref); @@ -105,8 +95,7 @@ void ProcessedLayout::collectFormFactors(const ParticleLayout& layout, FormFactorCoherentSum ProcessedLayout::processParticle(const IParticle& particle, const std::vector<Slice>& slices, - double z_ref) -{ + double z_ref) { double abundance = particle.abundance(); auto sliced_ffs = SlicedFormFactorList::createSlicedFormFactors(particle, slices, z_ref); auto region_map = sliced_ffs.regionMap(); @@ -141,8 +130,7 @@ FormFactorCoherentSum ProcessedLayout::processParticle(const IParticle& particle } void ProcessedLayout::mergeRegionMap( - const std::map<size_t, std::vector<HomogeneousRegion>>& region_map) -{ + const std::map<size_t, std::vector<HomogeneousRegion>>& region_map) { for (auto& entry : region_map) { size_t layer_index = entry.first; auto regions = entry.second; diff --git a/Sample/Processed/ProcessedLayout.h b/Sample/Processed/ProcessedLayout.h index 3fa507238a90a3d63c7b6f71eadd2e95143a42f9..74edd2870a763c00a0c12a8f35e445efc58c0596 100644 --- a/Sample/Processed/ProcessedLayout.h +++ b/Sample/Processed/ProcessedLayout.h @@ -34,8 +34,7 @@ class Slice; //! //! @ingroup algorithms_internal -class ProcessedLayout -{ +class ProcessedLayout { public: ProcessedLayout(const ParticleLayout& layout, const std::vector<Slice>& slices, double z_ref, const IFresnelMap* p_fresnel_map, bool polarized); diff --git a/Sample/Processed/ProcessedSample.cpp b/Sample/Processed/ProcessedSample.cpp index 271881d0d9b46d039c2ca1c1eea0ae977440890d..ee27db8ab6e235bb3e8c07ba6168afda6663c583 100644 --- a/Sample/Processed/ProcessedSample.cpp +++ b/Sample/Processed/ProcessedSample.cpp @@ -24,13 +24,11 @@ #include "Sample/Slice/LayerRoughness.h" #include "Sample/Specular/SpecularStrategyBuilder.h" -namespace -{ +namespace { std::unique_ptr<IFresnelMap> createFresnelMap(const MultiLayer& sample, const std::vector<Slice>& slices, - const SimulationOptions& options) -{ + const SimulationOptions& options) { std::unique_ptr<IFresnelMap> result; const bool magnetic = std::any_of(slices.cbegin(), slices.cend(), [](const Slice& slice) { return slice.material().isMagneticMaterial(); @@ -44,8 +42,7 @@ std::unique_ptr<IFresnelMap> createFresnelMap(const MultiLayer& sample, return result; } -bool checkRegions(const std::vector<HomogeneousRegion>& regions) -{ +bool checkRegions(const std::vector<HomogeneousRegion>& regions) { double total_fraction = 0.0; for (auto& region : regions) total_fraction += region.m_volume; @@ -54,8 +51,7 @@ bool checkRegions(const std::vector<HomogeneousRegion>& regions) std::vector<Slice> createAverageMaterialSlices(const std::vector<Slice>& slices, - const std::map<size_t, std::vector<HomogeneousRegion>>& region_map) -{ + const std::map<size_t, std::vector<HomogeneousRegion>>& region_map) { std::vector<Slice> result = slices; const auto last_slice_index = slices.size() - 1; for (const auto& entry : region_map) { @@ -82,8 +78,7 @@ ProcessedSample::ProcessedSample(const MultiLayer& sample, const SimulationOptio , m_top_z{0.0} , m_polarized{false} , m_crossCorrLength{sample.crossCorrLength()} - , m_ext_field{sample.externalField()} -{ + , m_ext_field{sample.externalField()} { initSlices(sample, options); m_fresnel_map = createFresnelMap(sample, m_slices, options); initBFields(); @@ -93,58 +88,48 @@ ProcessedSample::ProcessedSample(const MultiLayer& sample, const SimulationOptio ProcessedSample::~ProcessedSample() = default; -size_t ProcessedSample::numberOfSlices() const -{ +size_t ProcessedSample::numberOfSlices() const { return m_slices.size(); } -const std::vector<Slice>& ProcessedSample::slices() const -{ +const std::vector<Slice>& ProcessedSample::slices() const { return m_slices; } -const std::vector<Slice>& ProcessedSample::averageSlices() const -{ +const std::vector<Slice>& ProcessedSample::averageSlices() const { return m_fresnel_map->slices(); } -const std::vector<ProcessedLayout>& ProcessedSample::layouts() const -{ +const std::vector<ProcessedLayout>& ProcessedSample::layouts() const { return m_layouts; } -const IFresnelMap* ProcessedSample::fresnelMap() const -{ +const IFresnelMap* ProcessedSample::fresnelMap() const { return m_fresnel_map.get(); } -double ProcessedSample::crossCorrelationLength() const -{ +double ProcessedSample::crossCorrelationLength() const { return m_crossCorrLength; } -kvector_t ProcessedSample::externalField() const -{ +kvector_t ProcessedSample::externalField() const { return m_ext_field; } -const LayerRoughness* ProcessedSample::bottomRoughness(size_t i) const -{ +const LayerRoughness* ProcessedSample::bottomRoughness(size_t i) const { if (i + 2 > m_slices.size()) throw std::runtime_error("ProcessedSample::bottomRoughness: " "index out of bounds."); return m_slices[i + 1].topRoughness(); } -double ProcessedSample::sliceTopZ(size_t i) const -{ +double ProcessedSample::sliceTopZ(size_t i) const { if (i == 0) return m_top_z; return sliceBottomZ(i - 1); } -double ProcessedSample::sliceBottomZ(size_t i) const -{ +double ProcessedSample::sliceBottomZ(size_t i) const { if (numberOfSlices() < 2) return m_top_z; // Last slice has no bottom: @@ -156,13 +141,11 @@ double ProcessedSample::sliceBottomZ(size_t i) const return z; } -bool ProcessedSample::containsMagneticMaterial() const -{ +bool ProcessedSample::containsMagneticMaterial() const { return m_polarized; } -bool ProcessedSample::hasRoughness() const -{ +bool ProcessedSample::hasRoughness() const { for (auto& slice : m_slices) { if (slice.topRoughness()) return true; @@ -170,8 +153,7 @@ bool ProcessedSample::hasRoughness() const return false; } -double ProcessedSample::crossCorrSpectralFun(const kvector_t kvec, size_t j, size_t k) const -{ +double ProcessedSample::crossCorrSpectralFun(const kvector_t kvec, size_t j, size_t k) const { if (m_crossCorrLength <= 0.0) return 0.0; const double z_j = sliceBottomZ(j); @@ -191,8 +173,7 @@ double ProcessedSample::crossCorrSpectralFun(const kvector_t kvec, size_t j, siz } // Creates a array of slices with the correct thickness, roughness and material -void ProcessedSample::initSlices(const MultiLayer& sample, const SimulationOptions& options) -{ +void ProcessedSample::initSlices(const MultiLayer& sample, const SimulationOptions& options) { if (sample.numberOfLayers() == 0) return; bool use_slicing = options.useAvgMaterials() && sample.numberOfLayers() > 1; @@ -244,8 +225,7 @@ void ProcessedSample::initSlices(const MultiLayer& sample, const SimulationOptio } } -void ProcessedSample::initLayouts(const MultiLayer& sample) -{ +void ProcessedSample::initLayouts(const MultiLayer& sample) { double z_ref = -m_top_z; m_polarized = sample.isMagnetic(); for (size_t i = 0; i < sample.numberOfLayers(); ++i) { @@ -260,8 +240,7 @@ void ProcessedSample::initLayouts(const MultiLayer& sample) } void ProcessedSample::addSlice(double thickness, const Material& material, - const LayerRoughness* roughness) -{ + const LayerRoughness* roughness) { if (roughness) m_slices.emplace_back(thickness, material, *roughness); else @@ -269,8 +248,7 @@ void ProcessedSample::addSlice(double thickness, const Material& material, } void ProcessedSample::addNSlices(size_t n, double thickness, const Material& material, - const LayerRoughness* roughness) -{ + const LayerRoughness* roughness) { if (thickness <= 0.0) return; if (n == 0) @@ -283,8 +261,7 @@ void ProcessedSample::addNSlices(size_t n, double thickness, const Material& mat } } -void ProcessedSample::initBFields() -{ +void ProcessedSample::initBFields() { if (m_slices.empty()) return; const double m_z0 = m_slices[0].material().magnetization().z(); @@ -295,8 +272,7 @@ void ProcessedSample::initBFields() } void ProcessedSample::mergeRegionMap( - const std::map<size_t, std::vector<HomogeneousRegion>>& region_map) -{ + const std::map<size_t, std::vector<HomogeneousRegion>>& region_map) { for (const auto& entry : region_map) { size_t i = entry.first; auto& regions = entry.second; @@ -304,8 +280,7 @@ void ProcessedSample::mergeRegionMap( } } -void ProcessedSample::initFresnelMap(const SimulationOptions& sim_options) -{ +void ProcessedSample::initFresnelMap(const SimulationOptions& sim_options) { if (sim_options.useAvgMaterials()) { m_fresnel_map->setSlices(createAverageMaterialSlices(m_slices, m_region_map)); } else { diff --git a/Sample/Processed/ProcessedSample.h b/Sample/Processed/ProcessedSample.h index f9b6179273cccfb92fc19c70d424991b666bd193..8d17b842d86845b2bb3390e61dc3a343a4c55543 100644 --- a/Sample/Processed/ProcessedSample.h +++ b/Sample/Processed/ProcessedSample.h @@ -34,8 +34,7 @@ class SimulationOptions; //! //! @ingroup algorithms_internal -class ProcessedSample -{ +class ProcessedSample { public: ProcessedSample(const MultiLayer& sample, const SimulationOptions& options); ~ProcessedSample(); diff --git a/Sample/Processed/ProfileHelper.cpp b/Sample/Processed/ProfileHelper.cpp index a32af833ac174eff053cdcb1052053c99d8b1717..396940cae1c43b03278ba3c4a080988b8b532d22 100644 --- a/Sample/Processed/ProfileHelper.cpp +++ b/Sample/Processed/ProfileHelper.cpp @@ -16,23 +16,19 @@ #include "Sample/Processed/ProcessedSample.h" #include "Sample/Slice/LayerRoughness.h" -namespace -{ +namespace { const double prefactor = std::sqrt(2.0 / M_PI); -double TransitionTanh(double x) -{ +double TransitionTanh(double x) { return (1.0 - std::tanh(prefactor * x)) / 2.0; } -double Transition(double x, double sigma) -{ +double Transition(double x, double sigma) { if (sigma <= 0.0) return x < 0.0 ? 1.0 : 0.0; return TransitionTanh(x / sigma); } } // namespace -ProfileHelper::ProfileHelper(const ProcessedSample& sample) -{ +ProfileHelper::ProfileHelper(const ProcessedSample& sample) { auto N = sample.numberOfSlices(); m_materialdata.reserve(N); if (N > 1) { @@ -58,8 +54,7 @@ ProfileHelper::~ProfileHelper() = default; // Note: for refractive index materials, the material interpolation actually happens at the level // of n^2. To first order in delta and beta, this implies the same smooth interpolation of delta // and beta, as is done here. -std::vector<complex_t> ProfileHelper::calculateProfile(const std::vector<double>& z_values) const -{ +std::vector<complex_t> ProfileHelper::calculateProfile(const std::vector<double>& z_values) const { complex_t top_value = m_materialdata.size() ? m_materialdata[0] : 0.0; std::vector<complex_t> result(z_values.size(), top_value); for (size_t i = 0; i < m_zlimits.size(); ++i) { @@ -73,8 +68,7 @@ std::vector<complex_t> ProfileHelper::calculateProfile(const std::vector<double> return result; } -std::pair<double, double> ProfileHelper::defaultLimits() const -{ +std::pair<double, double> ProfileHelper::defaultLimits() const { if (m_zlimits.size() < 1) return {0.0, 0.0}; double interface_span = m_zlimits.front() - m_zlimits.back(); diff --git a/Sample/Processed/ProfileHelper.h b/Sample/Processed/ProfileHelper.h index f59ae31b9605ab52b71698234d76dbdd94f979a1..5d6bf1fb22bd0faa31ae4ce9aa12dfedb57280e1 100644 --- a/Sample/Processed/ProfileHelper.h +++ b/Sample/Processed/ProfileHelper.h @@ -28,8 +28,7 @@ class ProcessedSample; //! //! @ingroup algorithms_internal -class ProfileHelper -{ +class ProfileHelper { public: ProfileHelper(const ProcessedSample& sample); ~ProfileHelper(); diff --git a/Sample/RT/ILayerRTCoefficients.h b/Sample/RT/ILayerRTCoefficients.h index ddb296f6f2f64e14081e61a015e36f87e3c93ff9..694778e2d965b5103453f04bcaf5d9c12ac86f77 100644 --- a/Sample/RT/ILayerRTCoefficients.h +++ b/Sample/RT/ILayerRTCoefficients.h @@ -22,8 +22,7 @@ //! Interface to access reflection/transmission coefficients. //! @ingroup algorithms_internal -class ILayerRTCoefficients -{ +class ILayerRTCoefficients { public: virtual ~ILayerRTCoefficients() {} @@ -45,24 +44,20 @@ public: //! Scalar value getters; these throw errors by default as they should only //! be used when the derived object is really scalar #endif - virtual complex_t getScalarT() const - { + virtual complex_t getScalarT() const { throw Exceptions::NotImplementedException("ILayerRTCoefficients::" "getScalarT(): coefficients are not scalar."); } - virtual complex_t getScalarR() const - { + virtual complex_t getScalarR() const { throw Exceptions::NotImplementedException("ILayerRTCoefficients::" "getScalarR(): coefficients are not scalar."); } - virtual complex_t getScalarKz() const - { + virtual complex_t getScalarKz() const { throw Exceptions::NotImplementedException("ILayerRTCoefficients::" "getScalarKz(): coefficients are not scalar."); } - virtual Eigen::Matrix2cd getReflectionMatrix() const - { + virtual Eigen::Matrix2cd getReflectionMatrix() const { throw Exceptions::NotImplementedException("Only defined for Matrix coefficeints"); } }; diff --git a/Sample/RT/MatrixRTCoefficients.cpp b/Sample/RT/MatrixRTCoefficients.cpp index c639f19e86fbc088769ad1866441e45da362c85e..fe1d3181cc6d862a4de858503f9d320c740845db 100644 --- a/Sample/RT/MatrixRTCoefficients.cpp +++ b/Sample/RT/MatrixRTCoefficients.cpp @@ -14,13 +14,11 @@ #include "Sample/RT/MatrixRTCoefficients.h" -MatrixRTCoefficients* MatrixRTCoefficients::clone() const -{ +MatrixRTCoefficients* MatrixRTCoefficients::clone() const { return new MatrixRTCoefficients(*this); } -Eigen::Vector2cd MatrixRTCoefficients::T1plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients::T1plus() const { Eigen::Vector2cd result; Eigen::Matrix<complex_t, 4, 1> m = T1m * phi_psi_plus; result(0) = m(2); @@ -30,8 +28,7 @@ Eigen::Vector2cd MatrixRTCoefficients::T1plus() const return result; } -Eigen::Vector2cd MatrixRTCoefficients::R1plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients::R1plus() const { Eigen::Vector2cd result; Eigen::Matrix<complex_t, 4, 1> m = R1m * phi_psi_plus; result(0) = m(2); @@ -42,8 +39,7 @@ Eigen::Vector2cd MatrixRTCoefficients::R1plus() const return result; } -Eigen::Vector2cd MatrixRTCoefficients::T2plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients::T2plus() const { Eigen::Vector2cd result; Eigen::Matrix<complex_t, 4, 1> m = T2m * phi_psi_plus; result(0) = m(2); @@ -53,8 +49,7 @@ Eigen::Vector2cd MatrixRTCoefficients::T2plus() const return result; } -Eigen::Vector2cd MatrixRTCoefficients::R2plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients::R2plus() const { Eigen::Vector2cd result; Eigen::Matrix<complex_t, 4, 1> m = R2m * phi_psi_plus; result(0) = m(2); @@ -65,8 +60,7 @@ Eigen::Vector2cd MatrixRTCoefficients::R2plus() const return result; } -Eigen::Vector2cd MatrixRTCoefficients::T1min() const -{ +Eigen::Vector2cd MatrixRTCoefficients::T1min() const { Eigen::Vector2cd result; Eigen::Matrix<complex_t, 4, 1> m = T1m * phi_psi_min; result(0) = m(2); @@ -76,8 +70,7 @@ Eigen::Vector2cd MatrixRTCoefficients::T1min() const return result; } -Eigen::Vector2cd MatrixRTCoefficients::R1min() const -{ +Eigen::Vector2cd MatrixRTCoefficients::R1min() const { Eigen::Vector2cd result; Eigen::Matrix<complex_t, 4, 1> m = R1m * phi_psi_min; result(0) = m(2); @@ -88,8 +81,7 @@ Eigen::Vector2cd MatrixRTCoefficients::R1min() const return result; } -Eigen::Vector2cd MatrixRTCoefficients::T2min() const -{ +Eigen::Vector2cd MatrixRTCoefficients::T2min() const { Eigen::Vector2cd result; Eigen::Matrix<complex_t, 4, 1> m = T2m * phi_psi_min; result(0) = m(2); @@ -99,8 +91,7 @@ Eigen::Vector2cd MatrixRTCoefficients::T2min() const return result; } -Eigen::Vector2cd MatrixRTCoefficients::R2min() const -{ +Eigen::Vector2cd MatrixRTCoefficients::R2min() const { Eigen::Vector2cd result; Eigen::Matrix<complex_t, 4, 1> m = R2m * phi_psi_min; result(0) = m(2); @@ -111,8 +102,7 @@ Eigen::Vector2cd MatrixRTCoefficients::R2min() const return result; } -void MatrixRTCoefficients::calculateTRMatrices() -{ +void MatrixRTCoefficients::calculateTRMatrices() { if (m_b_mag == 0.0) { calculateTRWithoutMagnetization(); return; @@ -249,8 +239,7 @@ void MatrixRTCoefficients::calculateTRMatrices() } } -void MatrixRTCoefficients::calculateTRWithoutMagnetization() -{ +void MatrixRTCoefficients::calculateTRWithoutMagnetization() { T1m.setZero(); R1m.setZero(); T2m.setZero(); @@ -294,8 +283,7 @@ void MatrixRTCoefficients::calculateTRWithoutMagnetization() R2m(2, 2) = 0.5; } -void MatrixRTCoefficients::initializeBottomLayerPhiPsi() -{ +void MatrixRTCoefficients::initializeBottomLayerPhiPsi() { if (m_b_mag == 0.0) { phi_psi_min << 0.0, -std::sqrt(m_a), 0.0, 1.0; phi_psi_plus << -std::sqrt(m_a), 0.0, 1.0, 0.0; diff --git a/Sample/RT/MatrixRTCoefficients.h b/Sample/RT/MatrixRTCoefficients.h index f925897c4b4ad10050f07860265b77183a974da9..964a47d8a351c6be53befa459680d852dfe28262 100644 --- a/Sample/RT/MatrixRTCoefficients.h +++ b/Sample/RT/MatrixRTCoefficients.h @@ -21,8 +21,7 @@ //! of 2x2 matrix interactions between the layers and the scattered particle. //! @ingroup algorithms_internal -class MatrixRTCoefficients : public ILayerRTCoefficients -{ +class MatrixRTCoefficients : public ILayerRTCoefficients { public: MatrixRTCoefficients() : m_kt(0.0) {} virtual ~MatrixRTCoefficients() {} diff --git a/Sample/RT/MatrixRTCoefficients_v2.cpp b/Sample/RT/MatrixRTCoefficients_v2.cpp index ed8c3db269cfdf020ccd262e86885a1e4364eb05..f976fcf69574ab1080f53797fa7b06d305a1a799 100644 --- a/Sample/RT/MatrixRTCoefficients_v2.cpp +++ b/Sample/RT/MatrixRTCoefficients_v2.cpp @@ -14,94 +14,80 @@ #include "Sample/RT/MatrixRTCoefficients_v2.h" -namespace -{ +namespace { Eigen::Vector2cd waveVector(const Eigen::Matrix4cd& frob_matrix, const Eigen::Vector4cd& boundary_cond); } // namespace MatrixRTCoefficients_v2::MatrixRTCoefficients_v2(double kz_sign, Eigen::Vector2cd eigenvalues, kvector_t b) - : m_kz_sign(kz_sign), m_lambda(std::move(eigenvalues)), m_b(std::move(b)) -{ -} + : m_kz_sign(kz_sign), m_lambda(std::move(eigenvalues)), m_b(std::move(b)) {} MatrixRTCoefficients_v2::MatrixRTCoefficients_v2(const MatrixRTCoefficients_v2& other) = default; MatrixRTCoefficients_v2::~MatrixRTCoefficients_v2() = default; -MatrixRTCoefficients_v2* MatrixRTCoefficients_v2::clone() const -{ +MatrixRTCoefficients_v2* MatrixRTCoefficients_v2::clone() const { return new MatrixRTCoefficients_v2(*this); } -Eigen::Vector2cd MatrixRTCoefficients_v2::T1plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v2::T1plus() const { const Eigen::Vector2cd result = waveVector(T1, m_w_plus); if (m_lambda(0) == 0.0 && result == Eigen::Vector2cd::Zero()) return {0.5, 0.0}; return result; } -Eigen::Vector2cd MatrixRTCoefficients_v2::R1plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v2::R1plus() const { if (m_lambda(0) == 0.0 && waveVector(T1, m_w_plus) == Eigen::Vector2cd::Zero()) return {-0.5, 0.0}; return waveVector(R1, m_w_plus); } -Eigen::Vector2cd MatrixRTCoefficients_v2::T2plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v2::T2plus() const { const Eigen::Vector2cd result = waveVector(T2, m_w_plus); if (m_lambda(1) == 0.0 && result == Eigen::Vector2cd::Zero()) return {0.5, 0.0}; return result; } -Eigen::Vector2cd MatrixRTCoefficients_v2::R2plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v2::R2plus() const { if (m_lambda(1) == 0.0 && waveVector(T2, m_w_plus) == Eigen::Vector2cd::Zero()) return {-0.5, 0.0}; return waveVector(R2, m_w_plus); } -Eigen::Vector2cd MatrixRTCoefficients_v2::T1min() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v2::T1min() const { const Eigen::Vector2cd result = waveVector(T1, m_w_min); if (m_lambda(0) == 0.0 && result == Eigen::Vector2cd::Zero()) return {0.0, 0.5}; return result; } -Eigen::Vector2cd MatrixRTCoefficients_v2::R1min() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v2::R1min() const { if (m_lambda(0) == 0.0 && waveVector(T1, m_w_min) == Eigen::Vector2cd::Zero()) return {0.0, -0.5}; return waveVector(R1, m_w_min); } -Eigen::Vector2cd MatrixRTCoefficients_v2::T2min() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v2::T2min() const { const Eigen::Vector2cd result = waveVector(T2, m_w_min); if (m_lambda(1) == 0.0 && result == Eigen::Vector2cd::Zero()) return {0.0, 0.5}; return result; } -Eigen::Vector2cd MatrixRTCoefficients_v2::R2min() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v2::R2min() const { if (m_lambda(1) == 0.0 && waveVector(T2, m_w_min) == Eigen::Vector2cd::Zero()) return {0.0, -0.5}; return waveVector(R2, m_w_min); } -Eigen::Vector2cd MatrixRTCoefficients_v2::getKz() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v2::getKz() const { return -I * m_kz_sign * m_lambda; } -Eigen::Matrix2cd MatrixRTCoefficients_v2::getReflectionMatrix() const -{ +Eigen::Matrix2cd MatrixRTCoefficients_v2::getReflectionMatrix() const { Eigen::Matrix2cd R; R.col(0) = R1plus() + R2plus(); R.col(1) = R1min() + R2min(); @@ -109,11 +95,9 @@ Eigen::Matrix2cd MatrixRTCoefficients_v2::getReflectionMatrix() const return R; } -namespace -{ +namespace { Eigen::Vector2cd waveVector(const Eigen::Matrix4cd& frob_matrix, - const Eigen::Vector4cd& boundary_cond) -{ + const Eigen::Vector4cd& boundary_cond) { Eigen::Matrix<complex_t, 4, 1> m = frob_matrix * boundary_cond; return {m(2), m(3)}; } diff --git a/Sample/RT/MatrixRTCoefficients_v2.h b/Sample/RT/MatrixRTCoefficients_v2.h index 4bf3e8f094f44fcdfbd0a85a9fd5824542a4e4e9..dfdc242bcb1830d9ebb902242f15733711ae11dd 100644 --- a/Sample/RT/MatrixRTCoefficients_v2.h +++ b/Sample/RT/MatrixRTCoefficients_v2.h @@ -23,8 +23,7 @@ //! of magnetic interactions between the scattered particle and the layer. //! @ingroup algorithms_internal -class MatrixRTCoefficients_v2 : public ILayerRTCoefficients -{ +class MatrixRTCoefficients_v2 : public ILayerRTCoefficients { public: friend class SpecularMagneticStrategy; diff --git a/Sample/RT/MatrixRTCoefficients_v3.cpp b/Sample/RT/MatrixRTCoefficients_v3.cpp index 74a5eff1c84a63d952884f412b4bf82c6e272a29..0e3ccbf5bbd659907c7acbeaf70d9a7851e76957 100644 --- a/Sample/RT/MatrixRTCoefficients_v3.cpp +++ b/Sample/RT/MatrixRTCoefficients_v3.cpp @@ -15,8 +15,7 @@ #include "Sample/RT/MatrixRTCoefficients_v3.h" #include "Base/Utils/Assert.h" -namespace -{ +namespace { complex_t GetImExponential(complex_t exponent); const auto eps = std::numeric_limits<double>::epsilon() * 10.; } // namespace @@ -26,8 +25,7 @@ MatrixRTCoefficients_v3::MatrixRTCoefficients_v3(double kz_sign, Eigen::Vector2c : m_kz_sign(kz_sign) , m_lambda(std::move(eigenvalues)) , m_b(std::move(b)) - , m_magnetic_SLD(magnetic_SLD) -{ + , m_magnetic_SLD(magnetic_SLD) { ASSERT(std::abs(m_b.mag() - 1) < eps || (m_b.mag() < eps && magnetic_SLD < eps)); m_T << 1, 0, 0, 1; @@ -38,13 +36,11 @@ MatrixRTCoefficients_v3::MatrixRTCoefficients_v3(const MatrixRTCoefficients_v3& MatrixRTCoefficients_v3::~MatrixRTCoefficients_v3() = default; -MatrixRTCoefficients_v3* MatrixRTCoefficients_v3::clone() const -{ +MatrixRTCoefficients_v3* MatrixRTCoefficients_v3::clone() const { return new MatrixRTCoefficients_v3(*this); } -Eigen::Matrix2cd MatrixRTCoefficients_v3::TransformationMatrix(Eigen::Vector2d selection) const -{ +Eigen::Matrix2cd MatrixRTCoefficients_v3::TransformationMatrix(Eigen::Vector2d selection) const { const Eigen::Matrix2cd exp2 = Eigen::DiagonalMatrix<complex_t, 2>(selection); if (std::abs(m_b.mag() - 1.) < eps) { @@ -59,63 +55,51 @@ Eigen::Matrix2cd MatrixRTCoefficients_v3::TransformationMatrix(Eigen::Vector2d s throw std::runtime_error("Broken magnetic field vector"); } -Eigen::Matrix2cd MatrixRTCoefficients_v3::T1Matrix() const -{ +Eigen::Matrix2cd MatrixRTCoefficients_v3::T1Matrix() const { return TransformationMatrix({0., 1.}); } -Eigen::Matrix2cd MatrixRTCoefficients_v3::T2Matrix() const -{ +Eigen::Matrix2cd MatrixRTCoefficients_v3::T2Matrix() const { return TransformationMatrix({1., 0.}); } -Eigen::Vector2cd MatrixRTCoefficients_v3::T1plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v3::T1plus() const { return T1Matrix() * m_T.col(0); } -Eigen::Vector2cd MatrixRTCoefficients_v3::R1plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v3::R1plus() const { return T1Matrix() * m_R.col(0); } -Eigen::Vector2cd MatrixRTCoefficients_v3::T2plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v3::T2plus() const { return T2Matrix() * m_T.col(0); } -Eigen::Vector2cd MatrixRTCoefficients_v3::R2plus() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v3::R2plus() const { return T2Matrix() * m_R.col(0); } -Eigen::Vector2cd MatrixRTCoefficients_v3::T1min() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v3::T1min() const { return T1Matrix() * m_T.col(1); } -Eigen::Vector2cd MatrixRTCoefficients_v3::R1min() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v3::R1min() const { return T1Matrix() * m_R.col(1); } -Eigen::Vector2cd MatrixRTCoefficients_v3::T2min() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v3::T2min() const { return T2Matrix() * m_T.col(1); } -Eigen::Vector2cd MatrixRTCoefficients_v3::R2min() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v3::R2min() const { return T2Matrix() * m_R.col(1); } -Eigen::Vector2cd MatrixRTCoefficients_v3::getKz() const -{ +Eigen::Vector2cd MatrixRTCoefficients_v3::getKz() const { return m_kz_sign * m_lambda; } -Eigen::Matrix2cd MatrixRTCoefficients_v3::pMatrixHelper(double sign) const -{ +Eigen::Matrix2cd MatrixRTCoefficients_v3::pMatrixHelper(double sign) const { const complex_t alpha = m_lambda(1) + m_lambda(0); const complex_t beta = m_lambda(1) - m_lambda(0); @@ -129,16 +113,14 @@ Eigen::Matrix2cd MatrixRTCoefficients_v3::pMatrixHelper(double sign) const return result; } -Eigen::Matrix2cd MatrixRTCoefficients_v3::computeP() const -{ +Eigen::Matrix2cd MatrixRTCoefficients_v3::computeP() const { Eigen::Matrix2cd result = pMatrixHelper(1.); result *= 0.5; return result; } -Eigen::Matrix2cd MatrixRTCoefficients_v3::computeInverseP() const -{ +Eigen::Matrix2cd MatrixRTCoefficients_v3::computeInverseP() const { const complex_t alpha = m_lambda(1) + m_lambda(0); const complex_t beta = m_lambda(1) - m_lambda(0); @@ -151,8 +133,7 @@ Eigen::Matrix2cd MatrixRTCoefficients_v3::computeInverseP() const return result; } -Eigen::Matrix2cd MatrixRTCoefficients_v3::computeDeltaMatrix(double thickness) -{ +Eigen::Matrix2cd MatrixRTCoefficients_v3::computeDeltaMatrix(double thickness) { Eigen::Matrix2cd result; const complex_t alpha = 0.5 * thickness * (m_lambda(1) + m_lambda(0)); @@ -173,10 +154,8 @@ Eigen::Matrix2cd MatrixRTCoefficients_v3::computeDeltaMatrix(double thickness) throw std::runtime_error("Broken magnetic field vector"); } -namespace -{ -complex_t GetImExponential(complex_t exponent) -{ +namespace { +complex_t GetImExponential(complex_t exponent) { if (exponent.imag() > -std::log(std::numeric_limits<double>::min())) return 0.0; return std::exp(I * exponent); diff --git a/Sample/RT/MatrixRTCoefficients_v3.h b/Sample/RT/MatrixRTCoefficients_v3.h index ccbd8518d07dc8d78f668c357439c78aa976e301..7a239c1f011c2c589561cef9b6c51062f755ff39 100644 --- a/Sample/RT/MatrixRTCoefficients_v3.h +++ b/Sample/RT/MatrixRTCoefficients_v3.h @@ -23,8 +23,7 @@ //! of magnetic interactions between the scattered particle and the layer. //! @ingroup algorithms_internal -class MatrixRTCoefficients_v3 : public ILayerRTCoefficients -{ +class MatrixRTCoefficients_v3 : public ILayerRTCoefficients { public: friend class SpecularMagneticNewStrategy; friend class SpecularMagneticNewNCStrategy; diff --git a/Sample/RT/ScalarRTCoefficients.h b/Sample/RT/ScalarRTCoefficients.h index 15f56c39f88b2da28442ea2b57ee585c348a6a00..f6f3627fe67eec0688daf1a66a186c6428c6f790 100644 --- a/Sample/RT/ScalarRTCoefficients.h +++ b/Sample/RT/ScalarRTCoefficients.h @@ -21,8 +21,7 @@ //! of scalar interactions between the layers and the scattered particle. //! @ingroup algorithms_internal -class ScalarRTCoefficients : public ILayerRTCoefficients -{ +class ScalarRTCoefficients : public ILayerRTCoefficients { public: ScalarRTCoefficients(); virtual ~ScalarRTCoefficients() {} @@ -68,8 +67,7 @@ private: // implementation // ************************************************************************************************ -inline ScalarRTCoefficients::ScalarRTCoefficients() : kz(0) -{ +inline ScalarRTCoefficients::ScalarRTCoefficients() : kz(0) { m_plus(0) = 1.0; m_plus(1) = 0.0; m_min(0) = 0.0; @@ -77,63 +75,51 @@ inline ScalarRTCoefficients::ScalarRTCoefficients() : kz(0) t_r << complex_t(1.0, 0.0), complex_t(0.0, 0.0); } -inline ScalarRTCoefficients* ScalarRTCoefficients::clone() const -{ +inline ScalarRTCoefficients* ScalarRTCoefficients::clone() const { return new ScalarRTCoefficients(*this); } -inline Eigen::Vector2cd ScalarRTCoefficients::T1plus() const -{ +inline Eigen::Vector2cd ScalarRTCoefficients::T1plus() const { return Eigen::Vector2cd::Zero(); } -inline Eigen::Vector2cd ScalarRTCoefficients::R1plus() const -{ +inline Eigen::Vector2cd ScalarRTCoefficients::R1plus() const { return Eigen::Vector2cd::Zero(); } -inline Eigen::Vector2cd ScalarRTCoefficients::T2plus() const -{ +inline Eigen::Vector2cd ScalarRTCoefficients::T2plus() const { return m_plus * getScalarT(); } -inline Eigen::Vector2cd ScalarRTCoefficients::R2plus() const -{ +inline Eigen::Vector2cd ScalarRTCoefficients::R2plus() const { return m_plus * getScalarR(); } -inline Eigen::Vector2cd ScalarRTCoefficients::T1min() const -{ +inline Eigen::Vector2cd ScalarRTCoefficients::T1min() const { return m_min * getScalarT(); } -inline Eigen::Vector2cd ScalarRTCoefficients::R1min() const -{ +inline Eigen::Vector2cd ScalarRTCoefficients::R1min() const { return m_min * getScalarR(); } -inline Eigen::Vector2cd ScalarRTCoefficients::T2min() const -{ +inline Eigen::Vector2cd ScalarRTCoefficients::T2min() const { return Eigen::Vector2cd::Zero(); } -inline Eigen::Vector2cd ScalarRTCoefficients::R2min() const -{ +inline Eigen::Vector2cd ScalarRTCoefficients::R2min() const { return Eigen::Vector2cd::Zero(); } -inline Eigen::Vector2cd ScalarRTCoefficients::getKz() const -{ +inline Eigen::Vector2cd ScalarRTCoefficients::getKz() const { return (m_plus + m_min) * kz; } -inline complex_t ScalarRTCoefficients::getScalarR() const -{ +inline complex_t ScalarRTCoefficients::getScalarR() const { return t_r(1); } -inline complex_t ScalarRTCoefficients::getScalarT() const -{ +inline complex_t ScalarRTCoefficients::getScalarT() const { return t_r(0); } diff --git a/Sample/RT/SimulationOptions.cpp b/Sample/RT/SimulationOptions.cpp index cb72cd0af4ccd74cf1f41dcebfb10d6b8fb07b13..eca5095a5dfb004d351b4467ef596eee52acfdb5 100644 --- a/Sample/RT/SimulationOptions.cpp +++ b/Sample/RT/SimulationOptions.cpp @@ -17,24 +17,23 @@ #include <thread> SimulationOptions::SimulationOptions() - : m_mc_integration(false), m_include_specular(false), m_use_avg_materials(false), m_mc_points(1) -{ + : m_mc_integration(false) + , m_include_specular(false) + , m_use_avg_materials(false) + , m_mc_points(1) { m_thread_info.n_threads = getHardwareConcurrency(); } -bool SimulationOptions::isIntegrate() const -{ +bool SimulationOptions::isIntegrate() const { return m_mc_integration && m_mc_points > 1; } -void SimulationOptions::setMonteCarloIntegration(bool flag, size_t mc_points) -{ +void SimulationOptions::setMonteCarloIntegration(bool flag, size_t mc_points) { m_mc_integration = flag; m_mc_points = mc_points; } -void SimulationOptions::setNumberOfThreads(int nthreads) -{ +void SimulationOptions::setNumberOfThreads(int nthreads) { if (nthreads == 0) m_thread_info.n_threads = getHardwareConcurrency(); else if (nthreads > 0) @@ -43,39 +42,34 @@ void SimulationOptions::setNumberOfThreads(int nthreads) m_thread_info.n_threads = 1; } -unsigned SimulationOptions::getNumberOfThreads() const -{ +unsigned SimulationOptions::getNumberOfThreads() const { if (m_thread_info.n_threads < 1) throw std::runtime_error("Error in SimulationOptions::getNumberOfThreads: Number of " "threads must be positive"); return m_thread_info.n_threads; } -void SimulationOptions::setNumberOfBatches(int nbatches) -{ +void SimulationOptions::setNumberOfBatches(int nbatches) { if (nbatches < 1) throw std::runtime_error("Error in SimulationOptions::setNumberOfBatches: Number of " "batches must be positive"); m_thread_info.n_batches = nbatches; } -unsigned SimulationOptions::getNumberOfBatches() const -{ +unsigned SimulationOptions::getNumberOfBatches() const { if (m_thread_info.n_batches < 1) throw std::runtime_error("Error in SimulationOptions::getNumberOfBatches: Number of " "batches must be positive"); return m_thread_info.n_batches; } -unsigned SimulationOptions::getCurrentBatch() const -{ +unsigned SimulationOptions::getCurrentBatch() const { if (m_thread_info.current_batch >= getNumberOfBatches()) throw std::runtime_error( "Error in SimulationOptions::getCurrentBatch: current batch is out of range"); return m_thread_info.current_batch; } -unsigned SimulationOptions::getHardwareConcurrency() const -{ +unsigned SimulationOptions::getHardwareConcurrency() const { return std::thread::hardware_concurrency(); } diff --git a/Sample/RT/SimulationOptions.h b/Sample/RT/SimulationOptions.h index faacd848c3cb9c0a11be5819ad8d626dfe1b093c..72f7410df996adc88b9bd0607ccd68a0c713c4d7 100644 --- a/Sample/RT/SimulationOptions.h +++ b/Sample/RT/SimulationOptions.h @@ -24,8 +24,7 @@ using std::size_t; //! @ingroup simulation //! @ref SimulationOptions -class SimulationOptions -{ +class SimulationOptions { public: SimulationOptions(); diff --git a/Sample/SampleBuilderEngine/FixedBuilder.cpp b/Sample/SampleBuilderEngine/FixedBuilder.cpp index c60030ffcac6c7d2e11f410be8d9211e3f8da1e3..e784f6df3820bbe646be80ac1b6ce61596924548 100644 --- a/Sample/SampleBuilderEngine/FixedBuilder.cpp +++ b/Sample/SampleBuilderEngine/FixedBuilder.cpp @@ -17,7 +17,6 @@ FixedBuilder::FixedBuilder(const MultiLayer& sample) : m_sample(sample.clone()) {} -MultiLayer* FixedBuilder::buildSample() const -{ +MultiLayer* FixedBuilder::buildSample() const { return m_sample->clone(); } diff --git a/Sample/SampleBuilderEngine/FixedBuilder.h b/Sample/SampleBuilderEngine/FixedBuilder.h index 9b7d17bbb33078a4cf31f839e52f430c765c9f8a..813a399e56bdd4380f29b475fb151dc079b830b8 100644 --- a/Sample/SampleBuilderEngine/FixedBuilder.h +++ b/Sample/SampleBuilderEngine/FixedBuilder.h @@ -22,8 +22,7 @@ class MultiLayer; //! A trivial sample builder class that builds a fixed sample. -class FixedBuilder : public ISampleBuilder -{ +class FixedBuilder : public ISampleBuilder { public: FixedBuilder() = delete; FixedBuilder(const MultiLayer&); diff --git a/Sample/SampleBuilderEngine/IRegistry.h b/Sample/SampleBuilderEngine/IRegistry.h index 0b8b6fb0e4a631aed281b5c2ab73f695486b726d..d5faf312e1143c1599ea0a7a4a3bbd30222155af 100644 --- a/Sample/SampleBuilderEngine/IRegistry.h +++ b/Sample/SampleBuilderEngine/IRegistry.h @@ -25,19 +25,16 @@ //! @ingroup tools_internal //! @brief Templated object registry. -template <class ValueType> class IRegistry -{ +template <class ValueType> class IRegistry { public: - const ValueType* getItem(const std::string& key) const - { + const ValueType* getItem(const std::string& key) const { auto it = m_data.find(key); if (it == m_data.end()) throw std::runtime_error("Key '" + key + "' not found in registry"); return it->second.get(); } - std::vector<std::string> keys() const - { + std::vector<std::string> keys() const { std::vector<std::string> result; for (auto it = m_data.begin(); it != m_data.end(); ++it) result.push_back(it->first); @@ -47,8 +44,7 @@ public: size_t size() const { return m_data.size(); } protected: - void add(const std::string& key, ValueType* item) - { + void add(const std::string& key, ValueType* item) { if (m_data.find(key) != m_data.end()) throw std::runtime_error("Key '" + key + "' already in registry"); m_data[key] = std::unique_ptr<ValueType>(item); diff --git a/Sample/SampleBuilderEngine/ISampleBuilder.cpp b/Sample/SampleBuilderEngine/ISampleBuilder.cpp index 0139c1777d3d1edc417f19010b8e0733ae96c366..117b71cf4221fe42d22d25aacc53cebb3b256c4e 100644 --- a/Sample/SampleBuilderEngine/ISampleBuilder.cpp +++ b/Sample/SampleBuilderEngine/ISampleBuilder.cpp @@ -14,8 +14,7 @@ #include "Sample/SampleBuilderEngine/ISampleBuilder.h" -ISampleBuilder::ISampleBuilder() -{ +ISampleBuilder::ISampleBuilder() { setName("SampleBuilder"); } diff --git a/Sample/SampleBuilderEngine/ISampleBuilder.h b/Sample/SampleBuilderEngine/ISampleBuilder.h index 90de497f61d5a15ff3d5fa70b51e59fb2a85068b..9bb8935bdf2edfffd9914dea32f8381073a1b4bd 100644 --- a/Sample/SampleBuilderEngine/ISampleBuilder.h +++ b/Sample/SampleBuilderEngine/ISampleBuilder.h @@ -22,8 +22,7 @@ class MultiLayer; //! Interface to the class capable to build samples to simulate. //! @ingroup simulation_internal -class ISampleBuilder : public IParameterized -{ +class ISampleBuilder : public IParameterized { public: ISampleBuilder(); virtual ~ISampleBuilder(); diff --git a/Sample/SampleBuilderEngine/SampleBuilderNode.cpp b/Sample/SampleBuilderEngine/SampleBuilderNode.cpp index b0e75345f2fdb3c922886169745e027a873c6b20..edf3f4588b7fed7b0c5bd6d0282c3a1a0c0f85a5 100644 --- a/Sample/SampleBuilderEngine/SampleBuilderNode.cpp +++ b/Sample/SampleBuilderEngine/SampleBuilderNode.cpp @@ -19,24 +19,20 @@ #include "Sample/SampleBuilderEngine/ISampleBuilder.h" #include <stdexcept> -namespace -{ +namespace { const std::string& default_name = "SampleBuilderNode"; } -SampleBuilderNode::SampleBuilderNode() -{ +SampleBuilderNode::SampleBuilderNode() { setName(default_name); } SampleBuilderNode::SampleBuilderNode(const SampleBuilderNode& other) - : INode(), m_sample_builder(other.m_sample_builder) -{ + : INode(), m_sample_builder(other.m_sample_builder) { setName(other.getName()); } -SampleBuilderNode& SampleBuilderNode::operator=(const SampleBuilderNode& other) -{ +SampleBuilderNode& SampleBuilderNode::operator=(const SampleBuilderNode& other) { if (this != &other) { m_sample_builder = other.m_sample_builder; setName(other.getName()); @@ -46,8 +42,7 @@ SampleBuilderNode& SampleBuilderNode::operator=(const SampleBuilderNode& other) //! Sets sample builder and borrows its parameters. -void SampleBuilderNode::setSBN(const std::shared_ptr<ISampleBuilder>& sample_builder) -{ +void SampleBuilderNode::setSBN(const std::shared_ptr<ISampleBuilder>& sample_builder) { if (!sample_builder) throw std::runtime_error("SampleContainer::setSampleBuilder() -> Error. " "Attempt to set null sample builder."); @@ -59,8 +54,7 @@ void SampleBuilderNode::setSBN(const std::shared_ptr<ISampleBuilder>& sample_bui //! Resets to initial state by removing builder and its borrowed parameters. -void SampleBuilderNode::reset() -{ +void SampleBuilderNode::reset() { setName(default_name); parameterPool()->clear(); m_sample_builder.reset(); @@ -68,30 +62,26 @@ void SampleBuilderNode::reset() //! Creates a multilayer using sample builder. -std::unique_ptr<MultiLayer> SampleBuilderNode::createMultiLayer() -{ +std::unique_ptr<MultiLayer> SampleBuilderNode::createMultiLayer() { ASSERT(m_sample_builder); return std::unique_ptr<MultiLayer>(m_sample_builder->buildSample()); } //! Returns current sample builder. -std::shared_ptr<ISampleBuilder> SampleBuilderNode::builder() const -{ +std::shared_ptr<ISampleBuilder> SampleBuilderNode::builder() const { return m_sample_builder; } //! Returns true if sample builder is set. -SampleBuilderNode::operator bool() const -{ +SampleBuilderNode::operator bool() const { return (bool)m_sample_builder; } //! Fill local parameter pool with parameters from sample builder. -void SampleBuilderNode::borrow_builder_parameters() -{ +void SampleBuilderNode::borrow_builder_parameters() { parameterPool()->clear(); if (!m_sample_builder) diff --git a/Sample/SampleBuilderEngine/SampleBuilderNode.h b/Sample/SampleBuilderEngine/SampleBuilderNode.h index c27805cc330cdea61578db4c1669dc8acb0596e0..03dc79c7a16ff46b99ca0834db47ef325cdb5db0 100644 --- a/Sample/SampleBuilderEngine/SampleBuilderNode.h +++ b/Sample/SampleBuilderEngine/SampleBuilderNode.h @@ -24,8 +24,7 @@ class ISampleBuilder; //! Used by SampleProvider. //! @ingroup simulation_internal -class SampleBuilderNode : public INode -{ +class SampleBuilderNode : public INode { public: SampleBuilderNode(); SampleBuilderNode(const SampleBuilderNode& other); diff --git a/Sample/SampleBuilderEngine/SampleComponents.h b/Sample/SampleBuilderEngine/SampleComponents.h index 8c25d5b1bf2a7508de705bb19f00d14599e328a4..f92bc2b019e11aaff4e83d5bec96b2e657e077b4 100644 --- a/Sample/SampleBuilderEngine/SampleComponents.h +++ b/Sample/SampleBuilderEngine/SampleComponents.h @@ -21,8 +21,7 @@ //! @class FTDistribution2DComponents //! @brief Predefined Fourier transformed distributions for functional tests. -class FTDistribution2DComponents : public IRegistry<IFTDistribution2D> -{ +class FTDistribution2DComponents : public IRegistry<IFTDistribution2D> { public: FTDistribution2DComponents(); }; @@ -30,8 +29,7 @@ public: //! @class FormFactorComponents //! @brief Predefined form factors for functional tests. -class FormFactorComponents : public IRegistry<IFormFactor> -{ +class FormFactorComponents : public IRegistry<IFormFactor> { public: FormFactorComponents(); }; diff --git a/Sample/SampleBuilderEngine/SampleProvider.cpp b/Sample/SampleBuilderEngine/SampleProvider.cpp index 7ec48df8d3c612a3ff28df22ba2390f844735648..1801b023d5f5c58d6985f6df867efce118cdb5c3 100644 --- a/Sample/SampleBuilderEngine/SampleProvider.cpp +++ b/Sample/SampleBuilderEngine/SampleProvider.cpp @@ -17,8 +17,7 @@ SampleProvider::SampleProvider() = default; -SampleProvider::SampleProvider(const SampleProvider& other) : INode() -{ +SampleProvider::SampleProvider(const SampleProvider& other) : INode() { if (other.m_multilayer) setSample(*other.m_multilayer); @@ -26,8 +25,7 @@ SampleProvider::SampleProvider(const SampleProvider& other) : INode() setBuilder(other.m_sample_builder.builder()); } -SampleProvider& SampleProvider::operator=(const SampleProvider& other) -{ +SampleProvider& SampleProvider::operator=(const SampleProvider& other) { if (this != &other) { SampleProvider tmp(other); std::swap(m_multilayer, tmp.m_multilayer); @@ -38,15 +36,13 @@ SampleProvider& SampleProvider::operator=(const SampleProvider& other) SampleProvider::~SampleProvider() = default; -void SampleProvider::setSample(const MultiLayer& multilayer) -{ +void SampleProvider::setSample(const MultiLayer& multilayer) { m_multilayer.reset(multilayer.clone()); m_multilayer->setParent(parent()); m_sample_builder.reset(); } -void SampleProvider::setBuilder(const std::shared_ptr<ISampleBuilder>& sample_builder) -{ +void SampleProvider::setBuilder(const std::shared_ptr<ISampleBuilder>& sample_builder) { m_sample_builder.setSBN(sample_builder); m_sample_builder.setParent(parent()); m_multilayer.reset(); @@ -54,15 +50,13 @@ void SampleProvider::setBuilder(const std::shared_ptr<ISampleBuilder>& sample_bu //! Returns current sample. -const MultiLayer* SampleProvider::sample() const -{ +const MultiLayer* SampleProvider::sample() const { return m_multilayer.get(); } //! Generates new sample if sample builder defined. -void SampleProvider::updateSample() -{ +void SampleProvider::updateSample() { if (m_sample_builder) m_multilayer = m_sample_builder.createMultiLayer(); @@ -71,8 +65,7 @@ void SampleProvider::updateSample() "SampleProvider::updateSample called before sample or builder was set"); } -std::vector<const INode*> SampleProvider::getChildren() const -{ +std::vector<const INode*> SampleProvider::getChildren() const { if (m_sample_builder) return {&m_sample_builder}; if (m_multilayer) @@ -80,8 +73,7 @@ std::vector<const INode*> SampleProvider::getChildren() const return {}; } -void SampleProvider::setParent(const INode* newParent) -{ +void SampleProvider::setParent(const INode* newParent) { INode::setParent(newParent); if (m_sample_builder) m_sample_builder.setParent(parent()); diff --git a/Sample/SampleBuilderEngine/SampleProvider.h b/Sample/SampleBuilderEngine/SampleProvider.h index 878a662311652fb43e37c638761a51162e22b8e3..58e3921a1473598754023fefa3f7fb285b56e5cd 100644 --- a/Sample/SampleBuilderEngine/SampleProvider.h +++ b/Sample/SampleBuilderEngine/SampleProvider.h @@ -24,8 +24,7 @@ class MultiLayer; //! @ingroup simulation_internal -class SampleProvider : public INode -{ +class SampleProvider : public INode { public: SampleProvider(); SampleProvider(const SampleProvider& other); // TODO ASAP can't we clone? diff --git a/Sample/Scattering/FormFactorDecoratorMaterial.cpp b/Sample/Scattering/FormFactorDecoratorMaterial.cpp index d113cec96759293e4fd43e2f747376ee676f5758..fe8f722292f69fd83b565e90394c46e83eb2fa03 100644 --- a/Sample/Scattering/FormFactorDecoratorMaterial.cpp +++ b/Sample/Scattering/FormFactorDecoratorMaterial.cpp @@ -20,38 +20,32 @@ FormFactorDecoratorMaterial::FormFactorDecoratorMaterial(const IFormFactor& ff) : IFormFactorDecorator(ff) , m_material(HomogeneousMaterial()) - , m_ambient_material(HomogeneousMaterial()) -{ + , m_ambient_material(HomogeneousMaterial()) { setName("FormFactorDecoratorMaterial"); } FormFactorDecoratorMaterial::~FormFactorDecoratorMaterial() = default; -FormFactorDecoratorMaterial* FormFactorDecoratorMaterial::clone() const -{ +FormFactorDecoratorMaterial* FormFactorDecoratorMaterial::clone() const { auto* result = new FormFactorDecoratorMaterial(*m_ff); result->setMaterial(m_material); result->setAmbientMaterial(m_ambient_material); return result; } -void FormFactorDecoratorMaterial::setMaterial(const Material& material) -{ +void FormFactorDecoratorMaterial::setMaterial(const Material& material) { m_material = material; } -void FormFactorDecoratorMaterial::setAmbientMaterial(const Material& material) -{ +void FormFactorDecoratorMaterial::setAmbientMaterial(const Material& material) { m_ambient_material = material; } -complex_t FormFactorDecoratorMaterial::evaluate(const WavevectorInfo& wavevectors) const -{ +complex_t FormFactorDecoratorMaterial::evaluate(const WavevectorInfo& wavevectors) const { return getRefractiveIndexFactor(wavevectors) * m_ff->evaluate(wavevectors); } -Eigen::Matrix2cd FormFactorDecoratorMaterial::evaluatePol(const WavevectorInfo& wavevectors) const -{ +Eigen::Matrix2cd FormFactorDecoratorMaterial::evaluatePol(const WavevectorInfo& wavevectors) const { // the conjugated linear part of time reversal operator T // (T=UK with K complex conjugate operator and U is linear) Eigen::Matrix2cd time_reverse_conj = Eigen::Matrix2cd::Zero(); @@ -65,7 +59,6 @@ Eigen::Matrix2cd FormFactorDecoratorMaterial::evaluatePol(const WavevectorInfo& } complex_t -FormFactorDecoratorMaterial::getRefractiveIndexFactor(const WavevectorInfo& wavevectors) const -{ +FormFactorDecoratorMaterial::getRefractiveIndexFactor(const WavevectorInfo& wavevectors) const { return m_material.scalarSubtrSLD(wavevectors) - m_ambient_material.scalarSubtrSLD(wavevectors); } diff --git a/Sample/Scattering/FormFactorDecoratorMaterial.h b/Sample/Scattering/FormFactorDecoratorMaterial.h index d68974ca29338fe1fce42474f6c43db0eca159de..efee08b72f16781f4b75e0aef9ad70fc51a44cfc 100644 --- a/Sample/Scattering/FormFactorDecoratorMaterial.h +++ b/Sample/Scattering/FormFactorDecoratorMaterial.h @@ -23,8 +23,7 @@ //! refractive index and that of its surrounding material. //! @ingroup formfactors_decorations -class FormFactorDecoratorMaterial : public IFormFactorDecorator -{ +class FormFactorDecoratorMaterial : public IFormFactorDecorator { public: FormFactorDecoratorMaterial(const IFormFactor& ff); diff --git a/Sample/Scattering/FormFactorDecoratorPositionFactor.cpp b/Sample/Scattering/FormFactorDecoratorPositionFactor.cpp index 5d0e64b32c62523e73cb00897ef6fe14578aa7e0..44e81c99f7089e9c8b7e5f8a9fb7badb65206d43 100644 --- a/Sample/Scattering/FormFactorDecoratorPositionFactor.cpp +++ b/Sample/Scattering/FormFactorDecoratorPositionFactor.cpp @@ -18,37 +18,31 @@ FormFactorDecoratorPositionFactor::FormFactorDecoratorPositionFactor(const IFormFactor& ff, const kvector_t& position) - : IFormFactorDecorator(ff), m_position(position) -{ + : IFormFactorDecorator(ff), m_position(position) { setName("FormFactorDecoratorPositionFactor"); } -double FormFactorDecoratorPositionFactor::bottomZ(const IRotation& rotation) const -{ +double FormFactorDecoratorPositionFactor::bottomZ(const IRotation& rotation) const { kvector_t rotated_translation = rotation.transformed(m_position); return m_ff->bottomZ(rotation) + rotated_translation.z(); } -double FormFactorDecoratorPositionFactor::topZ(const IRotation& rotation) const -{ +double FormFactorDecoratorPositionFactor::topZ(const IRotation& rotation) const { kvector_t rotated_translation = rotation.transformed(m_position); return m_ff->topZ(rotation) + rotated_translation.z(); } -complex_t FormFactorDecoratorPositionFactor::evaluate(const WavevectorInfo& wavevectors) const -{ +complex_t FormFactorDecoratorPositionFactor::evaluate(const WavevectorInfo& wavevectors) const { return getPositionFactor(wavevectors) * m_ff->evaluate(wavevectors); } Eigen::Matrix2cd -FormFactorDecoratorPositionFactor::evaluatePol(const WavevectorInfo& wavevectors) const -{ +FormFactorDecoratorPositionFactor::evaluatePol(const WavevectorInfo& wavevectors) const { return getPositionFactor(wavevectors) * m_ff->evaluatePol(wavevectors); } complex_t -FormFactorDecoratorPositionFactor::getPositionFactor(const WavevectorInfo& wavevectors) const -{ +FormFactorDecoratorPositionFactor::getPositionFactor(const WavevectorInfo& wavevectors) const { cvector_t q = wavevectors.getQ(); return exp_I(m_position.dot(q)); } diff --git a/Sample/Scattering/FormFactorDecoratorPositionFactor.h b/Sample/Scattering/FormFactorDecoratorPositionFactor.h index 8ac880c9b9447f7a75a363d17f68dac9044e1403..c998328bba4733d80a430731e4cd5f60f4eb3815 100644 --- a/Sample/Scattering/FormFactorDecoratorPositionFactor.h +++ b/Sample/Scattering/FormFactorDecoratorPositionFactor.h @@ -20,13 +20,11 @@ //! Decorates a form factor with a position dependent phase factor. //! @ingroup formfactors_internal -class FormFactorDecoratorPositionFactor : public IFormFactorDecorator -{ +class FormFactorDecoratorPositionFactor : public IFormFactorDecorator { public: FormFactorDecoratorPositionFactor(const IFormFactor& ff, const kvector_t& position); - FormFactorDecoratorPositionFactor* clone() const final - { + FormFactorDecoratorPositionFactor* clone() const final { return new FormFactorDecoratorPositionFactor(*m_ff, m_position); } diff --git a/Sample/Scattering/FormFactorDecoratorRotation.cpp b/Sample/Scattering/FormFactorDecoratorRotation.cpp index cf95faf26842c02287431316ae7a860e5548a9ad..7e48f046cea86b6b2b93c708ce494c3510294472 100644 --- a/Sample/Scattering/FormFactorDecoratorRotation.cpp +++ b/Sample/Scattering/FormFactorDecoratorRotation.cpp @@ -19,44 +19,37 @@ FormFactorDecoratorRotation::FormFactorDecoratorRotation(const IFormFactor& ff, const IRotation& rotation) - : IFormFactorDecorator(ff) -{ + : IFormFactorDecorator(ff) { setName("FormFactorDecoratorRotation"); m_transform = rotation.getTransform3D(); } -FormFactorDecoratorRotation* FormFactorDecoratorRotation::clone() const -{ +FormFactorDecoratorRotation* FormFactorDecoratorRotation::clone() const { return new FormFactorDecoratorRotation(*m_ff, m_transform); } -double FormFactorDecoratorRotation::bottomZ(const IRotation& rotation) const -{ +double FormFactorDecoratorRotation::bottomZ(const IRotation& rotation) const { Transform3D transform = rotation.getTransform3D(); std::unique_ptr<IRotation> total_rotation(IRotation::createRotation(transform * m_transform)); return m_ff->bottomZ(*total_rotation); } -double FormFactorDecoratorRotation::topZ(const IRotation& rotation) const -{ +double FormFactorDecoratorRotation::topZ(const IRotation& rotation) const { Transform3D transform = rotation.getTransform3D(); std::unique_ptr<IRotation> total_rotation(IRotation::createRotation(transform * m_transform)); return m_ff->topZ(*total_rotation); } -complex_t FormFactorDecoratorRotation::evaluate(const WavevectorInfo& wavevectors) const -{ +complex_t FormFactorDecoratorRotation::evaluate(const WavevectorInfo& wavevectors) const { return m_ff->evaluate(wavevectors.transformed(m_transform.getInverse())); } -Eigen::Matrix2cd FormFactorDecoratorRotation::evaluatePol(const WavevectorInfo& wavevectors) const -{ +Eigen::Matrix2cd FormFactorDecoratorRotation::evaluatePol(const WavevectorInfo& wavevectors) const { return m_ff->evaluatePol(wavevectors.transformed(m_transform.getInverse())); } FormFactorDecoratorRotation::FormFactorDecoratorRotation(const IFormFactor& ff, const Transform3D& transform) - : IFormFactorDecorator(ff), m_transform(transform) -{ + : IFormFactorDecorator(ff), m_transform(transform) { setName("FormFactorDecoratorRotation"); } diff --git a/Sample/Scattering/FormFactorDecoratorRotation.h b/Sample/Scattering/FormFactorDecoratorRotation.h index 01a6a049edbdd289fcb4e251c73378cda0a3e79d..062ac7fe88ab190ba9aa3d276999c651fc65b409 100644 --- a/Sample/Scattering/FormFactorDecoratorRotation.h +++ b/Sample/Scattering/FormFactorDecoratorRotation.h @@ -23,8 +23,7 @@ class IRotation; //! Equips a form factor with a rotation. //! @ingroup formfactors_internal -class FormFactorDecoratorRotation : public IFormFactorDecorator -{ +class FormFactorDecoratorRotation : public IFormFactorDecorator { public: //! Constructor, setting form factor and rotation. FormFactorDecoratorRotation(const IFormFactor& ff, const IRotation& rotation); diff --git a/Sample/Scattering/IBornFF.cpp b/Sample/Scattering/IBornFF.cpp index 3fef61e21ce5403dc25e81dc823a32e894ab8b04..79cb7cc1e60510090c0eb0d0cbd0abe716bd4f62 100644 --- a/Sample/Scattering/IBornFF.cpp +++ b/Sample/Scattering/IBornFF.cpp @@ -22,51 +22,42 @@ IBornFF::IBornFF() = default; IBornFF::IBornFF(const NodeMeta& meta, const std::vector<double>& PValues) - : IFormFactor(meta, PValues) -{ -} + : IFormFactor(meta, PValues) {} IBornFF::~IBornFF() = default; -complex_t IBornFF::evaluate(const WavevectorInfo& wavevectors) const -{ +complex_t IBornFF::evaluate(const WavevectorInfo& wavevectors) const { return evaluate_for_q(wavevectors.getQ()); } -Eigen::Matrix2cd IBornFF::evaluatePol(const WavevectorInfo& wavevectors) const -{ +Eigen::Matrix2cd IBornFF::evaluatePol(const WavevectorInfo& wavevectors) const { return evaluate_for_q_pol(wavevectors.getQ()); } -double IBornFF::bottomZ(const IRotation& rotation) const -{ +double IBornFF::bottomZ(const IRotation& rotation) const { if (!m_shape) return 0; return BottomZ(m_shape->vertices(), rotation); } -double IBornFF::topZ(const IRotation& rotation) const -{ +double IBornFF::topZ(const IRotation& rotation) const { if (!m_shape) return 0; return TopZ(m_shape->vertices(), rotation); } -bool IBornFF::canSliceAnalytically(const IRotation& rot) const -{ +bool IBornFF::canSliceAnalytically(const IRotation& rot) const { if (rot.zInvariant()) return true; return false; } -Eigen::Matrix2cd IBornFF::evaluate_for_q_pol(cvector_t q) const -{ +Eigen::Matrix2cd IBornFF::evaluate_for_q_pol(cvector_t q) const { return evaluate_for_q(q) * Eigen::Matrix2cd::Identity(); } SlicingEffects IBornFF::computeSlicingEffects(ZLimits limits, const kvector_t& position, - double height) -{ + double height) { kvector_t new_position(position); double z_bottom = position.z(); double z_top = position.z() + height; @@ -88,16 +79,14 @@ SlicingEffects IBornFF::computeSlicingEffects(ZLimits limits, const kvector_t& p return {new_position, dz_bottom, dz_top}; } -double IBornFF::BottomZ(const std::vector<kvector_t>& vertices, const IRotation& rotation) -{ +double IBornFF::BottomZ(const std::vector<kvector_t>& vertices, const IRotation& rotation) { ASSERT(vertices.size()); return algo::min_value( vertices.begin(), vertices.end(), [&](const kvector_t& vertex) -> double { return rotation.transformed(vertex).z(); }); } -double IBornFF::TopZ(const std::vector<kvector_t>& vertices, const IRotation& rotation) -{ +double IBornFF::TopZ(const std::vector<kvector_t>& vertices, const IRotation& rotation) { ASSERT(vertices.size()); return algo::max_value( vertices.begin(), vertices.end(), diff --git a/Sample/Scattering/IBornFF.h b/Sample/Scattering/IBornFF.h index 722ac4f975ba76d33dc614484a87a97369ac7073..3860b1e031eb85079a48113a5ca6fd57d086441b 100644 --- a/Sample/Scattering/IBornFF.h +++ b/Sample/Scattering/IBornFF.h @@ -37,8 +37,7 @@ struct SlicingEffects { //! @ingroup formfactors_internal -class IBornFF : public IFormFactor -{ +class IBornFF : public IFormFactor { public: IBornFF(); IBornFF(const NodeMeta& meta, const std::vector<double>& PValues); diff --git a/Sample/Scattering/IFormFactor.cpp b/Sample/Scattering/IFormFactor.cpp index 8a99b3c369be6d9868938f537f45fc7da868f5d8..3f0639d463ced18d6dd01543c409c9985d2cc263 100644 --- a/Sample/Scattering/IFormFactor.cpp +++ b/Sample/Scattering/IFormFactor.cpp @@ -21,11 +21,9 @@ #include <memory> #include <utility> -namespace -{ +namespace { bool shapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits, const IRotation& rot, - kvector_t translation) -{ + kvector_t translation) { double zbottom = formfactor.bottomZ(rot) + translation.z(); double ztop = formfactor.topZ(rot) + translation.z(); OneSidedLimit lower_limit = limits.lowerLimit(); @@ -37,8 +35,7 @@ bool shapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits, con return true; } bool shapeOutsideLimits(const IFormFactor& formfactor, ZLimits limits, const IRotation& rot, - kvector_t translation) -{ + kvector_t translation) { double zbottom = formfactor.bottomZ(rot) + translation.z(); double ztop = formfactor.topZ(rot) + translation.z(); OneSidedLimit lower_limit = limits.lowerLimit(); @@ -52,13 +49,10 @@ bool shapeOutsideLimits(const IFormFactor& formfactor, ZLimits limits, const IRo } // namespace IFormFactor::IFormFactor(const NodeMeta& meta, const std::vector<double>& PValues) - : ISample(meta, PValues) -{ -} + : ISample(meta, PValues) {} IFormFactor* IFormFactor::createSlicedFormFactor(ZLimits limits, const IRotation& rot, - kvector_t translation) const -{ + kvector_t translation) const { if (shapeIsContainedInLimits(*this, limits, rot, translation)) return createTransformedFormFactor(*this, rot, translation); if (shapeOutsideLimits(*this, limits, rot, translation)) @@ -70,36 +64,29 @@ IFormFactor* IFormFactor::createSlicedFormFactor(ZLimits limits, const IRotation "the given rotation!"); } -Eigen::Matrix2cd IFormFactor::evaluatePol(const WavevectorInfo&) const -{ +Eigen::Matrix2cd IFormFactor::evaluatePol(const WavevectorInfo&) const { // Throws to prevent unanticipated behaviour throw std::runtime_error("IFormFactor::evaluatePol: is not implemented by default"); } -double IFormFactor::volume() const -{ +double IFormFactor::volume() const { auto zero_wavevectors = WavevectorInfo::GetZeroQ(); return std::abs(evaluate(zero_wavevectors)); } void IFormFactor::setSpecularInfo(std::unique_ptr<const ILayerRTCoefficients>, - std::unique_ptr<const ILayerRTCoefficients>) -{ -} + std::unique_ptr<const ILayerRTCoefficients>) {} -bool IFormFactor::canSliceAnalytically(const IRotation&) const -{ +bool IFormFactor::canSliceAnalytically(const IRotation&) const { return false; } -IFormFactor* IFormFactor::sliceFormFactor(ZLimits, const IRotation&, kvector_t) const -{ +IFormFactor* IFormFactor::sliceFormFactor(ZLimits, const IRotation&, kvector_t) const { throw std::runtime_error(getName() + "::sliceFormFactor error: not implemented!"); } IFormFactor* IFormFactor::createTransformedFormFactor(const IFormFactor& formfactor, - const IRotation& rot, kvector_t translation) -{ + const IRotation& rot, kvector_t translation) { std::unique_ptr<IFormFactor> P_fftemp, P_result; if (!rot.isIdentity()) P_fftemp = std::make_unique<FormFactorDecoratorRotation>(formfactor, rot); diff --git a/Sample/Scattering/IFormFactor.h b/Sample/Scattering/IFormFactor.h index 515aa00201f32e5c50a47664955a94aa859081a5..84388daaedace1af1a8c9cbbb3e758d8f68daff4 100644 --- a/Sample/Scattering/IFormFactor.h +++ b/Sample/Scattering/IFormFactor.h @@ -33,8 +33,7 @@ class WavevectorInfo; //! @ingroup formfactors_internal -class IFormFactor : public ISample -{ +class IFormFactor : public ISample { public: IFormFactor() = default; IFormFactor(const NodeMeta& meta, const std::vector<double>& PValues); diff --git a/Sample/Scattering/IFormFactorDecorator.h b/Sample/Scattering/IFormFactorDecorator.h index f944b2d9915828b69e205cf5fb7f28428e1cb1e0..908f0cb1d37729ec4cc0156928565958fd6141f0 100644 --- a/Sample/Scattering/IFormFactorDecorator.h +++ b/Sample/Scattering/IFormFactorDecorator.h @@ -25,15 +25,13 @@ //! //! @ingroup formfactors_internal -class IFormFactorDecorator : public IFormFactor -{ +class IFormFactorDecorator : public IFormFactor { public: IFormFactorDecorator(const IFormFactor& ff) : m_ff(ff.clone()) {} ~IFormFactorDecorator() override { delete m_ff; } IFormFactorDecorator* clone() const override = 0; - void setAmbientMaterial(const Material& material) override - { + void setAmbientMaterial(const Material& material) override { m_ff->setAmbientMaterial(material); } diff --git a/Sample/Scattering/ISample.cpp b/Sample/Scattering/ISample.cpp index d8d0d2500007bc29cf8d0fea132e868e9732ce75..80732eeee4d9c7af4fe13e73770fa1e9bef01567 100644 --- a/Sample/Scattering/ISample.cpp +++ b/Sample/Scattering/ISample.cpp @@ -21,8 +21,7 @@ ISample::ISample(const NodeMeta& meta, const std::vector<double>& PValues) : INode(meta, PValues) {} -std::vector<const Material*> ISample::containedMaterials() const -{ +std::vector<const Material*> ISample::containedMaterials() const { std::vector<const Material*> result; if (const Material* p_material = material()) result.push_back(p_material); @@ -35,8 +34,7 @@ std::vector<const Material*> ISample::containedMaterials() const return result; } -bool ISample::isMagnetic() const -{ +bool ISample::isMagnetic() const { const auto materials = containedMaterials(); return std::any_of(materials.cbegin(), materials.cend(), [](const Material* mat) { return mat->isMagneticMaterial(); }); diff --git a/Sample/Scattering/ISample.h b/Sample/Scattering/ISample.h index a09b8f55fe27da5c9a330ff7aeac5a1a70b117d9..34291785f3091978b699c619673be1b2321923e0 100644 --- a/Sample/Scattering/ISample.h +++ b/Sample/Scattering/ISample.h @@ -24,8 +24,7 @@ class Material; //! Abstract base class for sample components and properties related to scattering. //! @ingroup samples_internal -class ISample : public ICloneable, public INode -{ +class ISample : public ICloneable, public INode { public: ISample() = default; ISample(const NodeMeta& meta, const std::vector<double>& PValues); diff --git a/Sample/Scattering/LayerFillLimits.cpp b/Sample/Scattering/LayerFillLimits.cpp index 486e487f164758bda5c662d3e92423c9056b433a..2ed1446c40ab2339ad104d22bafe229ed99b4682 100644 --- a/Sample/Scattering/LayerFillLimits.cpp +++ b/Sample/Scattering/LayerFillLimits.cpp @@ -16,19 +16,17 @@ #include <algorithm> #include <stdexcept> -namespace -{ +namespace { ZLimits CalculateNewLayerLimits(ZLimits old_limits, ZLimits bounded_limits); } LayerFillLimits::LayerFillLimits(std::vector<double> layers_bottomz) - : m_layers_bottomz(std::move(layers_bottomz)), m_layer_fill_limits(m_layers_bottomz.size() + 1) + : m_layers_bottomz(std::move(layers_bottomz)) + , m_layer_fill_limits(m_layers_bottomz.size() + 1) // default ZLimits designate an absence of limits -{ -} +{} -void LayerFillLimits::update(ParticleLimits particle_limits, double offset) -{ +void LayerFillLimits::update(ParticleLimits particle_limits, double offset) { if (m_layers_bottomz.empty()) return; // do nothing for the single layer case double top = particle_limits.m_top + offset; @@ -45,13 +43,11 @@ void LayerFillLimits::update(ParticleLimits particle_limits, double offset) } } -std::vector<ZLimits> LayerFillLimits::layerZLimits() const -{ +std::vector<ZLimits> LayerFillLimits::layerZLimits() const { return m_layer_fill_limits; } -size_t LayerFillLimits::layerIndexTop(double top_z) const -{ +size_t LayerFillLimits::layerIndexTop(double top_z) const { if (m_layers_bottomz.empty()) return 0; if (top_z <= m_layers_bottomz.back()) @@ -60,8 +56,7 @@ size_t LayerFillLimits::layerIndexTop(double top_z) const return static_cast<size_t>(m_layers_bottomz.rend() - index_above); } -size_t LayerFillLimits::layerIndexBottom(double bottom_z) const -{ +size_t LayerFillLimits::layerIndexBottom(double bottom_z) const { if (m_layers_bottomz.empty()) return 0; if (bottom_z < m_layers_bottomz.back()) @@ -71,8 +66,7 @@ size_t LayerFillLimits::layerIndexBottom(double bottom_z) const return static_cast<size_t>(m_layers_bottomz.rend() - index_below); } -void LayerFillLimits::updateLayerLimits(size_t i_layer, ZLimits limits) -{ +void LayerFillLimits::updateLayerLimits(size_t i_layer, ZLimits limits) { if (!limits.isFinite()) throw std::runtime_error("LayerFillLimits::updateLayerLimits: given limits are not " "finite."); @@ -87,10 +81,8 @@ void LayerFillLimits::updateLayerLimits(size_t i_layer, ZLimits limits) m_layer_fill_limits[i_layer] = CalculateNewLayerLimits(old_limits, bounded_limits); } -namespace -{ -ZLimits CalculateNewLayerLimits(ZLimits old_limits, ZLimits bounded_limits) -{ +namespace { +ZLimits CalculateNewLayerLimits(ZLimits old_limits, ZLimits bounded_limits) { if (!old_limits.isFinite()) return bounded_limits; else diff --git a/Sample/Scattering/LayerFillLimits.h b/Sample/Scattering/LayerFillLimits.h index 23929f35974b8c91c6d0e51390173455399d6ec7..088a28bc68b83d506ec5ae29b563c6a1f2c73eaf 100644 --- a/Sample/Scattering/LayerFillLimits.h +++ b/Sample/Scattering/LayerFillLimits.h @@ -27,8 +27,7 @@ //! layers, only N-1 coordinates need to be passed (the last layer is assumed to be semi-infinite). //! @ingroup algorithms_internal -class LayerFillLimits -{ +class LayerFillLimits { public: LayerFillLimits(std::vector<double> layers_bottomz); diff --git a/Sample/Scattering/Rotations.cpp b/Sample/Scattering/Rotations.cpp index 6b4b42d5463c8f233fe488476f361da6c59691b4..aa4dfe0dad1305873edeea8c70944acaa391f04d 100644 --- a/Sample/Scattering/Rotations.cpp +++ b/Sample/Scattering/Rotations.cpp @@ -21,12 +21,9 @@ // ************************************************************************************************ IRotation::IRotation(const NodeMeta& meta, const std::vector<double>& PValues) - : INode(meta, PValues) -{ -} + : INode(meta, PValues) {} -IRotation* IRotation::createRotation(const Transform3D& transform) -{ +IRotation* IRotation::createRotation(const Transform3D& transform) { auto rot_type = transform.getRotationType(); switch (rot_type) { case Transform3D::XAXIS: { @@ -50,25 +47,21 @@ IRotation* IRotation::createRotation(const Transform3D& transform) ASSERT(0); // impossible case } -kvector_t IRotation::transformed(const kvector_t& v) const -{ +kvector_t IRotation::transformed(const kvector_t& v) const { return getTransform3D().transformed(v); } -bool IRotation::isIdentity() const -{ +bool IRotation::isIdentity() const { return getTransform3D().isIdentity(); } -bool IRotation::zInvariant() const -{ +bool IRotation::zInvariant() const { return getTransform3D().isZRotation(); } //! Returns concatenated rotation (first right, then left). -IRotation* createProduct(const IRotation& left, const IRotation& right) -{ +IRotation* createProduct(const IRotation& left, const IRotation& right) { Transform3D tr_left = left.getTransform3D(); Transform3D tr_right = right.getTransform3D(); IRotation* p_result = IRotation::createRotation(tr_left * tr_right); @@ -80,12 +73,9 @@ IRotation* createProduct(const IRotation& left, const IRotation& right) // ************************************************************************************************ IdentityRotation::IdentityRotation() - : IRotation({"IdentityRotation", "Identity rotation, does nothing", {}}, {}) -{ -} + : IRotation({"IdentityRotation", "Identity rotation, does nothing", {}}, {}) {} -Transform3D IdentityRotation::getTransform3D() const -{ +Transform3D IdentityRotation::getTransform3D() const { return {}; } @@ -97,14 +87,11 @@ Transform3D IdentityRotation::getTransform3D() const RotationX::RotationX(const std::vector<double> P) : IRotation( {"XRotation", "class_tooltip", {{"Angle", "rad", "Angle around x axis", -INF, +INF, 0}}}, P) - , m_angle(m_P[0]) -{ -} + , m_angle(m_P[0]) {} RotationX::RotationX(double angle) : RotationX(std::vector<double>{angle}) {} -Transform3D RotationX::getTransform3D() const -{ +Transform3D RotationX::getTransform3D() const { return Transform3D::createRotateX(m_angle); } @@ -116,14 +103,11 @@ Transform3D RotationX::getTransform3D() const RotationY::RotationY(const std::vector<double> P) : IRotation( {"YRotation", "class_tooltip", {{"Angle", "rad", "Angle around y axis", -INF, +INF, 0}}}, P) - , m_angle(m_P[0]) -{ -} + , m_angle(m_P[0]) {} RotationY::RotationY(double angle) : RotationY(std::vector<double>{angle}) {} -Transform3D RotationY::getTransform3D() const -{ +Transform3D RotationY::getTransform3D() const { return Transform3D::createRotateY(m_angle); } @@ -137,14 +121,11 @@ Transform3D RotationY::getTransform3D() const RotationZ::RotationZ(const std::vector<double> P) : IRotation( {"ZRotation", "class_tooltip", {{"Angle", "rad", "Angle around z axis", -INF, +INF, 0}}}, P) - , m_angle(m_P[0]) -{ -} + , m_angle(m_P[0]) {} RotationZ::RotationZ(double angle) : RotationZ(std::vector<double>{angle}) {} -Transform3D RotationZ::getTransform3D() const -{ +Transform3D RotationZ::getTransform3D() const { return Transform3D::createRotateZ(m_angle); } @@ -161,22 +142,16 @@ RotationEuler::RotationEuler(const std::vector<double> P) P) , m_alpha(m_P[0]) , m_beta(m_P[1]) - , m_gamma(m_P[2]) -{ -} + , m_gamma(m_P[2]) {} RotationEuler::RotationEuler(double alpha, double beta, double gamma) - : RotationEuler(std::vector<double>{alpha, beta, gamma}) -{ -} + : RotationEuler(std::vector<double>{alpha, beta, gamma}) {} -IRotation* RotationEuler::createInverse() const -{ +IRotation* RotationEuler::createInverse() const { Transform3D inverse_transform(getTransform3D().getInverse()); return createRotation(inverse_transform); } -Transform3D RotationEuler::getTransform3D() const -{ +Transform3D RotationEuler::getTransform3D() const { return Transform3D::createRotateEuler(m_alpha, m_beta, m_gamma); } diff --git a/Sample/Scattering/Rotations.h b/Sample/Scattering/Rotations.h index 1622a1903ed2fe5692d93bcc7764507a01343ea4..52f309e0919d4dafdef0c79ed783e46768f48501 100644 --- a/Sample/Scattering/Rotations.h +++ b/Sample/Scattering/Rotations.h @@ -23,8 +23,7 @@ class Transform3D; //! Abstract base class for rotations. //! @ingroup samples -class IRotation : public ICloneable, public INode -{ +class IRotation : public ICloneable, public INode { public: static IRotation* createRotation(const Transform3D& transform); @@ -67,8 +66,7 @@ public: //! A rotation about the x axis. -class RotationX : public IRotation -{ +class RotationX : public IRotation { public: RotationX(const std::vector<double> P); RotationX(double angle); @@ -88,8 +86,7 @@ protected: //! A rotation about the y axis. -class RotationY : public IRotation -{ +class RotationY : public IRotation { public: RotationY(const std::vector<double> P); RotationY(double angle); @@ -109,8 +106,7 @@ protected: //! A rotation about the z axis. -class RotationZ : public IRotation -{ +class RotationZ : public IRotation { public: RotationZ(const std::vector<double> P); RotationZ(double angle); @@ -130,8 +126,7 @@ protected: //! A sequence of rotations about the z-x'-z'' axes. -class RotationEuler : public IRotation -{ +class RotationEuler : public IRotation { public: RotationEuler(const std::vector<double> P); RotationEuler(double alpha, double beta, double gamma); diff --git a/Sample/Scattering/ZLimits.cpp b/Sample/Scattering/ZLimits.cpp index 7cd16d5df5abfc117a0741f0d15b0ba086851797..54ed08440c39bbd6fc9b06a51f497520195265cc 100644 --- a/Sample/Scattering/ZLimits.cpp +++ b/Sample/Scattering/ZLimits.cpp @@ -21,47 +21,40 @@ ZLimits::ZLimits() : m_lower{true, 0}, m_upper{true, 0} {} ZLimits::ZLimits(double min, double max) : ZLimits({false, min}, {false, max}) {} ZLimits::ZLimits(OneSidedLimit lower_limit, OneSidedLimit upper_limit) - : m_lower(std::move(lower_limit)), m_upper(std::move(upper_limit)) -{ + : m_lower(std::move(lower_limit)), m_upper(std::move(upper_limit)) { if (!lower_limit.m_limitless && !upper_limit.m_limitless && lower_limit.m_value > upper_limit.m_value) throw std::runtime_error("ZLimits constructor: " "lower limit bigger than upper limit."); } -bool ZLimits::isFinite() const -{ +bool ZLimits::isFinite() const { if (m_lower.m_limitless || m_upper.m_limitless) return false; return true; } -OneSidedLimit ZLimits::lowerLimit() const -{ +OneSidedLimit ZLimits::lowerLimit() const { return m_lower; } -OneSidedLimit ZLimits::upperLimit() const -{ +OneSidedLimit ZLimits::upperLimit() const { return m_upper; } -OneSidedLimit MinLimit(const OneSidedLimit& left, const OneSidedLimit& right) -{ +OneSidedLimit MinLimit(const OneSidedLimit& left, const OneSidedLimit& right) { if (left.m_limitless || right.m_limitless) return {true, 0}; return {false, std::min(left.m_value, right.m_value)}; } -OneSidedLimit MaxLimit(const OneSidedLimit& left, const OneSidedLimit& right) -{ +OneSidedLimit MaxLimit(const OneSidedLimit& left, const OneSidedLimit& right) { if (left.m_limitless || right.m_limitless) return {true, 0}; return {false, std::max(left.m_value, right.m_value)}; } -bool operator==(const OneSidedLimit& left, const OneSidedLimit& right) -{ +bool operator==(const OneSidedLimit& left, const OneSidedLimit& right) { if (left.m_limitless != right.m_limitless) return false; if (!left.m_limitless && left.m_value != right.m_value) @@ -69,33 +62,27 @@ bool operator==(const OneSidedLimit& left, const OneSidedLimit& right) return true; } -bool operator!=(const OneSidedLimit& left, const OneSidedLimit& right) -{ +bool operator!=(const OneSidedLimit& left, const OneSidedLimit& right) { return !(left == right); } -std::ostream& operator<<(std::ostream& ostr, const OneSidedLimit& limit) -{ +std::ostream& operator<<(std::ostream& ostr, const OneSidedLimit& limit) { return ostr << "{" << (limit.m_limitless ? "true, " : "false, ") << limit.m_value << "}"; } -ZLimits ConvexHull(const ZLimits& left, const ZLimits& right) -{ +ZLimits ConvexHull(const ZLimits& left, const ZLimits& right) { return {MinLimit(left.lowerLimit(), right.lowerLimit()), MaxLimit(left.upperLimit(), right.upperLimit())}; } -bool operator==(const ZLimits& left, const ZLimits& right) -{ +bool operator==(const ZLimits& left, const ZLimits& right) { return (left.lowerLimit() == right.lowerLimit() && left.upperLimit() == right.upperLimit()); } -bool operator!=(const ZLimits& left, const ZLimits& right) -{ +bool operator!=(const ZLimits& left, const ZLimits& right) { return !(left == right); } -std::ostream& operator<<(std::ostream& ostr, const ZLimits& limits) -{ +std::ostream& operator<<(std::ostream& ostr, const ZLimits& limits) { return ostr << "Lower: " << limits.lowerLimit() << ", Upper: " << limits.upperLimit(); } diff --git a/Sample/Scattering/ZLimits.h b/Sample/Scattering/ZLimits.h index 31d367f178095bb61bb814a7bb601584afcb5626..4d3a42205d2017f9aa46de28582e7e75aa27e060 100644 --- a/Sample/Scattering/ZLimits.h +++ b/Sample/Scattering/ZLimits.h @@ -37,8 +37,7 @@ struct OneSidedLimit { //! //! @ingroup intern -class ZLimits -{ +class ZLimits { public: ZLimits(); ZLimits(double min, double max); diff --git a/Sample/Shapes/Box.cpp b/Sample/Shapes/Box.cpp index 774e2b1ca45ba6e5ca14a14cf0527b6e32e2a912..e89745290ad612889c046c096ae68d0fe90d5277 100644 --- a/Sample/Shapes/Box.cpp +++ b/Sample/Shapes/Box.cpp @@ -16,8 +16,7 @@ #include <algorithm> -Box::Box(double length, double width, double height) -{ +Box::Box(double length, double width, double height) { m_vertices.resize(8); auto bottom_face = RectangleVertices(length, width, 0.0); auto top_face = RectangleVertices(length, width, height); diff --git a/Sample/Shapes/Box.h b/Sample/Shapes/Box.h index 8a948a558eca7e78ee30676f68db78cb9a274ff9..ae08c8f121ca466232aeac67109d6df9b0464a88 100644 --- a/Sample/Shapes/Box.h +++ b/Sample/Shapes/Box.h @@ -17,8 +17,7 @@ #include "Sample/Shapes/IShape.h" -class Box : public IShape -{ +class Box : public IShape { public: Box(double length, double width, double height); ~Box(); diff --git a/Sample/Shapes/DoubleEllipse.cpp b/Sample/Shapes/DoubleEllipse.cpp index 9ecc53723dbf517a7ada6076c87afa9efe1ad040..a717ce8e932d8285b2d2b68cc4e063e1a51b74c1 100644 --- a/Sample/Shapes/DoubleEllipse.cpp +++ b/Sample/Shapes/DoubleEllipse.cpp @@ -16,8 +16,7 @@ #include <algorithm> -DoubleEllipse::DoubleEllipse(double r0_x, double r0_y, double z, double rz_x, double rz_y) -{ +DoubleEllipse::DoubleEllipse(double r0_x, double r0_y, double z, double rz_x, double rz_y) { auto bottom_face = EllipseVertices(r0_x, r0_y, 0.0); size_t n_bottom = bottom_face.size(); auto top_face = EllipseVertices(rz_x, rz_y, z); diff --git a/Sample/Shapes/DoubleEllipse.h b/Sample/Shapes/DoubleEllipse.h index 85f1ec80206dadb0f1ac096bfc55b930f5ce32b3..f5bb1f850dc5c8d1b87735811577dc929d34373d 100644 --- a/Sample/Shapes/DoubleEllipse.h +++ b/Sample/Shapes/DoubleEllipse.h @@ -17,8 +17,7 @@ #include "Sample/Shapes/IShape.h" -class DoubleEllipse : public IShape -{ +class DoubleEllipse : public IShape { public: DoubleEllipse(double r0_x, double r0_y, double z, double rz_x, double rz_y); ~DoubleEllipse(); diff --git a/Sample/Shapes/IShape.cpp b/Sample/Shapes/IShape.cpp index bd6989a98871b0082afb323a385b2193013a2db8..fa6bdb455786a3387ad7ae3b9ebc7d65be5b5650 100644 --- a/Sample/Shapes/IShape.cpp +++ b/Sample/Shapes/IShape.cpp @@ -20,13 +20,11 @@ // 1% of the radius const size_t IShape::N_Circle = 24; -std::vector<kvector_t> IShape::vertices() const -{ +std::vector<kvector_t> IShape::vertices() const { return m_vertices; } -std::vector<kvector_t> RectangleVertices(double length, double width, double z) -{ +std::vector<kvector_t> RectangleVertices(double length, double width, double z) { std::vector<kvector_t> result = {{length / 2.0, width / 2.0, z}, {-length / 2.0, width / 2.0, z}, {-length / 2.0, -width / 2.0, z}, @@ -34,8 +32,7 @@ std::vector<kvector_t> RectangleVertices(double length, double width, double z) return result; } -std::vector<kvector_t> EllipseVertices(double r_x, double r_y, double z) -{ +std::vector<kvector_t> EllipseVertices(double r_x, double r_y, double z) { static constexpr double delta_angle = 2.0 * M_PI / IShape::N_Circle; std::vector<kvector_t> result(IShape::N_Circle); for (size_t i = 0; i < IShape::N_Circle; ++i) { diff --git a/Sample/Shapes/IShape.h b/Sample/Shapes/IShape.h index d4fca05aaa4f1ba261fe81205576d0c54f638e66..08d8133f924954998ce9483bd4851440b238fb96 100644 --- a/Sample/Shapes/IShape.h +++ b/Sample/Shapes/IShape.h @@ -25,8 +25,7 @@ //! @ingroup shapes_internal -class IShape -{ +class IShape { public: IShape() {} virtual ~IShape() {} diff --git a/Sample/Shapes/RippleCosine.cpp b/Sample/Shapes/RippleCosine.cpp index c6bdb19f7323e8685a149d42a3c427989b973ee4..afa0c8440aab9e517b00fc5bfa12eaffd7775d9a 100644 --- a/Sample/Shapes/RippleCosine.cpp +++ b/Sample/Shapes/RippleCosine.cpp @@ -16,8 +16,7 @@ #include <cmath> -RippleCosine::RippleCosine(double length, double width, double height) -{ +RippleCosine::RippleCosine(double length, double width, double height) { size_t n_y = IShape::N_Circle + 1; double y_step = width / (IShape::N_Circle); m_vertices.resize(2 * n_y); diff --git a/Sample/Shapes/RippleCosine.h b/Sample/Shapes/RippleCosine.h index e4c46da6dbdc2e6d565fda7992852b8c729feaff..d4caebe6705d6de2bdfa530b895ab766b8f10579 100644 --- a/Sample/Shapes/RippleCosine.h +++ b/Sample/Shapes/RippleCosine.h @@ -17,8 +17,7 @@ #include "Sample/Shapes/IShape.h" -class RippleCosine : public IShape -{ +class RippleCosine : public IShape { public: RippleCosine(double length, double width, double height); ~RippleCosine(); diff --git a/Sample/Shapes/RippleSawtooth.cpp b/Sample/Shapes/RippleSawtooth.cpp index 37041241afd7fa2e667360daee1cff14eae71682..06915ad31ae38f7a027129ca9d11fe4baf81736a 100644 --- a/Sample/Shapes/RippleSawtooth.cpp +++ b/Sample/Shapes/RippleSawtooth.cpp @@ -14,8 +14,7 @@ #include "Sample/Shapes/RippleSawtooth.h" -RippleSawtooth::RippleSawtooth(double length, double width, double height, double asymmetry) -{ +RippleSawtooth::RippleSawtooth(double length, double width, double height, double asymmetry) { double ymax = width / 2.0 - asymmetry; double ymin = -width / 2.0 - asymmetry; m_vertices.resize(6); diff --git a/Sample/Shapes/RippleSawtooth.h b/Sample/Shapes/RippleSawtooth.h index 796087e4d7dbd0c5ec15e0b18e99f768f7aebb0e..15a6972b74bb7c2a5a35bd0e7a24f7abf7d7bc1c 100644 --- a/Sample/Shapes/RippleSawtooth.h +++ b/Sample/Shapes/RippleSawtooth.h @@ -17,8 +17,7 @@ #include "Sample/Shapes/IShape.h" -class RippleSawtooth : public IShape -{ +class RippleSawtooth : public IShape { public: RippleSawtooth(double length, double width, double height, double asymmetry); ~RippleSawtooth(); diff --git a/Sample/Shapes/TruncatedEllipsoid.cpp b/Sample/Shapes/TruncatedEllipsoid.cpp index ae93d3373cc524a651330efee0df7381e67fe7d0..8218ae14f874d1972fc214273ff8f67fdd5a6c26 100644 --- a/Sample/Shapes/TruncatedEllipsoid.cpp +++ b/Sample/Shapes/TruncatedEllipsoid.cpp @@ -17,8 +17,8 @@ #include <algorithm> #include <cmath> -TruncatedEllipsoid::TruncatedEllipsoid(double r_x, double r_y, double r_z, double height, double dh) -{ +TruncatedEllipsoid::TruncatedEllipsoid(double r_x, double r_y, double r_z, double height, + double dh) { static const int n_heights = std::max(2, static_cast<int>(std::round( static_cast<double>(IShape::N_Circle) * height / 2.0 / r_z + 0.5))); diff --git a/Sample/Shapes/TruncatedEllipsoid.h b/Sample/Shapes/TruncatedEllipsoid.h index 80d59b7cbfbc065722fcd6ab525032b5d6a22023..c6a0ca2406a32659cdb74c0fc9027d773fc62fe4 100644 --- a/Sample/Shapes/TruncatedEllipsoid.h +++ b/Sample/Shapes/TruncatedEllipsoid.h @@ -17,8 +17,7 @@ #include "Sample/Shapes/IShape.h" -class TruncatedEllipsoid : public IShape -{ +class TruncatedEllipsoid : public IShape { public: TruncatedEllipsoid(double r_x, double r_y, double r_z, double height, double dh); ~TruncatedEllipsoid(); diff --git a/Sample/Slice/KzComputation.cpp b/Sample/Slice/KzComputation.cpp index 2a54d5421cec9f8e9af7cb9cbd7c265f360d56c6..452685e307d412293c367aa66b5e16e4b5f76d13 100644 --- a/Sample/Slice/KzComputation.cpp +++ b/Sample/Slice/KzComputation.cpp @@ -16,10 +16,8 @@ #include "Base/Const/Units.h" #include "Sample/Slice/Slice.h" -namespace -{ -complex_t normalizedSLD(const Material& material) -{ +namespace { +complex_t normalizedSLD(const Material& material) { if (material.typeID() != MATERIAL_TYPES::MaterialBySLD) throw std::runtime_error("Error in normalizedSLD: passed material has wrong type"); @@ -28,8 +26,7 @@ complex_t normalizedSLD(const Material& material) return sld; } -complex_t checkForUnderflow(complex_t val) -{ +complex_t checkForUnderflow(complex_t val) { return std::norm(val) < 1e-80 ? complex_t(0.0, 1e-40) : val; } } // namespace @@ -39,8 +36,7 @@ complex_t checkForUnderflow(complex_t val) // ************************************************************************************************ std::vector<complex_t> KzComputation::computeReducedKz(const std::vector<Slice>& slices, - kvector_t k) -{ + kvector_t k) { const size_t N = slices.size(); const double n_ref = slices[0].material().refractiveIndex(2 * M_PI / k.mag()).real(); const double k_base = k.mag() * (k.z() > 0.0 ? -1 : 1); @@ -56,8 +52,8 @@ std::vector<complex_t> KzComputation::computeReducedKz(const std::vector<Slice>& return result; } -std::vector<complex_t> KzComputation::computeKzFromSLDs(const std::vector<Slice>& slices, double kz) -{ +std::vector<complex_t> KzComputation::computeKzFromSLDs(const std::vector<Slice>& slices, + double kz) { const size_t N = slices.size(); const double k_sign = kz > 0.0 ? -1 : 1; complex_t kz2_base = kz * kz + normalizedSLD(slices[0].material()); @@ -73,8 +69,7 @@ std::vector<complex_t> KzComputation::computeKzFromSLDs(const std::vector<Slice> } std::vector<complex_t> KzComputation::computeKzFromRefIndices(const std::vector<Slice>& slices, - kvector_t k) -{ + kvector_t k) { const size_t N = slices.size(); const double kz = k.z(); const double k_sign = kz > 0.0 ? -1 : 1; diff --git a/Sample/Slice/KzComputation.h b/Sample/Slice/KzComputation.h index 8f49757e8da6dd5f24af3f98ef8df5c34a00eecb..ca86308ca30a7474588bc338d16e6854e164bd87 100644 --- a/Sample/Slice/KzComputation.h +++ b/Sample/Slice/KzComputation.h @@ -25,8 +25,7 @@ class Slice; //! on the surface of the sample. //! @ingroup samples_internal -namespace KzComputation -{ +namespace KzComputation { /* Computes kz values from known k vector and slices with the following assumptions: * - the beam penetrates fronting medium from a side * - the wavelength is known for a distant point in vacuum (ref. index = 1) diff --git a/Sample/Slice/LayerInterface.cpp b/Sample/Slice/LayerInterface.cpp index fb8a742ddcc662824d7de96708ad21f102f6801d..07d961b88f051170f628ad231bf1972279d3c8ed 100644 --- a/Sample/Slice/LayerInterface.cpp +++ b/Sample/Slice/LayerInterface.cpp @@ -16,21 +16,18 @@ #include "Base/Types/Exceptions.h" #include "Sample/Slice/LayerRoughness.h" -LayerInterface::LayerInterface() : m_topLayer(nullptr), m_bottomLayer(nullptr) -{ +LayerInterface::LayerInterface() : m_topLayer(nullptr), m_bottomLayer(nullptr) { setName("LayerInterface"); } LayerInterface::~LayerInterface() = default; -LayerInterface* LayerInterface::clone() const -{ +LayerInterface* LayerInterface::clone() const { throw Exceptions::NotImplementedException("LayerInterface::clone() -> Not allowed to clone."); } LayerInterface* LayerInterface::createSmoothInterface(const Layer* top_layer, - const Layer* bottom_layer) -{ + const Layer* bottom_layer) { LayerInterface* result = new LayerInterface(); result->setLayersTopBottom(top_layer, bottom_layer); return result; @@ -38,28 +35,24 @@ LayerInterface* LayerInterface::createSmoothInterface(const Layer* top_layer, LayerInterface* LayerInterface::createRoughInterface(const Layer* top_layer, const Layer* bottom_layer, - const LayerRoughness& roughness) -{ + const LayerRoughness& roughness) { LayerInterface* result = createSmoothInterface(top_layer, bottom_layer); result->setRoughness(roughness); return result; } -void LayerInterface::setRoughness(const LayerRoughness& roughness) -{ +void LayerInterface::setRoughness(const LayerRoughness& roughness) { m_roughness.reset(roughness.clone()); registerChild(m_roughness.get()); } -std::vector<const INode*> LayerInterface::getChildren() const -{ +std::vector<const INode*> LayerInterface::getChildren() const { return std::vector<const INode*>() << m_roughness; } //! Sets links to the layers above and below the interface. -void LayerInterface::setLayersTopBottom(const Layer* top_layer, const Layer* bottom_layer) -{ +void LayerInterface::setLayersTopBottom(const Layer* top_layer, const Layer* bottom_layer) { if (top_layer == nullptr || bottom_layer == nullptr) throw Exceptions::RuntimeErrorException("LayerInterface::setLayersTopBottom() -> Error. " "Attempt to set nullptr."); diff --git a/Sample/Slice/LayerInterface.h b/Sample/Slice/LayerInterface.h index bab466dd13919f91926da8c9b2ea8331a82fec1e..d87716fe3fee63be03a0ea131c5ec28a3dd01ccb 100644 --- a/Sample/Slice/LayerInterface.h +++ b/Sample/Slice/LayerInterface.h @@ -23,8 +23,7 @@ class LayerRoughness; //! Interface between two layers, possibly with roughness. //! @ingroup samples_internal -class LayerInterface : public ISample -{ +class LayerInterface : public ISample { public: virtual ~LayerInterface(); @@ -60,18 +59,15 @@ private: std::unique_ptr<LayerRoughness> m_roughness; //!< roughness of the interface }; -inline const LayerRoughness* LayerInterface::getRoughness() const -{ +inline const LayerRoughness* LayerInterface::getRoughness() const { return m_roughness.get(); } -inline const Layer* LayerInterface::topLayer() const -{ +inline const Layer* LayerInterface::topLayer() const { return m_topLayer; } -inline const Layer* LayerInterface::bottomLayer() const -{ +inline const Layer* LayerInterface::bottomLayer() const { return m_bottomLayer; } diff --git a/Sample/Slice/LayerRoughness.cpp b/Sample/Slice/LayerRoughness.cpp index d910f2908979212b785f77c4fb263d2d618501e6..fd8f3a8d32900c50d30df5137f9673fd9535b67f 100644 --- a/Sample/Slice/LayerRoughness.cpp +++ b/Sample/Slice/LayerRoughness.cpp @@ -22,8 +22,7 @@ //! dimensionless [0.0, 1.0], where 0.0 gives more spikes, 1.0 more smoothness //! @param lateralCorrLength: lateral correlation length of the roughness in nanometers LayerRoughness::LayerRoughness(double sigma, double hurstParameter, double lateralCorrLength) - : m_sigma(sigma), m_hurstParameter(hurstParameter), m_lateralCorrLength(lateralCorrLength) -{ + : m_sigma(sigma), m_hurstParameter(hurstParameter), m_lateralCorrLength(lateralCorrLength) { setName("LayerBasicRoughness"); registerParameter("Sigma", &m_sigma); registerParameter("Hurst", &m_hurstParameter); @@ -40,8 +39,7 @@ LayerRoughness::LayerRoughness() : LayerRoughness(0, 0, 0) {} //! D.K.G. de Boer, Physical review B, Volume 51, Number 8, 15 February 1995 //! "X-ray reflection and transmission by rough surfaces" /* ************************************************************************* */ -double LayerRoughness::getSpectralFun(const kvector_t kvec) const -{ +double LayerRoughness::getSpectralFun(const kvector_t kvec) const { double H = m_hurstParameter; double clength2 = m_lateralCorrLength * m_lateralCorrLength; double Qpar2 = kvec.x() * kvec.x() + kvec.y() * kvec.y(); @@ -51,8 +49,7 @@ double LayerRoughness::getSpectralFun(const kvector_t kvec) const //! Correlation function of the roughness profile -double LayerRoughness::getCorrFun(const kvector_t k) const -{ +double LayerRoughness::getCorrFun(const kvector_t k) const { double H = m_hurstParameter; double clength = m_lateralCorrLength; double R = sqrt(k.x() * k.x() + k.y() * k.y()); diff --git a/Sample/Slice/LayerRoughness.h b/Sample/Slice/LayerRoughness.h index e1c5fc71bd18981f371fcbe85c6650d1f0795ed0..6ad6bab9491a238ea9674904f69ab02878a65d8c 100644 --- a/Sample/Slice/LayerRoughness.h +++ b/Sample/Slice/LayerRoughness.h @@ -25,14 +25,12 @@ //! //! @ingroup samples -class LayerRoughness : public ISample -{ +class LayerRoughness : public ISample { public: LayerRoughness(double sigma, double hurstParameter, double lateralCorrLength); LayerRoughness(); - LayerRoughness* clone() const - { + LayerRoughness* clone() const { return new LayerRoughness(m_sigma, m_hurstParameter, m_lateralCorrLength); } virtual void accept(INodeVisitor* visitor) const { visitor->visit(this); } @@ -53,8 +51,7 @@ public: double getHurstParameter() const { return m_hurstParameter; } //! Sets lateral correlation length - void setLatteralCorrLength(double lateralCorrLength) - { + void setLatteralCorrLength(double lateralCorrLength) { m_lateralCorrLength = lateralCorrLength; } //! Returns lateral correlation length diff --git a/Sample/Slice/Slice.cpp b/Sample/Slice/Slice.cpp index 3b646b0b619b989486d80c79984b1714ff7dca42..7f1254089ad608ec244870dd316373fe84e344d2 100644 --- a/Sample/Slice/Slice.cpp +++ b/Sample/Slice/Slice.cpp @@ -17,24 +17,19 @@ #include "Sample/Slice/LayerRoughness.h" Slice::Slice(double thickness, const Material& material) - : m_thickness{thickness}, m_material{material}, m_B_field{}, m_top_roughness{nullptr} -{ -} + : m_thickness{thickness}, m_material{material}, m_B_field{}, m_top_roughness{nullptr} {} Slice::Slice(double thickness, const Material& material, const LayerRoughness& top_roughness) : m_thickness{thickness} , m_material{material} , m_B_field{} - , m_top_roughness{top_roughness.clone()} -{ -} + , m_top_roughness{top_roughness.clone()} {} Slice::Slice(const Slice& other) : m_thickness{other.m_thickness} , m_material{other.m_material} , m_B_field{other.m_B_field} - , m_top_roughness{} -{ + , m_top_roughness{} { if (other.m_top_roughness) { m_top_roughness.reset(other.m_top_roughness->clone()); } @@ -44,12 +39,9 @@ Slice::Slice(Slice&& other) : m_thickness{other.m_thickness} , m_material{std::move(other.m_material)} , m_B_field{other.m_B_field} - , m_top_roughness{std::move(other.m_top_roughness)} -{ -} + , m_top_roughness{std::move(other.m_top_roughness)} {} -Slice& Slice::operator=(const Slice& other) -{ +Slice& Slice::operator=(const Slice& other) { m_thickness = other.m_thickness; m_material = other.m_material; m_B_field = other.m_B_field; @@ -61,45 +53,37 @@ Slice& Slice::operator=(const Slice& other) Slice::~Slice() = default; -void Slice::setMaterial(const Material& material) -{ +void Slice::setMaterial(const Material& material) { m_material = material; } -Material Slice::material() const -{ +Material Slice::material() const { return m_material; } -double Slice::thickness() const -{ +double Slice::thickness() const { return m_thickness; } -const LayerRoughness* Slice::topRoughness() const -{ +const LayerRoughness* Slice::topRoughness() const { return m_top_roughness.get(); } -complex_t Slice::scalarReducedPotential(kvector_t k, double n_ref) const -{ +complex_t Slice::scalarReducedPotential(kvector_t k, double n_ref) const { complex_t n = m_material.refractiveIndex(2.0 * M_PI / k.mag()); return MaterialUtils::ScalarReducedPotential(n, k, n_ref); } -Eigen::Matrix2cd Slice::polarizedReducedPotential(kvector_t k, double n_ref) const -{ +Eigen::Matrix2cd Slice::polarizedReducedPotential(kvector_t k, double n_ref) const { complex_t n = m_material.refractiveIndex(2.0 * M_PI / k.mag()); return MaterialUtils::PolarizedReducedPotential(n, m_B_field, k, n_ref); } -void Slice::initBField(kvector_t h_field, double b_z) -{ +void Slice::initBField(kvector_t h_field, double b_z) { m_B_field = Magnetic_Permeability * (h_field + m_material.magnetization()); m_B_field.setZ(b_z); } -void Slice::invertBField() -{ +void Slice::invertBField() { m_B_field = -m_B_field; } diff --git a/Sample/Slice/Slice.h b/Sample/Slice/Slice.h index ad592c3884c08c4f45a8092ac54c3a1ccec8e954..5ada6acff015caabe643c34397c9547485a2c577 100644 --- a/Sample/Slice/Slice.h +++ b/Sample/Slice/Slice.h @@ -24,8 +24,7 @@ class LayerRoughness; //! //! @ingroup algorithms_internal -class Slice -{ +class Slice { public: Slice(double thickness, const Material& material); Slice(double thickness, const Material& material, const LayerRoughness& top_roughness); diff --git a/Sample/Slice/SlicedFormFactorList.cpp b/Sample/Slice/SlicedFormFactorList.cpp index d1d505895eefa0555999ed3538ea2ce81bd10594..7f75495d685558475ef53139bca5b22f30fbf089 100644 --- a/Sample/Slice/SlicedFormFactorList.cpp +++ b/Sample/Slice/SlicedFormFactorList.cpp @@ -19,8 +19,7 @@ #include "Sample/Slice/Slice.h" #include <utility> -namespace -{ +namespace { std::pair<size_t, size_t> SliceIndexSpan(const IParticle& particle, const std::vector<Slice>& slices, double z_ref); size_t TopZToSliceIndex(double z, const std::vector<Slice>& slices); @@ -32,8 +31,7 @@ void ScaleRegions(std::vector<HomogeneousRegion>& regions, double factor); SlicedFormFactorList SlicedFormFactorList::createSlicedFormFactors(const IParticle& particle, const std::vector<Slice>& slices, - double z_ref) -{ + double z_ref) { SlicedFormFactorList result; auto particles = particle.decompose(); for (auto p_particle : particles) { @@ -43,8 +41,7 @@ SlicedFormFactorList SlicedFormFactorList::createSlicedFormFactors(const IPartic } void SlicedFormFactorList::addParticle(IParticle& particle, const std::vector<Slice>& slices, - double z_ref) -{ + double z_ref) { auto slice_indices = SliceIndexSpan(particle, slices, z_ref); bool single_layer = (slice_indices.first == slice_indices.second); for (size_t i = slice_indices.first; i < slice_indices.second + 1; ++i) { @@ -64,29 +61,24 @@ void SlicedFormFactorList::addParticle(IParticle& particle, const std::vector<Sl } } -size_t SlicedFormFactorList::size() const -{ +size_t SlicedFormFactorList::size() const { return m_ff_list.size(); } -std::pair<const IFormFactor*, size_t> SlicedFormFactorList::operator[](size_t index) const -{ +std::pair<const IFormFactor*, size_t> SlicedFormFactorList::operator[](size_t index) const { if (index >= size()) throw std::out_of_range("SlicedFormFactorList::operator[] error: " "index out of range"); return {m_ff_list[index].first.get(), m_ff_list[index].second}; } -std::map<size_t, std::vector<HomogeneousRegion>> SlicedFormFactorList::regionMap() const -{ +std::map<size_t, std::vector<HomogeneousRegion>> SlicedFormFactorList::regionMap() const { return m_region_map; } -namespace -{ +namespace { std::pair<size_t, size_t> SliceIndexSpan(const IParticle& particle, - const std::vector<Slice>& slices, double z_ref) -{ + const std::vector<Slice>& slices, double z_ref) { auto bottomTopZ = particle.bottomTopZ(); double zbottom = bottomTopZ.m_bottom; double ztop = bottomTopZ.m_top; @@ -101,8 +93,7 @@ std::pair<size_t, size_t> SliceIndexSpan(const IParticle& particle, return {top_index, bottom_index}; } -size_t TopZToSliceIndex(double z, const std::vector<Slice>& slices) -{ +size_t TopZToSliceIndex(double z, const std::vector<Slice>& slices) { auto n_layers = slices.size(); if (n_layers < 2 || z > 0.0) return 0; @@ -117,8 +108,7 @@ size_t TopZToSliceIndex(double z, const std::vector<Slice>& slices) return i_slice; } -size_t BottomZToSliceIndex(double z, const std::vector<Slice>& slices) -{ +size_t BottomZToSliceIndex(double z, const std::vector<Slice>& slices) { auto n_layers = slices.size(); if (n_layers < 2 || z >= 0.0) return 0; @@ -133,8 +123,7 @@ size_t BottomZToSliceIndex(double z, const std::vector<Slice>& slices) return i_slice; } -double SliceTopZ(size_t i, const std::vector<Slice>& slices) -{ +double SliceTopZ(size_t i, const std::vector<Slice>& slices) { if (i == 0) return 0.0; double top_z = 0.0; @@ -143,8 +132,7 @@ double SliceTopZ(size_t i, const std::vector<Slice>& slices) return top_z; } -ZLimits SlicesZLimits(const std::vector<Slice>& slices, size_t slice_index) -{ +ZLimits SlicesZLimits(const std::vector<Slice>& slices, size_t slice_index) { size_t N = slices.size(); if (N < 2) return ZLimits{}; @@ -156,8 +144,7 @@ ZLimits SlicesZLimits(const std::vector<Slice>& slices, size_t slice_index) return ZLimits(-thickness, 0.0); } -void ScaleRegions(std::vector<HomogeneousRegion>& regions, double factor) -{ +void ScaleRegions(std::vector<HomogeneousRegion>& regions, double factor) { for (auto& region : regions) region.m_volume *= factor; } diff --git a/Sample/Slice/SlicedFormFactorList.h b/Sample/Slice/SlicedFormFactorList.h index dc7acc89e7975a97e6a043098123bebdbcdf7494..6741aa9cb3b5a70360e02086d1510771b13b3776 100644 --- a/Sample/Slice/SlicedFormFactorList.h +++ b/Sample/Slice/SlicedFormFactorList.h @@ -28,8 +28,7 @@ class Slice; //! //! @ingroup intern -class SlicedFormFactorList -{ +class SlicedFormFactorList { public: SlicedFormFactorList() = default; SlicedFormFactorList(SlicedFormFactorList&& other) = default; diff --git a/Sample/SoftParticle/FormFactorGauss.cpp b/Sample/SoftParticle/FormFactorGauss.cpp index 601ebf492d0f5c8545dc2639ffce8b1b04f5e0ac..48c66199a5a275997bb3db1e9feaf6aa3f6c478c 100644 --- a/Sample/SoftParticle/FormFactorGauss.cpp +++ b/Sample/SoftParticle/FormFactorGauss.cpp @@ -22,18 +22,14 @@ FormFactorGaussSphere::FormFactorGaussSphere(const std::vector<double> P) "class_tooltip", {{"MeanRadius", "nm", "para_tooltip", 0, +INF, 0}}}, P) - , m_mean_radius(m_P[0]) -{ + , m_mean_radius(m_P[0]) { onChange(); } FormFactorGaussSphere::FormFactorGaussSphere(double mean_radius) - : FormFactorGaussSphere(std::vector<double>{mean_radius}) -{ -} + : FormFactorGaussSphere(std::vector<double>{mean_radius}) {} -complex_t FormFactorGaussSphere::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorGaussSphere::evaluate_for_q(cvector_t q) const { const double max_ql = std::sqrt(-4 * M_PI * std::log(std::numeric_limits<double>::min()) / 3); double qzh = q.z().real() * m_mean_radius; diff --git a/Sample/SoftParticle/FormFactorGauss.h b/Sample/SoftParticle/FormFactorGauss.h index 2e6a650fe2bbd3c2468287d1c7f539746b79fe5e..64d6a80bc9c15ae44a171391841084a0b6902af0 100644 --- a/Sample/SoftParticle/FormFactorGauss.h +++ b/Sample/SoftParticle/FormFactorGauss.h @@ -20,8 +20,7 @@ //! The form factor of a Gaussian sphere. //! @ingroup softParticle -class FormFactorGaussSphere : public IBornFF -{ +class FormFactorGaussSphere : public IBornFF { public: FormFactorGaussSphere(const std::vector<double> P); FormFactorGaussSphere(double mean_radius); diff --git a/Sample/SoftParticle/FormFactorSphereGaussianRadius.cpp b/Sample/SoftParticle/FormFactorSphereGaussianRadius.cpp index 3637269436b5712642bd41b173cdd3a7be722a5d..4526d75e00e43797db455cfec453fa3923ba94cf 100644 --- a/Sample/SoftParticle/FormFactorSphereGaussianRadius.cpp +++ b/Sample/SoftParticle/FormFactorSphereGaussianRadius.cpp @@ -23,31 +23,25 @@ FormFactorSphereGaussianRadius::FormFactorSphereGaussianRadius(const std::vector {"SigmaRadius", "nm", "para_tooltip", 0, +INF, 0}}}, P) , m_mean(m_P[0]) - , m_sigma(m_P[1]) -{ + , m_sigma(m_P[1]) { m_mean_r3 = calculateMeanR3(); onChange(); } FormFactorSphereGaussianRadius::FormFactorSphereGaussianRadius(double mean, double sigma) - : FormFactorSphereGaussianRadius(std::vector<double>{mean, sigma}) -{ -} + : FormFactorSphereGaussianRadius(std::vector<double>{mean, sigma}) {} -complex_t FormFactorSphereGaussianRadius::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorSphereGaussianRadius::evaluate_for_q(cvector_t q) const { double q2 = std::norm(q.x()) + std::norm(q.y()) + std::norm(q.z()); double dw = std::exp(-q2 * m_sigma * m_sigma / 2.0); return dw * exp_I(q.z() * m_mean_r3) * someff::ffSphere(q, m_mean_r3); // TODO: don't center at bottom; revise mesocrystal1.py } -void FormFactorSphereGaussianRadius::onChange() -{ +void FormFactorSphereGaussianRadius::onChange() { m_shape = std::make_unique<TruncatedEllipsoid>(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0); } -double FormFactorSphereGaussianRadius::calculateMeanR3() const -{ +double FormFactorSphereGaussianRadius::calculateMeanR3() const { return std::pow(m_mean * (m_mean * m_mean + 3.0 * m_sigma * m_sigma), 1.0 / 3.0); } diff --git a/Sample/SoftParticle/FormFactorSphereGaussianRadius.h b/Sample/SoftParticle/FormFactorSphereGaussianRadius.h index 9312ba433bafa5b6980485ef2ddb3ccf473ac11a..1f52f138e15a337b21649efefa5c3e0835513aa1 100644 --- a/Sample/SoftParticle/FormFactorSphereGaussianRadius.h +++ b/Sample/SoftParticle/FormFactorSphereGaussianRadius.h @@ -21,14 +21,12 @@ //! A sphere with gaussian radius distribution. //! @ingroup softParticle -class FormFactorSphereGaussianRadius : public IBornFF -{ +class FormFactorSphereGaussianRadius : public IBornFF { public: FormFactorSphereGaussianRadius(const std::vector<double> P); FormFactorSphereGaussianRadius(double mean, double sigma); - FormFactorSphereGaussianRadius* clone() const final - { + FormFactorSphereGaussianRadius* clone() const final { return new FormFactorSphereGaussianRadius(m_mean, m_sigma); } diff --git a/Sample/SoftParticle/FormFactorSphereLogNormalRadius.cpp b/Sample/SoftParticle/FormFactorSphereLogNormalRadius.cpp index cc8751f416e249e682354e7c9ba1fc63f0c4b78b..8cb9eee5d436996c8883665d8c1fa21739132a6c 100644 --- a/Sample/SoftParticle/FormFactorSphereLogNormalRadius.cpp +++ b/Sample/SoftParticle/FormFactorSphereLogNormalRadius.cpp @@ -27,8 +27,7 @@ FormFactorSphereLogNormalRadius::FormFactorSphereLogNormalRadius(const std::vect P) , m_mean(m_P[0]) , m_scale_param(m_P[1]) - , m_n_samples(n_samples) -{ + , m_n_samples(n_samples) { DistributionLogNormal distri(m_mean, m_scale_param); m_radii.clear(); @@ -43,24 +42,19 @@ FormFactorSphereLogNormalRadius::FormFactorSphereLogNormalRadius(const std::vect FormFactorSphereLogNormalRadius::FormFactorSphereLogNormalRadius(double mean, double scale_param, size_t n_samples) - : FormFactorSphereLogNormalRadius(std::vector<double>{mean, scale_param}, n_samples) -{ -} + : FormFactorSphereLogNormalRadius(std::vector<double>{mean, scale_param}, n_samples) {} -FormFactorSphereLogNormalRadius* FormFactorSphereLogNormalRadius::clone() const -{ +FormFactorSphereLogNormalRadius* FormFactorSphereLogNormalRadius::clone() const { return new FormFactorSphereLogNormalRadius(m_mean, m_scale_param, m_n_samples); } -complex_t FormFactorSphereLogNormalRadius::evaluate_for_q(cvector_t q) const -{ +complex_t FormFactorSphereLogNormalRadius::evaluate_for_q(cvector_t q) const { complex_t result = 0; for (size_t i = 0; i < m_radii.size(); ++i) result += someff::ffSphere(q, m_radii[i]) * m_probabilities[i]; return result; } -void FormFactorSphereLogNormalRadius::onChange() -{ +void FormFactorSphereLogNormalRadius::onChange() { m_shape = std::make_unique<TruncatedEllipsoid>(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0); } diff --git a/Sample/SoftParticle/FormFactorSphereLogNormalRadius.h b/Sample/SoftParticle/FormFactorSphereLogNormalRadius.h index ad58939dc83f7818c57c9b001863643de6856728..268f570b677fc9206c579e98613591a9fe1590e9 100644 --- a/Sample/SoftParticle/FormFactorSphereLogNormalRadius.h +++ b/Sample/SoftParticle/FormFactorSphereLogNormalRadius.h @@ -22,8 +22,7 @@ //! A sphere with log normal radius distribution. //! @ingroup softParticle -class FormFactorSphereLogNormalRadius : public IBornFF -{ +class FormFactorSphereLogNormalRadius : public IBornFF { public: FormFactorSphereLogNormalRadius(const std::vector<double> P, size_t n_samples = 0); FormFactorSphereLogNormalRadius(double mean, double scale_param, size_t n_samples); diff --git a/Sample/Specular/ISpecularStrategy.h b/Sample/Specular/ISpecularStrategy.h index 5950279d01051946742ac19f4430805929109d8e..6ee8edf9134c8a0509188ae47cefd8ed3892dc6f 100644 --- a/Sample/Specular/ISpecularStrategy.h +++ b/Sample/Specular/ISpecularStrategy.h @@ -30,8 +30,7 @@ class Slice; //! @ingroup algorithms_internal -class ISpecularStrategy -{ +class ISpecularStrategy { public: ISpecularStrategy() = default; virtual ~ISpecularStrategy() = default; diff --git a/Sample/Specular/SpecularMagneticNewNCStrategy.cpp b/Sample/Specular/SpecularMagneticNewNCStrategy.cpp index 1b3a980841fbcdeb657997414c3e6f81853cf61a..5fd3633ac4ff66eab9e94a8769f82da7530561c2 100644 --- a/Sample/Specular/SpecularMagneticNewNCStrategy.cpp +++ b/Sample/Specular/SpecularMagneticNewNCStrategy.cpp @@ -14,16 +14,14 @@ #include "Sample/Specular/SpecularMagneticNewNCStrategy.h" -namespace -{ +namespace { complex_t checkForUnderflow(complex_t val); } std::pair<Eigen::Matrix2cd, Eigen::Matrix2cd> SpecularMagneticNewNCStrategy::computeRoughnessMatrices(const MatrixRTCoefficients_v3& coeff_i, const MatrixRTCoefficients_v3& coeff_i1, - double sigma) const -{ + double sigma) const { complex_t beta_i = coeff_i.m_lambda(1) - coeff_i.m_lambda(0); complex_t beta_i1 = coeff_i1.m_lambda(1) - coeff_i1.m_lambda(0); @@ -69,8 +67,7 @@ SpecularMagneticNewNCStrategy::computeRoughnessMatrices(const MatrixRTCoefficien std::pair<Eigen::Matrix2cd, Eigen::Matrix2cd> SpecularMagneticNewNCStrategy::computeBackwardsSubmatrices(const MatrixRTCoefficients_v3& coeff_i, const MatrixRTCoefficients_v3& coeff_i1, - double sigma) const -{ + double sigma) const { Eigen::Matrix2cd roughness_sum{Eigen::Matrix2cd::Identity()}; Eigen::Matrix2cd roughness_diff{Eigen::Matrix2cd::Identity()}; if (sigma != 0.) { @@ -86,10 +83,8 @@ SpecularMagneticNewNCStrategy::computeBackwardsSubmatrices(const MatrixRTCoeffic return {mp, mm}; } -namespace -{ -complex_t checkForUnderflow(complex_t val) -{ +namespace { +complex_t checkForUnderflow(complex_t val) { return std::abs(val.imag()) < 1e-80 && val.real() < 0 ? complex_t(val.real(), 1e-40) : val; } } // namespace diff --git a/Sample/Specular/SpecularMagneticNewNCStrategy.h b/Sample/Specular/SpecularMagneticNewNCStrategy.h index 0b4e13247584c755deb87a05fc888c80bb27aab2..66d402287521912e9bd4f42ce3f3a346829ed5e4 100644 --- a/Sample/Specular/SpecularMagneticNewNCStrategy.h +++ b/Sample/Specular/SpecularMagneticNewNCStrategy.h @@ -27,8 +27,7 @@ //! document "Polarized Implementation of the Transfer Matrix Method" //! //! @ingroup algorithms_internal -class SpecularMagneticNewNCStrategy : public SpecularMagneticNewStrategy -{ +class SpecularMagneticNewNCStrategy : public SpecularMagneticNewStrategy { private: std::pair<Eigen::Matrix2cd, Eigen::Matrix2cd> computeRoughnessMatrices(const MatrixRTCoefficients_v3& coeff_i, diff --git a/Sample/Specular/SpecularMagneticNewStrategy.cpp b/Sample/Specular/SpecularMagneticNewStrategy.cpp index 36cebe2e00b87440072a89522d6d6c4f3dab9c20..cb71ab7c766222053a34063244e123d5c65eadbd 100644 --- a/Sample/Specular/SpecularMagneticNewStrategy.cpp +++ b/Sample/Specular/SpecularMagneticNewStrategy.cpp @@ -18,8 +18,7 @@ #include "Sample/Slice/LayerRoughness.h" #include "Sample/Slice/Slice.h" -namespace -{ +namespace { double magneticSLD(kvector_t B_field); Eigen::Vector2cd eigenvalues(complex_t kz, double b_mag); Eigen::Vector2cd checkForUnderflow(const Eigen::Vector2cd& eigenvs); @@ -33,15 +32,13 @@ const LayerRoughness* GetBottomRoughness(const std::vector<Slice>& slices, } // namespace ISpecularStrategy::coeffs_t SpecularMagneticNewStrategy::Execute(const std::vector<Slice>& slices, - const kvector_t& k) const -{ + const kvector_t& k) const { return Execute(slices, KzComputation::computeReducedKz(slices, k)); } ISpecularStrategy::coeffs_t SpecularMagneticNewStrategy::Execute(const std::vector<Slice>& slices, - const std::vector<complex_t>& kz) const -{ + const std::vector<complex_t>& kz) const { if (slices.size() != kz.size()) throw std::runtime_error("Number of slices does not match the size of the kz-vector"); @@ -54,8 +51,7 @@ SpecularMagneticNewStrategy::Execute(const std::vector<Slice>& slices, std::vector<MatrixRTCoefficients_v3> SpecularMagneticNewStrategy::computeTR(const std::vector<Slice>& slices, - const std::vector<complex_t>& kzs) const -{ + const std::vector<complex_t>& kzs) const { const size_t N = slices.size(); if (slices.size() != kzs.size()) @@ -99,8 +95,7 @@ SpecularMagneticNewStrategy::computeTR(const std::vector<Slice>& slices, } void SpecularMagneticNewStrategy::calculateUpwards(std::vector<MatrixRTCoefficients_v3>& coeff, - const std::vector<Slice>& slices) const -{ + const std::vector<Slice>& slices) const { const auto N = slices.size(); std::vector<Eigen::Matrix2cd> SMatrices(N - 1); std::vector<complex_t> Normalization(N - 1); @@ -164,27 +159,23 @@ void SpecularMagneticNewStrategy::calculateUpwards(std::vector<MatrixRTCoefficie } } -namespace -{ -double magneticSLD(kvector_t B_field) -{ +namespace { +double magneticSLD(kvector_t B_field) { return magnetic_prefactor * B_field.mag(); } -Eigen::Vector2cd eigenvalues(complex_t kz, double magnetic_SLD) -{ +Eigen::Vector2cd eigenvalues(complex_t kz, double magnetic_SLD) { const complex_t a = kz * kz; return {std::sqrt(a - 4. * M_PI * magnetic_SLD), std::sqrt(a + 4. * M_PI * magnetic_SLD)}; } -Eigen::Vector2cd checkForUnderflow(const Eigen::Vector2cd& eigenvs) -{ +Eigen::Vector2cd checkForUnderflow(const Eigen::Vector2cd& eigenvs) { auto lambda = [](complex_t value) { return std::abs(value) < 1e-40 ? 1e-40 : value; }; return {lambda(eigenvs(0)), lambda(eigenvs(1))}; } -const LayerRoughness* GetBottomRoughness(const std::vector<Slice>& slices, const size_t slice_index) -{ +const LayerRoughness* GetBottomRoughness(const std::vector<Slice>& slices, + const size_t slice_index) { if (slice_index + 1 < slices.size()) return slices[slice_index + 1].topRoughness(); return nullptr; diff --git a/Sample/Specular/SpecularMagneticNewStrategy.h b/Sample/Specular/SpecularMagneticNewStrategy.h index 013fec12174b991f8bb1f2cc2631537bcfd4b04b..fc7e85f3afcee0b1061bfb2cbe43acff2f5991f1 100644 --- a/Sample/Specular/SpecularMagneticNewStrategy.h +++ b/Sample/Specular/SpecularMagneticNewStrategy.h @@ -30,8 +30,7 @@ class Slice; //! document "Polarized Implementation of the Transfer Matrix Method" //! //! @ingroup algorithms_internal -class SpecularMagneticNewStrategy : public ISpecularStrategy -{ +class SpecularMagneticNewStrategy : public ISpecularStrategy { public: //! Computes refraction angle reflection/transmission coefficients //! for given sliced multilayer and wavevector k diff --git a/Sample/Specular/SpecularMagneticNewTanhStrategy.cpp b/Sample/Specular/SpecularMagneticNewTanhStrategy.cpp index 6fe2703c9f77d4fdf7f3711735b6fdf004abf130..79708afac0ff317c4570834079e18dc2dd7810bc 100644 --- a/Sample/Specular/SpecularMagneticNewTanhStrategy.cpp +++ b/Sample/Specular/SpecularMagneticNewTanhStrategy.cpp @@ -16,15 +16,13 @@ #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" -namespace -{ +namespace { const double pi2_15 = std::pow(M_PI_2, 1.5); } // namespace Eigen::Matrix2cd SpecularMagneticNewTanhStrategy::computeRoughnessMatrix(const MatrixRTCoefficients_v3& coeff, - double sigma, bool inverse) const -{ + double sigma, bool inverse) const { if (sigma < 10 * std::numeric_limits<double>::epsilon()) return Eigen::Matrix2cd{Eigen::Matrix2cd::Identity()}; @@ -64,8 +62,7 @@ SpecularMagneticNewTanhStrategy::computeRoughnessMatrix(const MatrixRTCoefficien std::pair<Eigen::Matrix2cd, Eigen::Matrix2cd> SpecularMagneticNewTanhStrategy::computeBackwardsSubmatrices( const MatrixRTCoefficients_v3& coeff_i, const MatrixRTCoefficients_v3& coeff_i1, - double sigma) const -{ + double sigma) const { Eigen::Matrix2cd R{Eigen::Matrix2cd::Identity()}; Eigen::Matrix2cd RInv{Eigen::Matrix2cd::Identity()}; diff --git a/Sample/Specular/SpecularMagneticNewTanhStrategy.h b/Sample/Specular/SpecularMagneticNewTanhStrategy.h index a7193c6129063baa086b9accb8f00acf350ae094..9bcde6f1ab34f9fe0fa8b925c9e7749947e9ab0c 100644 --- a/Sample/Specular/SpecularMagneticNewTanhStrategy.h +++ b/Sample/Specular/SpecularMagneticNewTanhStrategy.h @@ -25,8 +25,7 @@ //! document "Polarized Implementation of the Transfer Matrix Method" //! //! @ingroup algorithms_internal -class SpecularMagneticNewTanhStrategy : public SpecularMagneticNewStrategy -{ +class SpecularMagneticNewTanhStrategy : public SpecularMagneticNewStrategy { private: virtual std::pair<Eigen::Matrix2cd, Eigen::Matrix2cd> computeBackwardsSubmatrices(const MatrixRTCoefficients_v3& coeff_i, diff --git a/Sample/Specular/SpecularMagneticOldStrategy.cpp b/Sample/Specular/SpecularMagneticOldStrategy.cpp index 0c96d705889f4d1488b0b974becd59af14a78ee3..601711f3c4f788dfa5f7ecf4fd5f2ca662edd824 100644 --- a/Sample/Specular/SpecularMagneticOldStrategy.cpp +++ b/Sample/Specular/SpecularMagneticOldStrategy.cpp @@ -20,8 +20,7 @@ #include "Sample/Slice/Slice.h" #include <Eigen/LU> -namespace -{ +namespace { void CalculateEigenvalues(const std::vector<Slice>& slices, const kvector_t k, std::vector<MatrixRTCoefficients>& coeff); void CalculateTransferAndBoundary(const std::vector<Slice>& slices, @@ -31,8 +30,7 @@ complex_t GetImExponential(complex_t exponent); } // namespace ISpecularStrategy::coeffs_t SpecularMagneticOldStrategy::Execute(const std::vector<Slice>& slices, - const kvector_t& k) const -{ + const kvector_t& k) const { std::vector<MatrixRTCoefficients> result(slices.size()); CalculateEigenvalues(slices, k, result); CalculateTransferAndBoundary(slices, result); @@ -45,16 +43,14 @@ ISpecularStrategy::coeffs_t SpecularMagneticOldStrategy::Execute(const std::vect } ISpecularStrategy::coeffs_t -SpecularMagneticOldStrategy::Execute(const std::vector<Slice>&, const std::vector<complex_t>&) const -{ +SpecularMagneticOldStrategy::Execute(const std::vector<Slice>&, + const std::vector<complex_t>&) const { throw std::runtime_error("Not implemented"); } -namespace -{ +namespace { void CalculateEigenvalues(const std::vector<Slice>& slices, const kvector_t k, - std::vector<MatrixRTCoefficients>& coeff) -{ + std::vector<MatrixRTCoefficients>& coeff) { double mag_k = k.mag(); double n_ref = slices[0].material().refractiveIndex(2 * M_PI / mag_k).real(); double sign_kz = k.z() > 0.0 ? -1.0 : 1.0; @@ -82,8 +78,7 @@ void CalculateEigenvalues(const std::vector<Slice>& slices, const kvector_t k, // todo: avoid overflows (see SpecularMatrix.cpp) void CalculateTransferAndBoundary(const std::vector<Slice>& slices, - std::vector<MatrixRTCoefficients>& coeff) -{ + std::vector<MatrixRTCoefficients>& coeff) { size_t N = coeff.size(); if (coeff[0].lambda == Eigen::Vector2cd::Zero() && N > 1) { SetForNoTransmission(coeff); @@ -141,8 +136,7 @@ void CalculateTransferAndBoundary(const std::vector<Slice>& slices, } } -void SetForNoTransmission(std::vector<MatrixRTCoefficients>& coeff) -{ +void SetForNoTransmission(std::vector<MatrixRTCoefficients>& coeff) { size_t N = coeff.size(); for (size_t i = 0; i < N; ++i) { coeff[i].phi_psi_plus.setZero(); @@ -154,8 +148,7 @@ void SetForNoTransmission(std::vector<MatrixRTCoefficients>& coeff) } } -complex_t GetImExponential(complex_t exponent) -{ +complex_t GetImExponential(complex_t exponent) { if (exponent.imag() > -std::log(std::numeric_limits<double>::min())) return 0.0; return std::exp(I * exponent); diff --git a/Sample/Specular/SpecularMagneticOldStrategy.h b/Sample/Specular/SpecularMagneticOldStrategy.h index b5ca027b2d4278302169d92c8f772f5f2c952a9f..88e6b17d87a4fe36201f586c7049bb7fbd595f39 100644 --- a/Sample/Specular/SpecularMagneticOldStrategy.h +++ b/Sample/Specular/SpecularMagneticOldStrategy.h @@ -26,8 +26,7 @@ class Slice; //! the coherent wave solution in a multilayer with magnetization. //! @ingroup algorithms_internal -class SpecularMagneticOldStrategy : public ISpecularStrategy -{ +class SpecularMagneticOldStrategy : public ISpecularStrategy { public: //! Computes refraction angle reflection/transmission coefficients //! for given sliced multilayer and wavevector k diff --git a/Sample/Specular/SpecularMagneticStrategy.cpp b/Sample/Specular/SpecularMagneticStrategy.cpp index 726e5a3c11ec463bca377649fb5d9c06eb6e9f5b..b46fca7567fd7a7700ecc2e9945649524eb651f3 100644 --- a/Sample/Specular/SpecularMagneticStrategy.cpp +++ b/Sample/Specular/SpecularMagneticStrategy.cpp @@ -17,8 +17,7 @@ #include "Sample/Slice/KzComputation.h" #include "Sample/Slice/Slice.h" -namespace -{ +namespace { kvector_t magneticImpact(kvector_t B_field); Eigen::Vector2cd eigenvalues(complex_t kz, double b_mag); Eigen::Vector2cd checkForUnderflow(const Eigen::Vector2cd& eigenvs); @@ -30,15 +29,13 @@ constexpr double magnetic_prefactor = PhysConsts::m_n * PhysConsts::g_factor_n * } // namespace ISpecularStrategy::coeffs_t SpecularMagneticStrategy::Execute(const std::vector<Slice>& slices, - const kvector_t& k) const -{ + const kvector_t& k) const { return Execute(slices, KzComputation::computeReducedKz(slices, k)); } ISpecularStrategy::coeffs_t SpecularMagneticStrategy::Execute(const std::vector<Slice>& slices, - const std::vector<complex_t>& kz) const -{ + const std::vector<complex_t>& kz) const { if (slices.size() != kz.size()) throw std::runtime_error("Number of slices does not match the size of the kz-vector"); @@ -51,8 +48,7 @@ SpecularMagneticStrategy::Execute(const std::vector<Slice>& slices, std::vector<MatrixRTCoefficients_v2> SpecularMagneticStrategy::computeTR(const std::vector<Slice>& slices, - const std::vector<complex_t>& kzs) -{ + const std::vector<complex_t>& kzs) { if (kzs[0] == 0.) throw std::runtime_error("Edge case k_z = 0 not implemented"); @@ -85,8 +81,7 @@ SpecularMagneticStrategy::computeTR(const std::vector<Slice>& slices, return result; } -void SpecularMagneticStrategy::calculateTR(MatrixRTCoefficients_v2& coeff) -{ +void SpecularMagneticStrategy::calculateTR(MatrixRTCoefficients_v2& coeff) { const double b = coeff.m_b.mag(); if (b == 0.0) { calculateZeroFieldTR(coeff); @@ -119,8 +114,7 @@ void SpecularMagneticStrategy::calculateTR(MatrixRTCoefficients_v2& coeff) -T2(2, 0), -T2(2, 1), T2(2, 2), T2(2, 3), -T2(3, 0), -T2(3, 1), T2(3, 2), T2(3, 3); } -void SpecularMagneticStrategy::calculateZeroFieldTR(MatrixRTCoefficients_v2& coeff) -{ +void SpecularMagneticStrategy::calculateZeroFieldTR(MatrixRTCoefficients_v2& coeff) { coeff.T1 = Eigen::Matrix4cd::Zero(); coeff.R1 = Eigen::Matrix4cd::Zero(); coeff.T2 = Eigen::Matrix4cd::Zero(); @@ -141,8 +135,7 @@ void SpecularMagneticStrategy::calculateZeroFieldTR(MatrixRTCoefficients_v2& coe coeff.R2.block<3, 3>(0, 0) = Rblock; } -void SpecularMagneticStrategy::setNoTransmission(MatrixRTCoefficients_v2& coeff) -{ +void SpecularMagneticStrategy::setNoTransmission(MatrixRTCoefficients_v2& coeff) { coeff.m_w_plus = Eigen::Vector4cd::Zero(); coeff.m_w_min = Eigen::Vector4cd::Zero(); coeff.T1 = Eigen::Matrix4cd::Identity() / 4.0; @@ -151,8 +144,7 @@ void SpecularMagneticStrategy::setNoTransmission(MatrixRTCoefficients_v2& coeff) coeff.R2 = coeff.T1; } -void SpecularMagneticStrategy::nullifyBottomReflection(MatrixRTCoefficients_v2& coeff) -{ +void SpecularMagneticStrategy::nullifyBottomReflection(MatrixRTCoefficients_v2& coeff) { const complex_t l_1 = coeff.m_lambda(0); const complex_t l_2 = coeff.m_lambda(1); const double b_mag = coeff.m_b.mag(); @@ -179,8 +171,7 @@ void SpecularMagneticStrategy::nullifyBottomReflection(MatrixRTCoefficients_v2& } void SpecularMagneticStrategy::propagateBackwardsForwards( - std::vector<MatrixRTCoefficients_v2>& coeff, const std::vector<Slice>& slices) -{ + std::vector<MatrixRTCoefficients_v2>& coeff, const std::vector<Slice>& slices) { const int size = static_cast<int>(coeff.size()); std::vector<Eigen::Matrix2cd> SMatrices(coeff.size()); std::vector<complex_t> Normalization(coeff.size()); @@ -243,8 +234,7 @@ void SpecularMagneticStrategy::propagateBackwardsForwards( } std::pair<Eigen::Matrix2cd, complex_t> -SpecularMagneticStrategy::findNormalizationCoefficients(const MatrixRTCoefficients_v2& coeff) -{ +SpecularMagneticStrategy::findNormalizationCoefficients(const MatrixRTCoefficients_v2& coeff) { const Eigen::Vector2cd Ta = coeff.T1plus() + coeff.T2plus(); const Eigen::Vector2cd Tb = coeff.T1min() + coeff.T2min(); @@ -260,27 +250,22 @@ SpecularMagneticStrategy::findNormalizationCoefficients(const MatrixRTCoefficien return {SInverse, denominator}; } -namespace -{ -kvector_t magneticImpact(kvector_t B_field) -{ +namespace { +kvector_t magneticImpact(kvector_t B_field) { return -magnetic_prefactor * B_field; } -Eigen::Vector2cd eigenvalues(complex_t kz, double b_mag) -{ +Eigen::Vector2cd eigenvalues(complex_t kz, double b_mag) { const complex_t a = kz * kz; return {I * std::sqrt(a + b_mag), I * std::sqrt(a - b_mag)}; } -Eigen::Vector2cd checkForUnderflow(const Eigen::Vector2cd& eigenvs) -{ +Eigen::Vector2cd checkForUnderflow(const Eigen::Vector2cd& eigenvs) { auto lambda = [](complex_t value) { return std::abs(value) < 1e-40 ? 1e-40 : value; }; return {lambda(eigenvs(0)), lambda(eigenvs(1))}; } -complex_t GetImExponential(complex_t exponent) -{ +complex_t GetImExponential(complex_t exponent) { if (exponent.imag() > -std::log(std::numeric_limits<double>::min())) return 0.0; return std::exp(I * exponent); diff --git a/Sample/Specular/SpecularMagneticStrategy.h b/Sample/Specular/SpecularMagneticStrategy.h index 1fda48c0bc346d54854e080651f905905793da3a..31a5c12d73652606c60f857d247a813494b713b1 100644 --- a/Sample/Specular/SpecularMagneticStrategy.h +++ b/Sample/Specular/SpecularMagneticStrategy.h @@ -29,8 +29,7 @@ class Slice; //! For a detailed description see internal document "Polarized Specular Reflectometry" //! //! @ingroup algorithms_internal -class SpecularMagneticStrategy : public ISpecularStrategy -{ +class SpecularMagneticStrategy : public ISpecularStrategy { public: //! Computes refraction angle reflection/transmission coefficients //! for given sliced multilayer and wavevector k diff --git a/Sample/Specular/SpecularScalarNCStrategy.cpp b/Sample/Specular/SpecularScalarNCStrategy.cpp index df536ea44dc9529839b284f8c9a8c8767ab5cf44..a975d93f1dff5882503f0e1efba6a0fa9ce1d038 100644 --- a/Sample/Specular/SpecularScalarNCStrategy.cpp +++ b/Sample/Specular/SpecularScalarNCStrategy.cpp @@ -16,8 +16,7 @@ #include <Eigen/Dense> std::pair<complex_t, complex_t> SpecularScalarNCStrategy::transition(complex_t kzi, complex_t kzi1, - double sigma) const -{ + double sigma) const { complex_t roughness_diff = 1; complex_t roughness_sum = 1; if (sigma > 0.0) { diff --git a/Sample/Specular/SpecularScalarNCStrategy.h b/Sample/Specular/SpecularScalarNCStrategy.h index ffd0a6e1b70aa7b65ca8eb5d3cdd67f618ec37ad..20323631e970744945ba71d1f3100213623871ac 100644 --- a/Sample/Specular/SpecularScalarNCStrategy.h +++ b/Sample/Specular/SpecularScalarNCStrategy.h @@ -27,8 +27,7 @@ class Slice; //! //! @ingroup algorithms_internal -class SpecularScalarNCStrategy : public SpecularScalarStrategy -{ +class SpecularScalarNCStrategy : public SpecularScalarStrategy { private: //! Roughness is modelled by a Gaussian profile, i.e. Nevot-Croce factors for the //! reflection coefficients. diff --git a/Sample/Specular/SpecularScalarStrategy.cpp b/Sample/Specular/SpecularScalarStrategy.cpp index b1990c0855353cc703f7938cce2047af65c57831..f55e7c59e48b3bb21e4173a604fbf3460d2402c8 100644 --- a/Sample/Specular/SpecularScalarStrategy.cpp +++ b/Sample/Specular/SpecularScalarStrategy.cpp @@ -20,22 +20,20 @@ #include <Eigen/Dense> #include <stdexcept> -namespace -{ +namespace { const LayerRoughness* GetBottomRoughness(const std::vector<Slice>& slices, const size_t slice_index); } // namespace ISpecularStrategy::coeffs_t SpecularScalarStrategy::Execute(const std::vector<Slice>& slices, - const kvector_t& k) const -{ + const kvector_t& k) const { std::vector<complex_t> kz = KzComputation::computeReducedKz(slices, k); return Execute(slices, kz); } -ISpecularStrategy::coeffs_t SpecularScalarStrategy::Execute(const std::vector<Slice>& slices, - const std::vector<complex_t>& kz) const -{ +ISpecularStrategy::coeffs_t +SpecularScalarStrategy::Execute(const std::vector<Slice>& slices, + const std::vector<complex_t>& kz) const { if (slices.size() != kz.size()) throw std::runtime_error("Number of slices does not match the size of the kz-vector"); @@ -48,8 +46,7 @@ ISpecularStrategy::coeffs_t SpecularScalarStrategy::Execute(const std::vector<Sl std::vector<ScalarRTCoefficients> SpecularScalarStrategy::computeTR(const std::vector<Slice>& slices, - const std::vector<complex_t>& kz) const -{ + const std::vector<complex_t>& kz) const { const size_t N = slices.size(); std::vector<ScalarRTCoefficients> coeff(N); @@ -72,8 +69,7 @@ SpecularScalarStrategy::computeTR(const std::vector<Slice>& slices, } void SpecularScalarStrategy::setZeroBelow(std::vector<ScalarRTCoefficients>& coeff, - size_t current_layer) -{ + size_t current_layer) { size_t N = coeff.size(); for (size_t i = current_layer + 1; i < N; ++i) { coeff[i].t_r.setZero(); @@ -82,8 +78,7 @@ void SpecularScalarStrategy::setZeroBelow(std::vector<ScalarRTCoefficients>& coe void SpecularScalarStrategy::calculateUpFromLayer(std::vector<ScalarRTCoefficients>& coeff, const std::vector<Slice>& slices, - const std::vector<complex_t>& kz) const -{ + const std::vector<complex_t>& kz) const { auto N = slices.size(); coeff.back().t_r(0) = 1.0; @@ -119,10 +114,9 @@ void SpecularScalarStrategy::calculateUpFromLayer(std::vector<ScalarRTCoefficien } } -namespace -{ -const LayerRoughness* GetBottomRoughness(const std::vector<Slice>& slices, const size_t slice_index) -{ +namespace { +const LayerRoughness* GetBottomRoughness(const std::vector<Slice>& slices, + const size_t slice_index) { if (slice_index + 1 < slices.size()) return slices[slice_index + 1].topRoughness(); return nullptr; diff --git a/Sample/Specular/SpecularScalarStrategy.h b/Sample/Specular/SpecularScalarStrategy.h index 625f27aacb62851206471b0f229cfd88775c93eb..eda61cef769dcc30b9e9ddcba0bcc2fb47afb789 100644 --- a/Sample/Specular/SpecularScalarStrategy.h +++ b/Sample/Specular/SpecularScalarStrategy.h @@ -30,8 +30,7 @@ class Slice; //! Inherited by SpecularScalarNCStrategy, SpecularScalarTanhStrategy //! //! @ingroup algorithms_internal -class SpecularScalarStrategy : public ISpecularStrategy -{ +class SpecularScalarStrategy : public ISpecularStrategy { public: //! Computes refraction angles and transmission/reflection coefficients //! for given coherent wave propagation in a multilayer. diff --git a/Sample/Specular/SpecularScalarTanhStrategy.cpp b/Sample/Specular/SpecularScalarTanhStrategy.cpp index 61f7b018c2f36786b1365c4f89bf4bbf8e4e7199..8fcd86e04955a44bef0eec3ebd9c6df520bb78b8 100644 --- a/Sample/Specular/SpecularScalarTanhStrategy.cpp +++ b/Sample/Specular/SpecularScalarTanhStrategy.cpp @@ -17,14 +17,12 @@ #include "Base/Math/Functions.h" #include <Eigen/Dense> -namespace -{ +namespace { const double pi2_15 = std::pow(M_PI_2, 1.5); } std::pair<complex_t, complex_t> -SpecularScalarTanhStrategy::transition(complex_t kzi, complex_t kzi1, double sigma) const -{ +SpecularScalarTanhStrategy::transition(complex_t kzi, complex_t kzi1, double sigma) const { complex_t roughness = 1; if (sigma > 0.0) { const double sigeff = pi2_15 * sigma; diff --git a/Sample/Specular/SpecularScalarTanhStrategy.h b/Sample/Specular/SpecularScalarTanhStrategy.h index 4a5e11d3197d3b86e3eddd10806e1bee7b38694f..494622e6e721f89778772e1b0e7753e2c88a0d2e 100644 --- a/Sample/Specular/SpecularScalarTanhStrategy.h +++ b/Sample/Specular/SpecularScalarTanhStrategy.h @@ -26,8 +26,7 @@ class Slice; //! coherent wave propagation in a multilayer by applying modified Fresnel coefficients. //! //! @ingroup algorithms_internal -class SpecularScalarTanhStrategy : public SpecularScalarStrategy -{ +class SpecularScalarTanhStrategy : public SpecularScalarStrategy { private: //! Roughness is modelled by tanh profile [see e.g. Phys. Rev. B, vol. 47 (8), p. 4385 (1993)]. virtual std::pair<complex_t, complex_t> transition(complex_t kzi, complex_t kzi1, diff --git a/Sample/Specular/SpecularStrategyBuilder.cpp b/Sample/Specular/SpecularStrategyBuilder.cpp index 92fbea79d8c8440d20234de27ca427ec0bbe23f5..b79d0decf6fbe99dff11a75683ab566a87a7bca8 100644 --- a/Sample/Specular/SpecularStrategyBuilder.cpp +++ b/Sample/Specular/SpecularStrategyBuilder.cpp @@ -20,8 +20,7 @@ #include "Sample/Specular/SpecularScalarTanhStrategy.h" std::unique_ptr<ISpecularStrategy> SpecularStrategyBuilder::build(const MultiLayer& sample, - const bool magnetic) -{ + const bool magnetic) { auto roughnessModel = sample.roughnessModel(); if (magnetic) { diff --git a/Sample/Specular/SpecularStrategyBuilder.h b/Sample/Specular/SpecularStrategyBuilder.h index a15146f0115cb2bf2ef72f8e7717465296172d34..bbe67b861508b55ed743a9d5e899369b8e9ae222 100644 --- a/Sample/Specular/SpecularStrategyBuilder.h +++ b/Sample/Specular/SpecularStrategyBuilder.h @@ -18,8 +18,7 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/Specular/ISpecularStrategy.h" -class SpecularStrategyBuilder -{ +class SpecularStrategyBuilder { public: static std::unique_ptr<ISpecularStrategy> build(const MultiLayer& sample, const bool magnetic); diff --git a/Sample/StandardSamples/BoxCompositionBuilder.cpp b/Sample/StandardSamples/BoxCompositionBuilder.cpp index abd68159d040e2f63f8286fdb47bfbcb33c557fa..20ea08c711ac98ef6d8c2e70d4585e4b0f5e4bb0 100644 --- a/Sample/StandardSamples/BoxCompositionBuilder.cpp +++ b/Sample/StandardSamples/BoxCompositionBuilder.cpp @@ -22,8 +22,7 @@ #include "Sample/Particle/ParticleComposition.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -namespace -{ +namespace { const Material particleMaterial = HomogeneousMaterial("Ag", 1.245e-5, 5.419e-7); const double layer_thickness = 100.0 * Units::nm; @@ -31,8 +30,7 @@ const double length = 50.0 * Units::nm; const double width = 20.0 * Units::nm; const double height = 10.0 * Units::nm; -MultiLayer* finalizeMultiLayer(const ParticleComposition& composition) -{ +MultiLayer* finalizeMultiLayer(const ParticleComposition& composition) { ParticleLayout layout; layout.addParticle(composition); @@ -52,8 +50,7 @@ MultiLayer* finalizeMultiLayer(const ParticleComposition& composition) // --- BoxCompositionRotateXBuilder --- -MultiLayer* BoxCompositionRotateXBuilder::buildSample() const -{ +MultiLayer* BoxCompositionRotateXBuilder::buildSample() const { Particle box(particleMaterial, FormFactorBox(length / 2.0, width, height)); ParticleComposition composition; composition.addParticle(box, kvector_t(0.0, 0.0, 0.0)); @@ -65,8 +62,7 @@ MultiLayer* BoxCompositionRotateXBuilder::buildSample() const // --- BoxCompositionRotateYBuilder --- -MultiLayer* BoxCompositionRotateYBuilder::buildSample() const -{ +MultiLayer* BoxCompositionRotateYBuilder::buildSample() const { Particle box(particleMaterial, FormFactorBox(length / 2.0, width, height)); ParticleComposition composition; composition.addParticle(box, kvector_t(0.0, 0.0, 0.0)); @@ -78,8 +74,7 @@ MultiLayer* BoxCompositionRotateYBuilder::buildSample() const // --- BoxCompositionRotateZBuilder --- -MultiLayer* BoxCompositionRotateZBuilder::buildSample() const -{ +MultiLayer* BoxCompositionRotateZBuilder::buildSample() const { Particle box(particleMaterial, FormFactorBox(length / 2.0, width, height)); ParticleComposition composition; composition.addParticle(box, kvector_t(0.0, 0.0, 0.0)); @@ -91,8 +86,7 @@ MultiLayer* BoxCompositionRotateZBuilder::buildSample() const // --- BoxCompositionRotateZandYBuilder --- -MultiLayer* BoxCompositionRotateZandYBuilder::buildSample() const -{ +MultiLayer* BoxCompositionRotateZandYBuilder::buildSample() const { Particle box(particleMaterial, FormFactorBox(length / 2.0, width, height)); ParticleComposition composition; composition.addParticle(box, kvector_t(0.0, 0.0, 0.0)); @@ -106,8 +100,7 @@ MultiLayer* BoxCompositionRotateZandYBuilder::buildSample() const // --- BoxStackCompositionBuilder --- // Composition of two boxes which gives you the box (10,20,50) with reference point as usual. -MultiLayer* BoxStackCompositionBuilder::buildSample() const -{ +MultiLayer* BoxStackCompositionBuilder::buildSample() const { ParticleComposition composition; // box1 (20,50,5), rotatedZ diff --git a/Sample/StandardSamples/BoxCompositionBuilder.h b/Sample/StandardSamples/BoxCompositionBuilder.h index 366921dfdef1168b2335981c77b1bb958825dbfd..414e377e3e02cde188bcbbcf96f0cd16e335ba41 100644 --- a/Sample/StandardSamples/BoxCompositionBuilder.h +++ b/Sample/StandardSamples/BoxCompositionBuilder.h @@ -20,8 +20,7 @@ //! Two boxes in particle composition rotated in X by 90 degrees. //! @ingroup standard_samples -class BoxCompositionRotateXBuilder : public ISampleBuilder -{ +class BoxCompositionRotateXBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -29,8 +28,7 @@ public: //! Two boxes in particle composition rotated in Y by 90 degrees. //! @ingroup standard_samples -class BoxCompositionRotateYBuilder : public ISampleBuilder -{ +class BoxCompositionRotateYBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -38,8 +36,7 @@ public: //! Two boxes in particle composition rotated in Z by 90 degrees. //! @ingroup standard_samples -class BoxCompositionRotateZBuilder : public ISampleBuilder -{ +class BoxCompositionRotateZBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -47,8 +44,7 @@ public: //! Two boxes in particle composition rotated in Z and Y by 90 degrees. //! @ingroup standard_samples -class BoxCompositionRotateZandYBuilder : public ISampleBuilder -{ +class BoxCompositionRotateZandYBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -56,8 +52,7 @@ public: //! Two different boxes are first rotated and then composed, composition is then rotated. //! @ingroup standard_samples -class BoxStackCompositionBuilder : public ISampleBuilder -{ +class BoxStackCompositionBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/BoxesSquareLatticeBuilder.cpp b/Sample/StandardSamples/BoxesSquareLatticeBuilder.cpp index 80628488aef275a7a5261b52411a8cbf427d2c58..4b1c5122699ac286bebbeae497084a4be9ac51ff 100644 --- a/Sample/StandardSamples/BoxesSquareLatticeBuilder.cpp +++ b/Sample/StandardSamples/BoxesSquareLatticeBuilder.cpp @@ -22,8 +22,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* BoxesSquareLattice2DBuilder::buildSample() const -{ +MultiLayer* BoxesSquareLattice2DBuilder::buildSample() const { const double length = 5 * Units::nm; const double height = 10 * Units::nm; diff --git a/Sample/StandardSamples/BoxesSquareLatticeBuilder.h b/Sample/StandardSamples/BoxesSquareLatticeBuilder.h index c24d0ca0749d20297aa84a33cfcd542fb2b7e3f5..880d1487c1c872ac64337ab3cede1b1a3e6cc334 100644 --- a/Sample/StandardSamples/BoxesSquareLatticeBuilder.h +++ b/Sample/StandardSamples/BoxesSquareLatticeBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: square boxes in a square lattice //! @ingroup standard_samples -class BoxesSquareLattice2DBuilder : public ISampleBuilder -{ +class BoxesSquareLattice2DBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/CoreShellParticleBuilder.cpp b/Sample/StandardSamples/CoreShellParticleBuilder.cpp index 8b3392a338d1b27409ec4674cb566cfcd4a65d2b..250049b0c003d5518b0fb0580025d83dca434a03 100644 --- a/Sample/StandardSamples/CoreShellParticleBuilder.cpp +++ b/Sample/StandardSamples/CoreShellParticleBuilder.cpp @@ -24,8 +24,7 @@ // --- CoreShellParticleBuilder --- -MultiLayer* CoreShellParticleBuilder::buildSample() const -{ +MultiLayer* CoreShellParticleBuilder::buildSample() const { complex_t n_particle_shell(1.0 - 1e-4, 2e-8); complex_t n_particle_core(1.0 - 6e-5, 2e-8); @@ -53,8 +52,7 @@ MultiLayer* CoreShellParticleBuilder::buildSample() const // --- CoreShellBoxRotateZandYBuilder --- -MultiLayer* CoreShellBoxRotateZandYBuilder::buildSample() const -{ +MultiLayer* CoreShellBoxRotateZandYBuilder::buildSample() const { const double layer_thickness(100.0 * Units::nm); // core shell particle diff --git a/Sample/StandardSamples/CoreShellParticleBuilder.h b/Sample/StandardSamples/CoreShellParticleBuilder.h index 63c7b1ce5b45b7106b1306ebe4ffe567eec8aee9..ed57756d85cceb5d965f53de82c37390aedeb0e6 100644 --- a/Sample/StandardSamples/CoreShellParticleBuilder.h +++ b/Sample/StandardSamples/CoreShellParticleBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: Core Shell Nanoparticles (IsGISAXS example #11). //! @ingroup standard_samples -class CoreShellParticleBuilder : public ISampleBuilder -{ +class CoreShellParticleBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -29,8 +28,7 @@ public: //! Rotation and translation of core shell box particle in 3 layers system. //! @ingroup standard_samples -class CoreShellBoxRotateZandYBuilder : public ISampleBuilder -{ +class CoreShellBoxRotateZandYBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/CustomMorphologyBuilder.cpp b/Sample/StandardSamples/CustomMorphologyBuilder.cpp index d799f577d1435dd76874fe9ef959b2007a7b6bcb..f8622615bd81e1cdda68a8b10d0f970a338fa98c 100644 --- a/Sample/StandardSamples/CustomMorphologyBuilder.cpp +++ b/Sample/StandardSamples/CustomMorphologyBuilder.cpp @@ -21,8 +21,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* CustomMorphologyBuilder::buildSample() const -{ +MultiLayer* CustomMorphologyBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); ParticleLayout particle_layout; diff --git a/Sample/StandardSamples/CustomMorphologyBuilder.h b/Sample/StandardSamples/CustomMorphologyBuilder.h index 158555334506c33e9c66c7ff5dbf7f8642e6c6e3..0e6b2f3f0e9251f83b0937e6f49b449a4d4bc5ac 100644 --- a/Sample/StandardSamples/CustomMorphologyBuilder.h +++ b/Sample/StandardSamples/CustomMorphologyBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: mixture of different particles (IsGISAXS example #7). //! @ingroup standard_samples -class CustomMorphologyBuilder : public ISampleBuilder -{ +class CustomMorphologyBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/CylindersAndPrismsBuilder.cpp b/Sample/StandardSamples/CylindersAndPrismsBuilder.cpp index 40b96e8b42995de3ead1f65f86b97e039d31ae2a..33659c04aa0c01b25e5148527b123115ffdac3b8 100644 --- a/Sample/StandardSamples/CylindersAndPrismsBuilder.cpp +++ b/Sample/StandardSamples/CylindersAndPrismsBuilder.cpp @@ -22,8 +22,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* CylindersAndPrismsBuilder::buildSample() const -{ +MultiLayer* CylindersAndPrismsBuilder::buildSample() const { MultiLayer* multi_layer = new MultiLayer(); Layer vacuum_layer(refMat::Vacuum); diff --git a/Sample/StandardSamples/CylindersAndPrismsBuilder.h b/Sample/StandardSamples/CylindersAndPrismsBuilder.h index 69d730d751b48dfbde32c86a89124361274da50d..58b0d0a7c87cf5e7a98f49ca7ea7dc32ecc91a86 100644 --- a/Sample/StandardSamples/CylindersAndPrismsBuilder.h +++ b/Sample/StandardSamples/CylindersAndPrismsBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: mixture of cylinders and prisms without interference (IsGISAXS example #1). //! @ingroup standard_samples -class CylindersAndPrismsBuilder : public ISampleBuilder -{ +class CylindersAndPrismsBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/CylindersBuilder.cpp b/Sample/StandardSamples/CylindersBuilder.cpp index 0603bb9d9204ef014e69c10f488d34a49f3261d1..3d928abadf7ef4980a73bcbf03bacf1b1420d94d 100644 --- a/Sample/StandardSamples/CylindersBuilder.cpp +++ b/Sample/StandardSamples/CylindersBuilder.cpp @@ -25,12 +25,10 @@ // ----------------------------------------------------------------------------- // Cylinders in DWBA // ----------------------------------------------------------------------------- -CylindersInDWBABuilder::CylindersInDWBABuilder() : m_height(5 * Units::nm), m_radius(5 * Units::nm) -{ -} +CylindersInDWBABuilder::CylindersInDWBABuilder() + : m_height(5 * Units::nm), m_radius(5 * Units::nm) {} -MultiLayer* CylindersInDWBABuilder::buildSample() const -{ +MultiLayer* CylindersInDWBABuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); @@ -50,14 +48,12 @@ MultiLayer* CylindersInDWBABuilder::buildSample() const // ----------------------------------------------------------------------------- // Cylinders in BA // ----------------------------------------------------------------------------- -CylindersInBABuilder::CylindersInBABuilder() : m_height(5 * Units::nm), m_radius(5 * Units::nm) -{ +CylindersInBABuilder::CylindersInBABuilder() : m_height(5 * Units::nm), m_radius(5 * Units::nm) { registerParameter("height", &m_height); registerParameter("radius", &m_radius); } -MultiLayer* CylindersInBABuilder::buildSample() const -{ +MultiLayer* CylindersInBABuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); FormFactorCylinder ff_cylinder(m_radius, m_height); @@ -76,12 +72,9 @@ MultiLayer* CylindersInBABuilder::buildSample() const // Large cylinders in DWBA // ----------------------------------------------------------------------------- LargeCylindersInDWBABuilder::LargeCylindersInDWBABuilder() - : m_height(1000 * Units::nm), m_radius(500 * Units::nm) -{ -} + : m_height(1000 * Units::nm), m_radius(500 * Units::nm) {} -MultiLayer* LargeCylindersInDWBABuilder::buildSample() const -{ +MultiLayer* LargeCylindersInDWBABuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); @@ -102,12 +95,9 @@ MultiLayer* LargeCylindersInDWBABuilder::buildSample() const // Rotated cylinders in DWBA // ----------------------------------------------------------------------------- RotatedCylindersBuilder::RotatedCylindersBuilder() - : m_height(5 * Units::nm), m_radius(5 * Units::nm) -{ -} + : m_height(5 * Units::nm), m_radius(5 * Units::nm) {} -MultiLayer* RotatedCylindersBuilder::buildSample() const -{ +MultiLayer* RotatedCylindersBuilder::buildSample() const { FormFactorCylinder ff_cylinder(m_radius, m_height); Particle particle(refMat::Particle, ff_cylinder); diff --git a/Sample/StandardSamples/CylindersBuilder.h b/Sample/StandardSamples/CylindersBuilder.h index c85e2c0080ecf014ba0c35751232e0fddd16049e..f184fc37094113ce50e4c33c5a23665246d3bd70 100644 --- a/Sample/StandardSamples/CylindersBuilder.h +++ b/Sample/StandardSamples/CylindersBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: cylinder form factor in DWBA (IsGISAXS example #3, part I). //! @ingroup standard_samples -class CylindersInDWBABuilder : public ISampleBuilder -{ +class CylindersInDWBABuilder : public ISampleBuilder { public: CylindersInDWBABuilder(); MultiLayer* buildSample() const; @@ -34,8 +33,7 @@ private: //! Builds sample: cylinder form factor in BA (IsGISAXS example #3, part II). //! @ingroup standard_samples -class CylindersInBABuilder : public ISampleBuilder -{ +class CylindersInBABuilder : public ISampleBuilder { public: CylindersInBABuilder(); MultiLayer* buildSample() const; @@ -48,8 +46,7 @@ private: //! Builds sample with large cylinders for MC integration tests. //! @ingroup standard_samples -class LargeCylindersInDWBABuilder : public ISampleBuilder -{ +class LargeCylindersInDWBABuilder : public ISampleBuilder { public: LargeCylindersInDWBABuilder(); MultiLayer* buildSample() const; @@ -62,8 +59,7 @@ private: //! Builds sample: cylinder form factor in DWBA (IsGISAXS example #3, part I). //! @ingroup standard_samples -class RotatedCylindersBuilder : public ISampleBuilder -{ +class RotatedCylindersBuilder : public ISampleBuilder { public: RotatedCylindersBuilder(); MultiLayer* buildSample() const; diff --git a/Sample/StandardSamples/FeNiBilayerBuilder.cpp b/Sample/StandardSamples/FeNiBilayerBuilder.cpp index a48499a0faec34e8da14bec52b255231cdaad5ff..b229adf7076d6e4119f1618014430c704bda327a 100644 --- a/Sample/StandardSamples/FeNiBilayerBuilder.cpp +++ b/Sample/StandardSamples/FeNiBilayerBuilder.cpp @@ -21,13 +21,11 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/Slice/LayerRoughness.h" -namespace -{ +namespace { auto constexpr rhoMconst = -PhysConsts::m_n * PhysConsts::g_factor_n * PhysConsts::mu_N / PhysConsts::h_bar / PhysConsts::h_bar * 1e-27; -class Options -{ +class Options { public: int _NBilayers = 4; double _angle = 0.; @@ -39,51 +37,42 @@ public: RoughnessModel _roughnessModel = RoughnessModel::TANH; Options() {} - Options NBilayers(int n) - { + Options NBilayers(int n) { _NBilayers = n; return *this; } - Options angle(double angle) - { + Options angle(double angle) { _angle = angle; return *this; } - Options magnetizationMagnitude(double M) - { + Options magnetizationMagnitude(double M) { _magnetizationMagnitude = M; return *this; } - Options thicknessFe(double t) - { + Options thicknessFe(double t) { _thicknessFe = t; return *this; } - Options thicknessNi(double t) - { + Options thicknessNi(double t) { _thicknessNi = t; return *this; } - Options sigmaRoughness(double r) - { + Options sigmaRoughness(double r) { _sigmaRoughness = r; return *this; } - Options effectiveSLD(int i) - { + Options effectiveSLD(int i) { _effectiveSLD = i; return *this; } - Options roughnessModel(RoughnessModel rm) - { + Options roughnessModel(RoughnessModel rm) { _roughnessModel = rm; return *this; } }; //! Creates the sample demonstrating an Fe-Ni Bilayer with and without roughness //! @ingroup standard_samples -class FeNiBilayer -{ +class FeNiBilayer { public: FeNiBilayer(Options opt = {}) : NBilayers(opt._NBilayers) @@ -93,8 +82,7 @@ public: , thicknessNi(opt._thicknessNi) , sigmaRoughness(opt._sigmaRoughness) , effectiveSLD(opt._effectiveSLD) - , roughnessModel(opt._roughnessModel) - { + , roughnessModel(opt._roughnessModel) { if (angle != 0. && effectiveSLD != 0.) throw std::runtime_error("Cannot perform scalar computation " "for non-colinear magnetization"); @@ -133,8 +121,7 @@ const complex_t FeNiBilayer::sldFe; const complex_t FeNiBilayer::sldAu; const complex_t FeNiBilayer::sldNi; -std::unique_ptr<MultiLayer> FeNiBilayer::constructSample() -{ +std::unique_ptr<MultiLayer> FeNiBilayer::constructSample() { auto sample = std::make_unique<MultiLayer>(); auto m_ambient = MaterialBySLD("Ambient", 0.0, 0.0); @@ -163,34 +150,29 @@ std::unique_ptr<MultiLayer> FeNiBilayer::constructSample() return sample; } -MultiLayer* FeNiBilayerBuilder::buildSample() const -{ +MultiLayer* FeNiBilayerBuilder::buildSample() const { auto sample = FeNiBilayer{Options()}; return sample.release(); } -MultiLayer* FeNiBilayerTanhBuilder::buildSample() const -{ +MultiLayer* FeNiBilayerTanhBuilder::buildSample() const { auto sample = FeNiBilayer{ Options().sigmaRoughness(2. * Units::angstrom).roughnessModel(RoughnessModel::TANH)}; return sample.release(); } -MultiLayer* FeNiBilayerNCBuilder::buildSample() const -{ +MultiLayer* FeNiBilayerNCBuilder::buildSample() const { auto sample = FeNiBilayer{ Options().sigmaRoughness(2. * Units::angstrom).roughnessModel(RoughnessModel::NEVOT_CROCE)}; return sample.release(); } -MultiLayer* FeNiBilayerSpinFlipBuilder::buildSample() const -{ +MultiLayer* FeNiBilayerSpinFlipBuilder::buildSample() const { auto sample = FeNiBilayer{Options().angle(38. * Units::deg)}; return sample.release(); } -MultiLayer* FeNiBilayerSpinFlipTanhBuilder::buildSample() const -{ +MultiLayer* FeNiBilayerSpinFlipTanhBuilder::buildSample() const { auto sample = FeNiBilayer{Options() .angle(38 * Units::deg) .sigmaRoughness(2. * Units::angstrom) @@ -198,8 +180,7 @@ MultiLayer* FeNiBilayerSpinFlipTanhBuilder::buildSample() const return sample.release(); } -MultiLayer* FeNiBilayerSpinFlipNCBuilder::buildSample() const -{ +MultiLayer* FeNiBilayerSpinFlipNCBuilder::buildSample() const { auto sample = FeNiBilayer{Options() .angle(38 * Units::deg) .sigmaRoughness(2. * Units::angstrom) diff --git a/Sample/StandardSamples/FeNiBilayerBuilder.h b/Sample/StandardSamples/FeNiBilayerBuilder.h index f2b087988ed5a545bdb3059663ad0000919f5358..dead27269ba56a9cb58c35294e7afcf116f14aa8 100644 --- a/Sample/StandardSamples/FeNiBilayerBuilder.h +++ b/Sample/StandardSamples/FeNiBilayerBuilder.h @@ -18,38 +18,32 @@ #include "Sample/SampleBuilderEngine/ISampleBuilder.h" -class FeNiBilayerBuilder : public ISampleBuilder -{ +class FeNiBilayerBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; -class FeNiBilayerTanhBuilder : public ISampleBuilder -{ +class FeNiBilayerTanhBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; -class FeNiBilayerNCBuilder : public ISampleBuilder -{ +class FeNiBilayerNCBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; -class FeNiBilayerSpinFlipBuilder : public ISampleBuilder -{ +class FeNiBilayerSpinFlipBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; -class FeNiBilayerSpinFlipTanhBuilder : public ISampleBuilder -{ +class FeNiBilayerSpinFlipTanhBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; -class FeNiBilayerSpinFlipNCBuilder : public ISampleBuilder -{ +class FeNiBilayerSpinFlipNCBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/HomogeneousMultilayerBuilder.cpp b/Sample/StandardSamples/HomogeneousMultilayerBuilder.cpp index 499e07ad59cd259cd1e18a9f2e7baf6f6d9e6531..9e1409f92b9f11daea1fa42ab300e975a1e1a28a 100644 --- a/Sample/StandardSamples/HomogeneousMultilayerBuilder.cpp +++ b/Sample/StandardSamples/HomogeneousMultilayerBuilder.cpp @@ -17,8 +17,7 @@ #include "Sample/Multilayer/Layer.h" #include "Sample/Multilayer/MultiLayer.h" -MultiLayer* HomogeneousMultilayerBuilder::buildSample() const -{ +MultiLayer* HomogeneousMultilayerBuilder::buildSample() const { const size_t number_of_layers = 10; const double delta_ti = -7.36e-7; const double delta_ni = 3.557e-6; diff --git a/Sample/StandardSamples/HomogeneousMultilayerBuilder.h b/Sample/StandardSamples/HomogeneousMultilayerBuilder.h index 2e8b54c5f36827ab8e94e1c8b846b7e21c72ed2a..09ee0e6dd258b7600132c4b862c4afe279cc2316 100644 --- a/Sample/StandardSamples/HomogeneousMultilayerBuilder.h +++ b/Sample/StandardSamples/HomogeneousMultilayerBuilder.h @@ -22,8 +22,7 @@ //! No absorption, no roughness, target wavelength is 1.54 angstroms. //! @ingroup standard_samples -class HomogeneousMultilayerBuilder : public ISampleBuilder -{ +class HomogeneousMultilayerBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/LatticeBuilder.cpp b/Sample/StandardSamples/LatticeBuilder.cpp index 8863c7738b7cc254379d969255412a04638fe907..13d29f82b88b3e320976148677efbbbc42a0a6c1 100644 --- a/Sample/StandardSamples/LatticeBuilder.cpp +++ b/Sample/StandardSamples/LatticeBuilder.cpp @@ -24,8 +24,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* Lattice1DBuilder::buildSample() const -{ +MultiLayer* Lattice1DBuilder::buildSample() const { const double length(20.0 * Units::nm); const double xi(10.0 * Units::deg); const double corr_length(1000.0 * Units::nm); diff --git a/Sample/StandardSamples/LatticeBuilder.h b/Sample/StandardSamples/LatticeBuilder.h index 140a47902165a7802babb370788da3888c0a03ff..bf0e947636c352a7350a9d447bb52c6ec07ca141 100644 --- a/Sample/StandardSamples/LatticeBuilder.h +++ b/Sample/StandardSamples/LatticeBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: cylinders with 1DDL structure factor. //! @ingroup standard_samples -class Lattice1DBuilder : public ISampleBuilder -{ +class Lattice1DBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/LayersWithAbsorptionBuilder.cpp b/Sample/StandardSamples/LayersWithAbsorptionBuilder.cpp index cff3e1209622df6483cbf8005facc40fc5f68c18..4d60ebbbbf5818bfb2266f1ad1ec5567d559120f 100644 --- a/Sample/StandardSamples/LayersWithAbsorptionBuilder.cpp +++ b/Sample/StandardSamples/LayersWithAbsorptionBuilder.cpp @@ -23,22 +23,18 @@ #include "Sample/Slice/LayerInterface.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -namespace -{ +namespace { static const FormFactorComponents ff_components; } // namespace LayersWithAbsorptionBuilder::LayersWithAbsorptionBuilder() - : m_ff(new FormFactorFullSphere(5.0 * Units::nm)) -{ -} + : m_ff(new FormFactorFullSphere(5.0 * Units::nm)) {} LayersWithAbsorptionBuilder::~LayersWithAbsorptionBuilder() = default; -MultiLayer* LayersWithAbsorptionBuilder::buildSample() const -{ +MultiLayer* LayersWithAbsorptionBuilder::buildSample() const { const double middle_layer_thickness(60.0 * Units::nm); Particle particle(refMat::Ag, *m_ff); @@ -63,15 +59,13 @@ MultiLayer* LayersWithAbsorptionBuilder::buildSample() const return multi_layer; } -MultiLayer* LayersWithAbsorptionBuilder::createSampleByIndex(size_t index) -{ +MultiLayer* LayersWithAbsorptionBuilder::createSampleByIndex(size_t index) { const std::string name = ff_components.keys().at(index); m_ff.reset(ff_components.getItem(name)->clone()); setName(name); return buildSample(); } -size_t LayersWithAbsorptionBuilder::size() -{ +size_t LayersWithAbsorptionBuilder::size() { return ff_components.size(); } diff --git a/Sample/StandardSamples/LayersWithAbsorptionBuilder.h b/Sample/StandardSamples/LayersWithAbsorptionBuilder.h index f43a2a8d84b06fb2af8e593206338044f6da456a..508cc4bc5a79c515ef0c54aeec2db739bcd5470c 100644 --- a/Sample/StandardSamples/LayersWithAbsorptionBuilder.h +++ b/Sample/StandardSamples/LayersWithAbsorptionBuilder.h @@ -27,8 +27,7 @@ class IFormFactor; //! The middle layer is populated with particles. //! Requires IComponentService which generates form factors, used for bulk form factors testing. -class LayersWithAbsorptionBuilder : public ISampleBuilder -{ +class LayersWithAbsorptionBuilder : public ISampleBuilder { public: LayersWithAbsorptionBuilder(); ~LayersWithAbsorptionBuilder(); diff --git a/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.cpp b/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.cpp index 7ca385d738087fe0826243ae44f7deba45e08266..42fb99bd7a0f3b0512b8ed32b41dba710227bab8 100644 --- a/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.cpp +++ b/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.cpp @@ -23,8 +23,7 @@ const double middle_layer_thickness(60.0 * Units::nm); -MultiLayer* LayersWithAbsorptionBySLDBuilder::buildSample() const -{ +MultiLayer* LayersWithAbsorptionBySLDBuilder::buildSample() const { Material ambience_mat = MaterialBySLD("Vacuum", 0.0, 0.0); Material middle_mat = MaterialBySLD("Teflon", 4.7573e-6, 1.6724e-12); Material substrate_mat = MaterialBySLD("Substrate", 2.0728e-06, 2.3747e-11); diff --git a/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h b/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h index 41bcb673092750804b73d7b991cec4b8ca38753f..8b6bc1796c545753ae116b706df55e66ca65a403 100644 --- a/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h +++ b/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h @@ -22,8 +22,7 @@ //! particles. MaterialBySLD is used to generate maaterials //! @ingroup standard_samples -class LayersWithAbsorptionBySLDBuilder : public ISampleBuilder -{ +class LayersWithAbsorptionBySLDBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/MagneticLayersBuilder.cpp b/Sample/StandardSamples/MagneticLayersBuilder.cpp index 7e4527a26c0c912fa654efe0b330f0f157ae6b65..7c55ca0ad66bf0580410a583ef492ee301871a06 100644 --- a/Sample/StandardSamples/MagneticLayersBuilder.cpp +++ b/Sample/StandardSamples/MagneticLayersBuilder.cpp @@ -23,13 +23,11 @@ #include "Sample/Particle/Particle.h" #include "Sample/Slice/LayerRoughness.h" -namespace -{ +namespace { const double sphere_radius = 5 * Units::nm; -MultiLayer* parametricBuild(double sigmaRoughness, RoughnessModel roughnessModel) -{ +MultiLayer* parametricBuild(double sigmaRoughness, RoughnessModel roughnessModel) { MultiLayer* multi_layer = new MultiLayer(); kvector_t substr_field = kvector_t(0.0, 1e6, 0.0); @@ -53,8 +51,7 @@ MultiLayer* parametricBuild(double sigmaRoughness, RoughnessModel roughnessModel } // namespace -MultiLayer* MagneticSubstrateZeroFieldBuilder::buildSample() const -{ +MultiLayer* MagneticSubstrateZeroFieldBuilder::buildSample() const { kvector_t substr_field(0.0, 0.0, 0.0); kvector_t particle_field(0.1, 0.0, 0.0); Material vacuum_material = HomogeneousMaterial("Vacuum", 0.0, 0.0); @@ -77,8 +74,7 @@ MultiLayer* MagneticSubstrateZeroFieldBuilder::buildSample() const return multi_layer; } -MultiLayer* SimpleMagneticLayerBuilder::buildSample() const -{ +MultiLayer* SimpleMagneticLayerBuilder::buildSample() const { MultiLayer* multi_layer = new MultiLayer(); kvector_t layer_field = kvector_t(0.0, 1e8, 0.0); @@ -96,8 +92,7 @@ MultiLayer* SimpleMagneticLayerBuilder::buildSample() const return multi_layer; } -MultiLayer* MagneticLayerBuilder::buildSample() const -{ +MultiLayer* MagneticLayerBuilder::buildSample() const { MultiLayer* multi_layer = new MultiLayer(); kvector_t layer_field = kvector_t(0.0, 0.0, 1e6); @@ -123,18 +118,15 @@ MultiLayer* MagneticLayerBuilder::buildSample() const return multi_layer; } -MultiLayer* SimpleMagneticRotationBuilder::buildSample() const -{ +MultiLayer* SimpleMagneticRotationBuilder::buildSample() const { return parametricBuild(0., RoughnessModel::TANH); } -size_t SimpleMagneticRotationBuilder::size() -{ +size_t SimpleMagneticRotationBuilder::size() { return 3; } -MultiLayer* SimpleMagneticRotationBuilder::createSampleByIndex(size_t index) -{ +MultiLayer* SimpleMagneticRotationBuilder::createSampleByIndex(size_t index) { switch (index) { case 0: @@ -153,8 +145,7 @@ MultiLayer* SimpleMagneticRotationBuilder::createSampleByIndex(size_t index) } } -MultiLayer* MagneticRotationBuilder::buildSample() const -{ +MultiLayer* MagneticRotationBuilder::buildSample() const { MultiLayer* multi_layer = new MultiLayer(); kvector_t substr_field = kvector_t(0.0, 1e6, 0.0); diff --git a/Sample/StandardSamples/MagneticLayersBuilder.h b/Sample/StandardSamples/MagneticLayersBuilder.h index e7b38d44d3519fb2279508badbf8314401ccf651..77c0b1ed9d46ebf829cc483ed49e7faa1214759a 100644 --- a/Sample/StandardSamples/MagneticLayersBuilder.h +++ b/Sample/StandardSamples/MagneticLayersBuilder.h @@ -21,8 +21,7 @@ //! Builds sample: spheres in substrate layer with a zero magnetic field. //! @ingroup standard_samples -class MagneticSubstrateZeroFieldBuilder : public ISampleBuilder -{ +class MagneticSubstrateZeroFieldBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -30,8 +29,7 @@ public: //! Builds sample: ambient and one magnetized layer on a non-magnetized substrate. //! @ingroup standard_samples -class SimpleMagneticLayerBuilder : public ISampleBuilder -{ +class SimpleMagneticLayerBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -39,8 +37,7 @@ public: //! Builds sample: magnetic spheres in a magnetized layer on a non-magnetized substrate. //! @ingroup standard_samples -class MagneticLayerBuilder : public ISampleBuilder -{ +class MagneticLayerBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -48,8 +45,7 @@ public: //! Builds sample: magnetic layer on a magnetic substrate with the fields rotated by 90° //! @ingroup standard_samples -class SimpleMagneticRotationBuilder : public ISampleBuilder -{ +class SimpleMagneticRotationBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const override; @@ -60,8 +56,7 @@ public: //! Builds sample: rotated magnetic spheres in substrate layer with a unit magnetic field. //! @ingroup standard_samples -class MagneticRotationBuilder : public ISampleBuilder -{ +class MagneticRotationBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/MagneticParticlesBuilder.cpp b/Sample/StandardSamples/MagneticParticlesBuilder.cpp index 9e9cc051abcb25677aebe7ec78c51e0118b01a00..7236c151dffb92c3d3babe989ca3f70932bf3e55 100644 --- a/Sample/StandardSamples/MagneticParticlesBuilder.cpp +++ b/Sample/StandardSamples/MagneticParticlesBuilder.cpp @@ -28,8 +28,7 @@ // Magnetic cylinders and zero magnetic field // ---------------------------------------------------------------------------- -MultiLayer* MagneticParticleZeroFieldBuilder::buildSample() const -{ +MultiLayer* MagneticParticleZeroFieldBuilder::buildSample() const { const double m_cylinder_radius(5 * Units::nm); const double m_cylinder_height(5 * Units::nm); @@ -58,8 +57,7 @@ MultiLayer* MagneticParticleZeroFieldBuilder::buildSample() const // Magnetic cylinders and non-zero magnetization // ---------------------------------------------------------------------------- -MultiLayer* MagneticCylindersBuilder::buildSample() const -{ +MultiLayer* MagneticCylindersBuilder::buildSample() const { const double m_cylinder_radius(5 * Units::nm); const double m_cylinder_height(5 * Units::nm); @@ -88,8 +86,7 @@ MultiLayer* MagneticCylindersBuilder::buildSample() const // Magnetic spheres inside substrate // ---------------------------------------------------------------------------- -MultiLayer* MagneticSpheresBuilder::buildSample() const -{ +MultiLayer* MagneticSpheresBuilder::buildSample() const { const double m_sphere_radius(5 * Units::nm); kvector_t magnetization(0.0, 0.0, 1e7); diff --git a/Sample/StandardSamples/MagneticParticlesBuilder.h b/Sample/StandardSamples/MagneticParticlesBuilder.h index dcf35e6e2b97e3d2d6de879c1ea0f465b1bbed80..73fcce62a8be4f2cfeed091cf3a6a73e9c381001 100644 --- a/Sample/StandardSamples/MagneticParticlesBuilder.h +++ b/Sample/StandardSamples/MagneticParticlesBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: cylinders with magnetic material and zero magnetic field. //! @ingroup standard_samples -class MagneticParticleZeroFieldBuilder : public ISampleBuilder -{ +class MagneticParticleZeroFieldBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -29,8 +28,7 @@ public: //! Builds sample: cylinders with magnetic material and non-zero magnetic field. //! @ingroup standard_samples -class MagneticCylindersBuilder : public ISampleBuilder -{ +class MagneticCylindersBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -38,8 +36,7 @@ public: //! Builds sample: spheres with magnetization inside substrate. //! @ingroup standard_samples -class MagneticSpheresBuilder : public ISampleBuilder -{ +class MagneticSpheresBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/MesoCrystalBuilder.cpp b/Sample/StandardSamples/MesoCrystalBuilder.cpp index 2311127677da3e7578baf735220d2cf1652c9523..8acd8bf4cc99243ea1143d649b37278b5599cce7 100644 --- a/Sample/StandardSamples/MesoCrystalBuilder.cpp +++ b/Sample/StandardSamples/MesoCrystalBuilder.cpp @@ -24,8 +24,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* MesoCrystalBuilder::buildSample() const -{ +MultiLayer* MesoCrystalBuilder::buildSample() const { // mesocrystal lattice kvector_t lattice_basis_a(5.0, 0.0, 0.0); kvector_t lattice_basis_b(0.0, 5.0, 0.0); diff --git a/Sample/StandardSamples/MesoCrystalBuilder.h b/Sample/StandardSamples/MesoCrystalBuilder.h index 80ca5cd77cfe6e31e79aee4f97059c2afec55e03..d5ea4154645900ca1f2170953333715e6acdc7fa 100644 --- a/Sample/StandardSamples/MesoCrystalBuilder.h +++ b/Sample/StandardSamples/MesoCrystalBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: cylindrical mesocrystal composed of spheres in a cubic lattice. //! @ingroup standard_samples -class MesoCrystalBuilder : public ISampleBuilder -{ +class MesoCrystalBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp b/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp index b3dacc8f880784d34cba2e38545002bae7238291..6fd668ff5ae3ac02f27406d6a742c13585fbca45 100644 --- a/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp +++ b/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp @@ -16,8 +16,7 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/Slice/LayerRoughness.h" -MultiLayer* MultiLayerWithNCRoughnessBuilder::buildSample() const -{ +MultiLayer* MultiLayerWithNCRoughnessBuilder::buildSample() const { auto multi_layer = MultiLayerWithRoughnessBuilder::buildSample(); multi_layer->setRoughnessModel(RoughnessModel::NEVOT_CROCE); return multi_layer; diff --git a/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.h b/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.h index b5cd2e3ca81ab753357c420f498891e1d69066ca..1ff76cec240171fd86a9cc1f255db8eff6c59ef2 100644 --- a/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.h +++ b/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: layers with correlated roughness. //! @ingroup standard_samples -class MultiLayerWithNCRoughnessBuilder : public MultiLayerWithRoughnessBuilder -{ +class MultiLayerWithNCRoughnessBuilder : public MultiLayerWithRoughnessBuilder { public: MultiLayer* buildSample() const override; }; diff --git a/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.cpp b/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.cpp index 3446e743fdc68e07760136518efa6e702fa065e7..86e9b38724465da43f1cb0cf33c7fa47b1762b8d 100644 --- a/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.cpp +++ b/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.cpp @@ -19,8 +19,7 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/Slice/LayerRoughness.h" -MultiLayer* MultiLayerWithRoughnessBuilder::buildSample() const -{ +MultiLayer* MultiLayerWithRoughnessBuilder::buildSample() const { const double thicknessA(2.5 * Units::nm); const double thicknessB(5.0 * Units::nm); const double sigma(1.0 * Units::nm); diff --git a/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.h b/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.h index a0ae30bd4d362c694c2320f5d9a5018a4e2cd3c7..fdc7fa55b2a5d3f242889a9f0522d02b281eff6d 100644 --- a/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.h +++ b/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: layers with correlated roughness. //! @ingroup standard_samples -class MultiLayerWithRoughnessBuilder : public ISampleBuilder -{ +class MultiLayerWithRoughnessBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/MultipleLayoutBuilder.cpp b/Sample/StandardSamples/MultipleLayoutBuilder.cpp index 5de1c446e5dcfc04ea8b2295101557e536a537ff..e382c027aa7103455b3e0e5d8df57e4c96f49e45 100644 --- a/Sample/StandardSamples/MultipleLayoutBuilder.cpp +++ b/Sample/StandardSamples/MultipleLayoutBuilder.cpp @@ -22,8 +22,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* MultipleLayoutBuilder::buildSample() const -{ +MultiLayer* MultipleLayoutBuilder::buildSample() const { const double cylinder_height(5 * Units::nm); const double cylinder_radius(5 * Units::nm); const double prisheight(5 * Units::nm); diff --git a/Sample/StandardSamples/MultipleLayoutBuilder.h b/Sample/StandardSamples/MultipleLayoutBuilder.h index 144a99c6f48107dbd4ca29275d2d2fa4298520a7..c4d3068b7ba74325d495bfdc2950959cb527cca1 100644 --- a/Sample/StandardSamples/MultipleLayoutBuilder.h +++ b/Sample/StandardSamples/MultipleLayoutBuilder.h @@ -21,8 +21,7 @@ //! using multiple particle layouts //! @ingroup standard_samples -class MultipleLayoutBuilder : public ISampleBuilder -{ +class MultipleLayoutBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/ParaCrystalBuilder.cpp b/Sample/StandardSamples/ParaCrystalBuilder.cpp index e6e87df022096e18516569625c25e2aa43f9184c..2d90b8d3e7f88569cdf68f8941c62bfce8b2ba3c 100644 --- a/Sample/StandardSamples/ParaCrystalBuilder.cpp +++ b/Sample/StandardSamples/ParaCrystalBuilder.cpp @@ -25,8 +25,7 @@ #include "Sample/SampleBuilderEngine/SampleComponents.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* RadialParaCrystalBuilder::buildSample() const -{ +MultiLayer* RadialParaCrystalBuilder::buildSample() const { const double m_corr_peak_distance(20.0 * Units::nm); const double m_corr_width(7 * Units::nm); const double m_corr_length(1e3 * Units::nm); @@ -59,14 +58,11 @@ MultiLayer* RadialParaCrystalBuilder::buildSample() const Basic2DParaCrystalBuilder::Basic2DParaCrystalBuilder() : m_pdf1(new FTDistribution2DCauchy(0.1 * Units::nm, 0.2 * Units::nm, 0)) - , m_pdf2(new FTDistribution2DCauchy(0.3 * Units::nm, 0.4 * Units::nm, 0)) -{ -} + , m_pdf2(new FTDistribution2DCauchy(0.3 * Units::nm, 0.4 * Units::nm, 0)) {} Basic2DParaCrystalBuilder::~Basic2DParaCrystalBuilder() = default; -MultiLayer* Basic2DParaCrystalBuilder::buildSample() const -{ +MultiLayer* Basic2DParaCrystalBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); @@ -90,8 +86,7 @@ MultiLayer* Basic2DParaCrystalBuilder::buildSample() const return multi_layer; } -MultiLayer* Basic2DParaCrystalBuilder::createSampleByIndex(size_t index) -{ +MultiLayer* Basic2DParaCrystalBuilder::createSampleByIndex(size_t index) { ASSERT(index < FTDistribution2DComponents().size()); auto names = FTDistribution2DComponents().keys(); @@ -106,8 +101,7 @@ MultiLayer* Basic2DParaCrystalBuilder::createSampleByIndex(size_t index) // HexParaCrystalBuilder // ----------------------------------------------------------------------------- -MultiLayer* HexParaCrystalBuilder::buildSample() const -{ +MultiLayer* HexParaCrystalBuilder::buildSample() const { const double m_peak_distance(20.0 * Units::nm); const double m_corr_length(0.0); const double m_domain_size_1(20.0 * Units::micrometer); @@ -142,8 +136,7 @@ MultiLayer* HexParaCrystalBuilder::buildSample() const // RectParaCrystalBuilder // ----------------------------------------------------------------------------- -MultiLayer* RectParaCrystalBuilder::buildSample() const -{ +MultiLayer* RectParaCrystalBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); diff --git a/Sample/StandardSamples/ParaCrystalBuilder.h b/Sample/StandardSamples/ParaCrystalBuilder.h index 6a045c826efd21ecdf3f8a6e1035bd2ec5feb2c5..4ab0938a10f96908f19ffadc100f176bdce02872 100644 --- a/Sample/StandardSamples/ParaCrystalBuilder.h +++ b/Sample/StandardSamples/ParaCrystalBuilder.h @@ -24,8 +24,7 @@ class FTDistribution2DComponents; //! @ingroup standard_samples //! Builds sample: cylinders with 1DDL structure factor (IsGISAXS example #4). -class RadialParaCrystalBuilder : public ISampleBuilder -{ +class RadialParaCrystalBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -34,8 +33,7 @@ public: //! distribution functions (PDF's). They are initialized via component service. //! @ingroup standard_samples -class Basic2DParaCrystalBuilder : public ISampleBuilder -{ +class Basic2DParaCrystalBuilder : public ISampleBuilder { public: Basic2DParaCrystalBuilder(); ~Basic2DParaCrystalBuilder(); @@ -51,8 +49,7 @@ private: //! Builds sample: cylinders with 2DDL structure factor (IsGISAXS example #4). //! @ingroup standard_samples -class HexParaCrystalBuilder : public ISampleBuilder -{ +class HexParaCrystalBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -60,8 +57,7 @@ public: //! @ingroup standard_samples //! Builds sample: 2D paracrystal lattice (IsGISAXS example #8). -class RectParaCrystalBuilder : public ISampleBuilder -{ +class RectParaCrystalBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/ParticleCompositionBuilder.cpp b/Sample/StandardSamples/ParticleCompositionBuilder.cpp index 801829461cf6bbbce64a7882a5afa8f27459b888..f56541e89ebe2c974a66b70f881f3a9543345074 100644 --- a/Sample/StandardSamples/ParticleCompositionBuilder.cpp +++ b/Sample/StandardSamples/ParticleCompositionBuilder.cpp @@ -25,8 +25,7 @@ // --- ParticleCompositionBuilder --- -MultiLayer* ParticleCompositionBuilder::buildSample() const -{ +MultiLayer* ParticleCompositionBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); diff --git a/Sample/StandardSamples/ParticleCompositionBuilder.h b/Sample/StandardSamples/ParticleCompositionBuilder.h index ae4b4d831cf7bf0151957e62ea66f2bad7f401dd..af864965bd14850abbf8ecdad95e299684d2d0f9 100644 --- a/Sample/StandardSamples/ParticleCompositionBuilder.h +++ b/Sample/StandardSamples/ParticleCompositionBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: two layers of spheres at hex lattice. //! @ingroup standard_samples -class ParticleCompositionBuilder : public ISampleBuilder -{ +class ParticleCompositionBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/ParticleDistributionsBuilder.cpp b/Sample/StandardSamples/ParticleDistributionsBuilder.cpp index 444beea44e2e20f0f936b290f214ff6811d800f3..8691b7e3f68ea7cb1d80ad370fe532006f5a2cef 100644 --- a/Sample/StandardSamples/ParticleDistributionsBuilder.cpp +++ b/Sample/StandardSamples/ParticleDistributionsBuilder.cpp @@ -28,8 +28,7 @@ #include "Sample/Particle/ParticleDistribution.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* CylindersWithSizeDistributionBuilder::buildSample() const -{ +MultiLayer* CylindersWithSizeDistributionBuilder::buildSample() const { const double height(5 * Units::nm); const double radius(5 * Units::nm); @@ -69,12 +68,9 @@ TwoTypesCylindersDistributionBuilder::TwoTypesCylindersDistributionBuilder() , m_height1(5 * Units::nm) , m_height2(10 * Units::nm) , m_sigma1_ratio(0.2) - , m_sigma2_ratio(0.02) -{ -} + , m_sigma2_ratio(0.02) {} -MultiLayer* TwoTypesCylindersDistributionBuilder::buildSample() const -{ +MultiLayer* TwoTypesCylindersDistributionBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); ParticleLayout particle_layout; @@ -121,12 +117,9 @@ RotatedPyramidsDistributionBuilder::RotatedPyramidsDistributionBuilder() : m_length(10 * Units::nm) , m_height(5 * Units::nm) , m_alpha(Units::deg2rad(54.73)) - , m_zangle(45. * Units::deg) -{ -} + , m_zangle(45. * Units::deg) {} -MultiLayer* RotatedPyramidsDistributionBuilder::buildSample() const -{ +MultiLayer* RotatedPyramidsDistributionBuilder::buildSample() const { // particle FormFactorPyramid ff_pyramid(m_length, m_height, m_alpha); Particle pyramid(refMat::Particle, ff_pyramid); @@ -155,8 +148,7 @@ MultiLayer* RotatedPyramidsDistributionBuilder::buildSample() const // ---------------------------------------------------------------------------- -MultiLayer* SpheresWithLimitsDistributionBuilder::buildSample() const -{ +MultiLayer* SpheresWithLimitsDistributionBuilder::buildSample() const { // particle FormFactorFullSphere ff(3.0 * Units::nm); Particle sphere(refMat::Particle, ff); @@ -186,8 +178,7 @@ MultiLayer* SpheresWithLimitsDistributionBuilder::buildSample() const // ---------------------------------------------------------------------------- -MultiLayer* ConesWithLimitsDistributionBuilder::buildSample() const -{ +MultiLayer* ConesWithLimitsDistributionBuilder::buildSample() const { // particle FormFactorCone ff(10.0 * Units::nm, 13.0 * Units::nm, 60.0 * Units::deg); Particle cone(refMat::Particle, ff); @@ -215,8 +206,7 @@ MultiLayer* ConesWithLimitsDistributionBuilder::buildSample() const return multi_layer; } -MultiLayer* LinkedBoxDistributionBuilder::buildSample() const -{ +MultiLayer* LinkedBoxDistributionBuilder::buildSample() const { // particle FormFactorBox ff(40.0 * Units::nm, 30.0 * Units::nm, 10.0 * Units::nm); Particle box(refMat::Particle, ff); diff --git a/Sample/StandardSamples/ParticleDistributionsBuilder.h b/Sample/StandardSamples/ParticleDistributionsBuilder.h index f59fb53d4277eed698dc5f2f8cc82e2e29fcbe54..773503afe9ceab31b594610a05d7750d1277dee6 100644 --- a/Sample/StandardSamples/ParticleDistributionsBuilder.h +++ b/Sample/StandardSamples/ParticleDistributionsBuilder.h @@ -20,8 +20,7 @@ //! Cylinders in BA with size distributions (IsGISAXS example #3, part II). //! @ingroup standard_samples -class CylindersWithSizeDistributionBuilder : public ISampleBuilder -{ +class CylindersWithSizeDistributionBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -29,8 +28,7 @@ public: //! Builds mixture of cylinder particles with different size distribution (IsGISAXS example #2) //! @ingroup standard_samples -class TwoTypesCylindersDistributionBuilder : public ISampleBuilder -{ +class TwoTypesCylindersDistributionBuilder : public ISampleBuilder { public: TwoTypesCylindersDistributionBuilder(); MultiLayer* buildSample() const; @@ -47,8 +45,7 @@ private: //! Rotated Pyramids with the distribution applied to the rotation angle. //! @ingroup standard_samples -class RotatedPyramidsDistributionBuilder : public ISampleBuilder -{ +class RotatedPyramidsDistributionBuilder : public ISampleBuilder { public: RotatedPyramidsDistributionBuilder(); MultiLayer* buildSample() const; @@ -63,8 +60,7 @@ private: //! Spherical particles with the distribution applied to the radius and RealLimits defined. //! @ingroup standard_samples -class SpheresWithLimitsDistributionBuilder : public ISampleBuilder -{ +class SpheresWithLimitsDistributionBuilder : public ISampleBuilder { public: SpheresWithLimitsDistributionBuilder() {} MultiLayer* buildSample() const; @@ -73,8 +69,7 @@ public: //! Cones with the distribution applied to the angle and RealLimits defined. //! @ingroup standard_samples -class ConesWithLimitsDistributionBuilder : public ISampleBuilder -{ +class ConesWithLimitsDistributionBuilder : public ISampleBuilder { public: ConesWithLimitsDistributionBuilder() {} MultiLayer* buildSample() const; @@ -83,8 +78,7 @@ public: //! Distribution of boxes with main parameter and two linked parameters. //! @ingroup standard_samples -class LinkedBoxDistributionBuilder : public ISampleBuilder -{ +class LinkedBoxDistributionBuilder : public ISampleBuilder { public: LinkedBoxDistributionBuilder() = default; MultiLayer* buildSample() const; diff --git a/Sample/StandardSamples/ParticleInVacuumBuilder.cpp b/Sample/StandardSamples/ParticleInVacuumBuilder.cpp index 7255003ce542f9932b3469432ef2576435a0d50e..55aad5773f39004631c854ef65cdf732f4576519 100644 --- a/Sample/StandardSamples/ParticleInVacuumBuilder.cpp +++ b/Sample/StandardSamples/ParticleInVacuumBuilder.cpp @@ -22,17 +22,14 @@ #include "Sample/SampleBuilderEngine/SampleComponents.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -namespace -{ +namespace { FormFactorComponents ff_components; } -ParticleInVacuumBuilder::ParticleInVacuumBuilder() : m_ff(new FormFactorFullSphere(5.0 * Units::nm)) -{ -} +ParticleInVacuumBuilder::ParticleInVacuumBuilder() + : m_ff(new FormFactorFullSphere(5.0 * Units::nm)) {} -MultiLayer* ParticleInVacuumBuilder::buildSample() const -{ +MultiLayer* ParticleInVacuumBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Particle particle(refMat::Particle, *m_ff); @@ -44,15 +41,13 @@ MultiLayer* ParticleInVacuumBuilder::buildSample() const return result; } -MultiLayer* ParticleInVacuumBuilder::createSampleByIndex(size_t index) -{ +MultiLayer* ParticleInVacuumBuilder::createSampleByIndex(size_t index) { auto name = ff_components.keys().at(index); m_ff.reset(ff_components.getItem(name)->clone()); setName(name); return buildSample(); } -size_t ParticleInVacuumBuilder::size() -{ +size_t ParticleInVacuumBuilder::size() { return ff_components.size(); } diff --git a/Sample/StandardSamples/ParticleInVacuumBuilder.h b/Sample/StandardSamples/ParticleInVacuumBuilder.h index 548dab28e926d5c0cbb24f4ca50edb995f0cb5ea..d36e1e5c8bab6890df5b5e0d563b7564c7b48519 100644 --- a/Sample/StandardSamples/ParticleInVacuumBuilder.h +++ b/Sample/StandardSamples/ParticleInVacuumBuilder.h @@ -25,8 +25,7 @@ class IFormFactor; //! Requires IComponentService which generates form factors, used for bulk form factors testing. //! @ingroup standard_samples -class ParticleInVacuumBuilder : public ISampleBuilder -{ +class ParticleInVacuumBuilder : public ISampleBuilder { public: ParticleInVacuumBuilder(); virtual MultiLayer* buildSample() const; diff --git a/Sample/StandardSamples/PercusYevickBuilder.cpp b/Sample/StandardSamples/PercusYevickBuilder.cpp index f6b12187a4b4e83bf4d43ce96dac17a81731b636..0461f4799ac08e191227141dc5de5dc9e07f6941 100644 --- a/Sample/StandardSamples/PercusYevickBuilder.cpp +++ b/Sample/StandardSamples/PercusYevickBuilder.cpp @@ -22,8 +22,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* HardDiskBuilder::buildSample() const -{ +MultiLayer* HardDiskBuilder::buildSample() const { const double m_cylinder_height(5 * Units::nm); const double m_cylinder_radius(5 * Units::nm); const double m_disk_radius(5 * Units::nm); diff --git a/Sample/StandardSamples/PercusYevickBuilder.h b/Sample/StandardSamples/PercusYevickBuilder.h index bed21363f322d6b083fb211362a0265f66c648fa..7789c6e29566debde8c9d14a9faff1f10ec4f799 100644 --- a/Sample/StandardSamples/PercusYevickBuilder.h +++ b/Sample/StandardSamples/PercusYevickBuilder.h @@ -20,8 +20,7 @@ //! @ingroup standard_samples //! Builds sample: cylinders with hard disk Percus-Yevick interference. -class HardDiskBuilder : public ISampleBuilder -{ +class HardDiskBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.cpp b/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.cpp index 7f43294f61fe2fdf4f5ca1057e7da8a2d828c193..29b74e291f98d6cb6c1827b8ff4587e54afd57d4 100644 --- a/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.cpp +++ b/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.cpp @@ -24,13 +24,11 @@ PlainMultiLayerBySLDBuilder::PlainMultiLayerBySLDBuilder(int n_layers) , m_ti{-1.9493e-06, 9.6013e-10} , m_ni{9.4245e-06, 1.1423e-09} , m_thick_ti(3.0) - , m_thick_ni(7.0) -{ + , m_thick_ni(7.0) { registerParameter("ti_thickness", &m_thick_ti); } -MultiLayer* PlainMultiLayerBySLDBuilder::buildSample() const -{ +MultiLayer* PlainMultiLayerBySLDBuilder::buildSample() const { Material vacuum_material = MaterialBySLD(); Material substrate_material = MaterialBySLD("Si_substrate", m_si.sld_real, m_si.sld_imag); Material ni_material = MaterialBySLD("Ni", m_ni.sld_real, m_ni.sld_imag); diff --git a/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.h b/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.h index 74e6d0b13c2332c7f94ff4b5ecb6341eb8c15d31..46ea0b583d296388c4e21f94d68187cf2b37b3ba 100644 --- a/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.h +++ b/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.h @@ -21,8 +21,7 @@ //! Ti is 70 angstroms thick, Ni is 30 angstroms thick. //! @ingroup standard_samples -class PlainMultiLayerBySLDBuilder : public ISampleBuilder -{ +class PlainMultiLayerBySLDBuilder : public ISampleBuilder { public: PlainMultiLayerBySLDBuilder(int n_layers = 10); MultiLayer* buildSample() const override; // passes ownership diff --git a/Sample/StandardSamples/ReferenceMaterials.h b/Sample/StandardSamples/ReferenceMaterials.h index 9128ef75f71a5bf0e7d12b728c99daa08a3bca5b..2dccbb86e46e813e8ac93575723c402002c19bed 100644 --- a/Sample/StandardSamples/ReferenceMaterials.h +++ b/Sample/StandardSamples/ReferenceMaterials.h @@ -19,8 +19,7 @@ //! Reference materials for use in tests and exemplary samples. -namespace refMat -{ +namespace refMat { static const Material Vacuum = HomogeneousMaterial("Vacuum", 0.0, 0.0); static const Material Substrate = HomogeneousMaterial("Substrate", 6e-6, 2e-8); diff --git a/Sample/StandardSamples/ResonatorBuilder.cpp b/Sample/StandardSamples/ResonatorBuilder.cpp index 65f16e7468fdec6b26d7c620720e039dfc932990..c2b5beb14cb3afca5077b844c3fccf47da300d9e 100644 --- a/Sample/StandardSamples/ResonatorBuilder.cpp +++ b/Sample/StandardSamples/ResonatorBuilder.cpp @@ -20,13 +20,11 @@ #include "Sample/Slice/LayerRoughness.h" #include <memory> -ResonatorBuilder::ResonatorBuilder() : ISampleBuilder(), m_l_ti(13.0 * Units::nm) -{ +ResonatorBuilder::ResonatorBuilder() : ISampleBuilder(), m_l_ti(13.0 * Units::nm) { registerParameter("ti_thickness", &m_l_ti); } -MultiLayer* ResonatorBuilder::buildSample() const -{ +MultiLayer* ResonatorBuilder::buildSample() const { auto* result = new MultiLayer; Material m_Si = HomogeneousMaterial("Si", 8.25218379931e-06, 0.0); diff --git a/Sample/StandardSamples/ResonatorBuilder.h b/Sample/StandardSamples/ResonatorBuilder.h index 6eb35ee506f18a9f8f117c775442283797b61cc8..6216d83292e001ccb19af0e19bdd5982da53b0c3 100644 --- a/Sample/StandardSamples/ResonatorBuilder.h +++ b/Sample/StandardSamples/ResonatorBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: multilayer with Ti/Pt layers sequence. //! @ingroup standard_samples -class ResonatorBuilder : public ISampleBuilder -{ +class ResonatorBuilder : public ISampleBuilder { public: ResonatorBuilder(); MultiLayer* buildSample() const; diff --git a/Sample/StandardSamples/RipplesBuilder.cpp b/Sample/StandardSamples/RipplesBuilder.cpp index 4a71a36b17887141f94a63d994c440a7c41a6f93..43465fe60fbe7050cfed39894239b3d6e7782bbc 100644 --- a/Sample/StandardSamples/RipplesBuilder.cpp +++ b/Sample/StandardSamples/RipplesBuilder.cpp @@ -23,8 +23,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* CosineRippleBuilder::buildSample() const -{ +MultiLayer* CosineRippleBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); FormFactorCosineRippleBox ff_ripple1(100.0, 20.0, 4.0); Particle ripple(refMat::Particle, ff_ripple1); @@ -48,13 +47,11 @@ MultiLayer* CosineRippleBuilder::buildSample() const // ---------------------------------------------------------------------------- -TriangularRippleBuilder::TriangularRippleBuilder() : m_d(0.0 * Units::nm) -{ +TriangularRippleBuilder::TriangularRippleBuilder() : m_d(0.0 * Units::nm) { registerParameter("asymmetry", &m_d); } -MultiLayer* TriangularRippleBuilder::buildSample() const -{ +MultiLayer* TriangularRippleBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); FormFactorSawtoothRippleBox ff_ripple2(100.0, 20.0, 4.0, m_d); Particle ripple(refMat::Particle, ff_ripple2); @@ -77,8 +74,7 @@ MultiLayer* TriangularRippleBuilder::buildSample() const // ---------------------------------------------------------------------------- -MultiLayer* AsymRippleBuilder::buildSample() const -{ +MultiLayer* AsymRippleBuilder::buildSample() const { TriangularRippleBuilder builder; builder.setParameterValue("asymmetry", -3.0); return builder.buildSample(); diff --git a/Sample/StandardSamples/RipplesBuilder.h b/Sample/StandardSamples/RipplesBuilder.h index da56391a9d9a4e7f10b6f9f82c423f8a349f2ea4..6011c8e56287933dbdedd75773605bee37e0a36c 100644 --- a/Sample/StandardSamples/RipplesBuilder.h +++ b/Sample/StandardSamples/RipplesBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: cosine ripple within the 1D-paracrystal model. //! @ingroup standard_samples -class CosineRippleBuilder : public ISampleBuilder -{ +class CosineRippleBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -29,8 +28,7 @@ public: //! Builds sample: triangular ripple within the 1D-paracrystal model (from PRB 85, 235415, 2012). //! @ingroup standard_samples -class TriangularRippleBuilder : public ISampleBuilder -{ +class TriangularRippleBuilder : public ISampleBuilder { public: TriangularRippleBuilder(); MultiLayer* buildSample() const; @@ -39,8 +37,7 @@ private: double m_d; }; -class AsymRippleBuilder : public ISampleBuilder -{ +class AsymRippleBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/RotatedPyramidsBuilder.cpp b/Sample/StandardSamples/RotatedPyramidsBuilder.cpp index 06ae3ed8563c186bf47de44087ce2a2fe2f0aeaa..19434255c24dc5fd9347bab79041e21a98132c5e 100644 --- a/Sample/StandardSamples/RotatedPyramidsBuilder.cpp +++ b/Sample/StandardSamples/RotatedPyramidsBuilder.cpp @@ -21,8 +21,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* RotatedPyramidsBuilder::buildSample() const -{ +MultiLayer* RotatedPyramidsBuilder::buildSample() const { const double m_length(10 * Units::nm); const double m_height(5 * Units::nm); const double m_alpha(Units::deg2rad(54.73)); diff --git a/Sample/StandardSamples/RotatedPyramidsBuilder.h b/Sample/StandardSamples/RotatedPyramidsBuilder.h index 82cd615eb7466be7fbe157f6a22992968bd3d815..1d51914b59780cad0553959c239d5f2e737f5deb 100644 --- a/Sample/StandardSamples/RotatedPyramidsBuilder.h +++ b/Sample/StandardSamples/RotatedPyramidsBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: Pyramids, rotated pyramids on top of substrate (IsGISAXS example #9) //! @ingroup standard_samples -class RotatedPyramidsBuilder : public ISampleBuilder -{ +class RotatedPyramidsBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/SampleBuilderFactory.cpp b/Sample/StandardSamples/SampleBuilderFactory.cpp index 2f12e38e1e3d9614d817706674498fcd7b556651..d703211d3a45a3f977b076792a97ce47cbf88ef5 100644 --- a/Sample/StandardSamples/SampleBuilderFactory.cpp +++ b/Sample/StandardSamples/SampleBuilderFactory.cpp @@ -46,8 +46,7 @@ #include "Sample/StandardSamples/TwoDimLatticeBuilder.h" #include "Sample/StandardSamples/TwoLayerRoughnessBuilder.h" -SampleBuilderFactory::SampleBuilderFactory() -{ +SampleBuilderFactory::SampleBuilderFactory() { registerItem("CylindersAndPrismsBuilder", create_new<CylindersAndPrismsBuilder>); registerItem("TwoTypesCylindersDistributionBuilder", @@ -199,7 +198,6 @@ SampleBuilderFactory::SampleBuilderFactory() //! Retrieves a SampleBuilder from the registry, does the build, and returns the result. -MultiLayer* SampleBuilderFactory::createSampleByName(const std::string& name) -{ +MultiLayer* SampleBuilderFactory::createSampleByName(const std::string& name) { return createItemPtr(name)->buildSample(); } diff --git a/Sample/StandardSamples/SampleBuilderFactory.h b/Sample/StandardSamples/SampleBuilderFactory.h index 0f428c0aaad4a91a59903856e0983d78fffe08ee..281e1aa1d387e7c135f0f4482134207229eb736b 100644 --- a/Sample/StandardSamples/SampleBuilderFactory.h +++ b/Sample/StandardSamples/SampleBuilderFactory.h @@ -23,8 +23,7 @@ class MultiLayer; //! Factory to create standard pre-defined samples //! @ingroup standard_samples -class SampleBuilderFactory : public IFactory<std::string, ISampleBuilder> -{ +class SampleBuilderFactory : public IFactory<std::string, ISampleBuilder> { public: SampleBuilderFactory(); MultiLayer* createSampleByName(const std::string& name); diff --git a/Sample/StandardSamples/SizeDistributionModelsBuilder.cpp b/Sample/StandardSamples/SizeDistributionModelsBuilder.cpp index 972b1eb2c43975d7c375dafdede819df83590e7a..a25ac5079a248133926bf41c3b2bcee47e37b51a 100644 --- a/Sample/StandardSamples/SizeDistributionModelsBuilder.cpp +++ b/Sample/StandardSamples/SizeDistributionModelsBuilder.cpp @@ -25,8 +25,7 @@ #include "Sample/Particle/ParticleDistribution.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* SizeDistributionDAModelBuilder::buildSample() const -{ +MultiLayer* SizeDistributionDAModelBuilder::buildSample() const { // cylindrical particle 1 double radius1(5 * Units::nm); double height1 = radius1; @@ -62,8 +61,7 @@ MultiLayer* SizeDistributionDAModelBuilder::buildSample() const // ---------------------------------------------------------------------------- -MultiLayer* SizeDistributionLMAModelBuilder::buildSample() const -{ +MultiLayer* SizeDistributionLMAModelBuilder::buildSample() const { // cylindrical particle 1 double radius1(5 * Units::nm); double height1 = radius1; @@ -107,8 +105,7 @@ MultiLayer* SizeDistributionLMAModelBuilder::buildSample() const // ---------------------------------------------------------------------------- -MultiLayer* SizeDistributionSSCAModelBuilder::buildSample() const -{ +MultiLayer* SizeDistributionSSCAModelBuilder::buildSample() const { // cylindrical particle 1 double radius1(5 * Units::nm); double height1 = radius1; @@ -145,8 +142,7 @@ MultiLayer* SizeDistributionSSCAModelBuilder::buildSample() const // ---------------------------------------------------------------------------- -MultiLayer* CylindersInSSCABuilder::buildSample() const -{ +MultiLayer* CylindersInSSCABuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); InterferenceFunctionRadialParaCrystal interference_function(15.0 * Units::nm, 1e3 * Units::nm); diff --git a/Sample/StandardSamples/SizeDistributionModelsBuilder.h b/Sample/StandardSamples/SizeDistributionModelsBuilder.h index ccf5098c1a0d38dd9efa8163ab27109f8a66e189..d986fe50dce44faf2377e18edc7265f678d73174 100644 --- a/Sample/StandardSamples/SizeDistributionModelsBuilder.h +++ b/Sample/StandardSamples/SizeDistributionModelsBuilder.h @@ -21,8 +21,7 @@ //! Equivalent of Examples/Python/simulation/ex03_InterferenceFunctions/ApproximationDA.py //! @ingroup standard_samples -class SizeDistributionDAModelBuilder : public ISampleBuilder -{ +class SizeDistributionDAModelBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -31,8 +30,7 @@ public: //! Equivalent of Examples/Python/simulation/ex03_InterferenceFunctions/ApproximationLMA.py //! @ingroup standard_samples -class SizeDistributionLMAModelBuilder : public ISampleBuilder -{ +class SizeDistributionLMAModelBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -41,8 +39,7 @@ public: //! Equivalent of Examples/Python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py //! @ingroup standard_samples -class SizeDistributionSSCAModelBuilder : public ISampleBuilder -{ +class SizeDistributionSSCAModelBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -50,8 +47,7 @@ public: //! Builds sample: size spacing correlation approximation (IsGISAXS example #15). //! @ingroup standard_samples -class CylindersInSSCABuilder : public ISampleBuilder -{ +class CylindersInSSCABuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/SlicedCompositionBuilder.cpp b/Sample/StandardSamples/SlicedCompositionBuilder.cpp index 11cc8479ef2478897a880e5f92c2bd9cf0e3504d..dd94e2f70ebe27f8433a3b679c78748551651640 100644 --- a/Sample/StandardSamples/SlicedCompositionBuilder.cpp +++ b/Sample/StandardSamples/SlicedCompositionBuilder.cpp @@ -22,8 +22,7 @@ #include "Sample/Particle/ParticleComposition.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* SlicedCompositionBuilder::buildSample() const -{ +MultiLayer* SlicedCompositionBuilder::buildSample() const { const double sphere_radius = 10.0; const double bottom_cup_height = 4.0; const double composition_shift = bottom_cup_height; diff --git a/Sample/StandardSamples/SlicedCompositionBuilder.h b/Sample/StandardSamples/SlicedCompositionBuilder.h index 0c70b1e32dd88b55316792e7422a93bded32fb98..1f7d2d498cdefdec63f9c01f3f5185458a1c15fa 100644 --- a/Sample/StandardSamples/SlicedCompositionBuilder.h +++ b/Sample/StandardSamples/SlicedCompositionBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: spherical composition made of top+bottom spherical cups //! @ingroup standard_samples -class SlicedCompositionBuilder : public ISampleBuilder -{ +class SlicedCompositionBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/SlicedCylindersBuilder.cpp b/Sample/StandardSamples/SlicedCylindersBuilder.cpp index 2b27614a7af10d2103b5974b26818f6fd80c4745..b3739c142f223c51e6af1e952dbc86e27f1583b6 100644 --- a/Sample/StandardSamples/SlicedCylindersBuilder.cpp +++ b/Sample/StandardSamples/SlicedCylindersBuilder.cpp @@ -22,8 +22,7 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/Particle/Particle.h" -namespace -{ +namespace { const double height(5 * Units::nm); const double radius(5 * Units::nm); const double wavelength(0.154); // nm @@ -31,20 +30,17 @@ const int n_slices(3); //! Returns SLD input (in inverse square Angstroms) for MaterialBySLD from _delta_ and _beta_, //! i.e. the input for HomogeneousMaterial. -complex_t getSLDFromN(double wavelength, double delta, double beta) -{ +complex_t getSLDFromN(double wavelength, double delta, double beta) { complex_t result{2 * delta - delta * delta + beta * beta, 2 * beta - 2 * delta * beta}; return result * M_PI / (wavelength * wavelength) * (Units::angstrom * Units::angstrom); } -complex_t averageSLD(complex_t sld_p, complex_t sld_l, double eff_vol) -{ +complex_t averageSLD(complex_t sld_p, complex_t sld_l, double eff_vol) { return sld_l + eff_vol * (sld_p - sld_l); } } // namespace -MultiLayer* SlicedCylindersBuilder::buildSample() const -{ +MultiLayer* SlicedCylindersBuilder::buildSample() const { Material vacuum_material = HomogeneousMaterial("Vacuum", 0.0, 0.0); Material substrate_material = HomogeneousMaterial("Substrate", 6e-6, 2e-8); Material particle_material = HomogeneousMaterial("Particle", 6e-4, 2e-8); @@ -66,8 +62,7 @@ MultiLayer* SlicedCylindersBuilder::buildSample() const return multi_layer; } -MultiLayer* SLDSlicedCylindersBuilder::buildSample() const -{ +MultiLayer* SLDSlicedCylindersBuilder::buildSample() const { Material vacuum_material = MaterialBySLD("Vacuum", 0.0, 0.0); complex_t sub_sld = getSLDFromN(wavelength, 6e-6, 2e-8); Material substrate_material = MaterialBySLD("Substrate", sub_sld.real(), sub_sld.imag()); @@ -91,8 +86,7 @@ MultiLayer* SLDSlicedCylindersBuilder::buildSample() const return multi_layer; } -MultiLayer* AveragedSlicedCylindersBuilder::buildSample() const -{ +MultiLayer* AveragedSlicedCylindersBuilder::buildSample() const { const auto par_surf_density = ParticleLayout().totalParticleSurfaceDensity(); complex_t vacuum_sld{0.0, 0.0}; diff --git a/Sample/StandardSamples/SlicedCylindersBuilder.h b/Sample/StandardSamples/SlicedCylindersBuilder.h index 51a21d7c681a03b4bce05657a5d454340ad69fc5..64e43d7bc6758cc949d61fe1fe29d6163101b54b 100644 --- a/Sample/StandardSamples/SlicedCylindersBuilder.h +++ b/Sample/StandardSamples/SlicedCylindersBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: cylinders on a silicon substrate //! @ingroup standard_samples -class SlicedCylindersBuilder : public ISampleBuilder -{ +class SlicedCylindersBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -30,8 +29,7 @@ public: //! sld-based materials. Assumed wavelength is 1.54 Angstrom. //! @ingroup standard_samples -class SLDSlicedCylindersBuilder : public ISampleBuilder -{ +class SLDSlicedCylindersBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -41,8 +39,7 @@ public: //! Assumed wavelength is 1.54 Angstrom. //! @ingroup standard_samples -class AveragedSlicedCylindersBuilder : public ISampleBuilder -{ +class AveragedSlicedCylindersBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.cpp b/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.cpp index 04fc9909300ec3586f95f2f480041ffd86c4400f..234b4747ed6ce298eb43689803c80b6a36751afb 100644 --- a/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.cpp +++ b/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.cpp @@ -19,8 +19,7 @@ #include "Sample/Multilayer/MultiLayer.h" #include "Sample/Slice/LayerRoughness.h" -MultiLayer* ThickAbsorptiveSampleBuilder::buildSample() const -{ +MultiLayer* ThickAbsorptiveSampleBuilder::buildSample() const { Material vacuum_material = MaterialBySLD("Vacuum", 0.0, 0.0); Material au_material = MaterialBySLD("Au", 3.48388057043e-05, 1.79057609656e-05); Material si_material = MaterialBySLD("Si", 3.84197565094e-07, 6.28211531498e-07); diff --git a/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.h b/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.h index 674b4cbb802582978371a5bea93974e90691ef1b..16f8f18bc9bcd597bc22ed481874cab2e7594128 100644 --- a/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.h +++ b/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.h @@ -17,8 +17,7 @@ #include "Sample/SampleBuilderEngine/ISampleBuilder.h" -class ThickAbsorptiveSampleBuilder : public ISampleBuilder -{ +class ThickAbsorptiveSampleBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const override; }; diff --git a/Sample/StandardSamples/TransformationsBuilder.cpp b/Sample/StandardSamples/TransformationsBuilder.cpp index 0b5765d45d2a1023251257ff7ae224fb6987a96b..929d68eece141f57887899d907e30533be5684d0 100644 --- a/Sample/StandardSamples/TransformationsBuilder.cpp +++ b/Sample/StandardSamples/TransformationsBuilder.cpp @@ -21,8 +21,7 @@ #include "Sample/Particle/Particle.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* TransformBoxBuilder::buildSample() const -{ +MultiLayer* TransformBoxBuilder::buildSample() const { const double layer_thickness(100); const double length(50); const double width(20); diff --git a/Sample/StandardSamples/TransformationsBuilder.h b/Sample/StandardSamples/TransformationsBuilder.h index a0d969b4971b8848baa46fcddfda71590287ec46..d39dfe02ff4d11858c5b9d6ceff0482827c943bc 100644 --- a/Sample/StandardSamples/TransformationsBuilder.h +++ b/Sample/StandardSamples/TransformationsBuilder.h @@ -20,8 +20,7 @@ //! Rotated box in 3 layers system. //! @ingroup standard_samples -class TransformBoxBuilder : public ISampleBuilder -{ +class TransformBoxBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/TwoDimLatticeBuilder.cpp b/Sample/StandardSamples/TwoDimLatticeBuilder.cpp index c1a33c4adc576ce847b09754a61d82d23b445eed..459c28ff03693de6b81b1972f7ad02be5f1cddad 100644 --- a/Sample/StandardSamples/TwoDimLatticeBuilder.cpp +++ b/Sample/StandardSamples/TwoDimLatticeBuilder.cpp @@ -25,8 +25,7 @@ #include "Sample/Particle/ParticleComposition.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* Basic2DLatticeBuilder::buildSample() const -{ +MultiLayer* Basic2DLatticeBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); @@ -55,8 +54,7 @@ MultiLayer* Basic2DLatticeBuilder::buildSample() const // ----------------------------------------------------------------------------- // lattice #1: // ----------------------------------------------------------------------------- -MultiLayer* SquareLattice2DBuilder::buildSample() const -{ +MultiLayer* SquareLattice2DBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); @@ -83,8 +81,7 @@ MultiLayer* SquareLattice2DBuilder::buildSample() const // ----------------------------------------------------------------------------- // lattice #2: centered // ----------------------------------------------------------------------------- -MultiLayer* CenteredSquareLattice2DBuilder::buildSample() const -{ +MultiLayer* CenteredSquareLattice2DBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); @@ -117,8 +114,7 @@ MultiLayer* CenteredSquareLattice2DBuilder::buildSample() const // ----------------------------------------------------------------------------- // lattice #3: rotated // ----------------------------------------------------------------------------- -MultiLayer* RotatedSquareLattice2DBuilder::buildSample() const -{ +MultiLayer* RotatedSquareLattice2DBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); @@ -147,8 +143,7 @@ MultiLayer* RotatedSquareLattice2DBuilder::buildSample() const // ----------------------------------------------------------------------------- // lattice #4: finite square // ----------------------------------------------------------------------------- -MultiLayer* FiniteSquareLattice2DBuilder::buildSample() const -{ +MultiLayer* FiniteSquareLattice2DBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); @@ -174,8 +169,7 @@ MultiLayer* FiniteSquareLattice2DBuilder::buildSample() const // ----------------------------------------------------------------------------- // lattice #5: superlattice // ----------------------------------------------------------------------------- -MultiLayer* SuperLatticeBuilder::buildSample() const -{ +MultiLayer* SuperLatticeBuilder::buildSample() const { Layer vacuum_layer(refMat::Vacuum); Layer substrate_layer(refMat::Substrate); diff --git a/Sample/StandardSamples/TwoDimLatticeBuilder.h b/Sample/StandardSamples/TwoDimLatticeBuilder.h index 7768b6e31be6e1d140ebcd320ba67eefdc0eeb92..def374cb8119e52f4c4913888326d859f99a249b 100644 --- a/Sample/StandardSamples/TwoDimLatticeBuilder.h +++ b/Sample/StandardSamples/TwoDimLatticeBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: 2D lattice with arbitrary angle and different lattice length_1 and length_2. //! @ingroup standard_samples -class Basic2DLatticeBuilder : public ISampleBuilder -{ +class Basic2DLatticeBuilder : public ISampleBuilder { public: Basic2DLatticeBuilder() {} MultiLayer* buildSample() const; @@ -30,8 +29,7 @@ public: //! Builds sample: 2D lattice with different disorder (IsGISAXS example #6). //! @ingroup standard_samples -class SquareLattice2DBuilder : public ISampleBuilder -{ +class SquareLattice2DBuilder : public ISampleBuilder { public: SquareLattice2DBuilder() {} MultiLayer* buildSample() const; @@ -40,8 +38,7 @@ public: //! Builds sample: 2D lattice with different disorder (IsGISAXS example #6). //! @ingroup standard_samples -class CenteredSquareLattice2DBuilder : public ISampleBuilder -{ +class CenteredSquareLattice2DBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -49,8 +46,7 @@ public: //! Builds sample: 2D lattice with different disorder (IsGISAXS example #6). //! @ingroup standard_samples -class RotatedSquareLattice2DBuilder : public ISampleBuilder -{ +class RotatedSquareLattice2DBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -58,8 +54,7 @@ public: //! Builds sample: 2D finite lattice with thermal disorder. //! @ingroup standard_samples -class FiniteSquareLattice2DBuilder : public ISampleBuilder -{ +class FiniteSquareLattice2DBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; @@ -67,8 +62,7 @@ public: //! Builds sample: 2D finite lattice of 2D finite lattices (superlattice). //! @ingroup standard_samples -class SuperLatticeBuilder : public ISampleBuilder -{ +class SuperLatticeBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Sample/StandardSamples/TwoLayerRoughnessBuilder.cpp b/Sample/StandardSamples/TwoLayerRoughnessBuilder.cpp index 1195eb48a36794c1dd820593711be547ebcf2a60..c91f2150a006e5999587d6804e276f4ad8ac7817 100644 --- a/Sample/StandardSamples/TwoLayerRoughnessBuilder.cpp +++ b/Sample/StandardSamples/TwoLayerRoughnessBuilder.cpp @@ -19,8 +19,7 @@ #include "Sample/Slice/LayerRoughness.h" #include "Sample/StandardSamples/ReferenceMaterials.h" -MultiLayer* TwoLayerRoughnessBuilder::buildSample() const -{ +MultiLayer* TwoLayerRoughnessBuilder::buildSample() const { const double m_sigma(1.0 * Units::nm); const double m_hurst(0.3); const double m_lateralCorrLength(5.0 * Units::nm); diff --git a/Sample/StandardSamples/TwoLayerRoughnessBuilder.h b/Sample/StandardSamples/TwoLayerRoughnessBuilder.h index 88b0d8a855eb832585fa3056629e60cfd78ff77a..76a19f28913cc45759d9c9c19175791498b4094e 100644 --- a/Sample/StandardSamples/TwoLayerRoughnessBuilder.h +++ b/Sample/StandardSamples/TwoLayerRoughnessBuilder.h @@ -20,8 +20,7 @@ //! Builds sample: two layers with rough interface. //! @ingroup standard_samples -class TwoLayerRoughnessBuilder : public ISampleBuilder -{ +class TwoLayerRoughnessBuilder : public ISampleBuilder { public: MultiLayer* buildSample() const; }; diff --git a/Tests/Functional/Core/Consistence/CompareTwoReferences.cpp b/Tests/Functional/Core/Consistence/CompareTwoReferences.cpp index 2ed06badf1548a7dd009080cbecbe6421f240e63..3cc2a1902d4edf9cc1056f3ee250b033aaa3241a 100644 --- a/Tests/Functional/Core/Consistence/CompareTwoReferences.cpp +++ b/Tests/Functional/Core/Consistence/CompareTwoReferences.cpp @@ -18,11 +18,9 @@ #include "Device/Instrument/IntensityDataFunctions.h" #include <iostream> -namespace -{ +namespace { -std::unique_ptr<OutputData<double>> load(const std::string& name) -{ +std::unique_ptr<OutputData<double>> load(const std::string& name) { ASSERT(name != ""); const std::string path = FileSystemUtils::jointPath(BATesting::ReferenceDir_Std(), name + ".int.gz"); @@ -40,8 +38,7 @@ std::unique_ptr<OutputData<double>> load(const std::string& name) } // namespace -int compareTwoReferences(const std::string& name0, const std::string& name1, const double limit) -{ +int compareTwoReferences(const std::string& name0, const std::string& name1, const double limit) { std::unique_ptr<OutputData<double>> data0 = load(name0); std::unique_ptr<OutputData<double>> data1 = load(name1); diff --git a/Tests/Functional/Core/Consistence/ConsistenceTests.cpp b/Tests/Functional/Core/Consistence/ConsistenceTests.cpp index 023fcd62d9c4df0bf6d97d877e30d85398e4f8ba..4eb7201ab8bd8fdfefcae2e75d4387d341236a3f 100644 --- a/Tests/Functional/Core/Consistence/ConsistenceTests.cpp +++ b/Tests/Functional/Core/Consistence/ConsistenceTests.cpp @@ -20,30 +20,24 @@ int compareTwoReferences(const std::string& name0, const std::string& name1, const double limit); -class Consistence : public ::testing::Test -{ -}; +class Consistence : public ::testing::Test {}; -TEST_F(Consistence, SpecularWithSlicing) -{ +TEST_F(Consistence, SpecularWithSlicing) { EXPECT_TRUE(compareTwoReferences("SpecularWithSlicing_01", "SpecularWithSlicing_02", 2e-10)); EXPECT_TRUE(compareTwoReferences("SpecularWithSlicing_01", "SpecularWithSlicing_03", 2e-10)); } -TEST_F(Consistence, InstrumentDefinitionComparison) -{ +TEST_F(Consistence, InstrumentDefinitionComparison) { EXPECT_TRUE(compareTwoReferences("InstrumentDefinitionComparison_0", "InstrumentDefinitionComparison_Q", 2e-10)); } -TEST_F(Consistence, TOFResolutionComparison) -{ +TEST_F(Consistence, TOFResolutionComparison) { EXPECT_TRUE( compareTwoReferences("TOFResolutionComparison_TP", "TOFResolutionComparison_TR", 2e-10)); } -TEST_F(Consistence, PolarizedQAngleReflectivity) -{ +TEST_F(Consistence, PolarizedQAngleReflectivity) { EXPECT_TRUE(compareTwoReferences("PolarizedQAngleReflectivityPP_0", "PolarizedQAngleReflectivityPP_Q", 2e-10)); EXPECT_TRUE(compareTwoReferences("PolarizedQAngleReflectivityMM_0", diff --git a/Tests/Functional/Core/CoreSpecial/BatchSimulation.cpp b/Tests/Functional/Core/CoreSpecial/BatchSimulation.cpp index 1829f9a7666e93fd471916a6456f3f1756ec3651..819dbc8a67851971b83761c0765abe70d47cfec4 100644 --- a/Tests/Functional/Core/CoreSpecial/BatchSimulation.cpp +++ b/Tests/Functional/Core/CoreSpecial/BatchSimulation.cpp @@ -18,12 +18,9 @@ #include <iostream> #include <memory> -class BatchSimulation : public ::testing::Test -{ -}; +class BatchSimulation : public ::testing::Test {}; -TEST_F(BatchSimulation, BatchSimulation) -{ +TEST_F(BatchSimulation, BatchSimulation) { SimulationFactory sim_registry; const std::unique_ptr<ISimulation> simulation = sim_registry.createItemPtr("MiniGISAS"); diff --git a/Tests/Functional/Core/CoreSpecial/CoreIOPathTest.cpp b/Tests/Functional/Core/CoreSpecial/CoreIOPathTest.cpp index c88a07c85a8a7745cb63200fd6d6132950c6e873..f56031fff3c5aeb20d60d90fde29a6017b4e775f 100644 --- a/Tests/Functional/Core/CoreSpecial/CoreIOPathTest.cpp +++ b/Tests/Functional/Core/CoreSpecial/CoreIOPathTest.cpp @@ -21,10 +21,8 @@ #include <iostream> #include <memory> -namespace -{ -std::unique_ptr<OutputData<double>> createTestData() -{ +namespace { +std::unique_ptr<OutputData<double>> createTestData() { std::unique_ptr<OutputData<double>> result(new OutputData<double>); result->addAxis("x", 10, 0.0, 10.0); for (size_t i = 0; i < result->getAllocatedSize(); ++i) @@ -32,8 +30,7 @@ std::unique_ptr<OutputData<double>> createTestData() return result; } -bool test_io(const OutputData<double>* data, const std::string& file_name) -{ +bool test_io(const OutputData<double>* data, const std::string& file_name) { IntensityDataIOFactory::writeOutputData(*data, file_name); std::unique_ptr<OutputData<double>> loaded(IntensityDataIOFactory::readOutputData(file_name)); return IntensityDataFunctions::getRelativeDifference(*data, *loaded) <= 1e-06; @@ -41,12 +38,9 @@ bool test_io(const OutputData<double>* data, const std::string& file_name) } // namespace -class CoreIOPathTest : public ::testing::Test -{ -}; +class CoreIOPathTest : public ::testing::Test {}; -TEST_F(CoreIOPathTest, CoreIOPath) -{ +TEST_F(CoreIOPathTest, CoreIOPath) { const auto data = createTestData(); const char filename_rus[] = "\xd0\xb4\xd0\xb0\xd0\xbd\xd0\xbd\xd1\x8b\xd0\xb5\x2e\x69\x6e\x74"; const char dirname_rus[] = @@ -63,6 +57,5 @@ TEST_F(CoreIOPathTest, CoreIOPath) // tests file writing and directory creation when dirname contains cyrillic characters boost::filesystem::path test_subdir_rus(dirname_rus); FileSystemUtils::createDirectories((test_dir / test_subdir_rus).string()); - EXPECT_TRUE( - test_io(data.get(), (test_dir / test_subdir_rus / test_file).string())); + EXPECT_TRUE(test_io(data.get(), (test_dir / test_subdir_rus / test_file).string())); } diff --git a/Tests/Functional/Core/CoreSpecial/FourierTransformationTest.cpp b/Tests/Functional/Core/CoreSpecial/FourierTransformationTest.cpp index 1415e30f56df9d4509299def502580a50c521cf0..151ed0a460294523e486205c4d33861aba56898e 100644 --- a/Tests/Functional/Core/CoreSpecial/FourierTransformationTest.cpp +++ b/Tests/Functional/Core/CoreSpecial/FourierTransformationTest.cpp @@ -21,22 +21,19 @@ #include <memory> #include <vector> -namespace -{ +namespace { const double threshold = 1e-10; //! Returns name of fft image based on given image name. -std::string fftReferenceImage(const std::string& input_image) -{ +std::string fftReferenceImage(const std::string& input_image) { auto filename = FileSystemUtils::filename(input_image); return FileSystemUtils::jointPath(BATesting::ReferenceDir_Core(), "FourierTransformation_" + filename); } //! Runs test over one image. Returns true upon success. -bool test_fft(const std::string& input_image_name, const std::string& reference_fft_name) -{ +bool test_fft(const std::string& input_image_name, const std::string& reference_fft_name) { std::cout << "Input image: " << input_image_name << std::endl; std::cout << "Reference fft: " << reference_fft_name << std::endl; @@ -80,12 +77,9 @@ bool test_fft(const std::string& input_image_name, const std::string& reference_ } // namespace -class FourierTransformationTest : public ::testing::Test -{ -}; +class FourierTransformationTest : public ::testing::Test {}; -TEST_F(FourierTransformationTest, FourierTransformation) -{ +TEST_F(FourierTransformationTest, FourierTransformation) { for (const char* inputImage : {"CylindersAndPrisms.int.gz", "RectDetectorGeneric.int.gz"}) EXPECT_TRUE(test_fft(inputImage, fftReferenceImage(inputImage))); } diff --git a/Tests/Functional/Core/Fitting/AdjustMinimizerPlan.cpp b/Tests/Functional/Core/Fitting/AdjustMinimizerPlan.cpp index 334bab0b4c992c0f591c631949f16a2a0d3e8cc6..3089a5149d2d297ede6b3a1a4fba273d717324c1 100644 --- a/Tests/Functional/Core/Fitting/AdjustMinimizerPlan.cpp +++ b/Tests/Functional/Core/Fitting/AdjustMinimizerPlan.cpp @@ -18,23 +18,20 @@ #include "Fit/Kernel/Minimizer.h" #include <iostream> -namespace -{ +namespace { const double nm = Units::nm; } using namespace mumufit; -AdjustMinimizerPlan::AdjustMinimizerPlan() : Plan("AdjustMinimizerPlan") -{ +AdjustMinimizerPlan::AdjustMinimizerPlan() : Plan("AdjustMinimizerPlan") { setBuilderName("CylindersInBABuilder"); setSimulationName("MiniGISASFit"); addParameter(Parameter("height", 2.0 * nm, AttLimits::limited(0.01, 30.0), 0.05), 5.0 * nm); addParameter(Parameter("radius", 10.0 * nm, AttLimits::limited(0.01, 30.0), 0.05), 5.0 * nm); } -bool AdjustMinimizerPlan::checkMinimizer(mumufit::Minimizer& minimizer) -{ +bool AdjustMinimizerPlan::checkMinimizer(mumufit::Minimizer& minimizer) { auto fit_objective = createFitObjective(); fcn_scalar_t scalar_func = [&](const mumufit::Parameters& params) { diff --git a/Tests/Functional/Core/Fitting/AdjustMinimizerPlan.h b/Tests/Functional/Core/Fitting/AdjustMinimizerPlan.h index c472e24585ba93799b0443ddd3f31342b2e4928c..b18820bb40651c1c5420ea387bfc1e3f0c4895b2 100644 --- a/Tests/Functional/Core/Fitting/AdjustMinimizerPlan.h +++ b/Tests/Functional/Core/Fitting/AdjustMinimizerPlan.h @@ -20,8 +20,7 @@ //! Two parameter fit: cylinders in BA with mini GISAS simulation. //! Parameters are made far from their original values, Genetic+Minuit used in pair. -class AdjustMinimizerPlan : public Plan -{ +class AdjustMinimizerPlan : public Plan { public: AdjustMinimizerPlan(); diff --git a/Tests/Functional/Core/Fitting/FitTests.cpp b/Tests/Functional/Core/Fitting/FitTests.cpp index 3615a7b595e3a7c5e05065e510394d10015ceb85..0cdc5c2bb8ca914081224ae5a59f34b653beea13 100644 --- a/Tests/Functional/Core/Fitting/FitTests.cpp +++ b/Tests/Functional/Core/Fitting/FitTests.cpp @@ -16,31 +16,25 @@ #include "Tests/Functional/Core/Fitting/PlanFactory.h" #include "Tests/GTestWrapper/google_test.h" -class Fitting : public ::testing::Test -{ -}; +class Fitting : public ::testing::Test {}; bool run(const std::string& minimizer_name, const std::string& algorithm_name, - const std::string& fit_plan_name, const std::string& options = "") -{ + const std::string& fit_plan_name, const std::string& options = "") { auto plan = PlanFactory().createItemPtr(fit_plan_name); mumufit::Minimizer minimizer; minimizer.setMinimizer(minimizer_name, algorithm_name, options); return plan->checkMinimizer(minimizer); } -TEST_F(Fitting, MigradCylindersInBA) -{ +TEST_F(Fitting, MigradCylindersInBA) { EXPECT_TRUE(run("Minuit2", "Migrad", "CylindersInBAPlan")); } -TEST_F(Fitting, MigradResidualCylindersInBA) -{ +TEST_F(Fitting, MigradResidualCylindersInBA) { EXPECT_TRUE(run("Minuit2", "Migrad", "CylindersInBAResidualPlan")); } -TEST_F(Fitting, BfgsCylindersInBA) -{ +TEST_F(Fitting, BfgsCylindersInBA) { EXPECT_TRUE(run("GSLMultiMin", "BFGS2", "CylindersInBAEasyPlan")); } @@ -51,29 +45,24 @@ TEST_F(Fitting, SteepestDescentCylindersInBA) } */ -TEST_F(Fitting, FumuliCylindersInBA) -{ +TEST_F(Fitting, FumuliCylindersInBA) { EXPECT_TRUE(run("Minuit2", "Fumili", "CylindersInBAResidualPlan")); } -TEST_F(Fitting, LevenbergMarquardtCylindersInBA) -{ +TEST_F(Fitting, LevenbergMarquardtCylindersInBA) { EXPECT_TRUE(run("GSLLMA", "", "CylindersInBAResidualPlan")); } -TEST_F(Fitting, SimAnCylindersInBA) -{ +TEST_F(Fitting, SimAnCylindersInBA) { EXPECT_TRUE(run("GSLSimAn", "", "CylindersInBAEasyPlan", "IterationsAtTemp=5;MaxIterations=10;t_min=1.0")); } -TEST_F(Fitting, GeneticCylindersInBA) -{ +TEST_F(Fitting, GeneticCylindersInBA) { EXPECT_TRUE(run("Genetic", "", "CylindersInBAEasyPlan", "MaxIterations=1;RandomSeed=1")); } -TEST_F(Fitting, RectDetectorFit) -{ +TEST_F(Fitting, RectDetectorFit) { EXPECT_TRUE(run("Minuit2", "Migrad", "RectDetPlan", "Strategy=2")); } @@ -84,22 +73,18 @@ TEST_F(Fitting, AdjustMinimizerFit) } */ -TEST_F(Fitting, SpecularFitTest) -{ +TEST_F(Fitting, SpecularFitTest) { EXPECT_TRUE(run("Minuit2", "Migrad", "SpecularPlan")); } -TEST_F(Fitting, SpecularFitTestQ) -{ +TEST_F(Fitting, SpecularFitTestQ) { EXPECT_TRUE(run("Minuit2", "Migrad", "SpecularPlanQ")); } -TEST_F(Fitting, MultipleSpecFittingTest) -{ +TEST_F(Fitting, MultipleSpecFittingTest) { EXPECT_TRUE(run("Minuit2", "Migrad", "MultipleSpecPlan")); } -TEST_F(Fitting, OffSpecFitTest) -{ +TEST_F(Fitting, OffSpecFitTest) { EXPECT_TRUE(run("Minuit2", "Migrad", "OffSpecPlan")); } diff --git a/Tests/Functional/Core/Fitting/Plan.cpp b/Tests/Functional/Core/Fitting/Plan.cpp index abd69028acd5053c9c1b87ea843b66c806d78091..817c3b03788bf4c0767f7ff42e917b3f413d3a74 100644 --- a/Tests/Functional/Core/Fitting/Plan.cpp +++ b/Tests/Functional/Core/Fitting/Plan.cpp @@ -20,14 +20,11 @@ #include "Sample/StandardSamples/SampleBuilderFactory.h" Plan::Plan(const std::string& name, bool residual_based) - : MinimizerTestPlan(name), m_residual_based(residual_based) -{ -} + : MinimizerTestPlan(name), m_residual_based(residual_based) {} Plan::~Plan() = default; -bool Plan::checkMinimizer(mumufit::Minimizer& minimizer) -{ +bool Plan::checkMinimizer(mumufit::Minimizer& minimizer) { std::unique_ptr<FitObjective> fit_objective = createFitObjective(); fcn_scalar_t scalar_func = [&](const mumufit::Parameters& params) { @@ -54,18 +51,15 @@ bool Plan::checkMinimizer(mumufit::Minimizer& minimizer) return success; } -void Plan::setBuilderName(const std::string& name) -{ +void Plan::setBuilderName(const std::string& name) { m_sample_builder_name = name; } -void Plan::setSimulationName(const std::string& name) -{ +void Plan::setSimulationName(const std::string& name) { m_simulation_name = name; } -std::unique_ptr<FitObjective> Plan::createFitObjective() const -{ +std::unique_ptr<FitObjective> Plan::createFitObjective() const { std::unique_ptr<FitObjective> result(new FitObjective); simulation_builder_t builder = [&](const mumufit::Parameters& params) { @@ -80,8 +74,7 @@ std::unique_ptr<FitObjective> Plan::createFitObjective() const //! Build simulation (sample included) for given set of fit parameters. -std::unique_ptr<ISimulation> Plan::buildSimulation(const mumufit::Parameters& params) const -{ +std::unique_ptr<ISimulation> Plan::buildSimulation(const mumufit::Parameters& params) const { auto simulation = createSimulation(params); auto sample = createMultiLayer(params); simulation->setSample(*sample); @@ -90,15 +83,13 @@ std::unique_ptr<ISimulation> Plan::buildSimulation(const mumufit::Parameters& pa //! Creates simulation for given set of fit parameters. No sample yets. -std::unique_ptr<ISimulation> Plan::createSimulation(const mumufit::Parameters&) const -{ +std::unique_ptr<ISimulation> Plan::createSimulation(const mumufit::Parameters&) const { return SimulationFactory().createItemPtr(m_simulation_name); } //! Creates sample for given set of fit parameters. -std::unique_ptr<MultiLayer> Plan::createMultiLayer(const mumufit::Parameters& params) const -{ +std::unique_ptr<MultiLayer> Plan::createMultiLayer(const mumufit::Parameters& params) const { auto sample_builder = SampleBuilderFactory().createItemPtr(m_sample_builder_name); // propagating current values of fit parameters to sample builder before building the sample @@ -110,8 +101,7 @@ std::unique_ptr<MultiLayer> Plan::createMultiLayer(const mumufit::Parameters& pa //! Creates "experimental" data for fitting. -std::unique_ptr<OutputData<double>> Plan::createOutputData() const -{ +std::unique_ptr<OutputData<double>> Plan::createOutputData() const { // use expected values of fit parameters to construct simulation auto params = parameters(); params.setValues(expectedValues()); diff --git a/Tests/Functional/Core/Fitting/Plan.h b/Tests/Functional/Core/Fitting/Plan.h index b9ec4ec7fd55e0e173b59142ecc8e7a7f6bef79d..2433bc4baf90a8d2ee0fb14eff65e556baec31fd 100644 --- a/Tests/Functional/Core/Fitting/Plan.h +++ b/Tests/Functional/Core/Fitting/Plan.h @@ -18,8 +18,7 @@ #include "Fit/TestEngine/MinimizerTestPlan.h" #include <memory> -namespace mumufit -{ +namespace mumufit { class Parameters; } class ISimulation; @@ -30,8 +29,7 @@ class FitObjective; //! Contains all logic to construct FitObjective, setup Minimizer and check minimization results. //! Parent of various *Plan classes in source file PlanCases. -class Plan : public MinimizerTestPlan -{ +class Plan : public MinimizerTestPlan { public: Plan(const std::string& name, bool residual_based = false); ~Plan(); diff --git a/Tests/Functional/Core/Fitting/PlanCases.cpp b/Tests/Functional/Core/Fitting/PlanCases.cpp index 5a2949b71c5453b2641d36b22c770373e75829f9..63b60720d28ec448ab213b9d2ab5f657ded3ccd0 100644 --- a/Tests/Functional/Core/Fitting/PlanCases.cpp +++ b/Tests/Functional/Core/Fitting/PlanCases.cpp @@ -28,21 +28,18 @@ using namespace mumufit; -namespace -{ +namespace { const double nm = Units::nm; } -CylindersInBAPlan::CylindersInBAPlan() : Plan("CylindersInBAPlan") -{ +CylindersInBAPlan::CylindersInBAPlan() : Plan("CylindersInBAPlan") { setBuilderName("CylindersInBABuilder"); setSimulationName("MiniGISAS"); addParameter(Parameter("height", 4.5 * nm, AttLimits::lowerLimited(0.01), 0.01), 5.0 * nm); addParameter(Parameter("radius", 5.5 * nm, AttLimits::lowerLimited(0.01), 0.01), 5.0 * nm); } -CylindersInBAEasyPlan::CylindersInBAEasyPlan() : Plan("CylindersInBAEasyPlan") -{ +CylindersInBAEasyPlan::CylindersInBAEasyPlan() : Plan("CylindersInBAEasyPlan") { setBuilderName("CylindersInBABuilder"); setSimulationName("MiniGISASFit"); const double tolerance = 0.1; @@ -53,8 +50,7 @@ CylindersInBAEasyPlan::CylindersInBAEasyPlan() : Plan("CylindersInBAEasyPlan") } CylindersInBAResidualPlan::CylindersInBAResidualPlan() - : Plan("CylindersInBAResidualPlan", /*residual_based*/ true) -{ + : Plan("CylindersInBAResidualPlan", /*residual_based*/ true) { setBuilderName("CylindersInBABuilder"); setSimulationName("MiniGISAS"); addParameter(Parameter("height", 4.5 * nm, AttLimits::limitless(), 0.01), 5.0 * nm); @@ -63,8 +59,7 @@ CylindersInBAResidualPlan::CylindersInBAResidualPlan() // ---------------------------------------------------------------------------- -RectDetPlan::RectDetPlan() : Plan("RectDetPlan") -{ +RectDetPlan::RectDetPlan() : Plan("RectDetPlan") { setBuilderName("CylindersInBABuilder"); addParameter(Parameter("height", 4.5 * nm, AttLimits::limited(4.0, 6.0), 0.01), 5.0 * nm); addParameter(Parameter("radius", 5.5 * nm, AttLimits::limited(4.0, 6.0), 0.01), 5.0 * nm); @@ -72,8 +67,7 @@ RectDetPlan::RectDetPlan() : Plan("RectDetPlan") RectDetPlan::~RectDetPlan() = default; -std::unique_ptr<ISimulation> RectDetPlan::createSimulation(const Parameters&) const -{ +std::unique_ptr<ISimulation> RectDetPlan::createSimulation(const Parameters&) const { std::unique_ptr<GISASSimulation> result(new GISASSimulation()); double detector_distance(500.0); @@ -90,8 +84,7 @@ std::unique_ptr<ISimulation> RectDetPlan::createSimulation(const Parameters&) co // ---------------------------------------------------------------------------- -SpecularPlan::SpecularPlan() : Plan("SpecularPlan") -{ +SpecularPlan::SpecularPlan() : Plan("SpecularPlan") { setSimulationName("BasicSpecular"); setBuilderName("PlainMultiLayerBySLDBuilder"); addParameter(Parameter("ti_thickness", 5.0 * nm, AttLimits::limited(1.0 * nm, 7.0 * nm), 0.1), @@ -100,8 +93,7 @@ SpecularPlan::SpecularPlan() : Plan("SpecularPlan") // ---------------------------------------------------------------------------- -SpecularPlanQ::SpecularPlanQ() : Plan("SpecularPlanQ") -{ +SpecularPlanQ::SpecularPlanQ() : Plan("SpecularPlanQ") { setSimulationName("BasicSpecularQ"); setBuilderName("PlainMultiLayerBySLDBuilder"); addParameter(Parameter("ti_thickness", 5.0 * nm, AttLimits::limited(1.0 * nm, 7.0 * nm), 0.1), @@ -110,8 +102,7 @@ SpecularPlanQ::SpecularPlanQ() : Plan("SpecularPlanQ") // ---------------------------------------------------------------------------- -MultipleSpecPlan::MultipleSpecPlan() : Plan("MultipleSpecPlan") -{ +MultipleSpecPlan::MultipleSpecPlan() : Plan("MultipleSpecPlan") { setSimulationName("BasicSpecular"); setBuilderName("PlainMultiLayerBySLDBuilder"); addParameter(Parameter("ti_thickness", 5.0 * nm, AttLimits::limited(1.0 * nm, 7.0 * nm), 0.1), @@ -120,8 +111,7 @@ MultipleSpecPlan::MultipleSpecPlan() : Plan("MultipleSpecPlan") MultipleSpecPlan::~MultipleSpecPlan() = default; -std::unique_ptr<FitObjective> MultipleSpecPlan::createFitObjective() const -{ +std::unique_ptr<FitObjective> MultipleSpecPlan::createFitObjective() const { std::unique_ptr<FitObjective> result(new FitObjective); simulation_builder_t builder = [&](const mumufit::Parameters& params) { @@ -137,8 +127,7 @@ std::unique_ptr<FitObjective> MultipleSpecPlan::createFitObjective() const // ---------------------------------------------------------------------------- -OffSpecPlan::OffSpecPlan() : Plan("OffSpecPlan") -{ +OffSpecPlan::OffSpecPlan() : Plan("OffSpecPlan") { setBuilderName("ResonatorBuilder"); setSimulationName("OffSpecMini"); addParameter( diff --git a/Tests/Functional/Core/Fitting/PlanCases.h b/Tests/Functional/Core/Fitting/PlanCases.h index 00f921adf090ea6a351eea35ba6359685c11aa1b..f1ea57480eb69ed519ed11a7f635311c2c660e05 100644 --- a/Tests/Functional/Core/Fitting/PlanCases.h +++ b/Tests/Functional/Core/Fitting/PlanCases.h @@ -19,8 +19,7 @@ //! Two parameter fit: cylinders in BA with mini GISAS simulation. -class CylindersInBAPlan : public Plan -{ +class CylindersInBAPlan : public Plan { public: CylindersInBAPlan(); }; @@ -28,8 +27,7 @@ public: //! Two parameter fit: cylinders in BA with mini GISAS simulation. //! Large tolerance on expected parameter values to help stocastic minimizers to converge fatser. -class CylindersInBAEasyPlan : public Plan -{ +class CylindersInBAEasyPlan : public Plan { public: CylindersInBAEasyPlan(); }; @@ -37,8 +35,7 @@ public: //! Two parameter fit: cylinders in BA with mini GISAS simulation. //! Residual like objective function is used -class CylindersInBAResidualPlan : public Plan -{ +class CylindersInBAResidualPlan : public Plan { public: CylindersInBAResidualPlan(); }; @@ -46,8 +43,7 @@ public: //! Two parameter fit: cylinders in BA with mini GISAS simulation. //! Rectangular detector. -class RectDetPlan : public Plan -{ +class RectDetPlan : public Plan { public: RectDetPlan(); ~RectDetPlan(); @@ -58,24 +54,21 @@ protected: //! Plan for fitting reflectometry curve on Ti/Ni multilayer -class SpecularPlan : public Plan -{ +class SpecularPlan : public Plan { public: SpecularPlan(); }; //! Plan for fitting reflectometry curve on Ti/Ni multilayer (q-defined beam) -class SpecularPlanQ : public Plan -{ +class SpecularPlanQ : public Plan { public: SpecularPlanQ(); }; //! The same as SpecularPlan, but with two (identical) datasets -class MultipleSpecPlan : public Plan -{ +class MultipleSpecPlan : public Plan { public: MultipleSpecPlan(); ~MultipleSpecPlan() override; @@ -86,8 +79,7 @@ protected: //! Fit for off-specular experiment -class OffSpecPlan : public Plan -{ +class OffSpecPlan : public Plan { public: OffSpecPlan(); ~OffSpecPlan() override = default; diff --git a/Tests/Functional/Core/Fitting/PlanFactory.cpp b/Tests/Functional/Core/Fitting/PlanFactory.cpp index 4ac27fce1cb38de8a4f6e4b31280ddc6c6057c6e..3a72fea24f1188b00f4bd679abe454afb6d1fcca 100644 --- a/Tests/Functional/Core/Fitting/PlanFactory.cpp +++ b/Tests/Functional/Core/Fitting/PlanFactory.cpp @@ -16,8 +16,7 @@ #include "Tests/Functional/Core/Fitting/AdjustMinimizerPlan.h" #include "Tests/Functional/Core/Fitting/PlanCases.h" -PlanFactory::PlanFactory() -{ +PlanFactory::PlanFactory() { registerItem("CylindersInBAPlan", create_new<CylindersInBAPlan>); registerItem("CylindersInBAEasyPlan", create_new<CylindersInBAEasyPlan>); registerItem("CylindersInBAResidualPlan", create_new<CylindersInBAResidualPlan>); diff --git a/Tests/Functional/Core/Fitting/PlanFactory.h b/Tests/Functional/Core/Fitting/PlanFactory.h index 34bf75039d130cdd8798878381ad4f9de10051d2..47244ba06e4abbcb81da79f862bf6228525b9cb8 100644 --- a/Tests/Functional/Core/Fitting/PlanFactory.h +++ b/Tests/Functional/Core/Fitting/PlanFactory.h @@ -20,8 +20,7 @@ //! Factory to generate plans for fitting with FitObjective. -class PlanFactory : public IFactory<std::string, MinimizerTestPlan> -{ +class PlanFactory : public IFactory<std::string, MinimizerTestPlan> { public: PlanFactory(); }; diff --git a/Tests/Functional/Core/MPI/mpitest.cpp b/Tests/Functional/Core/MPI/mpitest.cpp index 9bf517f369292c1d5b113796a2fb3fa1dcd9d73e..25f8c66d62f6c216b7bb8feab80c3259d7fe7f3f 100644 --- a/Tests/Functional/Core/MPI/mpitest.cpp +++ b/Tests/Functional/Core/MPI/mpitest.cpp @@ -8,8 +8,7 @@ #include <iostream> -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { MPI_Init(&argc, &argv); int world_size(0), world_rank(0); diff --git a/Tests/Functional/Core/Std/Check.cpp b/Tests/Functional/Core/Std/Check.cpp index 5f2da084bd963c1c122649c4288972a8cb145373..2510c410af3ad5423d2a4fa39dfc15ff6a08ed47 100644 --- a/Tests/Functional/Core/Std/Check.cpp +++ b/Tests/Functional/Core/Std/Check.cpp @@ -23,8 +23,7 @@ #include <iostream> bool checkSimulation(const std::string& name, const ISimulation& direct_simulation, - const double limit) -{ + const double limit) { const auto result_data = direct_simulation.result().data(); std::unique_ptr<OutputData<double>> reference; diff --git a/Tests/Functional/GUI/Std/Check.cpp b/Tests/Functional/GUI/Std/Check.cpp index e615ade2159d5ffd90512cf4b57c61ab437e6529..6e1bcbe384143e1758067563585b6031ad61f240 100644 --- a/Tests/Functional/GUI/Std/Check.cpp +++ b/Tests/Functional/GUI/Std/Check.cpp @@ -23,8 +23,7 @@ #include "GUI/coregui/Models/SampleModel.h" std::unique_ptr<OutputData<double>> domainData(const std::string& /*test_name*/, - const ISimulation& direct_simulation) -{ + const ISimulation& direct_simulation) { // initializing necessary GUI DocumentModel documentModel; SampleModel sampleModel; @@ -45,8 +44,7 @@ std::unique_ptr<OutputData<double>> domainData(const std::string& /*test_name*/, } bool checkSimulation(const std::string& name, const ISimulation& direct_simulation, - const double limit) -{ + const double limit) { const std::unique_ptr<OutputData<double>> domain_data = domainData(name, direct_simulation); const std::unique_ptr<OutputData<double>> ref_data = direct_simulation.result().data(); diff --git a/Tests/Functional/GUI/Translate/GUITranslationTest.cpp b/Tests/Functional/GUI/Translate/GUITranslationTest.cpp index 84cd7205a8332ee4212f15876fac090fbb4f75ee..62d036edf8b233a1b60afda5663cffba859ed4ff 100644 --- a/Tests/Functional/GUI/Translate/GUITranslationTest.cpp +++ b/Tests/Functional/GUI/Translate/GUITranslationTest.cpp @@ -37,11 +37,9 @@ #include "Sample/StandardSamples/SampleBuilderFactory.h" #include <QStack> -namespace -{ +namespace { -bool containsNames(const QString& text, const QStringList& names) -{ +bool containsNames(const QString& text, const QStringList& names) { for (const auto& name : names) if (text.contains(name)) return true; @@ -77,8 +75,7 @@ const QVector<QPair<QStringList, QStringList>> black_list{ //! Returns true, if it makes sence to look for GUI translation for given domain name. //! Intended to supress warnings about not-yet implemented translations. -bool requiresTranslation(ParameterItem* parItem) -{ +bool requiresTranslation(ParameterItem* parItem) { if (!parItem) return false; @@ -96,16 +93,16 @@ bool requiresTranslation(ParameterItem* parItem) return true; } -std::string header(size_t width = 80) -{ +std::string header(size_t width = 80) { return std::string(width, '-'); } } // namespace GUITranslationTest::GUITranslationTest(const std::string& simName, const std::string& sampleName) - : m_models(new ApplicationModels(nullptr)), m_simulationName(simName), m_sampleName(sampleName) -{ + : m_models(new ApplicationModels(nullptr)) + , m_simulationName(simName) + , m_sampleName(sampleName) { SimulationFactory simFactory; std::unique_ptr<ISimulation> simulation = simFactory.createItemPtr(m_simulationName); if (GISASSimulation* gisas = dynamic_cast<GISASSimulation*>(simulation.get())) { @@ -120,8 +117,7 @@ GUITranslationTest::GUITranslationTest(const std::string& simName, const std::st GUITranslationTest::~GUITranslationTest() = default; -bool GUITranslationTest::runTest() -{ +bool GUITranslationTest::runTest() { processParameterTree(); std::cout << translationResultsToString() << std::endl; @@ -138,8 +134,7 @@ bool GUITranslationTest::runTest() //! Runs through GUI models and constructs list of available domain fit parameters names. -void GUITranslationTest::processParameterTree() -{ +void GUITranslationTest::processParameterTree() { m_models->instrumentModel()->clear(); // populating GUI models from domain GUIObjectBuilder::populateSampleModelFromSim(m_models->sampleModel(), m_models->materialModel(), @@ -174,8 +169,7 @@ void GUITranslationTest::processParameterTree() //! Returns multiline string representing results of translation -std::string GUITranslationTest::translationResultsToString() const -{ +std::string GUITranslationTest::translationResultsToString() const { std::ostringstream ostr; ostr << "\n" << header() << "\n"; @@ -197,8 +191,7 @@ std::string GUITranslationTest::translationResultsToString() const return ostr.str(); } -bool GUITranslationTest::isValidDomainName(const std::string& domainName) const -{ +bool GUITranslationTest::isValidDomainName(const std::string& domainName) const { std::vector<std::string> invalidNames{"Direction", "Efficiency", "Transmission", "InclinationAngle", "AzimuthalAngle"}; for (auto name : invalidNames) { @@ -211,8 +204,7 @@ bool GUITranslationTest::isValidDomainName(const std::string& domainName) const //! Returns true, if it makes sence to look for domain translation for given GUI name. //! Intended to supress warnings about not-yet implemented translations. -bool GUITranslationTest::isValidGUIName(const std::string& guiName) const -{ +bool GUITranslationTest::isValidGUIName(const std::string& guiName) const { std::vector<std::string> invalidNames{}; for (auto name : invalidNames) { if (guiName.find(name) != std::string::npos) @@ -224,8 +216,7 @@ bool GUITranslationTest::isValidGUIName(const std::string& guiName) const //! Validates GUI translations against simulation parameters. Tries to retrieve fit parameter //! from domain parameter pool using translated name. -bool GUITranslationTest::checkExistingTranslations() -{ +bool GUITranslationTest::checkExistingTranslations() { if (m_translations.empty()) throw GUIHelpers::Error("GUITranslationTest::validateParameterTree() -> Error. " "Empty list of translations."); @@ -262,8 +253,7 @@ bool GUITranslationTest::checkExistingTranslations() //! Checks if all simulation parameters have translation. -bool GUITranslationTest::checkMissedTranslations() -{ +bool GUITranslationTest::checkMissedTranslations() { if (m_translations.empty()) throw GUIHelpers::Error("GUITranslationTest::validateParameterTree() -> Error. " "Empty list of translations."); diff --git a/Tests/Functional/GUI/Translate/GUITranslationTest.h b/Tests/Functional/GUI/Translate/GUITranslationTest.h index 3a437139a7c5e731df29eb5dbde16bf16e18afe2..bfee25deedc869f66c1028a98c7613aae926f120 100644 --- a/Tests/Functional/GUI/Translate/GUITranslationTest.h +++ b/Tests/Functional/GUI/Translate/GUITranslationTest.h @@ -30,8 +30,7 @@ class ApplicationModels; //! * Complains, if translated names doesn't match registered parameters of domain simulation. //! * Complains, if simulation contains parameters which do not have translations. -class GUITranslationTest -{ +class GUITranslationTest { public: GUITranslationTest(const std::string& simName, const std::string& sampleName); diff --git a/Tests/Functional/GUI/Translate/TranslationTests.cpp b/Tests/Functional/GUI/Translate/TranslationTests.cpp index 6def73c78dd7af3073b19e1d529e37fbc8c64efa..b285f38f10179eb787485d9b91b54e1600c98d22 100644 --- a/Tests/Functional/GUI/Translate/TranslationTests.cpp +++ b/Tests/Functional/GUI/Translate/TranslationTests.cpp @@ -15,91 +15,72 @@ #include "Tests/Functional/GUI/Translate/GUITranslationTest.h" #include "Tests/GTestWrapper/google_test.h" -class Translate : public ::testing::Test -{ -}; +class Translate : public ::testing::Test {}; -bool run(const std::string& sim_name, const std::string& sample_name) -{ +bool run(const std::string& sim_name, const std::string& sample_name) { return GUITranslationTest(sim_name, sample_name).runTest(); } -TEST_F(Translate, Basic) -{ +TEST_F(Translate, Basic) { EXPECT_TRUE(run("BasicGISAS", "CylindersAndPrismsBuilder")); } -TEST_F(Translate, RadialPara) -{ +TEST_F(Translate, RadialPara) { EXPECT_TRUE(run("BasicGISAS", "RadialParaCrystalBuilder")); } -TEST_F(Translate, HardDisk) -{ +TEST_F(Translate, HardDisk) { EXPECT_TRUE(run("BasicGISAS", "HardDiskBuilder")); } -TEST_F(Translate, HexPara) -{ +TEST_F(Translate, HexPara) { EXPECT_TRUE(run("BasicGISAS", "HexParaCrystalBuilder")); } -TEST_F(Translate, CoreShell) -{ +TEST_F(Translate, CoreShell) { EXPECT_TRUE(run("BasicGISAS", "CoreShellParticleBuilder")); } -TEST_F(Translate, Roughness) -{ +TEST_F(Translate, Roughness) { EXPECT_TRUE(run("BasicGISAS", "MultiLayerWithRoughnessBuilder")); } -TEST_F(Translate, SquareLattice2D) -{ +TEST_F(Translate, SquareLattice2D) { EXPECT_TRUE(run("BasicGISAS", "SquareLattice2DBuilder")); } -TEST_F(Translate, Rotation) -{ +TEST_F(Translate, Rotation) { EXPECT_TRUE(run("BasicGISAS", "RotatedPyramidsBuilder")); } -TEST_F(Translate, SizeDistribution) -{ +TEST_F(Translate, SizeDistribution) { EXPECT_TRUE(run("BasicGISAS", "CylindersWithSizeDistributionBuilder")); } -TEST_F(Translate, Composition) -{ +TEST_F(Translate, Composition) { EXPECT_TRUE(run("BasicGISAS", "ParticleCompositionBuilder")); } -TEST_F(Translate, Para2D) -{ +TEST_F(Translate, Para2D) { EXPECT_TRUE(run("BasicGISAS", "Basic2DParaCrystalBuilder")); } -TEST_F(Translate, Lattice1D) -{ +TEST_F(Translate, Lattice1D) { EXPECT_TRUE(run("BasicGISAS", "Lattice1DBuilder")); } -TEST_F(Translate, Lattice2D) -{ +TEST_F(Translate, Lattice2D) { EXPECT_TRUE(run("BasicGISAS", "Basic2DLatticeBuilder")); } -TEST_F(Translate, TwoLayerRoughness) -{ +TEST_F(Translate, TwoLayerRoughness) { EXPECT_TRUE(run("BasicGISAS", "TwoLayerRoughnessBuilder")); } -TEST_F(Translate, MesoCrystal) -{ +TEST_F(Translate, MesoCrystal) { EXPECT_TRUE(run("BasicGISAS", "MesoCrystalBuilder")); } -TEST_F(Translate, MagneticSpheres) -{ +TEST_F(Translate, MagneticSpheres) { EXPECT_TRUE(run("BasicPolarizedGISAS", "MagneticSpheresBuilder")); } diff --git a/Tests/Functional/Python/PyEmbedded/Tests.cpp b/Tests/Functional/Python/PyEmbedded/Tests.cpp index 80afd33ba3057a47788bbad3ea0715df9a897a68..2ce7b659551ef829e6bb8b3a9f9d7ceaf5ab248a 100644 --- a/Tests/Functional/Python/PyEmbedded/Tests.cpp +++ b/Tests/Functional/Python/PyEmbedded/Tests.cpp @@ -25,14 +25,11 @@ #include <iostream> #include <sstream> -class PyEmbedded : public ::testing::Test -{ -}; +class PyEmbedded : public ::testing::Test {}; //! Accessing to the information about Python used during the build, content of path.sys variable. -TEST_F(PyEmbedded, SysPath) -{ +TEST_F(PyEmbedded, SysPath) { // Python build info std::cout << "pythonExecutable(): " << BABuild::pythonExecutable() << std::endl; std::cout << "pythonInterpreterID(): " << BABuild::pythonInterpreterID() << std::endl; @@ -54,8 +51,7 @@ TEST_F(PyEmbedded, SysPath) //! Importing numpy and accessing its version string. -TEST_F(PyEmbedded, ImportNumpy) -{ +TEST_F(PyEmbedded, ImportNumpy) { Py_Initialize(); PyObject* pmod = PyImport_ImportModule("numpy"); @@ -78,8 +74,7 @@ TEST_F(PyEmbedded, ImportNumpy) //! Comparing results of GetVersionNumber() function obtained in "embedded" and "native C++" ways. -TEST_F(PyEmbedded, FunctionCall) -{ +TEST_F(PyEmbedded, FunctionCall) { Py_Initialize(); PyObject* sysPath = PySys_GetObject((char*)"path"); @@ -126,8 +121,7 @@ TEST_F(PyEmbedded, FunctionCall) //! Creating instance of FormFactorCylinder and calling its method in embedded Python. -TEST_F(PyEmbedded, MethodCall) -{ +TEST_F(PyEmbedded, MethodCall) { const double radius(5.0), height(6.0); Py_Initialize(); @@ -189,8 +183,7 @@ TEST_F(PyEmbedded, MethodCall) //! From https://www.awasu.com/weblog/embedding-python/calling-python-code-from-your-program/ -TEST_F(PyEmbedded, CompiledFunction) -{ +TEST_F(PyEmbedded, CompiledFunction) { Py_Initialize(); // compile our function @@ -260,8 +253,7 @@ TEST_F(PyEmbedded, CompiledFunction) //! Creating MultiLayer in Python and extracting object to C++. //! https://stackoverflow.com/questions/9040669/how-can-i-implement-a-c-class-in-python-to-be-called-by-c/ -TEST_F(PyEmbedded, ObjectExtract) -{ +TEST_F(PyEmbedded, ObjectExtract) { Py_Initialize(); PyObject* sysPath = PySys_GetObject((char*)"path"); @@ -299,8 +291,7 @@ TEST_F(PyEmbedded, ObjectExtract) //! Running Python snippet which creates a multilayer in embedded way. //! Casting resulting PyObject to C++ MultiLayer. -TEST_F(PyEmbedded, EmbeddedMultiLayer) -{ +TEST_F(PyEmbedded, EmbeddedMultiLayer) { Py_Initialize(); PyObject* sysPath = PySys_GetObject((char*)"path"); @@ -367,8 +358,7 @@ TEST_F(PyEmbedded, EmbeddedMultiLayer) //! is casted back to C++ object and used again, to generate code snippet. //! Two code snippets must be identical. -TEST_F(PyEmbedded, ExportToPythonAndBack) -{ +TEST_F(PyEmbedded, ExportToPythonAndBack) { SampleBuilderFactory factory; std::unique_ptr<MultiLayer> sample(factory.createSampleByName("CylindersAndPrismsBuilder")); @@ -387,8 +377,7 @@ TEST_F(PyEmbedded, ExportToPythonAndBack) //! Retrieves list of functions from the imported script and checks, that there is //! one function in a dictioonary with name "get_simulation". -TEST_F(PyEmbedded, ModuleFunctionsList) -{ +TEST_F(PyEmbedded, ModuleFunctionsList) { // compile our function std::stringstream buf; buf << "import bornagain as ba \n"; diff --git a/Tests/Functional/Python/Std/Check.cpp b/Tests/Functional/Python/Std/Check.cpp index c38a42b24615355a30afa31817473a3c13c5b1c9..940c30efafd59f81ea6f2577ba4ef8b523416211 100644 --- a/Tests/Functional/Python/Std/Check.cpp +++ b/Tests/Functional/Python/Std/Check.cpp @@ -23,8 +23,7 @@ #include <iostream> std::unique_ptr<OutputData<double>> domainData(const std::string& test_name, - const ISimulation& direct_simulation) -{ + const ISimulation& direct_simulation) { const std::string output_name = FileSystemUtils::jointPath(BATesting::TestOutDir_PyStd(), test_name); const std::string output_path = output_name + ".ref.int.gz"; @@ -61,8 +60,7 @@ std::unique_ptr<OutputData<double>> domainData(const std::string& test_name, } bool checkSimulation(const std::string& name, const ISimulation& direct_simulation, - const double limit) -{ + const double limit) { const std::unique_ptr<OutputData<double>> domain_data = domainData(name, direct_simulation); const std::unique_ptr<OutputData<double>> ref_data = direct_simulation.result().data(); diff --git a/Tests/Functional/Std/Run.cpp b/Tests/Functional/Std/Run.cpp index 9b145e69afbd9b79f287903d9cb72a6414e4653b..a2505a205d6af177078383bd0a88d36351682f5e 100644 --- a/Tests/Functional/Std/Run.cpp +++ b/Tests/Functional/Std/Run.cpp @@ -26,8 +26,7 @@ bool checkSimulation(const std::string& name, const ISimulation& direct_simulati //! It then compares with reference data, or with results from Py or GUI runs. int run(const std::string& test_name, const std::string& sim_name, - const std::string& sample_builder_name, const double limit) -{ + const std::string& sample_builder_name, const double limit) { std::cout << "run std test " << test_name << std::endl; std::cout << "- create sim " << sim_name << std::endl; std::unique_ptr<ISimulation> simulation{SimulationFactory().createItem(sim_name)}; diff --git a/Tests/Functional/Std/StandardTests.h b/Tests/Functional/Std/StandardTests.h index 3e241dcc527560ab44bc7537ce87e0955b5e5c71..a46cec6696f371e618cba2093858cebbeb167f24 100644 --- a/Tests/Functional/Std/StandardTests.h +++ b/Tests/Functional/Std/StandardTests.h @@ -17,402 +17,328 @@ #include "Tests/GTestWrapper/google_test.h" -class Std : public ::testing::Test -{ -}; +class Std : public ::testing::Test {}; -TEST_F(Std, FormFactors) -{ +TEST_F(Std, FormFactors) { EXPECT_TRUE(run("FormFactors", "MiniGISAS", "ParticleInVacuumBuilder", 2e-10)); } -TEST_F(Std, GISASAbsorptiveSLDLayers) -{ +TEST_F(Std, GISASAbsorptiveSLDLayers) { EXPECT_TRUE( run("GISASAbsorptiveSLDLayers", "MiniGISAS", "LayersWithAbsorptionBySLDBuilder", 2e-10)); } -TEST_F(Std, CylindersAndPrisms) -{ +TEST_F(Std, CylindersAndPrisms) { EXPECT_TRUE(run("CylindersAndPrisms", "MiniGISAS", "CylindersAndPrismsBuilder", 2e-10)); } -TEST_F(Std, RadialParaCrystal) -{ +TEST_F(Std, RadialParaCrystal) { EXPECT_TRUE(run("RadialParaCrystal", "MiniGISAS", "RadialParaCrystalBuilder", 2e-10)); } -TEST_F(Std, HardDisk) -{ +TEST_F(Std, HardDisk) { EXPECT_TRUE(run("HardDisk", "MiniGISAS", "HardDiskBuilder", 2e-10)); } -TEST_F(Std, Basic2DParaCrystal) -{ +TEST_F(Std, Basic2DParaCrystal) { EXPECT_TRUE(run("Basic2DParaCrystal", "MiniGISAS", "Basic2DParaCrystalBuilder", 2e-10)); } -TEST_F(Std, HexParaCrystal) -{ +TEST_F(Std, HexParaCrystal) { EXPECT_TRUE(run("HexParaCrystal", "MiniGISAS", "HexParaCrystalBuilder", 2e-10)); } -TEST_F(Std, Lattice1D) -{ +TEST_F(Std, Lattice1D) { EXPECT_TRUE(run("Lattice1D", "MiniGISAS", "Lattice1DBuilder", 2e-10)); } -TEST_F(Std, RectParaCrystal) -{ +TEST_F(Std, RectParaCrystal) { // TODO: investigate numeric integration, which has become problematic under Windows // after moving code from Core/Tools to Base/Utils EXPECT_TRUE(run("RectParaCrystal", "MiniGISAS", "RectParaCrystalBuilder", 1e-9)); } -TEST_F(Std, CoreShellParticle) -{ +TEST_F(Std, CoreShellParticle) { EXPECT_TRUE(run("CoreShellParticle", "MiniGISAS", "CoreShellParticleBuilder", 2e-10)); } -TEST_F(Std, CoreShellBoxRotateZandY) -{ +TEST_F(Std, CoreShellBoxRotateZandY) { EXPECT_TRUE( run("CoreShellBoxRotateZandY", "MiniGISAS", "CoreShellBoxRotateZandYBuilder", 2e-10)); } -TEST_F(Std, MultiLayerWithRoughness) -{ +TEST_F(Std, MultiLayerWithRoughness) { EXPECT_TRUE( run("MultiLayerWithRoughness", "MiniGISAS", "MultiLayerWithRoughnessBuilder", 2e-10)); } -TEST_F(Std, SquareLattice2D) -{ +TEST_F(Std, SquareLattice2D) { EXPECT_TRUE(run("SquareLattice2D", "MiniGISAS", "SquareLattice2DBuilder", 2e-10)); } -TEST_F(Std, CenteredSquareLattice2D) -{ +TEST_F(Std, CenteredSquareLattice2D) { EXPECT_TRUE( run("CenteredSquareLattice2D", "MiniGISAS", "CenteredSquareLattice2DBuilder", 2e-10)); } -TEST_F(Std, RotatedSquareLattice2D) -{ +TEST_F(Std, RotatedSquareLattice2D) { EXPECT_TRUE(run("RotatedSquareLattice2D", "MiniGISAS", "RotatedSquareLattice2DBuilder", 2e-10)); } -TEST_F(Std, FiniteSquareLattice2D) -{ +TEST_F(Std, FiniteSquareLattice2D) { EXPECT_TRUE(run("FiniteSquareLattice2D", "MiniGISAS", "FiniteSquareLattice2DBuilder", 2e-10)); } -TEST_F(Std, RotatedPyramids) -{ +TEST_F(Std, RotatedPyramids) { EXPECT_TRUE(run("RotatedPyramids", "MiniGISAS", "RotatedPyramidsBuilder", 2e-10)); } -TEST_F(Std, ThickAbsorptiveSampleWithRoughness) -{ +TEST_F(Std, ThickAbsorptiveSampleWithRoughness) { EXPECT_TRUE(run("ThickAbsorptiveSampleWithRoughness", "ExtraLongWavelengthGISAS", "ThickAbsorptiveSampleBuilder", 2e-10)); } -TEST_F(Std, ParticleComposition) -{ +TEST_F(Std, ParticleComposition) { EXPECT_TRUE(run("ParticleComposition", "MiniGISAS", "ParticleCompositionBuilder", 2e-10)); } -TEST_F(Std, BoxCompositionRotateX) -{ +TEST_F(Std, BoxCompositionRotateX) { EXPECT_TRUE(run("BoxCompositionRotateX", "MiniGISAS", "BoxCompositionRotateXBuilder", 2e-10)); } -TEST_F(Std, BoxCompositionRotateY) -{ +TEST_F(Std, BoxCompositionRotateY) { EXPECT_TRUE(run("BoxCompositionRotateY", "MiniGISAS", "BoxCompositionRotateYBuilder", 2e-10)); } -TEST_F(Std, BoxCompositionRotateZ) -{ +TEST_F(Std, BoxCompositionRotateZ) { EXPECT_TRUE(run("BoxCompositionRotateZ", "MiniGISAS", "BoxCompositionRotateZBuilder", 2e-10)); } -TEST_F(Std, BoxCompositionRotateZandY) -{ +TEST_F(Std, BoxCompositionRotateZandY) { EXPECT_TRUE( run("BoxCompositionRotateZandY", "MiniGISAS", "BoxCompositionRotateZandYBuilder", 2e-10)); } -TEST_F(Std, BoxStackComposition) -{ +TEST_F(Std, BoxStackComposition) { EXPECT_TRUE(run("BoxStackComposition", "MiniGISAS", "BoxStackCompositionBuilder", 2e-10)); } -TEST_F(Std, CylindersWithSizeDistribution) -{ +TEST_F(Std, CylindersWithSizeDistribution) { EXPECT_TRUE(run("CylindersWithSizeDistribution", "MiniGISAS", "CylindersWithSizeDistributionBuilder", 2e-10)); } -TEST_F(Std, TwoTypesCylindersDistribution) -{ +TEST_F(Std, TwoTypesCylindersDistribution) { EXPECT_TRUE(run("TwoTypesCylindersDistribution", "MiniGISAS", "TwoTypesCylindersDistributionBuilder", 2e-10)); } -TEST_F(Std, RotatedPyramidsDistribution) -{ +TEST_F(Std, RotatedPyramidsDistribution) { EXPECT_TRUE(run("RotatedPyramidsDistribution", "MiniGISAS", "RotatedPyramidsDistributionBuilder", 2e-10)); } -TEST_F(Std, SpheresWithLimitsDistribution) -{ +TEST_F(Std, SpheresWithLimitsDistribution) { EXPECT_TRUE(run("SpheresWithLimitsDistribution", "MiniGISAS", "SpheresWithLimitsDistributionBuilder", 2e-10)); } -TEST_F(Std, ConesWithLimitsDistribution) -{ +TEST_F(Std, ConesWithLimitsDistribution) { EXPECT_TRUE(run("ConesWithLimitsDistribution", "MiniGISAS", "ConesWithLimitsDistributionBuilder", 2e-10)); } -TEST_F(Std, LinkedBoxDistribution) -{ +TEST_F(Std, LinkedBoxDistribution) { EXPECT_TRUE(run("LinkedBoxDistribution", "MiniGISAS", "LinkedBoxDistributionBuilder", 2e-10)); } -TEST_F(Std, BeamDivergence) -{ +TEST_F(Std, BeamDivergence) { EXPECT_TRUE(run("BeamDivergence", "MiniGISASBeamDivergence", "CylindersInBABuilder", 2e-10)); } -TEST_F(Std, DetectorResolution) -{ +TEST_F(Std, DetectorResolution) { EXPECT_TRUE( run("DetectorResolution", "MiniGISASDetectorResolution", "CylindersInBABuilder", 2e-10)); } -TEST_F(Std, MultipleLayout) -{ +TEST_F(Std, MultipleLayout) { EXPECT_TRUE(run("MultipleLayout", "MiniGISAS", "MultipleLayoutBuilder", 2e-10)); } -TEST_F(Std, ApproximationDA) -{ +TEST_F(Std, ApproximationDA) { EXPECT_TRUE(run("ApproximationDA", "MiniGISAS", "SizeDistributionDAModelBuilder", 2e-10)); } -TEST_F(Std, ApproximationLMA) -{ +TEST_F(Std, ApproximationLMA) { EXPECT_TRUE(run("ApproximationLMA", "MiniGISAS", "SizeDistributionLMAModelBuilder", 2e-10)); } -TEST_F(Std, ApproximationSSCA) -{ +TEST_F(Std, ApproximationSSCA) { EXPECT_TRUE(run("ApproximationSSCA", "MiniGISAS", "SizeDistributionSSCAModelBuilder", 2e-10)); } -TEST_F(Std, CylindersInSSCA) -{ +TEST_F(Std, CylindersInSSCA) { EXPECT_TRUE(run("CylindersInSSCA", "MiniGISAS", "CylindersInSSCABuilder", 2e-10)); } -TEST_F(Std, CosineRipple) -{ +TEST_F(Std, CosineRipple) { EXPECT_TRUE(run("CosineRipple", "MiniGISAS", "CosineRippleBuilder", 2e-10)); } -TEST_F(Std, TriangularRipple) -{ +TEST_F(Std, TriangularRipple) { EXPECT_TRUE(run("TriangularRipple", "MiniGISAS", "TriangularRippleBuilder", 2e-10)); } -TEST_F(Std, AsymRipple) -{ +TEST_F(Std, AsymRipple) { EXPECT_TRUE(run("AsymRipple", "MiniGISAS", "AsymRippleBuilder", 2e-10)); } -TEST_F(Std, MesoCrystal) -{ +TEST_F(Std, MesoCrystal) { EXPECT_TRUE(run("MesoCrystal", "MiniGISAS", "MesoCrystalBuilder", 2e-10)); } -TEST_F(Std, CustomMorphology) -{ +TEST_F(Std, CustomMorphology) { EXPECT_TRUE(run("CustomMorphology", "MiniGISAS", "CustomMorphologyBuilder", 2e-10)); } -TEST_F(Std, TransformBox) -{ +TEST_F(Std, TransformBox) { EXPECT_TRUE(run("TransformBox", "MiniGISAS", "TransformBoxBuilder", 1e-10)); } -TEST_F(Std, MagneticParticleZeroField) -{ +TEST_F(Std, MagneticParticleZeroField) { EXPECT_TRUE( run("MagneticParticleZeroField", "MiniGISAS", "MagneticParticleZeroFieldBuilder", 2e-10)); } -TEST_F(Std, MagneticSubstrateZeroField) -{ +TEST_F(Std, MagneticSubstrateZeroField) { EXPECT_TRUE(run("MagneticSubstrateZeroField", "MiniGISASPolarizationPP", "MagneticSubstrateZeroFieldBuilder", 2e-10)); } -TEST_F(Std, MagneticRotation) -{ +TEST_F(Std, MagneticRotation) { EXPECT_TRUE( run("MagneticRotation", "MiniGISASPolarizationPM", "MagneticRotationBuilder", 2e-10)); } -TEST_F(Std, MagneticSpheres) -{ +TEST_F(Std, MagneticSpheres) { EXPECT_TRUE(run("MagneticSpheres", "MiniGISASPolarizationPM", "MagneticSpheresBuilder", 2e-10)); } -TEST_F(Std, MagneticCylindersPP) -{ +TEST_F(Std, MagneticCylindersPP) { EXPECT_TRUE( run("MagneticCylindersPP", "MiniGISASPolarizationPP", "MagneticCylindersBuilder", 2e-10)); } -TEST_F(Std, MagneticCylindersPM) -{ +TEST_F(Std, MagneticCylindersPM) { EXPECT_TRUE( run("MagneticCylindersPM", "MiniGISASPolarizationPM", "MagneticCylindersBuilder", 2e-10)); } -TEST_F(Std, MagneticCylindersMP) -{ +TEST_F(Std, MagneticCylindersMP) { EXPECT_TRUE( run("MagneticCylindersMP", "MiniGISASPolarizationMP", "MagneticCylindersBuilder", 2e-10)); } -TEST_F(Std, MagneticCylindersMM) -{ +TEST_F(Std, MagneticCylindersMM) { EXPECT_TRUE( run("MagneticCylindersMM", "MiniGISASPolarizationMM", "MagneticCylindersBuilder", 2e-10)); } -TEST_F(Std, MagneticSpheresInMagLayerPP) -{ +TEST_F(Std, MagneticSpheresInMagLayerPP) { EXPECT_TRUE(run("MagneticSpheresInMagLayerPP", "MiniGISASPolarizationPP", "MagneticLayerBuilder", 2e-10)); } -TEST_F(Std, MagneticSpheresInMagLayerMP) -{ +TEST_F(Std, MagneticSpheresInMagLayerMP) { EXPECT_TRUE(run("MagneticSpheresInMagLayerMP", "MiniGISASPolarizationMP", "MagneticLayerBuilder", 2e-10)); } -TEST_F(Std, SimulationWithMasks) -{ +TEST_F(Std, SimulationWithMasks) { EXPECT_TRUE(run("SimulationWithMasks", "GISASWithMasks", "CylindersAndPrismsBuilder", 1e-10)); } -TEST_F(Std, RectDetectorGeneric) -{ +TEST_F(Std, RectDetectorGeneric) { EXPECT_TRUE(run("RectDetectorGeneric", "RectDetectorGeneric", "CylindersInBABuilder", 1e-10)); } -TEST_F(Std, RectDetectorPerpToSample) -{ +TEST_F(Std, RectDetectorPerpToSample) { EXPECT_TRUE( run("RectDetectorPerpToSample", "RectDetectorPerpToSample", "CylindersInBABuilder", 1e-10)); } -TEST_F(Std, RectDetectorPerpToDirectBeam) -{ +TEST_F(Std, RectDetectorPerpToDirectBeam) { EXPECT_TRUE(run("RectDetectorPerpToDirectBeam", "RectDetectorPerpToDirectBeam", "CylindersInBABuilder", 1e-10)); } -TEST_F(Std, RectDetectorPerpToReflectedBeam) -{ +TEST_F(Std, RectDetectorPerpToReflectedBeam) { EXPECT_TRUE(run("RectDetectorPerpToReflectedBeam", "RectDetectorPerpToReflectedBeam", "CylindersInBABuilder", 1e-10)); } -TEST_F(Std, RectDetectorPerpToReflectedBeamDpos) -{ +TEST_F(Std, RectDetectorPerpToReflectedBeamDpos) { EXPECT_TRUE(run("RectDetectorPerpToReflectedBeamDpos", "RectDetectorPerpToReflectedBeamDpos", "CylindersInBABuilder", 1e-10)); } -TEST_F(Std, LargeCylindersMonteCarlo) -{ +TEST_F(Std, LargeCylindersMonteCarlo) { EXPECT_TRUE(run("LargeCylindersMonteCarlo", "MiniGISASMonteCarlo", "LargeCylindersInDWBABuilder", 5e-1)); } -TEST_F(Std, SphericalDetWithRoi) -{ +TEST_F(Std, SphericalDetWithRoi) { EXPECT_TRUE( run("SphericalDetWithRoi", "SphericalDetWithRoi", "CylindersAndPrismsBuilder", 1e-10)); } -TEST_F(Std, RectDetWithRoi) -{ +TEST_F(Std, RectDetWithRoi) { EXPECT_TRUE(run("RectDetWithRoi", "RectDetWithRoi", "CylindersAndPrismsBuilder", 1e-10)); } -TEST_F(Std, BoxesWithSpecular) -{ +TEST_F(Std, BoxesWithSpecular) { EXPECT_TRUE( run("BoxesWithSpecular", "MiniGISASSpecular", "BoxesSquareLattice2DBuilder", 1e-10)); } -TEST_F(Std, RotatedCylinder) -{ +TEST_F(Std, RotatedCylinder) { EXPECT_TRUE(run("RotatedCylinder", "MiniGISAS", "RotatedCylindersBuilder", 1e-10)); } -TEST_F(Std, SlicedComposition) -{ +TEST_F(Std, SlicedComposition) { EXPECT_TRUE(run("SlicedComposition", "MiniGISAS", "SlicedCompositionBuilder", 1e-10)); } -TEST_F(Std, ConstantBackground) -{ +TEST_F(Std, ConstantBackground) { EXPECT_TRUE(run("ConstantBackground", "ConstantBackground", "CylindersInBABuilder", 1e-10)); } -TEST_F(Std, HomogeneousTiNiSample) -{ +TEST_F(Std, HomogeneousTiNiSample) { EXPECT_TRUE( run("HomogeneousTiNiSample", "BasicSpecular", "HomogeneousMultilayerBuilder", 1e-10)); } -TEST_F(Std, HomogeneousTiNiSampleWithAbsorption) -{ +TEST_F(Std, HomogeneousTiNiSampleWithAbsorption) { EXPECT_TRUE(run("HomogeneousTiNiSampleWithAbsorption", "BasicSpecular", "PlainMultiLayerBySLDBuilder", 1e-10)); } -TEST_F(Std, RoughnessInSpecular) -{ +TEST_F(Std, RoughnessInSpecular) { EXPECT_TRUE( run("RoughnessInSpecular", "BasicSpecular", "MultiLayerWithRoughnessBuilder", 2e-9)); } -TEST_F(Std, GaussianBeamFootprint) -{ +TEST_F(Std, GaussianBeamFootprint) { EXPECT_TRUE(run("GaussianBeamFootprint", "SpecularWithGaussianBeam", "HomogeneousMultilayerBuilder", 1e-10)); } -TEST_F(Std, SquareBeamFootprint) -{ +TEST_F(Std, SquareBeamFootprint) { EXPECT_TRUE(run("SquareBeamFootprint", "SpecularWithSquareBeam", "HomogeneousMultilayerBuilder", 1e-10)); } -TEST_F(Std, SpecularDivergentBeam) -{ +TEST_F(Std, SpecularDivergentBeam) { EXPECT_TRUE(run("SpecularDivergentBeam", "SpecularDivergentBeam", "HomogeneousMultilayerBuilder", 1e-10)); } @@ -423,8 +349,7 @@ TEST_F(Std, SpecularDivergentBeam) #ifndef GUI_STD_TEST -TEST_F(Std, RelativeResolutionTOF) -{ +TEST_F(Std, RelativeResolutionTOF) { EXPECT_TRUE(run("RelativeResolutionTOF", "TOFRWithRelativeResolution", "PlainMultiLayerBySLDBuilder", 1e-10)); } @@ -437,13 +362,11 @@ TEST_F(Std, RelativeResolutionTOF) #ifndef PYTHON_STD_TEST -TEST_F(Std, OffSpecularResonator) -{ +TEST_F(Std, OffSpecularResonator) { EXPECT_TRUE(run("OffSpecularResonator", "OffSpecMini", "ResonatorBuilder", 1e-10)); } -TEST_F(Std, FormFactorsWithAbsorption) -{ +TEST_F(Std, FormFactorsWithAbsorption) { EXPECT_TRUE( run("FormFactorsWithAbsorption", "MiniGISAS_v2", "LayersWithAbsorptionBuilder", 2e-10)); } @@ -456,19 +379,16 @@ TEST_F(Std, FormFactorsWithAbsorption) #ifndef PYTHON_STD_TEST #ifndef GUI_STD_TEST -TEST_F(Std, NCRoughnessInSpecular) -{ +TEST_F(Std, NCRoughnessInSpecular) { EXPECT_TRUE( run("NCRoughnessInSpecular", "BasicSpecular", "MultiLayerWithNCRoughnessBuilder", 2e-9)); } -TEST_F(Std, SuperLattice) -{ +TEST_F(Std, SuperLattice) { EXPECT_TRUE(run("SuperLattice", "MiniGISAS", "SuperLatticeBuilder", 2e-10)); } -TEST_F(Std, SpecularWithSlicing) -{ +TEST_F(Std, SpecularWithSlicing) { EXPECT_TRUE(run("SpecularWithSlicing_01", "BasicSpecular", "SlicedCylindersBuilder", 1e-10)); EXPECT_TRUE(run("SpecularWithSlicing_02", "BasicSpecular", "SLDSlicedCylindersBuilder", 1e-10)); EXPECT_TRUE( @@ -477,50 +397,43 @@ TEST_F(Std, SpecularWithSlicing) run("SpecularWithSlicing_Q2", "BasicSpecularQ", "SLDSlicedCylindersBuilder", 1e-10)); } -TEST_F(Std, InstrumentDefinitionComparison) -{ +TEST_F(Std, InstrumentDefinitionComparison) { EXPECT_TRUE(run("InstrumentDefinitionComparison_0", "BasicSpecular", "PlainMultiLayerBySLDBuilder", 1e-10)); EXPECT_TRUE(run("InstrumentDefinitionComparison_Q", "BasicSpecularQ", "PlainMultiLayerBySLDBuilder", 1e-10)); } -TEST_F(Std, TOFResolutionComparison) -{ +TEST_F(Std, TOFResolutionComparison) { EXPECT_TRUE(run("TOFResolutionComparison_TR", "TOFRWithRelativeResolution", "PlainMultiLayerBySLDBuilder", 1e-10)); EXPECT_TRUE(run("TOFResolutionComparison_TP", "TOFRWithPointwiseResolution", "PlainMultiLayerBySLDBuilder", 1e-10)); } -TEST_F(Std, BasicSpecularPP) -{ +TEST_F(Std, BasicSpecularPP) { EXPECT_TRUE(run("BasicSpecularPP", "BasicSpecularPP", "SimpleMagneticLayerBuilder", 1e-10)); } -TEST_F(Std, BasicSpecularMM) -{ +TEST_F(Std, BasicSpecularMM) { EXPECT_TRUE(run("BasicSpecularMM", "BasicSpecularMM", "SimpleMagneticLayerBuilder", 1e-10)); } -TEST_F(Std, PolarizedQAngleReflectivityPP) -{ +TEST_F(Std, PolarizedQAngleReflectivityPP) { EXPECT_TRUE(run("PolarizedQAngleReflectivityPP_0", "BasicSpecularPP", "SimpleMagneticLayerBuilder", 1e-10)); EXPECT_TRUE(run("PolarizedQAngleReflectivityPP_Q", "BasicQSpecularPP", "SimpleMagneticLayerBuilder", 1e-10)); } -TEST_F(Std, PolarizedQAngleReflectivityMM) -{ +TEST_F(Std, PolarizedQAngleReflectivityMM) { EXPECT_TRUE(run("PolarizedQAngleReflectivityMM_0", "BasicSpecularMM", "SimpleMagneticLayerBuilder", 1e-10)); EXPECT_TRUE(run("PolarizedQAngleReflectivityMM_Q", "BasicQSpecularMM", "SimpleMagneticLayerBuilder", 1e-10)); } -TEST_F(Std, MagneticRotationReflectivity) -{ +TEST_F(Std, MagneticRotationReflectivity) { EXPECT_TRUE(run("MagneticRotationReflectivityPP", "BasicSpecularPP", "SimpleMagneticRotationBuilder", 1e-10)); EXPECT_TRUE(run("MagneticRotationReflectivityMM", "BasicSpecularMM", @@ -531,146 +444,127 @@ TEST_F(Std, MagneticRotationReflectivity) "SimpleMagneticRotationBuilder", 1e-10)); } -TEST_F(Std, PolarizedFeNiBilayerPP) -{ +TEST_F(Std, PolarizedFeNiBilayerPP) { EXPECT_TRUE(run("PolarizedFeNiBilayerPP", "BasicSpecularPP", "FeNiBilayerBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerPP_Q", "BasicQSpecularPP", "FeNiBilayerBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerMM) -{ +TEST_F(Std, PolarizedFeNiBilayerMM) { EXPECT_TRUE(run("PolarizedFeNiBilayerMM", "BasicSpecularMM", "FeNiBilayerBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerMM_Q", "BasicQSpecularMM", "FeNiBilayerBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerTanhPP) -{ +TEST_F(Std, PolarizedFeNiBilayerTanhPP) { EXPECT_TRUE( run("PolarizedFeNiBilayerTanhPP", "BasicSpecularPP", "FeNiBilayerTanhBuilder", 1e-7)); EXPECT_TRUE( run("PolarizedFeNiBilayerTanhPP_Q", "BasicQSpecularPP", "FeNiBilayerTanhBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerTanhMM) -{ +TEST_F(Std, PolarizedFeNiBilayerTanhMM) { EXPECT_TRUE( run("PolarizedFeNiBilayerTanhMM", "BasicSpecularMM", "FeNiBilayerTanhBuilder", 1e-7)); EXPECT_TRUE( run("PolarizedFeNiBilayerTanhMM_Q", "BasicQSpecularMM", "FeNiBilayerTanhBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerNCPP) -{ +TEST_F(Std, PolarizedFeNiBilayerNCPP) { EXPECT_TRUE(run("PolarizedFeNiBilayerNCPP", "BasicSpecularPP", "FeNiBilayerNCBuilder", 1e-7)); EXPECT_TRUE( run("PolarizedFeNiBilayerNCPP_Q", "BasicQSpecularPP", "FeNiBilayerNCBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerNCMM) -{ +TEST_F(Std, PolarizedFeNiBilayerNCMM) { EXPECT_TRUE(run("PolarizedFeNiBilayerNCMM", "BasicSpecularMM", "FeNiBilayerTanhBuilder", 1e-7)); EXPECT_TRUE( run("PolarizedFeNiBilayerNCMM_Q", "BasicQSpecularMM", "FeNiBilayerNCBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipPP) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipPP) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipPP", "BasicSpecularPP", "FeNiBilayerSpinFlipBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipPP_Q", "BasicQSpecularPP", "FeNiBilayerSpinFlipBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipMM) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipMM) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipMM", "BasicSpecularMM", "FeNiBilayerSpinFlipBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipMM_Q", "BasicQSpecularMM", "FeNiBilayerSpinFlipBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipPM) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipPM) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipPM", "BasicSpecularPM", "FeNiBilayerSpinFlipBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipPM_Q", "BasicQSpecularPM", "FeNiBilayerSpinFlipBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipMP) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipMP) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipMP", "BasicSpecularMP", "FeNiBilayerSpinFlipBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipMP_Q", "BasicQSpecularMP", "FeNiBilayerSpinFlipBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipTanhPP) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipTanhPP) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipTanhPP", "BasicSpecularPP", "FeNiBilayerSpinFlipTanhBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipTanhPP_Q", "BasicQSpecularPP", "FeNiBilayerSpinFlipTanhBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipTanhMM) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipTanhMM) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipTanhMM", "BasicSpecularMM", "FeNiBilayerSpinFlipTanhBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipTanhMM_Q", "BasicQSpecularMM", "FeNiBilayerSpinFlipTanhBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipTanhPM) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipTanhPM) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipTanhPM", "BasicSpecularPM", "FeNiBilayerSpinFlipTanhBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipTanhPM_Q", "BasicQSpecularPM", "FeNiBilayerSpinFlipTanhBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipTanhMP) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipTanhMP) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipTanhMP", "BasicSpecularMP", "FeNiBilayerSpinFlipTanhBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipTanhMP_Q", "BasicQSpecularMP", "FeNiBilayerSpinFlipTanhBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipNCPP) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipNCPP) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipNCPP", "BasicSpecularPP", "FeNiBilayerSpinFlipNCBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipNCPP_Q", "BasicQSpecularPP", "FeNiBilayerSpinFlipNCBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipNCMM) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipNCMM) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipNCMM", "BasicSpecularMM", "FeNiBilayerSpinFlipNCBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipNCMM_Q", "BasicQSpecularMM", "FeNiBilayerSpinFlipNCBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipNCPM) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipNCPM) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipNCPM", "BasicSpecularPM", "FeNiBilayerSpinFlipNCBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipNCPM_Q", "BasicQSpecularPM", "FeNiBilayerSpinFlipNCBuilder", 1e-7)); } -TEST_F(Std, PolarizedFeNiBilayerSpinFlipNCMP) -{ +TEST_F(Std, PolarizedFeNiBilayerSpinFlipNCMP) { EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipNCMP", "BasicSpecularMP", "FeNiBilayerSpinFlipNCBuilder", 1e-7)); EXPECT_TRUE(run("PolarizedFeNiBilayerSpinFlipNCMP_Q", "BasicQSpecularMP", "FeNiBilayerSpinFlipNCBuilder", 1e-7)); } -TEST_F(Std, DepthProbeTest) -{ +TEST_F(Std, DepthProbeTest) { EXPECT_TRUE(run("DepthProbeTest", "BasicDepthProbe", "HomogeneousMultilayerBuilder", 1e-10)); } diff --git a/Tests/GTestWrapper/TestAll.cpp b/Tests/GTestWrapper/TestAll.cpp index 59122773134355b5a95019e2d2e967aada8b591a..2c7d770903ae664bd4653c05ce0f6722f816bf46 100644 --- a/Tests/GTestWrapper/TestAll.cpp +++ b/Tests/GTestWrapper/TestAll.cpp @@ -1,7 +1,6 @@ #include "Tests/GTestWrapper/google_test.h" -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // run all google tests diff --git a/Tests/Performance/Benchmark.cpp b/Tests/Performance/Benchmark.cpp index 279f449dfa07021c1d8f7c05a7026ef88dae3e0e..7f5b97276b5af75c19e1549f37e3f943c4b497e6 100644 --- a/Tests/Performance/Benchmark.cpp +++ b/Tests/Performance/Benchmark.cpp @@ -18,15 +18,13 @@ #include <sstream> #include <stdexcept> -Benchmark::~Benchmark() -{ +Benchmark::~Benchmark() { for (auto it = m_data.begin(); it != m_data.end(); ++it) { delete it->second; } } -void Benchmark::start(const std::string& name) -{ +void Benchmark::start(const std::string& name) { std::cout << "Benchmark::start() -> Starting '" << name << "'" << std::endl; if (m_data.find(name) == m_data.end()) m_data.insert(name, new Duration()); @@ -34,24 +32,21 @@ void Benchmark::start(const std::string& name) m_data[name]->start(); } -void Benchmark::stop(const std::string& name) -{ +void Benchmark::stop(const std::string& name) { if (m_data.find(name) == m_data.end()) throw std::runtime_error("Benchmark::stop() -> No such process '" + name + "'"); m_data[name]->stop(); } -double Benchmark::runTime(const std::string& name) -{ +double Benchmark::runTime(const std::string& name) { if (m_data.find(name) == m_data.end()) throw std::runtime_error("Benchmark::stop() -> No such process '" + name + "'"); return m_data[name]->runTime(); } -std::string Benchmark::report() const -{ +std::string Benchmark::report() const { std::ostringstream result; for (auto it = m_data.begin(); it != m_data.end(); ++it) { @@ -65,8 +60,7 @@ std::string Benchmark::report() const //! Tests method by running it several times. -void Benchmark::test_method(const std::string& name, std::function<void()> f, int ntries) -{ +void Benchmark::test_method(const std::string& name, std::function<void()> f, int ntries) { std::cout << " " << name << " trying " << std::to_string(ntries) << " times\n"; // warming up diff --git a/Tests/Performance/Benchmark.h b/Tests/Performance/Benchmark.h index b78f03b31c437ebd84f0f34b09eaa30b4aa37f6f..720b6c1bef00cd354f294776f0714cf8d7a6640a 100644 --- a/Tests/Performance/Benchmark.h +++ b/Tests/Performance/Benchmark.h @@ -24,14 +24,12 @@ // No Win export symbols here, because Benchmark.cpp is linked directly to the executables, // and not in form of a library -class Duration -{ +class Duration { public: Duration() : m_totalTime(0) {} void start() { m_timer.start(); } - void stop() - { + void stop() { m_timer.stop(); m_totalTime += m_timer.runTime(); } @@ -44,8 +42,7 @@ private: //! Benchmark tool to measure duration of several processes. -class Benchmark -{ +class Benchmark { typedef OrderedMap<std::string, Duration*> BenchmarkMap; public: diff --git a/Tests/Performance/Core/CoreIO.cpp b/Tests/Performance/Core/CoreIO.cpp index b7bf2073d2c20155e23bcecaa4aac9f1e408e36d..abed40b124ecf8617bf45473833a273804fa32db 100644 --- a/Tests/Performance/Core/CoreIO.cpp +++ b/Tests/Performance/Core/CoreIO.cpp @@ -21,8 +21,7 @@ #include <iostream> #include <random> -namespace -{ +namespace { struct TestResults { int m_nx; @@ -38,8 +37,7 @@ struct TestResults { std::vector<TestResults> results; -std::unique_ptr<OutputData<double>> createData(int nx, int ny, bool fill) -{ +std::unique_ptr<OutputData<double>> createData(int nx, int ny, bool fill) { std::unique_ptr<OutputData<double>> result(new OutputData<double>); result->addAxis("x", nx, 0.0, static_cast<double>(nx)); result->addAxis("y", ny, 0.0, static_cast<double>(ny)); @@ -59,8 +57,7 @@ std::unique_ptr<OutputData<double>> createData(int nx, int ny, bool fill) //! Returns biggest element difference found. -double biggest_difference(const OutputData<double>& data, const OutputData<double>& ref) -{ +double biggest_difference(const OutputData<double>& data, const OutputData<double>& ref) { if (data.getAllocatedSize() != ref.getAllocatedSize()) throw std::runtime_error("CoreIOTest::biggest_difference() -> Error. Size is different."); @@ -73,8 +70,7 @@ double biggest_difference(const OutputData<double>& data, const OutputData<doubl return max_diff; } -bool test_io(int nx, int ny, bool random_data, const std::string& ext) -{ +bool test_io(int nx, int ny, bool random_data, const std::string& ext) { std::cout << "Test " << nx << "x" << ny << ", " << (random_data ? "random data" : "zeros") << ", file_format: " << ext << "\n"; @@ -121,8 +117,7 @@ bool test_io(int nx, int ny, bool random_data, const std::string& ext) return success; } -std::string report() -{ +std::string report() { std::ostringstream result; result << "--- CoreIOTest::report() ---\n"; @@ -139,8 +134,7 @@ std::string report() } // namespace -int main() -{ +int main() { bool success(true); // 1024x768, zeros diff --git a/Tests/Performance/Core/Mesocrystal.cpp b/Tests/Performance/Core/Mesocrystal.cpp index ecac94aab5e451a56b23a69527c32c0fda936bb4..fa0e9ffa2934ab8167a0543d5b8ed8575d383f3a 100644 --- a/Tests/Performance/Core/Mesocrystal.cpp +++ b/Tests/Performance/Core/Mesocrystal.cpp @@ -31,8 +31,7 @@ #include "Sample/SoftParticle/FormFactorSphereLogNormalRadius.h" #include <iostream> -namespace -{ +namespace { const double m_distance(909.99); const double m_pixel_size = 4 * 41.74e-3; @@ -41,8 +40,7 @@ const int m_ny = 1024; const double m_center_x = 108.2; const double m_center_y = 942.0; -std::unique_ptr<RectangularDetector> create_detector() -{ +std::unique_ptr<RectangularDetector> create_detector() { double width = m_nx * m_pixel_size; double height = m_ny * m_pixel_size; double u0 = m_center_x * m_pixel_size; @@ -53,8 +51,7 @@ std::unique_ptr<RectangularDetector> create_detector() return result; } -Lattice3D createLattice(double a, double c) -{ +Lattice3D createLattice(double a, double c) { Lattice3D result = bake::HexagonalLattice(a, c); result.setSelectionRule(SimpleSelectionRule(-1, 1, 1, 3)); return result; @@ -67,8 +64,7 @@ using Units::nm; //! Runs heavy mesocrystal simulation to investigate where it spends time. -class MesoCrystalPerformanceBuilder : public ISampleBuilder -{ +class MesoCrystalPerformanceBuilder : public ISampleBuilder { public: MesoCrystalPerformanceBuilder(); @@ -111,12 +107,9 @@ MesoCrystalPerformanceBuilder::MesoCrystalPerformanceBuilder() , m_phi_rotation_steps(5) , m_tilt_start(0.0 * deg) , m_tilt_stop(1.0 * deg) - , m_tilt_steps(1) -{ -} + , m_tilt_steps(1) {} -MultiLayer* MesoCrystalPerformanceBuilder::buildSample() const -{ +MultiLayer* MesoCrystalPerformanceBuilder::buildSample() const { double surface_density = m_surface_filling_ratio / M_PI / m_meso_radius / m_meso_radius; complex_t n_particle(1.0 - 2.84e-5, 4.7e-7); auto avg_n_squared_meso = 0.7886 * n_particle * n_particle + 0.2114; @@ -168,8 +161,7 @@ MultiLayer* MesoCrystalPerformanceBuilder::buildSample() const } std::unique_ptr<MesoCrystal> -MesoCrystalPerformanceBuilder::createMeso(Material material, const IFormFactor& form_factor) const -{ +MesoCrystalPerformanceBuilder::createMeso(Material material, const IFormFactor& form_factor) const { auto lattice = createLattice(m_lattice_length_a, m_lattice_length_c); auto bas_a = lattice.getBasisVectorA(); @@ -193,8 +185,7 @@ MesoCrystalPerformanceBuilder::createMeso(Material material, const IFormFactor& return std::make_unique<MesoCrystal>(npc, form_factor); } -int main() -{ +int main() { GISASSimulation simulation; simulation.setTerminalProgressMonitor(); diff --git a/Tests/Performance/Core/Multilayer.cpp b/Tests/Performance/Core/Multilayer.cpp index f41731243b932d2b6fea7db3710794a25856f9a3..b4cc059dbb0700fcc7d4ae2969662d9c778af218 100644 --- a/Tests/Performance/Core/Multilayer.cpp +++ b/Tests/Performance/Core/Multilayer.cpp @@ -20,8 +20,7 @@ using Results = std::vector<std::pair<int, long>>; -namespace -{ +namespace { const std::vector<int> n_layers = {10, 100, 200, 500, 1000}; const auto now = std::chrono::high_resolution_clock::now; @@ -29,15 +28,13 @@ const auto duration = [](auto time_interval) { return std::chrono::duration_cast<std::chrono::milliseconds>(time_interval).count(); }; -void report(const Results& results) -{ +void report(const Results& results) { for (auto& pair : results) std::cout << "n_layers = " << pair.first << ",\t time = " << pair.second << " ms\n"; } } // namespace -int main() -{ +int main() { Results results; results.reserve(n_layers.size()); diff --git a/Tests/Performance/Core/Threading.cpp b/Tests/Performance/Core/Threading.cpp index a73d9862d10c69c2dd01fb9f1a193ca849ee63f4..40d6d36e794caad981196d0bedde1d8140800829 100644 --- a/Tests/Performance/Core/Threading.cpp +++ b/Tests/Performance/Core/Threading.cpp @@ -37,8 +37,7 @@ using namespace TestComponents; //! Two aspects are addressed: performance scaling with number of threads, influence of //! simulation settings on scaling. -class MultiThreadPerformanceTest -{ +class MultiThreadPerformanceTest { public: bool runTest(); @@ -66,8 +65,7 @@ private: TestResult test_case(const std::string& sim_type, size_t nrepetitions, size_t nthreads) const; }; -namespace -{ +namespace { const auto now = std::chrono::high_resolution_clock::now; const auto duration = [](auto time_interval) { @@ -99,8 +97,7 @@ std::map<std::string, builder_t> builders{ {sim_wavelength, CreateWavelengthGISAS}, {sim_mc, CreateMCGISAS}}; //! Calculates scale factor (100% means perfect scaling with number of threads). -void normalize_to_single_thread(MultiThreadPerformanceTest::test_results_t& data) -{ +void normalize_to_single_thread(MultiThreadPerformanceTest::test_results_t& data) { const double single_thread_performance = data[0].time_msec; for (auto& x : data) x.scale_par = 100.0 * single_thread_performance / (x.time_msec * x.nthreads); @@ -109,8 +106,7 @@ void normalize_to_single_thread(MultiThreadPerformanceTest::test_results_t& data //! Returns list of threads to measure. For system with 8 hardware threads //! the list will be formed as {1, 2, 4, 6, 8}, //! for 32 threads {1, 2, 4, 8, 10, 12, 16, 20, 24, 28, 32} -std::vector<size_t> threads_to_measure() -{ +std::vector<size_t> threads_to_measure() { std::vector<size_t> result; auto max_threads = std::thread::hardware_concurrency(); for (size_t n_thread = 1; n_thread <= max_threads; ++n_thread) { @@ -123,8 +119,7 @@ std::vector<size_t> threads_to_measure() } // namespace -bool MultiThreadPerformanceTest::runTest() -{ +bool MultiThreadPerformanceTest::runTest() { std::cout << "MultiThreadPerformanceTest::runTest()" << std::endl; // std::vector<SimData> sim_data = {{sim_realistic, 10}}; @@ -149,8 +144,7 @@ bool MultiThreadPerformanceTest::runTest() } //! Warm up all cores. -void MultiThreadPerformanceTest::warm_up() const -{ +void MultiThreadPerformanceTest::warm_up() const { std::cout << "Warming up" << std::endl; test_case(sim_simple, 500, std::thread::hardware_concurrency()); } @@ -158,8 +152,7 @@ void MultiThreadPerformanceTest::warm_up() const //! Runs all measurements. MultiThreadPerformanceTest::test_map_t MultiThreadPerformanceTest::run_measurements(std::vector<size_t> threads_data, - std::vector<SimData> sim_data) const -{ + std::vector<SimData> sim_data) const { const auto start_time = now(); test_map_t results; @@ -176,8 +169,7 @@ MultiThreadPerformanceTest::run_measurements(std::vector<size_t> threads_data, } //! Prints fancy table with results of measurements. -void MultiThreadPerformanceTest::fancy_print(const test_map_t& results) const -{ +void MultiThreadPerformanceTest::fancy_print(const test_map_t& results) const { // print results std::ostringstream ostr; ostr << "\nPerformance in msec and thread scaling efficiency for various simulations.\n"; @@ -223,8 +215,7 @@ void MultiThreadPerformanceTest::fancy_print(const test_map_t& results) const MultiThreadPerformanceTest::TestResult MultiThreadPerformanceTest::test_case(const std::string& sim_type, size_t nrepetitions, - size_t nthreads) const -{ + size_t nthreads) const { auto simulation = builders[sim_type](); simulation->getOptions().setNumberOfThreads(nthreads); @@ -235,7 +226,6 @@ MultiThreadPerformanceTest::test_case(const std::string& sim_type, size_t nrepet return {sim_type, nrepetitions, nthreads, static_cast<int>(duration(now() - start_time)), 0.0}; } -int main() -{ +int main() { return !MultiThreadPerformanceTest().runTest(); } diff --git a/Tests/Performance/Core/Threading.h b/Tests/Performance/Core/Threading.h index 91d233e57b37b7a86b80be051456c6e5d496ba39..141883198bfbedbf4cdabecc19c226c5118b0752 100644 --- a/Tests/Performance/Core/Threading.h +++ b/Tests/Performance/Core/Threading.h @@ -22,8 +22,7 @@ //! Two aspects are addressed: performance scaling with number of threads, influence of //! simulation settings on scaling. -class MultiThreadPerformanceTest -{ +class MultiThreadPerformanceTest { public: bool runTest(); diff --git a/Tests/Performance/Core/ThreadingComponents.cpp b/Tests/Performance/Core/ThreadingComponents.cpp index c83ce7386d0cc3c3b974478249eeede35affa4d7..5ad0701f42f00248b7ccd1443a158dafa0412ef5 100644 --- a/Tests/Performance/Core/ThreadingComponents.cpp +++ b/Tests/Performance/Core/ThreadingComponents.cpp @@ -29,12 +29,10 @@ #include "Sample/Particle/ParticleDistribution.h" #include "Sample/StandardSamples/CylindersBuilder.h" -namespace -{ +namespace { //! Returns multilayer spheres distribution at lattice points. -std::unique_ptr<MultiLayer> createSampleSpheresDistribution(int nspheres) -{ +std::unique_ptr<MultiLayer> createSampleSpheresDistribution(int nspheres) { auto material_1 = HomogeneousMaterial("example06_Vacuum", 0.0, 0.0); auto material_2 = HomogeneousMaterial("example08_Particle", 0.0006, 2e-08); auto material_3 = HomogeneousMaterial("example06_Substrate", 6e-06, 2e-08); @@ -73,8 +71,7 @@ std::unique_ptr<MultiLayer> createSampleSpheresDistribution(int nspheres) //! Creates realistic GISAS simulation (without sample). //! Rectangular PILATUS detector 981x1043, ROI and masks. -std::unique_ptr<ISimulation> CreateRealisticGISASSimulation() -{ +std::unique_ptr<ISimulation> CreateRealisticGISASSimulation() { auto result = std::make_unique<GISASSimulation>(); result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::deg, 0.0 * Units::deg); @@ -101,8 +98,7 @@ std::unique_ptr<ISimulation> CreateRealisticGISASSimulation() //! Spherical detector 100x100, cylinders in DWBA. //! Intended to study the performance of "real time" parameter tuning in GUI. -std::unique_ptr<ISimulation> TestComponents::CreateSimpleGISAS() -{ +std::unique_ptr<ISimulation> TestComponents::CreateSimpleGISAS() { auto result = std::make_unique<GISASSimulation>(); result->setDetectorParameters(100, 0.0 * Units::deg, 2.0 * Units::deg, 100, 0.0 * Units::deg, 2.0 * Units::deg); @@ -116,8 +112,7 @@ std::unique_ptr<ISimulation> TestComponents::CreateSimpleGISAS() //! Creates simulation representing realistic GISAS. //! Intended to study the performance of some real life experiment. -std::unique_ptr<ISimulation> TestComponents::CreateRealisticGISAS() -{ +std::unique_ptr<ISimulation> TestComponents::CreateRealisticGISAS() { auto result = CreateRealisticGISASSimulation(); auto sample = std::unique_ptr<MultiLayer>(CylindersInDWBABuilder().buildSample()); result->setSample(*sample); @@ -129,8 +124,7 @@ std::unique_ptr<ISimulation> TestComponents::CreateRealisticGISAS() //! ROI and masks, noise, background. //! Intended to study the performance of some real life experiment. -std::unique_ptr<ISimulation> TestComponents::CreateRealisticAndHeavyGISAS() -{ +std::unique_ptr<ISimulation> TestComponents::CreateRealisticAndHeavyGISAS() { auto result = CreateRealisticGISASSimulation(); auto sample = createSampleSpheresDistribution(50); result->setSample(*sample); @@ -142,8 +136,7 @@ std::unique_ptr<ISimulation> TestComponents::CreateRealisticAndHeavyGISAS() //! Intended to study the influence of SimulationElements and IPixel constructions on overall //! performance. -std::unique_ptr<ISimulation> TestComponents::CreateGiganticGISAS() -{ +std::unique_ptr<ISimulation> TestComponents::CreateGiganticGISAS() { const int nbins = 2048; auto result = std::make_unique<GISASSimulation>(); result->setDetectorParameters(nbins, -2.0 * Units::deg, 2.0 * Units::deg, nbins, @@ -158,8 +151,7 @@ std::unique_ptr<ISimulation> TestComponents::CreateGiganticGISAS() //! Tiny spherical detector 64x64, cylinders in BA, huge wavelength. //! Intended to study parameter distribution in ISimulation::runSingleSimulation context. -std::unique_ptr<ISimulation> TestComponents::CreateWavelengthGISAS() -{ +std::unique_ptr<ISimulation> TestComponents::CreateWavelengthGISAS() { const int nbins = 64; auto result = std::make_unique<GISASSimulation>(); result->setDetectorParameters(nbins, -2.0 * Units::deg, 2.0 * Units::deg, nbins, @@ -181,8 +173,7 @@ std::unique_ptr<ISimulation> TestComponents::CreateWavelengthGISAS() //! Spherical detector 100x100, cylinders in DWBA. //! Intended to study the performance in MonteCarlo mode. -std::unique_ptr<ISimulation> TestComponents::CreateMCGISAS() -{ +std::unique_ptr<ISimulation> TestComponents::CreateMCGISAS() { auto result = std::make_unique<GISASSimulation>(); result->setDetectorParameters(100, 0.0 * Units::deg, 2.0 * Units::deg, 100, 0.0 * Units::deg, 2.0 * Units::deg); diff --git a/Tests/Performance/Core/ThreadingComponents.h b/Tests/Performance/Core/ThreadingComponents.h index 87e696b2cf14e8aff7cbb5b1dddc7491abb13902..1fccba65442bb0eaf1bd40a776d373c4fcd5e388 100644 --- a/Tests/Performance/Core/ThreadingComponents.h +++ b/Tests/Performance/Core/ThreadingComponents.h @@ -20,8 +20,7 @@ class ISimulation; //! Collection of simulations for MultiThreadPerformanceTest. -namespace TestComponents -{ +namespace TestComponents { std::unique_ptr<ISimulation> CreateSimpleGISAS(); diff --git a/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.cpp b/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.cpp index e603e4a71901784d49f52ba217f0efcb434385f8..83ba62b8d0f31e66fb0033c061374d77b25c5eb9 100644 --- a/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.cpp +++ b/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.cpp @@ -20,16 +20,14 @@ #include <ctime> #include <iostream> -void CsvImportAssistantPerformanceTest::writeTestFile() -{ +void CsvImportAssistantPerformanceTest::writeTestFile() { remove(m_testFilename.c_str()); OutputDataWriter* writer = OutputDataWriteFactory::getWriter(m_testFilename); OutputData<double>* data = ArrayUtils::createData(m_testVector).release(); writer->writeOutputData(*data); } -void CsvImportAssistantPerformanceTest::writeTestFile(size_t nRows, size_t nCols) -{ +void CsvImportAssistantPerformanceTest::writeTestFile(size_t nRows, size_t nCols) { remove(m_testFilename.c_str()); std::ofstream myfile; myfile.open(m_testFilename); @@ -42,15 +40,13 @@ void CsvImportAssistantPerformanceTest::writeTestFile(size_t nRows, size_t nCols myfile.close(); } -OutputData<double>* CsvImportAssistantPerformanceTest::readTestFile() -{ +OutputData<double>* CsvImportAssistantPerformanceTest::readTestFile() { OutputDataReader* reader = OutputDataReadFactory::getReader(m_testFilename); OutputData<double>* data = reader->getOutputData(); return data; } -bool CsvImportAssistantPerformanceTest::runTest() -{ +bool CsvImportAssistantPerformanceTest::runTest() { std::cout << "CsvImportAssistantPerformanceTest -> Running ..." << std::endl; size_t maxRows = 1000; size_t maxCols = 1000; @@ -90,7 +86,6 @@ bool CsvImportAssistantPerformanceTest::runTest() return true; } -int main() -{ +int main() { return !CsvImportAssistantPerformanceTest().runTest(); } diff --git a/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.h b/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.h index dc51485ae4a60f44f30f9ecb13478cd857940ef1..a9e01d6dc9001aaae4998ddb5d340f5045d03058 100644 --- a/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.h +++ b/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.h @@ -20,8 +20,7 @@ #include <memory> //! Functional test to measure performance of CsvImportAssistant by loading files of different sizes -class CsvImportAssistantPerformanceTest -{ +class CsvImportAssistantPerformanceTest { public: bool runTest(); diff --git a/Tests/Performance/GUI/GUIPerformanceTest.cpp b/Tests/Performance/GUI/GUIPerformanceTest.cpp index 6eec4dd0e327cab5ed0f7625f7e3c43d1cf032da..81255834d9e211397b1ca0cb18ee3a67c9ca8d06 100644 --- a/Tests/Performance/GUI/GUIPerformanceTest.cpp +++ b/Tests/Performance/GUI/GUIPerformanceTest.cpp @@ -38,20 +38,16 @@ #include <QElapsedTimer> #include <random> -namespace -{ +namespace { std::random_device rd; std::mt19937 mt(rd()); std::uniform_real_distribution<double> rndm_radius(5., 6.); } // namespace GUIPerformanceTest::GUIPerformanceTest() - : m_models(new ApplicationModels(nullptr)), m_sample_name("ParticleCompositionBuilder") -{ -} + : m_models(new ApplicationModels(nullptr)), m_sample_name("ParticleCompositionBuilder") {} -bool GUIPerformanceTest::runTest() -{ +bool GUIPerformanceTest::runTest() { #ifndef NDEBUG const int mult = 1; #else @@ -74,8 +70,7 @@ bool GUIPerformanceTest::runTest() //! Creates domain sample once and then populates sample model. -void GUIPerformanceTest::test_domain_to_gui() -{ +void GUIPerformanceTest::test_domain_to_gui() { static std::unique_ptr<MultiLayer> sample; if (!sample) { @@ -91,8 +86,7 @@ void GUIPerformanceTest::test_domain_to_gui() //! Creates gui sample once and then populates domain. -void GUIPerformanceTest::test_gui_to_domain() -{ +void GUIPerformanceTest::test_gui_to_domain() { static bool is_initialized(false); if (!is_initialized) { @@ -112,8 +106,7 @@ void GUIPerformanceTest::test_gui_to_domain() m_models->sampleModel()->multiLayerItem(), m_models->instrumentModel()->instrumentItem()); } -void GUIPerformanceTest::test_real_time() -{ +void GUIPerformanceTest::test_real_time() { static JobItem* jobItem(0); if (!jobItem) { @@ -165,7 +158,6 @@ void GUIPerformanceTest::test_real_time() } } -int main() -{ +int main() { return !GUIPerformanceTest().runTest(); } diff --git a/Tests/Performance/GUI/GUIPerformanceTest.h b/Tests/Performance/GUI/GUIPerformanceTest.h index 9393c930890f381a4cf3fb692beff4d50157487d..3b293bdaf9491552e33deb3ff0f8e10af217d05b 100644 --- a/Tests/Performance/GUI/GUIPerformanceTest.h +++ b/Tests/Performance/GUI/GUIPerformanceTest.h @@ -22,8 +22,7 @@ class ApplicationModels; //! Functional test to measure performance of GUI by mimicking activity typical for RealTimeView. -class GUIPerformanceTest -{ +class GUIPerformanceTest { public: GUIPerformanceTest(); diff --git a/Tests/UnitTests/Core/Axes/CVectorTest.cpp b/Tests/UnitTests/Core/Axes/CVectorTest.cpp index 66e00cba9bba36b02edd43450287978e30e972ef..698d2a307630643dbddc248ef5ba6e6f907a366d 100644 --- a/Tests/UnitTests/Core/Axes/CVectorTest.cpp +++ b/Tests/UnitTests/Core/Axes/CVectorTest.cpp @@ -3,12 +3,9 @@ #include "Base/Vector/Vectors3D.h" #include "Tests/GTestWrapper/google_test.h" -class CVectorTest : public ::testing::Test -{ -}; +class CVectorTest : public ::testing::Test {}; -TEST_F(CVectorTest, TrivialOperations) -{ +TEST_F(CVectorTest, TrivialOperations) { kvector_t vec_k(1., 2., 3.); EXPECT_EQ(vec_k.complex().z(), complex_t(3., 0.)); @@ -17,8 +14,7 @@ TEST_F(CVectorTest, TrivialOperations) EXPECT_DOUBLE_EQ(vec_c.mag(), 8.); } -TEST_F(CVectorTest, BasicArithmetics) -{ +TEST_F(CVectorTest, BasicArithmetics) { // Dot product with "Eigen" library Eigen::Vector3cd va(complex_t(1., 0.), complex_t(2., 0.), complex_t(3., 0.)); Eigen::Vector3cd vc(complex_t(1., 1.), complex_t(2., -5.), complex_t(3., 4.)); diff --git a/Tests/UnitTests/Core/Axes/ConstKBinAxisTest.cpp b/Tests/UnitTests/Core/Axes/ConstKBinAxisTest.cpp index 27565872ba3ce73c1867be2b07a694138b1a6211..4bcfe6058ba6c766258596b18c783c7d0a363348 100644 --- a/Tests/UnitTests/Core/Axes/ConstKBinAxisTest.cpp +++ b/Tests/UnitTests/Core/Axes/ConstKBinAxisTest.cpp @@ -4,15 +4,13 @@ #include "Tests/GTestWrapper/google_test.h" #include <vector> -class ConstKBinAxisTest : public ::testing::Test -{ +class ConstKBinAxisTest : public ::testing::Test { protected: ConstKBinAxisTest() : m_nbins(10) , m_start(-5.0 * Units::deg) , m_end(5.0 * Units::deg) - , m_axis("name", m_nbins, m_start, m_end) - { + , m_axis("name", m_nbins, m_start, m_end) { double start_sin = std::sin(m_start); double end_sin = std::sin(m_end); double step = (end_sin - start_sin) / m_nbins; @@ -37,8 +35,7 @@ protected: //[-5.0, -3.99816897832528, -2.9975609824866662, -1.99786732193833, -0.9987818274427882, 0.0, // 0.9987818274427874, 1.9978673219383292, 2.997560982486666, 3.998168978325279, 5.0] -TEST_F(ConstKBinAxisTest, TypicalAxis) -{ +TEST_F(ConstKBinAxisTest, TypicalAxis) { EXPECT_EQ(m_nbins, m_axis.size()); EXPECT_EQ(m_start, m_axis.lowerBound()); EXPECT_EQ(m_end, m_axis.upperBound()); @@ -56,15 +53,13 @@ TEST_F(ConstKBinAxisTest, TypicalAxis) } } -TEST_F(ConstKBinAxisTest, CheckClone) -{ +TEST_F(ConstKBinAxisTest, CheckClone) { ConstKBinAxis* clone = m_axis.clone(); EXPECT_TRUE(m_axis == *clone); delete clone; } -TEST_F(ConstKBinAxisTest, IOStream) -{ +TEST_F(ConstKBinAxisTest, IOStream) { std::ostringstream oss; oss << m_axis; std::istringstream iss(oss.str()); @@ -76,8 +71,7 @@ TEST_F(ConstKBinAxisTest, IOStream) //[-5.0, -3.99816897832528, -2.9975609824866662, -1.99786732193833, -0.9987818274427882, 0.0, // 0.9987818274427874, 1.9978673219383292, 2.997560982486666, 3.998168978325279, 5.0] -TEST_F(ConstKBinAxisTest, ClippedAxis) -{ +TEST_F(ConstKBinAxisTest, ClippedAxis) { ConstKBinAxis* clip1 = m_axis.createClippedAxis(Units::deg2rad(-10.0), Units::deg2rad(10.0)); EXPECT_TRUE(*clip1 == m_axis); delete clip1; diff --git a/Tests/UnitTests/Core/Axes/CustomBinAxisTest.cpp b/Tests/UnitTests/Core/Axes/CustomBinAxisTest.cpp index e0c22d4b8e1d07fd60ae47b4bf6d9faaf9c58b15..98d4681e050f1ca3940ae8240d22e88ea94a80d0 100644 --- a/Tests/UnitTests/Core/Axes/CustomBinAxisTest.cpp +++ b/Tests/UnitTests/Core/Axes/CustomBinAxisTest.cpp @@ -4,22 +4,19 @@ #include "Tests/GTestWrapper/google_test.h" #include <vector> -class CusomBinAxisTest : public ::testing::Test -{ +class CusomBinAxisTest : public ::testing::Test { protected: CusomBinAxisTest() : m_axis("name", 100, -1.0, 1.0) {} CustomBinAxis m_axis; }; -TEST_F(CusomBinAxisTest, CheckClone) -{ +TEST_F(CusomBinAxisTest, CheckClone) { CustomBinAxis* clone = m_axis.clone(); EXPECT_TRUE(m_axis == *clone); delete clone; } -TEST_F(CusomBinAxisTest, IOStream) -{ +TEST_F(CusomBinAxisTest, IOStream) { std::ostringstream oss; oss << m_axis; std::istringstream iss(oss.str()); diff --git a/Tests/UnitTests/Core/Axes/DepthProbeConverterTest.cpp b/Tests/UnitTests/Core/Axes/DepthProbeConverterTest.cpp index 7e5ba5894c96d20bea62eb9dc5c1d6131c7c93fb..3fb9258a5cb5177d343201a34a9a08fc297fd2f0 100644 --- a/Tests/UnitTests/Core/Axes/DepthProbeConverterTest.cpp +++ b/Tests/UnitTests/Core/Axes/DepthProbeConverterTest.cpp @@ -5,8 +5,7 @@ #include "Device/Detector/SimpleUnitConverters.h" #include "Tests/GTestWrapper/google_test.h" -class DepthProbeConverterTest : public ::testing::Test -{ +class DepthProbeConverterTest : public ::testing::Test { protected: DepthProbeConverterTest(); @@ -26,12 +25,9 @@ protected: DepthProbeConverterTest::DepthProbeConverterTest() : m_inclination_axis("Angles", m_nbins, m_alpha_start, m_alpha_end) // angles in radians , m_z_axis("Positions", m_nbins, m_z_start, m_z_end) // z positions in nm - , m_beam(Beam::horizontalBeam()) -{ -} + , m_beam(Beam::horizontalBeam()) {} -void DepthProbeConverterTest::checkMainFunctionality(const DepthProbeConverter& test_object) -{ +void DepthProbeConverterTest::checkMainFunctionality(const DepthProbeConverter& test_object) { EXPECT_EQ(test_object.dimension(), 2u); EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::DEFAULT), 2.8647889757e+1, @@ -67,8 +63,7 @@ void DepthProbeConverterTest::checkMainFunctionality(const DepthProbeConverter& } void DepthProbeConverterTest::checkAlphaAxis(Axes::Units units, - const DepthProbeConverter& test_object) -{ + const DepthProbeConverter& test_object) { auto axis = test_object.createConvertedAxis(0, units); EXPECT_TRUE(dynamic_cast<FixedBinAxis*>(axis.get())); EXPECT_EQ(axis->size(), test_object.axisSize(0)); @@ -77,8 +72,8 @@ void DepthProbeConverterTest::checkAlphaAxis(Axes::Units units, EXPECT_EQ(axis->upperBound(), test_object.calculateMax(0, units)); } -void DepthProbeConverterTest::checkZAxis(Axes::Units units, const DepthProbeConverter& test_object) -{ +void DepthProbeConverterTest::checkZAxis(Axes::Units units, + const DepthProbeConverter& test_object) { auto axis = test_object.createConvertedAxis(1, units); EXPECT_TRUE(dynamic_cast<FixedBinAxis*>(axis.get())); EXPECT_EQ(axis->size(), test_object.axisSize(1)); @@ -93,14 +88,12 @@ void DepthProbeConverterTest::checkZAxis(Axes::Units units, const DepthProbeConv EXPECT_NEAR(axis->upperBound(), test_max, std::abs(test_max) * 1e-10); } -TEST_F(DepthProbeConverterTest, DepthProbeConverter) -{ +TEST_F(DepthProbeConverterTest, DepthProbeConverter) { DepthProbeConverter converter(m_beam, m_inclination_axis, m_z_axis); checkMainFunctionality(converter); } -TEST_F(DepthProbeConverterTest, DepthProbeConverterExceptions) -{ +TEST_F(DepthProbeConverterTest, DepthProbeConverterExceptions) { DepthProbeConverter converter(m_beam, m_inclination_axis, m_z_axis); EXPECT_THROW(converter.axisName(0, Axes::Units::MM), std::runtime_error); @@ -120,8 +113,7 @@ TEST_F(DepthProbeConverterTest, DepthProbeConverterExceptions) EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::DEFAULT), std::runtime_error); } -TEST_F(DepthProbeConverterTest, DepthProbeConverterClone) -{ +TEST_F(DepthProbeConverterTest, DepthProbeConverterClone) { DepthProbeConverter converter(m_beam, m_inclination_axis, m_z_axis); std::unique_ptr<DepthProbeConverter> converter_clone(converter.clone()); checkMainFunctionality(*converter_clone); diff --git a/Tests/UnitTests/Core/Axes/FixedBinAxisTest.cpp b/Tests/UnitTests/Core/Axes/FixedBinAxisTest.cpp index 0b11cc52f4dac1d44f195e1accddb12a97a6be94..331f86ee806b4abae04fd992889e4e5010b09e0a 100644 --- a/Tests/UnitTests/Core/Axes/FixedBinAxisTest.cpp +++ b/Tests/UnitTests/Core/Axes/FixedBinAxisTest.cpp @@ -4,12 +4,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <iostream> -class FixedBinAxisTest : public ::testing::Test -{ -}; +class FixedBinAxisTest : public ::testing::Test {}; -TEST_F(FixedBinAxisTest, IndexedAccessor) -{ +TEST_F(FixedBinAxisTest, IndexedAccessor) { FixedBinAxis a1("length", 100, 0.0, 10.0); ASSERT_EQ(100u, a1.size()); EXPECT_EQ(0.0, a1.lowerBound()); @@ -26,8 +23,7 @@ TEST_F(FixedBinAxisTest, IndexedAccessor) ASSERT_THROW(a2[3], Exceptions::OutOfBoundsException); } -TEST_F(FixedBinAxisTest, VectorOfUnitLength) -{ +TEST_F(FixedBinAxisTest, VectorOfUnitLength) { FixedBinAxis vec("name", 1, 1.0, 2.0); EXPECT_EQ(1u, vec.size()); EXPECT_EQ(double(1.0), vec.lowerBound()); @@ -35,8 +31,7 @@ TEST_F(FixedBinAxisTest, VectorOfUnitLength) EXPECT_EQ(1.5, vec[0]); } -TEST_F(FixedBinAxisTest, FindClosestIndex) -{ +TEST_F(FixedBinAxisTest, FindClosestIndex) { FixedBinAxis v1("name", 2, 0.0, 1.0); EXPECT_EQ(size_t(2), v1.size()); EXPECT_EQ(size_t(0), v1.findClosestIndex(0.0)); @@ -57,8 +52,7 @@ TEST_F(FixedBinAxisTest, FindClosestIndex) EXPECT_EQ(size_t(2), v2.findClosestIndex(1.5)); } -TEST_F(FixedBinAxisTest, CheckBin) -{ +TEST_F(FixedBinAxisTest, CheckBin) { FixedBinAxis axis("name", 20, 0, 10); Bin1D bin0 = axis.bin(0); @@ -91,8 +85,7 @@ TEST_F(FixedBinAxisTest, CheckBin) EXPECT_DOUBLE_EQ(1.5, axis2.bin(2).center()); } -TEST_F(FixedBinAxisTest, CheckEquality) -{ +TEST_F(FixedBinAxisTest, CheckEquality) { FixedBinAxis b1("axis", 99, -1.01, 3.3); FixedBinAxis b2("axis", 99, -1.01, 3.3); EXPECT_TRUE(b1 == b2); @@ -106,16 +99,14 @@ TEST_F(FixedBinAxisTest, CheckEquality) EXPECT_FALSE(b1 == b6); } -TEST_F(FixedBinAxisTest, CheckClone) -{ +TEST_F(FixedBinAxisTest, CheckClone) { FixedBinAxis a1("axis", 99, -1.2, 5.4); FixedBinAxis* clone = a1.clone(); EXPECT_TRUE(a1 == *clone); delete clone; } -TEST_F(FixedBinAxisTest, IOStream) -{ +TEST_F(FixedBinAxisTest, IOStream) { FixedBinAxis axis("name", 99, -1.2, 5.4); std::ostringstream oss; @@ -126,8 +117,7 @@ TEST_F(FixedBinAxisTest, IOStream) EXPECT_TRUE(axis == *result); } -TEST_F(FixedBinAxisTest, BinCenters) -{ +TEST_F(FixedBinAxisTest, BinCenters) { FixedBinAxis axis("name", 3, -1.5, 1.5); std::vector<double> centers = axis.binCenters(); EXPECT_EQ(size_t(3), centers.size()); @@ -140,8 +130,7 @@ TEST_F(FixedBinAxisTest, BinCenters) EXPECT_DOUBLE_EQ(axis.binCenter(2), centers[2]); } -TEST_F(FixedBinAxisTest, BinBoundaries) -{ +TEST_F(FixedBinAxisTest, BinBoundaries) { FixedBinAxis axis("name", 3, -1.5, 1.5); std::vector<double> boundaries = axis.binBoundaries(); EXPECT_EQ(size_t(4), boundaries.size()); @@ -151,8 +140,7 @@ TEST_F(FixedBinAxisTest, BinBoundaries) EXPECT_DOUBLE_EQ(1.5, boundaries[3]); } -TEST_F(FixedBinAxisTest, ClippedAxis) -{ +TEST_F(FixedBinAxisTest, ClippedAxis) { FixedBinAxis axis("name", 4, -1.0, 3.0); FixedBinAxis* clip1 = axis.createClippedAxis(-0.5, 2.5); diff --git a/Tests/UnitTests/Core/Axes/Histogram1DTest.cpp b/Tests/UnitTests/Core/Axes/Histogram1DTest.cpp index f06796b83e268aec12dfccc8ce32113c6c8d739a..7527ee5c110e24952d09facedcb023d3067843c2 100644 --- a/Tests/UnitTests/Core/Axes/Histogram1DTest.cpp +++ b/Tests/UnitTests/Core/Axes/Histogram1DTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class Histogram1DTest : public ::testing::Test -{ -}; +class Histogram1DTest : public ::testing::Test {}; -TEST_F(Histogram1DTest, FixedBinConstructor) -{ +TEST_F(Histogram1DTest, FixedBinConstructor) { Histogram1D hist(5, 0.0, 5.0); EXPECT_EQ(size_t(1), hist.rank()); @@ -21,8 +18,7 @@ TEST_F(Histogram1DTest, FixedBinConstructor) } } -TEST_F(Histogram1DTest, FixedBinDefaultContent) -{ +TEST_F(Histogram1DTest, FixedBinDefaultContent) { Histogram1D hist(5, 0.0, 5.0); // bin centers @@ -54,8 +50,7 @@ TEST_F(Histogram1DTest, FixedBinDefaultContent) } } -TEST_F(Histogram1DTest, FixedBinFill) -{ +TEST_F(Histogram1DTest, FixedBinFill) { Histogram1D hist(5, 0.0, 5.0); // filling two different bins @@ -109,8 +104,7 @@ TEST_F(Histogram1DTest, FixedBinFill) // -1.0 -0.5 0.5 1.0 2.0 X -TEST_F(Histogram1DTest, crop) -{ +TEST_F(Histogram1DTest, crop) { std::vector<double> xedges = {-1.0, -0.5, 0.5, 1.0, 2.0}; std::vector<double> xvalues = {-0.75, 0.0, 0.75, 1.5}; Histogram1D hist(4, xedges); @@ -128,8 +122,7 @@ TEST_F(Histogram1DTest, crop) EXPECT_EQ(20.0, crop->binContent(1)); } -TEST_F(Histogram1DTest, CreateHistogram) -{ +TEST_F(Histogram1DTest, CreateHistogram) { OutputData<double> data; data.addAxis("x-axis", 10, 0.0, 10.0); for (size_t i = 0; i < data.getAllocatedSize(); ++i) { @@ -149,8 +142,7 @@ TEST_F(Histogram1DTest, CreateHistogram) } } -TEST_F(Histogram1DTest, CreateOutputData) -{ +TEST_F(Histogram1DTest, CreateOutputData) { Histogram1D hist(10, -5.0, 5.0); for (size_t i = 0; i < hist.getNbinsX(); ++i) { @@ -183,8 +175,7 @@ TEST_F(Histogram1DTest, CreateOutputData) } } -TEST_F(Histogram1DTest, GetMaximumGetMinimum) -{ +TEST_F(Histogram1DTest, GetMaximumGetMinimum) { Histogram1D hist(10, -5.0, 5.0); hist.fill(-4.5, 10.); EXPECT_EQ(10.0, hist.getMaximum()); @@ -197,8 +188,7 @@ TEST_F(Histogram1DTest, GetMaximumGetMinimum) EXPECT_EQ(size_t(1), hist.getMaximumBinIndex()); } -TEST_F(Histogram1DTest, Scale) -{ +TEST_F(Histogram1DTest, Scale) { Histogram1D hist(10, -5.0, 5.0); for (size_t i = 0; i < hist.getTotalNumberOfBins(); ++i) { @@ -210,8 +200,7 @@ TEST_F(Histogram1DTest, Scale) } } -TEST_F(Histogram1DTest, Integral) -{ +TEST_F(Histogram1DTest, Integral) { Histogram1D hist(10, -5.0, 5.0); for (size_t i = 0; i < hist.getTotalNumberOfBins(); ++i) { @@ -220,8 +209,7 @@ TEST_F(Histogram1DTest, Integral) EXPECT_EQ(10.0, hist.integral()); } -TEST_F(Histogram1DTest, Addition) -{ +TEST_F(Histogram1DTest, Addition) { Histogram1D hist1(10, -5.0, 5.0); for (size_t i = 0; i < hist1.getTotalNumberOfBins(); ++i) { hist1.fill(-4.5 + i, 1.0); diff --git a/Tests/UnitTests/Core/Axes/Histogram2DTest.cpp b/Tests/UnitTests/Core/Axes/Histogram2DTest.cpp index faf396ef7a0997e116c87d9c6a5706358e51c484..84cac0ad73dd555ec1329567ce91835e2f60b000 100644 --- a/Tests/UnitTests/Core/Axes/Histogram2DTest.cpp +++ b/Tests/UnitTests/Core/Axes/Histogram2DTest.cpp @@ -3,8 +3,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class Histogram2DTest : public ::testing::Test -{ +class Histogram2DTest : public ::testing::Test { protected: Histogram2DTest(); @@ -22,12 +21,10 @@ protected: // 0.0 ----------------------------------- // -1.0 -0.5 0.5 1.0 2.0 X -Histogram2DTest::Histogram2DTest() : hist{4, {-1.0, -0.5, 0.5, 1.0, 2.0}, 3, {0.0, 1.0, 2.0, 4.0}} -{ -} +Histogram2DTest::Histogram2DTest() + : hist{4, {-1.0, -0.5, 0.5, 1.0, 2.0}, 3, {0.0, 1.0, 2.0, 4.0}} {} -TEST_F(Histogram2DTest, VariableHist) -{ +TEST_F(Histogram2DTest, VariableHist) { hist.reset(); // basic axes check @@ -97,8 +94,7 @@ TEST_F(Histogram2DTest, VariableHist) // 0.0 ----------------------------------- // -1.0 -0.5 0.5 1.0 2.0 X -TEST_F(Histogram2DTest, VariableHistFill) -{ +TEST_F(Histogram2DTest, VariableHistFill) { hist.reset(); // values to fill all histogram @@ -138,8 +134,7 @@ TEST_F(Histogram2DTest, VariableHistFill) // 0.0 ----------------------------------- // -1.0 -0.5 0.5 1.0 2.0 X -TEST_F(Histogram2DTest, projectionX) -{ +TEST_F(Histogram2DTest, projectionX) { hist.reset(); // values to fill all histogram @@ -216,8 +211,7 @@ TEST_F(Histogram2DTest, projectionX) // 0.0 ----------------------------------- // -1.0 -0.5 0.5 1.0 2.0 X -TEST_F(Histogram2DTest, projectionY) -{ +TEST_F(Histogram2DTest, projectionY) { hist.reset(); // values to fill all histogram @@ -303,8 +297,7 @@ TEST_F(Histogram2DTest, projectionY) // 0.0 ----------------------------------- // -1.0 -0.5 0.5 1.0 2.0 X -TEST_F(Histogram2DTest, crop) -{ +TEST_F(Histogram2DTest, crop) { hist.reset(); // values to fill all histogram @@ -334,8 +327,7 @@ TEST_F(Histogram2DTest, crop) EXPECT_EQ(2.0, crop->binContent(2, 1)); } -TEST_F(Histogram2DTest, CreateHistogram) -{ +TEST_F(Histogram2DTest, CreateHistogram) { OutputData<double> data; data.addAxis("x-axis", 10, 0.0, 10.0); data.addAxis("y-axis", 5, -5.0, 0.0); @@ -358,8 +350,7 @@ TEST_F(Histogram2DTest, CreateHistogram) } } -TEST_F(Histogram2DTest, CreateOutputData) -{ +TEST_F(Histogram2DTest, CreateOutputData) { Histogram2D h2(10, -5.0, 5.0, 5, -5.0, 0.0); for (size_t nx = 0; nx < h2.getNbinsX(); ++nx) { @@ -397,8 +388,7 @@ TEST_F(Histogram2DTest, CreateOutputData) } } -TEST_F(Histogram2DTest, GetMaximumGetMinimum) -{ +TEST_F(Histogram2DTest, GetMaximumGetMinimum) { Histogram2D h2(10, -5.0, 5.0, 5, -5.0, 0.0); for (size_t ix = 0; ix < h2.getNbinsX(); ++ix) { diff --git a/Tests/UnitTests/Core/Axes/KVectorTest.cpp b/Tests/UnitTests/Core/Axes/KVectorTest.cpp index 4dfbfd2f72e289a2b0de4e69dfab3b8f9eb24c3b..404ecdc27d55ee50c7813647b567aec360fbdd93 100644 --- a/Tests/UnitTests/Core/Axes/KVectorTest.cpp +++ b/Tests/UnitTests/Core/Axes/KVectorTest.cpp @@ -1,12 +1,9 @@ #include "Base/Vector/Transform3D.h" #include "Tests/GTestWrapper/google_test.h" -class KVectorTest : public ::testing::Test -{ -}; +class KVectorTest : public ::testing::Test {}; -TEST_F(KVectorTest, BasicMethods) -{ +TEST_F(KVectorTest, BasicMethods) { kvector_t v; EXPECT_EQ(double(0), v.x()); EXPECT_EQ(double(0), v.y()); @@ -35,8 +32,7 @@ TEST_F(KVectorTest, BasicMethods) EXPECT_DOUBLE_EQ(v3.mag(), std::sqrt(1 * 1 + 2 * 2 + 3 * 3)); } -TEST_F(KVectorTest, BasicArithmetics) -{ +TEST_F(KVectorTest, BasicArithmetics) { // assignment, self assignment, copy constructor kvector_t v1; kvector_t v2(v1); @@ -145,8 +141,7 @@ TEST_F(KVectorTest, BasicArithmetics) EXPECT_TRUE(a != kvector_t(1., 1., 3.)); } -TEST_F(KVectorTest, BasicTransformation) -{ +TEST_F(KVectorTest, BasicTransformation) { const double epsilon = 1e-12; kvector_t a, v; diff --git a/Tests/UnitTests/Core/Axes/PointwiseAxisTest.cpp b/Tests/UnitTests/Core/Axes/PointwiseAxisTest.cpp index 81be893272480b3bafa59ef43f858fd71549a67e..8396c6f72a517f28b3cc704076f1597b9b97ea58 100644 --- a/Tests/UnitTests/Core/Axes/PointwiseAxisTest.cpp +++ b/Tests/UnitTests/Core/Axes/PointwiseAxisTest.cpp @@ -4,12 +4,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <iostream> -class PointwiseAxisTest : public ::testing::Test -{ -}; +class PointwiseAxisTest : public ::testing::Test {}; -TEST_F(PointwiseAxisTest, Construction) -{ +TEST_F(PointwiseAxisTest, Construction) { EXPECT_THROW(PointwiseAxis("length", std::vector<double>{0.0}), std::runtime_error); EXPECT_THROW(PointwiseAxis("length", std::vector<double>{1.0, 0.0}), std::runtime_error); EXPECT_THROW(PointwiseAxis("length", std::vector<double>{0.0, 1.0, 0.5}), std::runtime_error); @@ -20,8 +17,7 @@ TEST_F(PointwiseAxisTest, Construction) EXPECT_TRUE(a1 == a2); } -TEST_F(PointwiseAxisTest, BasicProperties) -{ +TEST_F(PointwiseAxisTest, BasicProperties) { std::vector<double> coordinates{0.0, 1.0, 4.0, 8.0}; PointwiseAxis a1("length", coordinates); EXPECT_EQ(4u, a1.size()); @@ -40,8 +36,7 @@ TEST_F(PointwiseAxisTest, BasicProperties) EXPECT_TRUE(coordinates == a1.binCenters()); } -TEST_F(PointwiseAxisTest, FindClosestIndex) -{ +TEST_F(PointwiseAxisTest, FindClosestIndex) { PointwiseAxis v1("name", std::vector<double>{0.0, 1.0, 4.0, 8.0}); EXPECT_EQ(4u, v1.size()); EXPECT_EQ(v1.findClosestIndex(-1.0), 0u); @@ -64,8 +59,7 @@ TEST_F(PointwiseAxisTest, FindClosestIndex) EXPECT_EQ(1u, v2.findClosestIndex(1.0)); } -TEST_F(PointwiseAxisTest, CheckBin) -{ +TEST_F(PointwiseAxisTest, CheckBin) { PointwiseAxis axis("name", std::vector<double>{0, 2, 10}); auto boundaries = axis.binBoundaries(); EXPECT_EQ(4u, boundaries.size()); @@ -97,8 +91,7 @@ TEST_F(PointwiseAxisTest, CheckBin) EXPECT_THROW(axis.bin(3), std::runtime_error); } -TEST_F(PointwiseAxisTest, CheckEquality) -{ +TEST_F(PointwiseAxisTest, CheckEquality) { PointwiseAxis b1("axis", std::vector<double>{1.0, 2.0, 5.0}); PointwiseAxis b2("axis", std::vector<double>{1.0, 2.0, 5.0}); EXPECT_TRUE(b1 == b2); @@ -110,15 +103,13 @@ TEST_F(PointwiseAxisTest, CheckEquality) EXPECT_FALSE(b1 == b6); } -TEST_F(PointwiseAxisTest, CheckClone) -{ +TEST_F(PointwiseAxisTest, CheckClone) { PointwiseAxis a1("axis", std::vector<double>{1.0, 2.0, 5.0}); std::unique_ptr<PointwiseAxis> clone(a1.clone()); EXPECT_TRUE(a1 == *clone); } -TEST_F(PointwiseAxisTest, IOStream) -{ +TEST_F(PointwiseAxisTest, IOStream) { PointwiseAxis axis("name", std::vector<double>{1.0, 2.0, 5.0}); std::ostringstream oss; @@ -129,8 +120,7 @@ TEST_F(PointwiseAxisTest, IOStream) EXPECT_TRUE(axis == *result); } -TEST_F(PointwiseAxisTest, ClippedAxis) -{ +TEST_F(PointwiseAxisTest, ClippedAxis) { PointwiseAxis axis("name", std::vector<double>{1.0, 2.0, 2.5, 2.7, 5.0}); std::unique_ptr<PointwiseAxis> clip1(axis.createClippedAxis(0.99, 5.1)); @@ -149,8 +139,7 @@ TEST_F(PointwiseAxisTest, ClippedAxis) EXPECT_THROW(axis.createClippedAxis(5.0, 1.0), std::runtime_error); } -TEST_F(PointwiseAxisTest, FixedBinAxisComparison) -{ +TEST_F(PointwiseAxisTest, FixedBinAxisComparison) { FixedBinAxis fixed_axis("name", 4, 0.0, 4.0); PointwiseAxis pointwise_axis("name", std::vector<double>{0.5, 1.5, 2.5, 3.5}); @@ -184,8 +173,7 @@ TEST_F(PointwiseAxisTest, FixedBinAxisComparison) EXPECT_DOUBLE_EQ(clipped_fixed->binCenter(2), clipped_pointwise->binCenter(2)); } -TEST_F(PointwiseAxisTest, FixedBinAxisComparisonWithMask) -{ +TEST_F(PointwiseAxisTest, FixedBinAxisComparisonWithMask) { FixedBinAxis axis("reference", 10, 0.0, 10.0); const std::vector<size_t> mask{0u, 2u, 3u, 4u, 7u, 8u, 9u}; diff --git a/Tests/UnitTests/Core/Axes/UnitConverter1DTest.cpp b/Tests/UnitTests/Core/Axes/UnitConverter1DTest.cpp index 8306a66825aa0b123b72386edfea01a84b9cc5d0..1059ec1aeb39d6dfb4b232021e18e84800fea65a 100644 --- a/Tests/UnitTests/Core/Axes/UnitConverter1DTest.cpp +++ b/Tests/UnitTests/Core/Axes/UnitConverter1DTest.cpp @@ -8,8 +8,7 @@ #include "Device/Data/OutputData.h" #include "Tests/GTestWrapper/google_test.h" -class UnitConverter1DTest : public ::testing::Test -{ +class UnitConverter1DTest : public ::testing::Test { public: UnitConverter1DTest(); @@ -28,12 +27,9 @@ UnitConverter1DTest::UnitConverter1DTest() : m_axis("Angles", 5, 0.5, 1.0) // angles in radians , m_q_axis("Q values", 5, 0.0, 1.0) // q axis in inv. nm , m_qscan(m_q_axis) - , m_beam(Beam::horizontalBeam()) -{ -} + , m_beam(Beam::horizontalBeam()) {} -void UnitConverter1DTest::checkConventionalConverter(const UnitConverter1D& test_object) -{ +void UnitConverter1DTest::checkConventionalConverter(const UnitConverter1D& test_object) { double expected_min = m_axis.binCenter(0); EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::DEFAULT), Units::rad2deg(expected_min), Units::rad2deg(expected_min) * 1e-10); @@ -113,8 +109,7 @@ void UnitConverter1DTest::checkConventionalConverter(const UnitConverter1D& test } } -void UnitConverter1DTest::checkQSpecConverter(const UnitConverter1D& test_object) -{ +void UnitConverter1DTest::checkQSpecConverter(const UnitConverter1D& test_object) { double expected_min = m_q_axis.binCenter(0); EXPECT_EQ(test_object.calculateMin(0, Axes::Units::DEFAULT), expected_min); EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::NBINS), 0.0, 1e-10); @@ -181,14 +176,12 @@ void UnitConverter1DTest::checkQSpecConverter(const UnitConverter1D& test_object } } -TEST_F(UnitConverter1DTest, MainFunctionality) -{ +TEST_F(UnitConverter1DTest, MainFunctionality) { checkConventionalConverter(UnitConverterConvSpec(m_beam, m_axis)); checkQSpecConverter(UnitConverterQSpec(m_qscan)); } -TEST_F(UnitConverter1DTest, Exceptions) -{ +TEST_F(UnitConverter1DTest, Exceptions) { UnitConverterConvSpec converter(m_beam, m_axis); EXPECT_THROW(converter.calculateMin(0, Axes::Units::MM), std::runtime_error); @@ -219,8 +212,7 @@ TEST_F(UnitConverter1DTest, Exceptions) EXPECT_THROW(converter2.createConvertedAxis(1, Axes::Units::DEFAULT), std::runtime_error); } -TEST_F(UnitConverter1DTest, Clone) -{ +TEST_F(UnitConverter1DTest, Clone) { UnitConverterConvSpec converter(m_beam, m_axis); std::unique_ptr<UnitConverter1D> converter_clone(converter.clone()); checkConventionalConverter(*converter_clone); @@ -230,8 +222,7 @@ TEST_F(UnitConverter1DTest, Clone) checkQSpecConverter(*converterQ_clone); } -TEST_F(UnitConverter1DTest, NonDefaultUnitsInInput) -{ +TEST_F(UnitConverter1DTest, NonDefaultUnitsInInput) { PointwiseAxis axis("x", std::vector<double>{0.0, 0.5, 1.0}); EXPECT_THROW(UnitConverterConvSpec(m_beam, axis, Axes::Units::NBINS), std::runtime_error); diff --git a/Tests/UnitTests/Core/Axes/VariableBinAxisTest.cpp b/Tests/UnitTests/Core/Axes/VariableBinAxisTest.cpp index 3d8aee98e4a241c7f3ecc3b09f1b1da31eee7bbf..54f2a966680226252e1d0a200f05755909f178a5 100644 --- a/Tests/UnitTests/Core/Axes/VariableBinAxisTest.cpp +++ b/Tests/UnitTests/Core/Axes/VariableBinAxisTest.cpp @@ -3,12 +3,9 @@ #include "Device/InputOutput/DataFormatUtils.h" #include "Tests/GTestWrapper/google_test.h" -class VariableBinAxisTest : public ::testing::Test -{ -}; +class VariableBinAxisTest : public ::testing::Test {}; -TEST_F(VariableBinAxisTest, VectorOfUnitLength) -{ +TEST_F(VariableBinAxisTest, VectorOfUnitLength) { static const double arr[] = {0., 1.}; std::vector<double> values(arr, arr + sizeof(arr) / sizeof(arr[0])); VariableBinAxis axis("name", 1, values); @@ -18,8 +15,7 @@ TEST_F(VariableBinAxisTest, VectorOfUnitLength) EXPECT_EQ(0.5, axis[0]); } -TEST_F(VariableBinAxisTest, ValidityOfCOnstructor) -{ +TEST_F(VariableBinAxisTest, ValidityOfCOnstructor) { std::vector<double> values; ASSERT_THROW(VariableBinAxis("name", 1, values), Exceptions::LogicErrorException); values.resize(5); @@ -34,8 +30,7 @@ TEST_F(VariableBinAxisTest, ValidityOfCOnstructor) ASSERT_THROW(VariableBinAxis("name", 3, v2), Exceptions::LogicErrorException); } -TEST_F(VariableBinAxisTest, IndexedAccessor) -{ +TEST_F(VariableBinAxisTest, IndexedAccessor) { std::vector<double> values; double start(0.0); @@ -65,8 +60,7 @@ TEST_F(VariableBinAxisTest, IndexedAccessor) ASSERT_THROW(a2[3], Exceptions::OutOfBoundsException); } -TEST_F(VariableBinAxisTest, FindClosestIndex) -{ +TEST_F(VariableBinAxisTest, FindClosestIndex) { static const double arr1[] = {0.0, 0.5, 1.0}; std::vector<double> values1(arr1, arr1 + sizeof(arr1) / sizeof(arr1[0])); @@ -106,8 +100,7 @@ TEST_F(VariableBinAxisTest, FindClosestIndex) EXPECT_EQ(size_t(3), v3.findClosestIndex(1.9999)); } -TEST_F(VariableBinAxisTest, CheckBin) -{ +TEST_F(VariableBinAxisTest, CheckBin) { static const double arr3[] = {-1.0, -0.5, 0.5, 1.0, 2.0}; std::vector<double> values3(arr3, arr3 + sizeof(arr3) / sizeof(arr3[0])); VariableBinAxis axis("name", 4, values3); @@ -132,8 +125,7 @@ TEST_F(VariableBinAxisTest, CheckBin) EXPECT_DOUBLE_EQ(1.0, axis.bin(3).binSize()); } -TEST_F(VariableBinAxisTest, CheckEquality) -{ +TEST_F(VariableBinAxisTest, CheckEquality) { static const double arr3[] = {-1.0, -0.5, 0.5, 1.0, 2.0}; std::vector<double> values3(arr3, arr3 + sizeof(arr3) / sizeof(arr3[0])); @@ -149,8 +141,7 @@ TEST_F(VariableBinAxisTest, CheckEquality) EXPECT_FALSE(a1 == a4); } -TEST_F(VariableBinAxisTest, CheckClone) -{ +TEST_F(VariableBinAxisTest, CheckClone) { static const double arr3[] = {-1.0, -0.5, 0.5, 1.0, 2.0}; std::vector<double> values3(arr3, arr3 + sizeof(arr3) / sizeof(arr3[0])); VariableBinAxis a1("name", 4, values3); @@ -160,8 +151,7 @@ TEST_F(VariableBinAxisTest, CheckClone) delete clone; } -TEST_F(VariableBinAxisTest, IOStream) -{ +TEST_F(VariableBinAxisTest, IOStream) { static const double arr[] = {-1.0, -0.5, 0.5, 1.0, 2.0}; std::vector<double> values(arr, arr + sizeof(arr) / sizeof(arr[0])); VariableBinAxis axis("name", 4, values); @@ -174,8 +164,7 @@ TEST_F(VariableBinAxisTest, IOStream) EXPECT_TRUE(axis == *result); } -TEST_F(VariableBinAxisTest, BinCenters) -{ +TEST_F(VariableBinAxisTest, BinCenters) { static const double arr[] = {-1.0, -0.5, 0.5, 1.0, 2.0}; std::vector<double> values(arr, arr + sizeof(arr) / sizeof(arr[0])); VariableBinAxis axis("name", 4, values); @@ -188,8 +177,7 @@ TEST_F(VariableBinAxisTest, BinCenters) EXPECT_DOUBLE_EQ(1.5, centers[3]); } -TEST_F(VariableBinAxisTest, BinBoundaries) -{ +TEST_F(VariableBinAxisTest, BinBoundaries) { static const double arr[] = {-1.0, -0.5, 0.5, 1.0, 2.0}; std::vector<double> values(arr, arr + sizeof(arr) / sizeof(arr[0])); VariableBinAxis axis("name", 4, values); @@ -203,8 +191,7 @@ TEST_F(VariableBinAxisTest, BinBoundaries) EXPECT_DOUBLE_EQ(2.0, boundaries[4]); } -TEST_F(VariableBinAxisTest, ClippedAxis) -{ +TEST_F(VariableBinAxisTest, ClippedAxis) { static const double arr[] = {-1.0, -0.5, 0.5, 1.0, 2.0}; std::vector<double> values(arr, arr + sizeof(arr) / sizeof(arr[0])); VariableBinAxis axis("name", 4, values); diff --git a/Tests/UnitTests/Core/Basics/Concat.cpp b/Tests/UnitTests/Core/Basics/Concat.cpp index 95a6ec54ed83aff0d357a94954c731a0aed6468c..ededb0b6e8a85ae3e7536f216aebee885d7c3d2d 100644 --- a/Tests/UnitTests/Core/Basics/Concat.cpp +++ b/Tests/UnitTests/Core/Basics/Concat.cpp @@ -3,12 +3,9 @@ #include <string> #include <vector> -class ConcatTest : public ::testing::Test -{ -}; +class ConcatTest : public ::testing::Test {}; -TEST_F(ConcatTest, SimpleType) -{ +TEST_F(ConcatTest, SimpleType) { std::vector<int> A{1, 2, 3}; std::vector<int> B{4, 5}; std::vector<int> N; @@ -19,8 +16,7 @@ TEST_F(ConcatTest, SimpleType) EXPECT_EQ(algo::concat(N, B), B); } -TEST_F(ConcatTest, Struct) -{ +TEST_F(ConcatTest, Struct) { struct S { std::string nam; double val; diff --git a/Tests/UnitTests/Core/Basics/MinMaxValueTest.cpp b/Tests/UnitTests/Core/Basics/MinMaxValueTest.cpp index e6d5a5a589255e3dd919d219a0bd2fe95e1ebcc6..637f096a5ac81cb6f25d8a81b8d0aa430dc110cb 100644 --- a/Tests/UnitTests/Core/Basics/MinMaxValueTest.cpp +++ b/Tests/UnitTests/Core/Basics/MinMaxValueTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <cmath> -class MinMaxValueTest : public ::testing::Test -{ -}; +class MinMaxValueTest : public ::testing::Test {}; -TEST_F(MinMaxValueTest, MinMaxValueAlmostEq) -{ +TEST_F(MinMaxValueTest, MinMaxValueAlmostEq) { double val; std::vector<double> A{0.}; std::vector<int> C{1, 2, 3}; diff --git a/Tests/UnitTests/Core/DataStructure/ArrayUtilsTest.cpp b/Tests/UnitTests/Core/DataStructure/ArrayUtilsTest.cpp index f3ae0d1cabaae3bff93ed5def7c4285d7251eee3..96bbb82d1f498c3a8b2664fab498ee224fb464a7 100644 --- a/Tests/UnitTests/Core/DataStructure/ArrayUtilsTest.cpp +++ b/Tests/UnitTests/Core/DataStructure/ArrayUtilsTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <vector> -class ArrayUtilsTest : public ::testing::Test -{ -}; +class ArrayUtilsTest : public ::testing::Test {}; -TEST_F(ArrayUtilsTest, OutputDataFromVector1D) -{ +TEST_F(ArrayUtilsTest, OutputDataFromVector1D) { // double const std::vector<double> vec_double = {10.0, 20.0, 30.0, 40.0}; auto data1 = ArrayUtils::createData(vec_double); @@ -27,8 +24,7 @@ TEST_F(ArrayUtilsTest, OutputDataFromVector1D) EXPECT_EQ(data2->axis(0).upperBound(), 3.0); } -TEST_F(ArrayUtilsTest, OutputDataToVector1D) -{ +TEST_F(ArrayUtilsTest, OutputDataToVector1D) { const std::vector<double> expected = {10.0, 20.0, 30.0, 40.0}; OutputData<double> data; data.addAxis("axis0", 4, 10.0, 20.0); @@ -40,8 +36,7 @@ TEST_F(ArrayUtilsTest, OutputDataToVector1D) EXPECT_EQ(vec, expected); } -TEST_F(ArrayUtilsTest, OutputDataFromVector2D) -{ +TEST_F(ArrayUtilsTest, OutputDataFromVector2D) { const std::vector<std::vector<double>> vec_double = { {0.0, 1.0, 2.0, 3.0}, {4.0, 5.0, 6.0, 7.0}, {8.0, 9.0, 10.0, 11.0}}; auto data = ArrayUtils::createData(vec_double); @@ -61,8 +56,7 @@ TEST_F(ArrayUtilsTest, OutputDataFromVector2D) EXPECT_EQ(data->getRawDataVector(), expected); } -TEST_F(ArrayUtilsTest, OutputDataToVector2D) -{ +TEST_F(ArrayUtilsTest, OutputDataToVector2D) { OutputData<double> data; data.addAxis("axis0", 4, 10.0, 20.0); data.addAxis("axis1", 3, 30.0, 40.0); diff --git a/Tests/UnitTests/Core/DataStructure/IOStrategyTest.cpp b/Tests/UnitTests/Core/DataStructure/IOStrategyTest.cpp index ff4f42876a5eeec0ec0f899eea5147f8f8e46dd9..2b776a96a009cf19a3a5cdd44e90d7b308453fda 100644 --- a/Tests/UnitTests/Core/DataStructure/IOStrategyTest.cpp +++ b/Tests/UnitTests/Core/DataStructure/IOStrategyTest.cpp @@ -3,16 +3,14 @@ #include "Device/InputOutput/OutputDataWriteStrategy.h" #include "Tests/GTestWrapper/google_test.h" -class IOStrategyTest : public ::testing::Test -{ +class IOStrategyTest : public ::testing::Test { protected: IOStrategyTest(); OutputData<double> m_model_data; }; -IOStrategyTest::IOStrategyTest() -{ +IOStrategyTest::IOStrategyTest() { FixedBinAxis axis1("x", 5, 1.0, 5.0); FixedBinAxis axis2("y", 10, 6.0, 7.0); m_model_data.addAxis(axis1); @@ -21,8 +19,7 @@ IOStrategyTest::IOStrategyTest() m_model_data[i] = static_cast<double>(i); } -TEST_F(IOStrategyTest, TestINTStrategies) -{ +TEST_F(IOStrategyTest, TestINTStrategies) { std::stringstream ss; OutputDataWriteINTStrategy write_int_strategy; write_int_strategy.writeOutputData(m_model_data, ss); @@ -43,8 +40,7 @@ TEST_F(IOStrategyTest, TestINTStrategies) EXPECT_EQ(m_model_data[i], (*result)[i]); } -TEST_F(IOStrategyTest, TestNumpyTXTStrategies) -{ +TEST_F(IOStrategyTest, TestNumpyTXTStrategies) { std::stringstream ss; OutputDataWriteNumpyTXTStrategy write_txt_strategy; write_txt_strategy.writeOutputData(m_model_data, ss); @@ -59,8 +55,7 @@ TEST_F(IOStrategyTest, TestNumpyTXTStrategies) #ifdef BORNAGAIN_TIFF_SUPPORT -TEST_F(IOStrategyTest, TestTIFFStrategies) -{ +TEST_F(IOStrategyTest, TestTIFFStrategies) { std::stringstream ss; OutputDataWriteTiffStrategy write_tiff_strategy; write_tiff_strategy.writeOutputData(m_model_data, ss); diff --git a/Tests/UnitTests/Core/DataStructure/IntensityDataFunctionsTest.cpp b/Tests/UnitTests/Core/DataStructure/IntensityDataFunctionsTest.cpp index e9fa888e5d945775fde9038cd2e59e4497dc53ac..7cb8cac72205f4cc2b458b585505205f48b7f4f7 100644 --- a/Tests/UnitTests/Core/DataStructure/IntensityDataFunctionsTest.cpp +++ b/Tests/UnitTests/Core/DataStructure/IntensityDataFunctionsTest.cpp @@ -2,12 +2,9 @@ #include "Base/Axis/VariableBinAxis.h" #include "Tests/GTestWrapper/google_test.h" -class IntensityDataFunctionsTest : public ::testing::Test -{ -}; +class IntensityDataFunctionsTest : public ::testing::Test {}; -TEST_F(IntensityDataFunctionsTest, ClipDataSetFixed) -{ +TEST_F(IntensityDataFunctionsTest, ClipDataSetFixed) { OutputData<double> data; FixedBinAxis axis0("axis0", 10, -5.0, 5.0); data.addAxis(axis0); @@ -25,8 +22,7 @@ TEST_F(IntensityDataFunctionsTest, ClipDataSetFixed) EXPECT_EQ(vref[index++], (*clip)[i]); } -TEST_F(IntensityDataFunctionsTest, ClipDataSetVariable) -{ +TEST_F(IntensityDataFunctionsTest, ClipDataSetVariable) { static const double arr[] = {-1.0, -0.5, 0.5, 1.0, 2.0}; std::vector<double> values(arr, arr + sizeof(arr) / sizeof(arr[0])); @@ -47,8 +43,7 @@ TEST_F(IntensityDataFunctionsTest, ClipDataSetVariable) EXPECT_EQ(vref[index++], (*clip)[i]); } -TEST_F(IntensityDataFunctionsTest, createRearrangedDataSet) -{ +TEST_F(IntensityDataFunctionsTest, createRearrangedDataSet) { OutputData<double> input_data; input_data.addAxis("axis0", 2, 1.0, 2.0); input_data.addAxis("axis1", 3, 3.0, 4.0); @@ -104,8 +99,7 @@ TEST_F(IntensityDataFunctionsTest, createRearrangedDataSet) EXPECT_EQ(input_data[2], (*output_data)[5]); } -TEST_F(IntensityDataFunctionsTest, coordinateToFromBinf) -{ +TEST_F(IntensityDataFunctionsTest, coordinateToFromBinf) { FixedBinAxis axis("axis", 8, -5.0, 3.0); EXPECT_EQ(0.5, IntensityDataFunctions::coordinateToBinf(-4.5, axis)); EXPECT_EQ(-4.5, IntensityDataFunctions::coordinateFromBinf(0.5, axis)); @@ -126,8 +120,7 @@ TEST_F(IntensityDataFunctionsTest, coordinateToFromBinf) //! Transformation of coordinates from one OutputData to another using conversion from axes //! coordinates to bin-fraction-coordinates and then to another axes coordinates. -TEST_F(IntensityDataFunctionsTest, outputDataCoordinatesToFromBinf) -{ +TEST_F(IntensityDataFunctionsTest, outputDataCoordinatesToFromBinf) { OutputData<double> data1; data1.addAxis("axis0", 8, -5.0, 3.0); data1.addAxis("axis1", 3, 2.0, 5.0); @@ -150,8 +143,7 @@ TEST_F(IntensityDataFunctionsTest, outputDataCoordinatesToFromBinf) EXPECT_DOUBLE_EQ(y, 21.0); } -TEST_F(IntensityDataFunctionsTest, create2DArrayfromOutputDataTest) -{ +TEST_F(IntensityDataFunctionsTest, create2DArrayfromOutputDataTest) { OutputData<double> out_data; out_data.addAxis("axis0", 2, 1.0, 2.0); out_data.addAxis("axis1", 3, 3.0, 4.0); @@ -180,8 +172,7 @@ TEST_F(IntensityDataFunctionsTest, create2DArrayfromOutputDataTest) EXPECT_EQ(array_expected_2d, array_2d); } -TEST_F(IntensityDataFunctionsTest, createOutputDatafrom2DArrayTest) -{ +TEST_F(IntensityDataFunctionsTest, createOutputDatafrom2DArrayTest) { std::vector<double> arr_in{1, 2, 3, 4, 5, 6}; std::vector<std::vector<double>> array_2d{{arr_in[0], arr_in[1], arr_in[2]}, {arr_in[3], arr_in[4], arr_in[5]}}; diff --git a/Tests/UnitTests/Core/DataStructure/LLDataTest.cpp b/Tests/UnitTests/Core/DataStructure/LLDataTest.cpp index b0f71e22aef31bcf6993bc67ac8ef21d7475db6b..f675e6ab002bf250fcd13b4595a86b24642ad23d 100644 --- a/Tests/UnitTests/Core/DataStructure/LLDataTest.cpp +++ b/Tests/UnitTests/Core/DataStructure/LLDataTest.cpp @@ -3,8 +3,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <algorithm> -class LLDataTest : public ::testing::Test -{ +class LLDataTest : public ::testing::Test { protected: LLDataTest(); @@ -15,8 +14,7 @@ protected: LLData<Eigen::Matrix2d>* matrix_data_2d; }; -LLDataTest::LLDataTest() -{ +LLDataTest::LLDataTest() { int* dim0 = new int[0]; int* dim1 = new int[1]; @@ -38,24 +36,21 @@ LLDataTest::LLDataTest() matrix_data_2d = new LLData<Eigen::Matrix2d>(2u, dim2); } -TEST_F(LLDataTest, TotalSize) -{ +TEST_F(LLDataTest, TotalSize) { EXPECT_EQ(1u, int_data_0d->getTotalSize()); EXPECT_EQ(10u, fl_data_1d->getTotalSize()); EXPECT_EQ(3000u, db_data_3d->getTotalSize()); EXPECT_EQ(600u, matrix_data_2d->getTotalSize()); } -TEST_F(LLDataTest, GetRank) -{ +TEST_F(LLDataTest, GetRank) { EXPECT_EQ(0u, int_data_0d->rank()); EXPECT_EQ(1u, fl_data_1d->rank()); EXPECT_EQ(3u, db_data_3d->rank()); EXPECT_EQ(2u, matrix_data_2d->rank()); } -TEST_F(LLDataTest, SetAll) -{ +TEST_F(LLDataTest, SetAll) { db_data_3d->setAll(1.0); EXPECT_DOUBLE_EQ((*db_data_3d)[0], 1.0); @@ -63,8 +58,7 @@ TEST_F(LLDataTest, SetAll) EXPECT_EQ((*matrix_data_2d)[0], Eigen::Matrix2d::Identity()); } -TEST_F(LLDataTest, ScaleAll) -{ +TEST_F(LLDataTest, ScaleAll) { db_data_3d->setAll(2.0); db_data_3d->scaleAll(2.5); EXPECT_DOUBLE_EQ((*db_data_3d)[0], 5.0); @@ -74,8 +68,7 @@ TEST_F(LLDataTest, ScaleAll) EXPECT_EQ((*matrix_data_2d)[0], 3 * Eigen::Matrix2d::Identity() * Eigen::Matrix2d::Identity()); } -TEST_F(LLDataTest, TotalSum) -{ +TEST_F(LLDataTest, TotalSum) { fl_data_1d->setAll(2.0); EXPECT_FLOAT_EQ(fl_data_1d->getTotalSum(), 20.0); @@ -86,16 +79,14 @@ TEST_F(LLDataTest, TotalSum) EXPECT_EQ(600 * Eigen::Matrix2d::Identity(), matrix_data_2d->getTotalSum()); } -TEST_F(LLDataTest, GetDimensions) -{ +TEST_F(LLDataTest, GetDimensions) { EXPECT_EQ(int_data_0d->dimensions(), (int*)0); EXPECT_EQ(fl_data_1d->dimensions()[0], 10); EXPECT_EQ(db_data_3d->dimensions()[1], 15); EXPECT_EQ(matrix_data_2d->dimensions()[1], 30); } -TEST_F(LLDataTest, DataCopyingConstructor) -{ +TEST_F(LLDataTest, DataCopyingConstructor) { LLData<int>* other_int_data_0d = new LLData<int>(*int_data_0d); EXPECT_TRUE(HaveSameDimensions(*int_data_0d, *other_int_data_0d)); @@ -123,8 +114,7 @@ TEST_F(LLDataTest, DataCopyingConstructor) delete other_matrix_data_2d; } -TEST_F(LLDataTest, DataAssignment) -{ +TEST_F(LLDataTest, DataAssignment) { LLData<float>* other_fl_data_1d = new LLData<float>(*fl_data_1d); fl_data_1d->setAll(1.1f); @@ -149,8 +139,7 @@ TEST_F(LLDataTest, DataAssignment) delete other_matrix_data_2d; } -TEST_F(LLDataTest, Addition) -{ +TEST_F(LLDataTest, Addition) { LLData<float>* other_fl_data_1d = new LLData<float>(*fl_data_1d); fl_data_1d->setAll(1.1f); @@ -188,8 +177,7 @@ TEST_F(LLDataTest, Addition) delete other_matrix_data_2d; } -TEST_F(LLDataTest, Substraction) -{ +TEST_F(LLDataTest, Substraction) { LLData<float>* other_fl_data_1d = new LLData<float>(*fl_data_1d); fl_data_1d->setAll(1.15f); @@ -226,8 +214,7 @@ TEST_F(LLDataTest, Substraction) delete other_matrix_data_2d; } -TEST_F(LLDataTest, Multiplication) -{ +TEST_F(LLDataTest, Multiplication) { LLData<float>* other_fl_data_1d = new LLData<float>(*fl_data_1d); fl_data_1d->setAll(1.15f); @@ -264,8 +251,7 @@ TEST_F(LLDataTest, Multiplication) delete other_matrix_data_2d; } -TEST_F(LLDataTest, Division) -{ +TEST_F(LLDataTest, Division) { LLData<float>* other_fl_data_1d = new LLData<float>(*fl_data_1d); fl_data_1d->setAll(1.15f); @@ -294,8 +280,7 @@ TEST_F(LLDataTest, Division) delete other_db_data_3d; } -TEST_F(LLDataTest, HaveSameDimensions) -{ +TEST_F(LLDataTest, HaveSameDimensions) { int* odim0 = new int[0]; int* odim1 = new int[1]; @@ -335,8 +320,7 @@ TEST_F(LLDataTest, HaveSameDimensions) delete[] odim2; } -TEST_F(LLDataTest, Accessors) -{ +TEST_F(LLDataTest, Accessors) { for (size_t i = 0; i < fl_data_1d->getTotalSize(); ++i) { (*fl_data_1d)[i] = 0.5f * i; } diff --git a/Tests/UnitTests/Core/DataStructure/OutputDataIteratorTest.cpp b/Tests/UnitTests/Core/DataStructure/OutputDataIteratorTest.cpp index ff22240019c7598eb4abbc3490387d81d2a48670..6c7346b7be4e00bf86f24bfa9fd0ce2f0f6d662a 100644 --- a/Tests/UnitTests/Core/DataStructure/OutputDataIteratorTest.cpp +++ b/Tests/UnitTests/Core/DataStructure/OutputDataIteratorTest.cpp @@ -1,16 +1,14 @@ #include "Device/Data/OutputData.h" #include "Tests/GTestWrapper/google_test.h" -class OutputDataIteratorTest : public ::testing::Test -{ +class OutputDataIteratorTest : public ::testing::Test { protected: OutputDataIteratorTest(); OutputData<double> _data; }; -OutputDataIteratorTest::OutputDataIteratorTest() -{ +OutputDataIteratorTest::OutputDataIteratorTest() { int* dims = new int[2]; dims[0] = 3; dims[1] = 5; @@ -24,8 +22,7 @@ OutputDataIteratorTest::OutputDataIteratorTest() } } -TEST_F(OutputDataIteratorTest, Iterate) -{ +TEST_F(OutputDataIteratorTest, Iterate) { OutputData<double>::iterator it = _data.begin(); EXPECT_EQ(0.0, *it); for (size_t i = 0; i < 14; ++i) { @@ -38,8 +35,7 @@ TEST_F(OutputDataIteratorTest, Iterate) EXPECT_EQ(it, _data.end()); } -TEST_F(OutputDataIteratorTest, ConstIterate) -{ +TEST_F(OutputDataIteratorTest, ConstIterate) { OutputData<double>::const_iterator it = _data.begin(); EXPECT_EQ(0.0, *it); for (size_t i = 0; i < 14; ++i) { diff --git a/Tests/UnitTests/Core/DataStructure/OutputDataTest.cpp b/Tests/UnitTests/Core/DataStructure/OutputDataTest.cpp index a227240b8880ca28ecdf77badb40b9a919824d90..de02169456d168dc9d37ddfcd79da6fe509a1bcc 100644 --- a/Tests/UnitTests/Core/DataStructure/OutputDataTest.cpp +++ b/Tests/UnitTests/Core/DataStructure/OutputDataTest.cpp @@ -3,8 +3,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <algorithm> -class OutputDataTest : public ::testing::Test -{ +class OutputDataTest : public ::testing::Test { protected: OutputDataTest(); @@ -16,8 +15,7 @@ protected: OutputData<Eigen::Matrix2d> matrix_data_2d; }; -OutputDataTest::OutputDataTest() -{ +OutputDataTest::OutputDataTest() { zero_3d_coordinate.push_back(0); zero_3d_coordinate.push_back(0); zero_3d_coordinate.push_back(0); @@ -40,13 +38,11 @@ OutputDataTest::OutputDataTest() matrix_data_2d.setAllTo(Eigen::Matrix2d::Identity()); } -TEST_F(OutputDataTest, SingleElementAfterConstruction) -{ +TEST_F(OutputDataTest, SingleElementAfterConstruction) { EXPECT_EQ(1u, int_data_0d.getAllocatedSize()); } -TEST_F(OutputDataTest, SizeAfterAddingAxes) -{ +TEST_F(OutputDataTest, SizeAfterAddingAxes) { EXPECT_EQ(1u, int_data_0d.getAllocatedSize()); EXPECT_EQ(20u, fl_data_1d.getAllocatedSize()); EXPECT_EQ(2000u, db_data_3d.getAllocatedSize()); @@ -54,8 +50,7 @@ TEST_F(OutputDataTest, SizeAfterAddingAxes) EXPECT_EQ(200u, matrix_data_2d.getAllocatedSize()); } -TEST_F(OutputDataTest, DataInitialization) -{ +TEST_F(OutputDataTest, DataInitialization) { std::vector<unsigned> coordinates; coordinates.push_back(11); coordinates.push_back(4); @@ -69,8 +64,7 @@ TEST_F(OutputDataTest, DataInitialization) matrix_data_2d[matrix_data_2d.toGlobalIndex(coordinates2)]); } -TEST_F(OutputDataTest, isInitialized) -{ +TEST_F(OutputDataTest, isInitialized) { OutputData<double> data1; EXPECT_FALSE(data1.isInitialized()); data1.addAxis("axis", 10, 0.0, 10.0); @@ -79,8 +73,7 @@ TEST_F(OutputDataTest, isInitialized) EXPECT_FALSE(data1.isInitialized()); } -TEST_F(OutputDataTest, DataCopying) -{ +TEST_F(OutputDataTest, DataCopying) { OutputData<double> data1; OutputData<double> data2; data1.addAxis("axis1", 10, 0., 10.); @@ -142,8 +135,7 @@ TEST_F(OutputDataTest, DataCopying) EXPECT_TRUE(mdata2.hasSameShape(mdata2)); } -TEST_F(OutputDataTest, MaxElement) -{ +TEST_F(OutputDataTest, MaxElement) { OutputData<double> data; data.addAxis("axis1", 10, 0., 10.); data.addAxis("axis2", 2, 0., 10.); @@ -163,8 +155,7 @@ TEST_F(OutputDataTest, MaxElement) // 0 | 0 2 4 6 8 10 12 14 16 18 | // -------------------------------------------- // | 0 1 2 3 4 5 6 7 8 9 | x -TEST_F(OutputDataTest, ValueOfAxis) -{ +TEST_F(OutputDataTest, ValueOfAxis) { OutputData<double> data; data.addAxis("axis1", 10, 0., 10.); data.addAxis("axis2", 2, 0., 10.); @@ -210,8 +201,7 @@ TEST_F(OutputDataTest, ValueOfAxis) // 0 | 0 2 4 6 8 10 12 14 16 18 | // -------------------------------------------- // | 0 1 2 3 4 5 6 7 8 9 | x -TEST_F(OutputDataTest, GetAxisBin) -{ +TEST_F(OutputDataTest, GetAxisBin) { OutputData<double> data; data.addAxis("axis1", 10, 0., 10.); data.addAxis("axis2", 2, 0., 10.); @@ -226,8 +216,7 @@ TEST_F(OutputDataTest, GetAxisBin) EXPECT_EQ(7.5, data.getAxisBin(19, "axis2").center()); } -TEST_F(OutputDataTest, SetCleared) -{ +TEST_F(OutputDataTest, SetCleared) { db_data_3d.clear(); db_data_3d.setAllTo(1.0); EXPECT_EQ(db_data_3d[0], 1.0); @@ -237,8 +226,7 @@ TEST_F(OutputDataTest, SetCleared) EXPECT_EQ(10 * Eigen::Matrix2d::Identity(), matrix_data_2d[0]); } -TEST_F(OutputDataTest, MixedTypeOperations) -{ +TEST_F(OutputDataTest, MixedTypeOperations) { OutputData<bool> data_bool; data_bool.addAxis("axis1", 10, 0.0, 10.0); diff --git a/Tests/UnitTests/Core/Detector/BesselTest.cpp b/Tests/UnitTests/Core/Detector/BesselTest.cpp index 1238c776074311afa96614b20e44aea2354d4d0e..f05fdc039908102f845f0685e6cdd1035532a181 100644 --- a/Tests/UnitTests/Core/Detector/BesselTest.cpp +++ b/Tests/UnitTests/Core/Detector/BesselTest.cpp @@ -1,13 +1,10 @@ #include "Base/Math/Bessel.h" #include "Tests/GTestWrapper/google_test.h" -class BesselTest : public ::testing::Test -{ -}; +class BesselTest : public ::testing::Test {}; // Test complex Bessel function J1 -TEST_F(BesselTest, BesselJ1) -{ +TEST_F(BesselTest, BesselJ1) { const double eps = 4.7e-16; // more than twice the machine precision complex_t res; diff --git a/Tests/UnitTests/Core/Detector/DetectorMaskTest.cpp b/Tests/UnitTests/Core/Detector/DetectorMaskTest.cpp index 8ab0b26e48ffaf6c77cd11a77179e98f10a09b8d..9579a08d3c0dff2263fabbf29c5e61c732896e05 100644 --- a/Tests/UnitTests/Core/Detector/DetectorMaskTest.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorMaskTest.cpp @@ -3,12 +3,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class DetectorMaskTest : public ::testing::Test -{ -}; +class DetectorMaskTest : public ::testing::Test {}; -TEST_F(DetectorMaskTest, InitialState) -{ +TEST_F(DetectorMaskTest, InitialState) { DetectorMask test; EXPECT_FALSE(test.isMasked(0)); EXPECT_FALSE(test.getMaskData()->isInitialized()); @@ -29,8 +26,7 @@ TEST_F(DetectorMaskTest, InitialState) // -2.0 ------------------------------------------------------------------------- // -4.0 -3.0 -2.0 -1.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 -TEST_F(DetectorMaskTest, AddMask) -{ +TEST_F(DetectorMaskTest, AddMask) { DetectorMask detectorMask; std::vector<double> x = {4.0, -4.0, -4.0, 4.0, 4.0}; @@ -92,8 +88,7 @@ TEST_F(DetectorMaskTest, AddMask) } } -TEST_F(DetectorMaskTest, AssignmentOperator) -{ +TEST_F(DetectorMaskTest, AssignmentOperator) { DetectorMask detectorMask; std::vector<double> x = {4.0, -4.0, -4.0, 4.0, 4.0}; @@ -124,8 +119,7 @@ TEST_F(DetectorMaskTest, AssignmentOperator) EXPECT_EQ(mask.numberOfMaskedChannels(), 32); } -TEST_F(DetectorMaskTest, CopyConstructor) -{ +TEST_F(DetectorMaskTest, CopyConstructor) { DetectorMask detectorMask; std::vector<double> x = {4.0, -4.0, -4.0, 4.0, 4.0}; diff --git a/Tests/UnitTests/Core/Detector/OffSpecularConverterTest.cpp b/Tests/UnitTests/Core/Detector/OffSpecularConverterTest.cpp index 4038b02dae14ce99e7c739db009669155c762dcc..04e0e066c9a0ba8ac1fb294c0d4838c17a2e531e 100644 --- a/Tests/UnitTests/Core/Detector/OffSpecularConverterTest.cpp +++ b/Tests/UnitTests/Core/Detector/OffSpecularConverterTest.cpp @@ -4,8 +4,7 @@ #include "Device/Detector/SphericalDetector.h" #include "Tests/GTestWrapper/google_test.h" -class OffSpecularConverterTest : public ::testing::Test -{ +class OffSpecularConverterTest : public ::testing::Test { public: OffSpecularConverterTest(); @@ -18,12 +17,9 @@ protected: OffSpecularConverterTest::OffSpecularConverterTest() : m_detector(100, 0.0, 5.0 * Units::deg, 70, -2.0 * Units::deg, 1.5) , m_alpha_i_axis("alpha_i", 51, 0.0, 7.0 * Units::deg) - , m_beam(1.0, 1.0 * Units::deg, 0.0, 1.0) -{ -} + , m_beam(1.0, 1.0 * Units::deg, 0.0, 1.0) {} -TEST_F(OffSpecularConverterTest, OffSpecularConverter) -{ +TEST_F(OffSpecularConverterTest, OffSpecularConverter) { OffSpecularConverter converter(m_detector, m_beam, m_alpha_i_axis); EXPECT_EQ(converter.dimension(), 2u); @@ -75,8 +71,7 @@ TEST_F(OffSpecularConverterTest, OffSpecularConverter) EXPECT_THROW(converter.createConvertedAxis(1, Axes::Units::QSPACE), std::runtime_error); } -TEST_F(OffSpecularConverterTest, OffSpecularConverterClone) -{ +TEST_F(OffSpecularConverterTest, OffSpecularConverterClone) { OffSpecularConverter converter(m_detector, m_beam, m_alpha_i_axis); std::unique_ptr<OffSpecularConverter> P_clone(converter.clone()); diff --git a/Tests/UnitTests/Core/Detector/PolygonTest.cpp b/Tests/UnitTests/Core/Detector/PolygonTest.cpp index b615930d4249da3fc6ad529bdfe0c5c91eaf573e..b8eb667fac1d44b9d916a0cb45ad954233ffabae 100644 --- a/Tests/UnitTests/Core/Detector/PolygonTest.cpp +++ b/Tests/UnitTests/Core/Detector/PolygonTest.cpp @@ -3,12 +3,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class PolygonTest : public ::testing::Test -{ -}; +class PolygonTest : public ::testing::Test {}; -TEST_F(PolygonTest, SimpleRectangle) -{ +TEST_F(PolygonTest, SimpleRectangle) { // simple closed rectangle std::vector<double> x = {4.0, -4.0, -4.0, 4.0, 4.0}; std::vector<double> y = {2.0, 2.0, -2.0, -2.0, 2.0}; @@ -42,8 +39,7 @@ TEST_F(PolygonTest, SimpleRectangle) // * * // ************************************************************************************************ -TEST_F(PolygonTest, SandWatchShape) -{ +TEST_F(PolygonTest, SandWatchShape) { std::vector<double> x = {2.0, -2.0, 2.0, -2.0, 2.0}; std::vector<double> y = {2.0, 2.0, -2.0, -2.0, 2.0}; Polygon polygon(x, y); @@ -61,8 +57,7 @@ TEST_F(PolygonTest, SandWatchShape) EXPECT_FALSE(polygon.contains(-1.5, 0.5)); } -TEST_F(PolygonTest, ContainsBin) -{ +TEST_F(PolygonTest, ContainsBin) { // simple closed rectangle std::vector<double> x = {4.0, -4.0, -4.0, 4.0, 4.0}; std::vector<double> y = {2.0, 2.0, -2.0, -2.0, 2.0}; @@ -77,8 +72,7 @@ TEST_F(PolygonTest, ContainsBin) EXPECT_FALSE(polygon.contains(binx2, biny2)); } -TEST_F(PolygonTest, Clone) -{ +TEST_F(PolygonTest, Clone) { std::vector<double> x = {4.0, -4.0, -4.0, 4.0, 4.0}; std::vector<double> y = {2.0, 2.0, -2.0, -2.0, 2.0}; Polygon polygon(x, y); @@ -93,8 +87,7 @@ TEST_F(PolygonTest, Clone) EXPECT_FALSE(clone->contains(4.0, -2.01)); } -TEST_F(PolygonTest, ConstructFrom2DArray) -{ +TEST_F(PolygonTest, ConstructFrom2DArray) { // simple closed rectangle const size_t npoints(5); double array[npoints][2] = {{4.0, 2.0}, {-4.0, 2.0}, {-4.0, -2.0}, {4.0, -2.0}, {4.0, 2.0}}; diff --git a/Tests/UnitTests/Core/Detector/PrecomputedTest.cpp b/Tests/UnitTests/Core/Detector/PrecomputedTest.cpp index 4bb6e29dae3f63c92f86ad4700e0bccedaaacbde..501a225ddc3e7fd4c3d464c5742e3b8d156b9583 100644 --- a/Tests/UnitTests/Core/Detector/PrecomputedTest.cpp +++ b/Tests/UnitTests/Core/Detector/PrecomputedTest.cpp @@ -2,17 +2,13 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -namespace -{ +namespace { constexpr auto ReciprocalFactorialArray = Math::generateReciprocalFactorialArray<171>(); } -class PrecomputedTest : public ::testing::Test -{ -}; +class PrecomputedTest : public ::testing::Test {}; -TEST_F(PrecomputedTest, ReciprocalFactorial) -{ +TEST_F(PrecomputedTest, ReciprocalFactorial) { const double eps = 2.3e-16; // about the machine precision EXPECT_TRUE(ReciprocalFactorialArray.size() > 150); EXPECT_DOUBLE_EQ(ReciprocalFactorialArray[0], 1.); diff --git a/Tests/UnitTests/Core/Detector/RectangularConverterTest.cpp b/Tests/UnitTests/Core/Detector/RectangularConverterTest.cpp index 4762a6814dee2814229523d5124afc3dbc9a4555..7dd6cb5209c97fb7fa1d7bf3ec1b3793afe59397 100644 --- a/Tests/UnitTests/Core/Detector/RectangularConverterTest.cpp +++ b/Tests/UnitTests/Core/Detector/RectangularConverterTest.cpp @@ -5,8 +5,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <cmath> -namespace -{ +namespace { const double det_width = 200.0; const double det_height = 140.0; const double det_distance = 1000.0; @@ -14,8 +13,7 @@ const size_t det_nx = 100u; const size_t det_ny = 70u; } // namespace -class RectangularConverterTest : public ::testing::Test -{ +class RectangularConverterTest : public ::testing::Test { public: RectangularConverterTest(); @@ -27,8 +25,7 @@ protected: }; RectangularConverterTest::RectangularConverterTest() - : m_detector(det_nx, det_width, det_ny, det_height), m_beam(1.0, 1.0 * Units::deg, 0.0, 1.0) -{ + : m_detector(det_nx, det_width, det_ny, det_height), m_beam(1.0, 1.0 * Units::deg, 0.0, 1.0) { m_detector.setPerpendicularToSampleX(det_distance, det_width / 2.0, 0.0); m_detector.init(m_beam); m_phi = std::atan2(det_width / 2.0, det_distance); @@ -40,8 +37,7 @@ RectangularConverterTest::RectangularConverterTest() m_kfz = K * std::sin(m_alpha); } -TEST_F(RectangularConverterTest, RectangularConverter) -{ +TEST_F(RectangularConverterTest, RectangularConverter) { RectangularConverter converter(m_detector, m_beam); EXPECT_EQ(converter.dimension(), 2u); @@ -98,8 +94,7 @@ TEST_F(RectangularConverterTest, RectangularConverter) EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::DEFAULT), std::runtime_error); } -TEST_F(RectangularConverterTest, RectangularConverterClone) -{ +TEST_F(RectangularConverterTest, RectangularConverterClone) { RectangularConverter converter(m_detector, m_beam); std::unique_ptr<RectangularConverter> P_clone(converter.clone()); @@ -143,8 +138,7 @@ TEST_F(RectangularConverterTest, RectangularConverterClone) EXPECT_THROW(P_clone->calculateMax(2, Axes::Units::DEFAULT), std::runtime_error); } -TEST_F(RectangularConverterTest, RectangularConverterWithROI) -{ +TEST_F(RectangularConverterTest, RectangularConverterWithROI) { const double roi_xmin = 100; const double roi_xmax = 150; // xmax in roi will be 152 due to binning const double roi_ymin = 50; diff --git a/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp b/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp index 071f362bf8344b8b1ed78bbafa6836795a87f7e5..95a89252aac5e274acd9d6abddfc60abb9d43801 100644 --- a/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp +++ b/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp @@ -6,16 +6,14 @@ #include <iostream> #include <memory> -class RectangularDetectorTest : public ::testing::Test -{ +class RectangularDetectorTest : public ::testing::Test { protected: // double phi(DetectorElement& element, double wavelength); // double alpha(DetectorElement& element, double wavelength); double phi(kvector_t k) { return k.phi() / Units::deg; } double alpha(kvector_t k) { return 90.0 - k.theta() / Units::deg; } - bool isEqual(const kvector_t lhs, const kvector_t rhs) - { + bool isEqual(const kvector_t lhs, const kvector_t rhs) { bool is_equal = algo::almostEqual(lhs.x(), rhs.x()) && algo::almostEqual(lhs.y(), rhs.y()) && algo::almostEqual(lhs.z(), rhs.z()); if (!is_equal) { @@ -25,8 +23,7 @@ protected: } }; -TEST_F(RectangularDetectorTest, InitialState) -{ +TEST_F(RectangularDetectorTest, InitialState) { RectangularDetector det(50u, 10.0, 60u, 20.0); EXPECT_EQ(50u, det.getNbinsX()); EXPECT_EQ(10.0, det.getWidth()); @@ -43,8 +40,7 @@ TEST_F(RectangularDetectorTest, InitialState) EXPECT_EQ(RectangularDetector::GENERIC, det.getDetectorArrangment()); } -TEST_F(RectangularDetectorTest, Clone) -{ +TEST_F(RectangularDetectorTest, Clone) { RectangularDetector det(50u, 10.0, 60u, 20.0); kvector_t normal(10.0, 20.0, 30.0); kvector_t direction(1.0, 2.0, 3.0); @@ -59,8 +55,7 @@ TEST_F(RectangularDetectorTest, Clone) EXPECT_EQ(RectangularDetector::GENERIC, clone->getDetectorArrangment()); } -TEST_F(RectangularDetectorTest, PerpToSample) -{ +TEST_F(RectangularDetectorTest, PerpToSample) { size_t nbinsx(5u), nbinsy(4u); double width(50.0), height(40.0); double distance(100.0), u0(20.0), v0(10.0); @@ -112,8 +107,7 @@ TEST_F(RectangularDetectorTest, PerpToSample) // EXPECT_NEAR(alpha(k), alpha(elements[19], wavelength), 1e-10 * std::abs(alpha(k))); } -TEST_F(RectangularDetectorTest, PerpToDirectBeam) -{ +TEST_F(RectangularDetectorTest, PerpToDirectBeam) { size_t nbinsx(5u), nbinsy(4u); double width(50.0), height(40.0); double distance(100.0), u0(20.0), v0(10.0); @@ -155,8 +149,7 @@ TEST_F(RectangularDetectorTest, PerpToDirectBeam) // EXPECT_NEAR(alpha(k), alpha(elements[0], wavelength), 1e-10 * std::abs(alpha(k))); } -TEST_F(RectangularDetectorTest, PerpToReflectedBeam) -{ +TEST_F(RectangularDetectorTest, PerpToReflectedBeam) { size_t nbinsx(5u), nbinsy(4u); double width(50.0), height(40.0); double distance(100.0), u0(20.0), v0(10.0); @@ -200,8 +193,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeam) } // detector perpendicular to reflected beam, when direct beam position is known -TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos) -{ +TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos) { size_t nbinsx(5u), nbinsy(4u); double width(50.0), height(40.0); double distance(100.0), u0(20.0), v0(10.0); @@ -258,8 +250,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos) } // Test retrieval of analyzer properties -TEST_F(RectangularDetectorTest, AnalyzerProperties) -{ +TEST_F(RectangularDetectorTest, AnalyzerProperties) { RectangularDetector detector(50u, 10.0, 60u, 20.0); kvector_t direction; diff --git a/Tests/UnitTests/Core/Detector/RegionOfInterestTest.cpp b/Tests/UnitTests/Core/Detector/RegionOfInterestTest.cpp index a49db8d5a17195969c241aa0e4eae37f7f7ecdb1..0735b45dd626630e1273553e0ce72351dd1d7317 100644 --- a/Tests/UnitTests/Core/Detector/RegionOfInterestTest.cpp +++ b/Tests/UnitTests/Core/Detector/RegionOfInterestTest.cpp @@ -3,14 +3,11 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class RegionOfInterestTest : public ::testing::Test -{ -}; +class RegionOfInterestTest : public ::testing::Test {}; //! Testing region of interest with reasonable area within the detector. -TEST_F(RegionOfInterestTest, constructor) -{ +TEST_F(RegionOfInterestTest, constructor) { SphericalDetector detector; detector.addAxis(FixedBinAxis("axis0", 8, -3.0, 5.0)); detector.addAxis(FixedBinAxis("axis1", 4, 0.0, 4.0)); @@ -44,8 +41,7 @@ TEST_F(RegionOfInterestTest, constructor) //! Testing region of interest which is larger than the detector. -TEST_F(RegionOfInterestTest, largeArea) -{ +TEST_F(RegionOfInterestTest, largeArea) { SphericalDetector detector; detector.addAxis(FixedBinAxis("axis0", 8, -3.0, 5.0)); detector.addAxis(FixedBinAxis("axis1", 4, 0.0, 4.0)); @@ -71,8 +67,7 @@ TEST_F(RegionOfInterestTest, largeArea) //! Testing clone -TEST_F(RegionOfInterestTest, clone) -{ +TEST_F(RegionOfInterestTest, clone) { SphericalDetector detector; detector.addAxis(FixedBinAxis("axis0", 8, -3.0, 5.0)); detector.addAxis(FixedBinAxis("axis1", 4, 0.0, 4.0)); diff --git a/Tests/UnitTests/Core/Detector/SimulationAreaTest.cpp b/Tests/UnitTests/Core/Detector/SimulationAreaTest.cpp index 6b83b9abd3fccd8c122bf0886e2e85e4fdc4bc42..b7f74af9ffefa09032262eb6bf9ed325646f987a 100644 --- a/Tests/UnitTests/Core/Detector/SimulationAreaTest.cpp +++ b/Tests/UnitTests/Core/Detector/SimulationAreaTest.cpp @@ -5,14 +5,11 @@ #include <iostream> #include <memory> -class SimulationAreaTest : public ::testing::Test -{ -}; +class SimulationAreaTest : public ::testing::Test {}; // Iterators test -TEST_F(SimulationAreaTest, iteratorOperations) -{ +TEST_F(SimulationAreaTest, iteratorOperations) { SphericalDetector detector(4, -1.0, 3.0, 2, 0.0, 2.0); SimulationArea area(&detector); @@ -56,8 +53,7 @@ TEST_F(SimulationAreaTest, iteratorOperations) //! Iteration over non-masked detector -TEST_F(SimulationAreaTest, detectorIteration) -{ +TEST_F(SimulationAreaTest, detectorIteration) { SphericalDetector detector(4, -1.0, 3.0, 2, 0.0, 2.0); SimulationArea area(&detector); @@ -79,8 +75,7 @@ TEST_F(SimulationAreaTest, detectorIteration) //! Iteration over masked detector -TEST_F(SimulationAreaTest, maskedIteration) -{ +TEST_F(SimulationAreaTest, maskedIteration) { SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.addMask(Rectangle(0.1, 1.1, 2.9, 2.9), true); detector.addMask(Rectangle(3.1, 3.1, 3.9, 3.9), true); @@ -100,8 +95,7 @@ TEST_F(SimulationAreaTest, maskedIteration) //! Iteration over the detector with first and alst bin masked -TEST_F(SimulationAreaTest, maskedCornerIteration) -{ +TEST_F(SimulationAreaTest, maskedCornerIteration) { SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.addMask(Rectangle(-0.9, 0.1, -0.1, 0.9), true); detector.addMask(Rectangle(3.1, 3.1, 3.9, 3.9), true); @@ -123,8 +117,7 @@ TEST_F(SimulationAreaTest, maskedCornerIteration) //! Iteration when whole detector is masked -TEST_F(SimulationAreaTest, allMaskedIteration) -{ +TEST_F(SimulationAreaTest, allMaskedIteration) { SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.addMask(Rectangle(-0.9, 0.1, 3.9, 3.9), true); SimulationArea area(&detector); @@ -141,8 +134,7 @@ TEST_F(SimulationAreaTest, allMaskedIteration) //! Iteration when RegionOfInterest and masks are present -TEST_F(SimulationAreaTest, maskAndRoiIteration) -{ +TEST_F(SimulationAreaTest, maskAndRoiIteration) { SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.setRegionOfInterest(0.1, 1.1, 2.9, 3.9); detector.addMask(Rectangle(-0.9, 0.1, 0.9, 1.9), true); @@ -185,8 +177,7 @@ TEST_F(SimulationAreaTest, maskAndRoiIteration) //! Iteration when RegionOfInterest and masks are present. Iteration visit masked areas too. -TEST_F(SimulationAreaTest, maskAndRoiIterationVisitMasks) -{ +TEST_F(SimulationAreaTest, maskAndRoiIterationVisitMasks) { SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.setRegionOfInterest(0.1, 1.1, 2.9, 3.9); detector.addMask(Rectangle(-0.9, 0.1, 0.9, 1.9), true); @@ -231,8 +222,7 @@ TEST_F(SimulationAreaTest, maskAndRoiIterationVisitMasks) //! Checking index of ROI -TEST_F(SimulationAreaTest, indexInRoi) -{ +TEST_F(SimulationAreaTest, indexInRoi) { SphericalDetector detector(5, -1.0, 4.0, 4, 0.0, 4.0); detector.setRegionOfInterest(0.1, 1.1, 2.9, 3.9); detector.addMask(Rectangle(-0.9, 0.1, 0.9, 1.9), true); diff --git a/Tests/UnitTests/Core/Detector/SpecialFunctionsTest.cpp b/Tests/UnitTests/Core/Detector/SpecialFunctionsTest.cpp index c0d293a012b89c8b7d15993a8f9ddbf4b04a4120..a3e44e81cf7da8db21e56b53afa86d35e2677f22 100644 --- a/Tests/UnitTests/Core/Detector/SpecialFunctionsTest.cpp +++ b/Tests/UnitTests/Core/Detector/SpecialFunctionsTest.cpp @@ -6,14 +6,11 @@ EXPECT_NEAR((a).real(), (b).real(), epsi); \ EXPECT_NEAR((a).imag(), (b).imag(), epsi); -class SpecialFunctionsTest : public ::testing::Test -{ -}; +class SpecialFunctionsTest : public ::testing::Test {}; // Test accuracy of complex function sinc(z) near the removable singularity at z=0 -TEST_F(SpecialFunctionsTest, csinc) -{ +TEST_F(SpecialFunctionsTest, csinc) { const double eps = 4.7e-16; // more than twice the machine precision for (int i = 0; i < 24; ++i) { diff --git a/Tests/UnitTests/Core/Detector/SpecularDetector1DTest.cpp b/Tests/UnitTests/Core/Detector/SpecularDetector1DTest.cpp index 781f1a65ec19b2ee38efa2244f6839c1cb4fafdc..b55f0773536372c1d928556bc98ce21963b474f1 100644 --- a/Tests/UnitTests/Core/Detector/SpecularDetector1DTest.cpp +++ b/Tests/UnitTests/Core/Detector/SpecularDetector1DTest.cpp @@ -6,13 +6,10 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class SpecularDetectorTest : public ::testing::Test -{ -}; +class SpecularDetectorTest : public ::testing::Test {}; // Default detector construction -TEST_F(SpecularDetectorTest, basicBehaviour) -{ +TEST_F(SpecularDetectorTest, basicBehaviour) { FixedBinAxis axis("axis0", 10, 0.0, 10.0); SpecularDetector1D detector(axis); @@ -32,8 +29,7 @@ TEST_F(SpecularDetectorTest, basicBehaviour) } // Creation of the detector map with axes in given units -TEST_F(SpecularDetectorTest, createDetectorMap) -{ +TEST_F(SpecularDetectorTest, createDetectorMap) { FixedBinAxis axis("axis0", 10, 1.0 * Units::deg, 10.0 * Units::deg); SpecularDetector1D detector(axis); @@ -44,8 +40,7 @@ TEST_F(SpecularDetectorTest, createDetectorMap) EXPECT_EQ(data->axis(0).upperBound(), 10.0 * Units::deg); } -TEST_F(SpecularDetectorTest, Clone) -{ +TEST_F(SpecularDetectorTest, Clone) { FixedBinAxis axis("axis0", 5, 1.0 * Units::deg, 10.0 * Units::deg); SpecularDetector1D detector(axis); std::unique_ptr<SpecularDetector1D> clone(detector.clone()); diff --git a/Tests/UnitTests/Core/Detector/SphericalConverterTest.cpp b/Tests/UnitTests/Core/Detector/SphericalConverterTest.cpp index fd94995ce09f8fe177601f94867fcd0896a4cc7d..f0ca02d215ad30991b33acb886be32861567dc5f 100644 --- a/Tests/UnitTests/Core/Detector/SphericalConverterTest.cpp +++ b/Tests/UnitTests/Core/Detector/SphericalConverterTest.cpp @@ -4,8 +4,7 @@ #include "Device/Detector/SphericalDetector.h" #include "Tests/GTestWrapper/google_test.h" -class SphericalConverterTest : public ::testing::Test -{ +class SphericalConverterTest : public ::testing::Test { public: SphericalConverterTest(); @@ -17,8 +16,7 @@ protected: SphericalConverterTest::SphericalConverterTest() : m_detector(100, 0.0, 5.0 * Units::deg, 70, -2.0 * Units::deg, 1.5) - , m_beam(1.0, 1.0 * Units::deg, 0.0, 1.0) -{ + , m_beam(1.0, 1.0 * Units::deg, 0.0, 1.0) { const auto k_i = m_beam.getCentralK(); m_kiz = k_i.z(); const double K = 2.0 * M_PI / m_beam.getWavelength(); @@ -27,8 +25,7 @@ SphericalConverterTest::SphericalConverterTest() m_kfz2 = K * std::sin(1.5); } -TEST_F(SphericalConverterTest, SphericalConverter) -{ +TEST_F(SphericalConverterTest, SphericalConverter) { SphericalConverter converter(m_detector, m_beam); EXPECT_EQ(converter.dimension(), 2u); @@ -79,8 +76,7 @@ TEST_F(SphericalConverterTest, SphericalConverter) EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::DEFAULT), std::runtime_error); } -TEST_F(SphericalConverterTest, SphericalConverterClone) -{ +TEST_F(SphericalConverterTest, SphericalConverterClone) { SphericalConverter converter(m_detector, m_beam); std::unique_ptr<SphericalConverter> P_clone(converter.clone()); diff --git a/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp b/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp index 38be783288edf8ce1cfc3dcca716211d1dd66d6d..16abd26e79cb2ca809f3fd89cf4d8e8d8e1814ad 100644 --- a/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp +++ b/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp @@ -10,13 +10,10 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class SphericalDetectorTest : public ::testing::Test -{ -}; +class SphericalDetectorTest : public ::testing::Test {}; // Default detector construction -TEST_F(SphericalDetectorTest, initialState) -{ +TEST_F(SphericalDetectorTest, initialState) { SphericalDetector detector; // checking size @@ -40,8 +37,7 @@ TEST_F(SphericalDetectorTest, initialState) } // Construction of the detector with axes. -TEST_F(SphericalDetectorTest, constructionWithAxes) -{ +TEST_F(SphericalDetectorTest, constructionWithAxes) { SphericalDetector detector; FixedBinAxis axis0("axis0", 10, 0.0, 10.0); FixedBinAxis axis1("axis1", 20, 0.0, 20.0); @@ -57,8 +53,7 @@ TEST_F(SphericalDetectorTest, constructionWithAxes) } // Construction of the detector via classical constructor. -TEST_F(SphericalDetectorTest, constructionWithParameters) -{ +TEST_F(SphericalDetectorTest, constructionWithParameters) { SphericalDetector detector(10, -1.0, 1.0, 20, 0.0, 2.0); EXPECT_EQ(10u, detector.axis(0).size()); EXPECT_EQ(-1.0, detector.axis(0).lowerBound()); @@ -69,8 +64,7 @@ TEST_F(SphericalDetectorTest, constructionWithParameters) } // Creation of the detector map with axes in given units -TEST_F(SphericalDetectorTest, createDetectorMap) -{ +TEST_F(SphericalDetectorTest, createDetectorMap) { SphericalDetector detector(10, -1.0 * Units::deg, 1.0 * Units::deg, 20, 0.0 * Units::deg, 2.0 * Units::deg); @@ -85,8 +79,7 @@ TEST_F(SphericalDetectorTest, createDetectorMap) } // Testing region of interest. -TEST_F(SphericalDetectorTest, regionOfInterest) -{ +TEST_F(SphericalDetectorTest, regionOfInterest) { SphericalDetector detector; detector.addAxis(FixedBinAxis("axis0", 8, -3.0, 5.0)); detector.addAxis(FixedBinAxis("axis1", 4, 0.0, 4.0)); @@ -114,8 +107,7 @@ TEST_F(SphericalDetectorTest, regionOfInterest) } // Create detector map in the presence of region of interest. -TEST_F(SphericalDetectorTest, regionOfInterestAndDetectorMap) -{ +TEST_F(SphericalDetectorTest, regionOfInterestAndDetectorMap) { SphericalDetector detector(6, -1.0 * Units::deg, 5.0 * Units::deg, 4, 0.0 * Units::deg, 4.0 * Units::deg); @@ -132,8 +124,7 @@ TEST_F(SphericalDetectorTest, regionOfInterestAndDetectorMap) EXPECT_EQ(data->axis(1).upperBound(), 3.0 * Units::deg); } -TEST_F(SphericalDetectorTest, MaskOfDetector) -{ +TEST_F(SphericalDetectorTest, MaskOfDetector) { SphericalDetector detector; detector.addAxis(FixedBinAxis("x-axis", 12, -4.0, 8.0)); detector.addAxis(FixedBinAxis("y-axis", 6, -2.0, 4.0)); @@ -180,8 +171,7 @@ TEST_F(SphericalDetectorTest, MaskOfDetector) } // Checking clone in the presence of ROI and masks. -TEST_F(SphericalDetectorTest, Clone) -{ +TEST_F(SphericalDetectorTest, Clone) { SphericalDetector detector(6, -1.0 * Units::deg, 5.0 * Units::deg, 4, 0.0 * Units::deg, 4.0 * Units::deg); detector.setRegionOfInterest(0.1 * Units::deg, 1.1 * Units::deg, 3.0 * Units::deg, @@ -220,8 +210,7 @@ TEST_F(SphericalDetectorTest, Clone) } // Test retrieval of analyzer properties -TEST_F(SphericalDetectorTest, AnalyzerProperties) -{ +TEST_F(SphericalDetectorTest, AnalyzerProperties) { SphericalDetector detector(6, -1.0 * Units::deg, 5.0 * Units::deg, 4, 0.0 * Units::deg, 4.0 * Units::deg); diff --git a/Tests/UnitTests/Core/ExportToPython/PythonFormattingTest.cpp b/Tests/UnitTests/Core/ExportToPython/PythonFormattingTest.cpp index e867165f1234e8f1bd3db8430f3b36721230333f..e62fa353bd655f840ad5bab3a3bbe349b0d34f43 100644 --- a/Tests/UnitTests/Core/ExportToPython/PythonFormattingTest.cpp +++ b/Tests/UnitTests/Core/ExportToPython/PythonFormattingTest.cpp @@ -8,19 +8,15 @@ #include "Param/Varia/PyFmtLimits.h" #include "Tests/GTestWrapper/google_test.h" -class PythonFormattingTest : public ::testing::Test -{ -}; +class PythonFormattingTest : public ::testing::Test {}; -TEST_F(PythonFormattingTest, ValueTimesUnits) -{ +TEST_F(PythonFormattingTest, ValueTimesUnits) { EXPECT_EQ("2.0*nm", pyfmt::printValue(2.0, "nm")); EXPECT_EQ("2.0*deg", pyfmt::printValue(2.0 * Units::deg, "rad")); EXPECT_EQ("2.0", pyfmt::printValue(2.0, "")); } -TEST_F(PythonFormattingTest, RealLimits) -{ +TEST_F(PythonFormattingTest, RealLimits) { EXPECT_EQ("RealLimits.lowerLimited(1.0)", pyfmt::printRealLimits(RealLimits::lowerLimited(1.0))); EXPECT_EQ("RealLimits.lowerLimited(1.0*nm)", @@ -51,8 +47,7 @@ TEST_F(PythonFormattingTest, RealLimits) EXPECT_EQ("", pyfmt::printRealLimitsArg(RealLimits::limitless())); } -TEST_F(PythonFormattingTest, printDistribution) -{ +TEST_F(PythonFormattingTest, printDistribution) { EXPECT_EQ(pyfmt2::printDistribution(DistributionGate(1.0, 2.0)), "ba.DistributionGate(1.0, 2.0)"); @@ -67,8 +62,7 @@ TEST_F(PythonFormattingTest, printDistribution) "ba.DistributionLogNormal(1.0*deg, 0.01)"); } -TEST_F(PythonFormattingTest, printParameterDistribution) -{ +TEST_F(PythonFormattingTest, printParameterDistribution) { DistributionGate gate(1.0, 2.0); ParameterDistribution dist("ParName", gate, 5, 2.0); @@ -97,8 +91,7 @@ TEST_F(PythonFormattingTest, printParameterDistribution) "distr_1, 5, 2.0, ba.RealLimits.limited(1.0*deg, 2.0*deg))"); } -TEST_F(PythonFormattingTest, printAxis) -{ +TEST_F(PythonFormattingTest, printAxis) { FixedBinAxis axis1("axis0", 10, -1.0, 2.0); EXPECT_EQ(axis1.pyString("", 0), "ba.FixedBinAxis(\"axis0\", 10, -1.0, 2.0)"); diff --git a/Tests/UnitTests/Core/Fitting/FitObjectiveTest.cpp b/Tests/UnitTests/Core/Fitting/FitObjectiveTest.cpp index ff6d8cab4046fd5ad3b65012d9e628fdd8dcd043..3697764aedad18df3b106315ca8ab6c28ab68184 100644 --- a/Tests/UnitTests/Core/Fitting/FitObjectiveTest.cpp +++ b/Tests/UnitTests/Core/Fitting/FitObjectiveTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include "Tests/UnitTests/Core/Fitting/FittingTestHelper.h" -class FitObjectiveTest : public ::testing::Test -{ -}; +class FitObjectiveTest : public ::testing::Test {}; -TEST_F(FitObjectiveTest, twoDatasets) -{ +TEST_F(FitObjectiveTest, twoDatasets) { // creating two simulation builders FittingTestHelper helper1(2, 3); simulation_builder_t builder1 = [&](const mumufit::Parameters& pars) { diff --git a/Tests/UnitTests/Core/Fitting/FitObserverTest.cpp b/Tests/UnitTests/Core/Fitting/FitObserverTest.cpp index d0ac48f855332104da6ff63589a9545ceb006060..6ee894e233652ae5c60dcfc04037a65425782682 100644 --- a/Tests/UnitTests/Core/Fitting/FitObserverTest.cpp +++ b/Tests/UnitTests/Core/Fitting/FitObserverTest.cpp @@ -1,11 +1,9 @@ #include "Core/Fitting/FitObserver.h" #include "Tests/GTestWrapper/google_test.h" -class FitObserverTest : public ::testing::Test -{ +class FitObserverTest : public ::testing::Test { public: - class TestHelper - { + class TestHelper { public: TestHelper() : m_ncalls(0), m_data(42) {} int m_ncalls; @@ -15,8 +13,7 @@ public: //! Checks that single observer is called on every iteration. -TEST_F(FitObserverTest, oneObserverOneEveryIteration) -{ +TEST_F(FitObserverTest, oneObserverOneEveryIteration) { TestHelper helper; FitObserver<TestHelper> observer; @@ -44,8 +41,7 @@ TEST_F(FitObserverTest, oneObserverOneEveryIteration) //! Checks that single observer called every 2-nd iteration. -TEST_F(FitObserverTest, oneObserverEverySecondIteration) -{ +TEST_F(FitObserverTest, oneObserverEverySecondIteration) { TestHelper helper; FitObserver<TestHelper> observer; @@ -62,8 +58,7 @@ TEST_F(FitObserverTest, oneObserverEverySecondIteration) //! Checks that two observers are called: one every 10-th iteration, another every 20-th. -TEST_F(FitObserverTest, twoObservers) -{ +TEST_F(FitObserverTest, twoObservers) { TestHelper helper; FitObserver<TestHelper> observer; diff --git a/Tests/UnitTests/Core/Fitting/FittingTestHelper.h b/Tests/UnitTests/Core/Fitting/FittingTestHelper.h index 1a032acc10be99ee02243943b398de37028a62c8..2b185053376196da12d638efc42ebeece74aa9f0 100644 --- a/Tests/UnitTests/Core/Fitting/FittingTestHelper.h +++ b/Tests/UnitTests/Core/Fitting/FittingTestHelper.h @@ -11,8 +11,7 @@ //! Helper class to simplify testing of SimDataPair and FitObjective -class FittingTestHelper -{ +class FittingTestHelper { public: FittingTestHelper(size_t nx = 5, size_t ny = 5) : m_nx(nx), m_ny(ny), m_builder_calls(0) {} @@ -25,8 +24,7 @@ public: size_t m_builder_calls; - std::unique_ptr<ISimulation> createSimulation(const mumufit::Parameters&) - { + std::unique_ptr<ISimulation> createSimulation(const mumufit::Parameters&) { MultiLayer multilayer; auto material = HomogeneousMaterial("Shell", 0.0, 0.0); multilayer.addLayer(Layer(material)); @@ -40,8 +38,7 @@ public: return std::unique_ptr<ISimulation>(result.release()); } - std::unique_ptr<OutputData<double>> createData(double value) - { + std::unique_ptr<OutputData<double>> createData(double value) { std::unique_ptr<OutputData<double>> result(new OutputData<double>); result->addAxis(FixedBinAxis("phi_f", m_nx, m_xmin, m_xmax)); result->addAxis(FixedBinAxis("alpha_f", m_ny, m_ymin, m_ymax)); diff --git a/Tests/UnitTests/Core/Fitting/ObjectiveMetricTest.cpp b/Tests/UnitTests/Core/Fitting/ObjectiveMetricTest.cpp index 8c98048954a6d1c05d8d15c9e372fe2a28604c04..85cfaab789cb9e5fea2b745ccca3fce31fe1ac52 100644 --- a/Tests/UnitTests/Core/Fitting/ObjectiveMetricTest.cpp +++ b/Tests/UnitTests/Core/Fitting/ObjectiveMetricTest.cpp @@ -3,12 +3,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <cmath> -class ObjectiveMetricTest : public ::testing::Test -{ -}; +class ObjectiveMetricTest : public ::testing::Test {}; -TEST_F(ObjectiveMetricTest, Chi2WellFormed) -{ +TEST_F(ObjectiveMetricTest, Chi2WellFormed) { std::vector<double> sim_data{1.0, 2.0, 3.0, 4.0}; std::vector<double> exp_data{2.0, 1.0, 4.0, 3.0}; std::vector<double> uncertainties{0.1, 0.1, 0.5, 0.5}; @@ -45,8 +42,7 @@ TEST_F(ObjectiveMetricTest, Chi2WellFormed) EXPECT_DOUBLE_EQ(metric.computeFromArrays({}, {}, {}), 0.0); } -TEST_F(ObjectiveMetricTest, Chi2IllFormed) -{ +TEST_F(ObjectiveMetricTest, Chi2IllFormed) { std::vector<double> sim_data{1.0, 2.0, 3.0, 4.0}; std::vector<double> exp_data{2.0, 1.0, 4.0, 3.0}; std::vector<double> uncertainties{0.1, 0.1, 0.5, 0.5}; @@ -78,8 +74,7 @@ TEST_F(ObjectiveMetricTest, Chi2IllFormed) std::numeric_limits<double>::max()); } -TEST_F(ObjectiveMetricTest, PoissionLikeWellFormed) -{ +TEST_F(ObjectiveMetricTest, PoissionLikeWellFormed) { std::vector<double> sim_data{1.0, 2.0, 4.0, 4.0}; std::vector<double> exp_data{2.0, 1.0, 5.0, 3.0}; std::vector<double> weight_factors{1.0, 1.0, 1.0, 2.0}; @@ -107,8 +102,7 @@ TEST_F(ObjectiveMetricTest, PoissionLikeWellFormed) EXPECT_DOUBLE_EQ(metric.computeFromArrays({}, {}, {}), 0.0); } -TEST_F(ObjectiveMetricTest, PoissionLikeIllFormed) -{ +TEST_F(ObjectiveMetricTest, PoissionLikeIllFormed) { std::vector<double> sim_data{1.0, 2.0, 3.0, 4.0}; std::vector<double> exp_data{2.0, 1.0, 4.0, 3.0}; std::vector<double> weight_factors{1.0, 1.0, 1.0, 2.0}; @@ -130,8 +124,7 @@ TEST_F(ObjectiveMetricTest, PoissionLikeIllFormed) EXPECT_DOUBLE_EQ(metric.computeFromArrays(sim_data, exp_data, weight_factors_1), 0.0); } -TEST_F(ObjectiveMetricTest, LogWellFormed) -{ +TEST_F(ObjectiveMetricTest, LogWellFormed) { std::vector<double> sim_data{1.0, 10.0, 1.e+2, 1.e+4}; std::vector<double> exp_data{10.0, 1.0, 1.e+3, 1.e+5}; std::vector<double> uncertainties{0.1, 0.1, 0.5, 0.5}; @@ -169,8 +162,7 @@ TEST_F(ObjectiveMetricTest, LogWellFormed) EXPECT_DOUBLE_EQ(metric.computeFromArrays({}, {}, {}), 0.0); } -TEST_F(ObjectiveMetricTest, LogIllFormed) -{ +TEST_F(ObjectiveMetricTest, LogIllFormed) { std::vector<double> sim_data{1.0, 10.0, 1.e+2, 1.e+4}; std::vector<double> exp_data{10.0, 1.0, 1.e+3, 1.e+5}; std::vector<double> uncertainties{0.1, 0.1, 0.5, 0.5}; @@ -199,8 +191,7 @@ TEST_F(ObjectiveMetricTest, LogIllFormed) std::numeric_limits<double>::max()); } -TEST_F(ObjectiveMetricTest, RelativeDifferenceWellFormed) -{ +TEST_F(ObjectiveMetricTest, RelativeDifferenceWellFormed) { std::vector<double> sim_data{1.0, 2.0, 4.0, 4.0}; std::vector<double> exp_data{2.0, 1.0, 2.0, 2.0}; std::vector<double> uncertainties{1.0, 1.0, 2.0, 1.0}; @@ -230,8 +221,7 @@ TEST_F(ObjectiveMetricTest, RelativeDifferenceWellFormed) EXPECT_DOUBLE_EQ(metric.computeFromArrays({}, {}, {}), 0.0); } -TEST_F(ObjectiveMetricTest, RelativeDifferenceIllFormed) -{ +TEST_F(ObjectiveMetricTest, RelativeDifferenceIllFormed) { std::vector<double> sim_data{1.0, 2.0, 4.0, 4.0}; std::vector<double> exp_data{2.0, 1.0, 3.0, 2.0}; std::vector<double> uncertainties{1.0, 1.0, 2.0, 1.0}; @@ -256,8 +246,7 @@ TEST_F(ObjectiveMetricTest, RelativeDifferenceIllFormed) EXPECT_DOUBLE_EQ(metric.computeFromArrays(sim_data, exp_data, weight_factors_1), 0.0); } -TEST_F(ObjectiveMetricTest, RQ4WellFormed) -{ +TEST_F(ObjectiveMetricTest, RQ4WellFormed) { std::vector<double> sim_data{1.0, 2.0, 4.0, 4.0}; std::vector<double> exp_data{2.0, 1.0, 2.0, 2.0}; std::vector<double> uncertainties{1.0, 1.0, 2.0, 1.0}; @@ -287,8 +276,7 @@ TEST_F(ObjectiveMetricTest, RQ4WellFormed) EXPECT_DOUBLE_EQ(metric.computeFromArrays({}, {}, {}), 0.0); } -TEST_F(ObjectiveMetricTest, RQ4IllFormed) -{ +TEST_F(ObjectiveMetricTest, RQ4IllFormed) { std::vector<double> sim_data{1.0, 2.0, 4.0, 4.0}; std::vector<double> exp_data{2.0, 1.0, 3.0, 2.0}; std::vector<double> uncertainties{1.0, 1.0, 2.0, 1.0}; @@ -311,8 +299,7 @@ TEST_F(ObjectiveMetricTest, RQ4IllFormed) EXPECT_DOUBLE_EQ(metric.computeFromArrays(sim_data, exp_data, weight_factors_1), 0.0); } -TEST_F(ObjectiveMetricTest, createMetric) -{ +TEST_F(ObjectiveMetricTest, createMetric) { auto result = ObjectiveMetricUtils::createMetric("Poisson-like"); EXPECT_TRUE(dynamic_cast<PoissonLikeMetric*>(result.get())); // Since norm functions lack equality comparison, check the equality of applying them diff --git a/Tests/UnitTests/Core/Fitting/SimDataPairTest.cpp b/Tests/UnitTests/Core/Fitting/SimDataPairTest.cpp index fdba4fc658ba3490253aa301e3c84fec56531b1b..31edb59eb623c451aa9ac237814a4c0ae4847455 100644 --- a/Tests/UnitTests/Core/Fitting/SimDataPairTest.cpp +++ b/Tests/UnitTests/Core/Fitting/SimDataPairTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include "Tests/UnitTests/Core/Fitting/FittingTestHelper.h" -class SimDataPairTest : public ::testing::Test -{ -}; +class SimDataPairTest : public ::testing::Test {}; -TEST_F(SimDataPairTest, standardPair) -{ +TEST_F(SimDataPairTest, standardPair) { FittingTestHelper helper; simulation_builder_t builder = [&](const mumufit::Parameters& pars) { @@ -61,8 +58,7 @@ TEST_F(SimDataPairTest, standardPair) EXPECT_DOUBLE_EQ(std::accumulate(array.begin(), array.end(), 0), expected_size * exp_value); } -TEST_F(SimDataPairTest, moveTest) -{ +TEST_F(SimDataPairTest, moveTest) { FittingTestHelper helper; simulation_builder_t builder = [&](const mumufit::Parameters& pars) { diff --git a/Tests/UnitTests/Core/Fresnel/DepthProbeSimulationTest.cpp b/Tests/UnitTests/Core/Fresnel/DepthProbeSimulationTest.cpp index 08a7dcac0e2ee7274055e46b6e8e36f515eba792..5041a197682f37244ffa56380c1fe57d62dcfe6d 100644 --- a/Tests/UnitTests/Core/Fresnel/DepthProbeSimulationTest.cpp +++ b/Tests/UnitTests/Core/Fresnel/DepthProbeSimulationTest.cpp @@ -11,8 +11,7 @@ #include "Sample/SampleBuilderEngine/ISampleBuilder.h" #include "Tests/GTestWrapper/google_test.h" -class DepthProbeSimulationTest : public ::testing::Test -{ +class DepthProbeSimulationTest : public ::testing::Test { protected: DepthProbeSimulationTest(); @@ -23,8 +22,7 @@ protected: MultiLayer multilayer; }; -DepthProbeSimulationTest::DepthProbeSimulationTest() -{ +DepthProbeSimulationTest::DepthProbeSimulationTest() { Material mat0 = HomogeneousMaterial("ambience", 0.0, 0.0); Material mat1 = HomogeneousMaterial("PartA", 5e-6, 0.0); Material mat2 = HomogeneousMaterial("substrate", 15e-6, 0.0); @@ -38,8 +36,7 @@ DepthProbeSimulationTest::DepthProbeSimulationTest() multilayer.addLayer(layer2); } -std::unique_ptr<DepthProbeSimulation> DepthProbeSimulationTest::defaultSimulation() -{ +std::unique_ptr<DepthProbeSimulation> DepthProbeSimulationTest::defaultSimulation() { std::unique_ptr<DepthProbeSimulation> result = std::make_unique<DepthProbeSimulation>(); result->setBeamParameters(1.0, 10, 0.0 * Units::deg, 2.0 * Units::deg); result->setZSpan(12, -30.0 * Units::nm, 10.0 * Units::nm); @@ -47,16 +44,14 @@ std::unique_ptr<DepthProbeSimulation> DepthProbeSimulationTest::defaultSimulatio return result; } -void DepthProbeSimulationTest::checkBeamState(const DepthProbeSimulation& sim) -{ +void DepthProbeSimulationTest::checkBeamState(const DepthProbeSimulation& sim) { const auto* inclination = sim.instrument().beam().parameter("InclinationAngle"); const auto test_limits = RealLimits::limited(-M_PI_2, M_PI_2); EXPECT_EQ(test_limits, inclination->limits()); EXPECT_EQ(0.0, inclination->value()); } -void DepthProbeSimulationTest::checkEmptySimulation(DepthProbeSimulation& sim) -{ +void DepthProbeSimulationTest::checkEmptySimulation(DepthProbeSimulation& sim) { ASSERT_THROW(sim.runSimulation(), std::runtime_error); ASSERT_THROW(sim.getAlphaAxis(), std::runtime_error); ASSERT_THROW(sim.getZAxis(), std::runtime_error); @@ -66,8 +61,7 @@ void DepthProbeSimulationTest::checkEmptySimulation(DepthProbeSimulation& sim) checkBeamState(sim); } -TEST_F(DepthProbeSimulationTest, InitialState) -{ +TEST_F(DepthProbeSimulationTest, InitialState) { std::unique_ptr<DepthProbeSimulation> sim = std::make_unique<DepthProbeSimulation>(); std::unique_ptr<DepthProbeSimulation> sim_clone(sim->clone()); checkEmptySimulation(*sim); @@ -75,8 +69,7 @@ TEST_F(DepthProbeSimulationTest, InitialState) checkEmptySimulation(*sim_clone); } -TEST_F(DepthProbeSimulationTest, CheckAxesOfDefaultSimulation) -{ +TEST_F(DepthProbeSimulationTest, CheckAxesOfDefaultSimulation) { auto sim = defaultSimulation(); const auto alpha_axis = sim->getAlphaAxis(); @@ -96,8 +89,7 @@ TEST_F(DepthProbeSimulationTest, CheckAxesOfDefaultSimulation) EXPECT_FALSE(z_axis == sim_clone->getZAxis()); } -TEST_F(DepthProbeSimulationTest, SetBeamParameters) -{ +TEST_F(DepthProbeSimulationTest, SetBeamParameters) { DepthProbeSimulation sim; const auto& beam = sim.instrument().beam(); @@ -135,8 +127,7 @@ TEST_F(DepthProbeSimulationTest, SetBeamParameters) checkBeamState(sim); } -TEST_F(DepthProbeSimulationTest, ResultAquisition) -{ +TEST_F(DepthProbeSimulationTest, ResultAquisition) { auto sim = defaultSimulation(); EXPECT_EQ(3u, sim->sample()->numberOfLayers()); @@ -167,8 +158,7 @@ TEST_F(DepthProbeSimulationTest, ResultAquisition) checkBeamState(*sim); } -TEST_F(DepthProbeSimulationTest, SimulationClone) -{ +TEST_F(DepthProbeSimulationTest, SimulationClone) { auto sim = defaultSimulation(); sim->runSimulation(); @@ -187,8 +177,7 @@ TEST_F(DepthProbeSimulationTest, SimulationClone) } } -TEST_F(DepthProbeSimulationTest, AddingBeamDistributions) -{ +TEST_F(DepthProbeSimulationTest, AddingBeamDistributions) { auto sim = defaultSimulation(); DistributionGaussian distribution(1.0, 2.0); diff --git a/Tests/UnitTests/Core/Fresnel/KzComputationTest.cpp b/Tests/UnitTests/Core/Fresnel/KzComputationTest.cpp index e56c2a33c5bff6df327ec25f8ff32448d1b787fb..6ffa36d49c611a30940f4ee20dc27afae4b12f32 100644 --- a/Tests/UnitTests/Core/Fresnel/KzComputationTest.cpp +++ b/Tests/UnitTests/Core/Fresnel/KzComputationTest.cpp @@ -8,12 +8,9 @@ #include "Sample/StandardSamples/PlainMultiLayerBySLDBuilder.h" #include "Tests/GTestWrapper/google_test.h" -class KzComputationTest : public ::testing::Test -{ -}; +class KzComputationTest : public ::testing::Test {}; -TEST_F(KzComputationTest, initial) -{ +TEST_F(KzComputationTest, initial) { const complex_t sld_0(0.0, 0.0); const complex_t sld_1(8.0241e-06, 6.0448e-8); const complex_t sld_2(4.0241e-06, 2.0448e-8); @@ -52,8 +49,7 @@ TEST_F(KzComputationTest, initial) } } -TEST_F(KzComputationTest, negativeKz) -{ +TEST_F(KzComputationTest, negativeKz) { const complex_t sld_0(0.0, 0.0); const complex_t sld_1(8.0241e-06, 6.0448e-8); const complex_t sld_2(4.0241e-06, 2.0448e-8); @@ -92,8 +88,7 @@ TEST_F(KzComputationTest, negativeKz) } } -TEST_F(KzComputationTest, absorptiveAmbience) -{ +TEST_F(KzComputationTest, absorptiveAmbience) { const complex_t sld_0(8.0241e-06, 6.0448e-5); const complex_t sld_1(8.0241e-06, 6.0448e-8); const complex_t sld_2(4.0241e-06, 2.0448e-8); @@ -128,8 +123,7 @@ TEST_F(KzComputationTest, absorptiveAmbience) } } -TEST_F(KzComputationTest, TiNiSampleWithRoughness) -{ +TEST_F(KzComputationTest, TiNiSampleWithRoughness) { PlainMultiLayerBySLDBuilder builder; std::unique_ptr<MultiLayer> sample(builder.buildSample()); diff --git a/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficientsTest.cpp b/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficientsTest.cpp index 13740f30eece28a0c6be01bf031f67cb665aab66..bcee4702fe57ffae5e474146f4f1ce71b3806bab 100644 --- a/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficientsTest.cpp +++ b/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficientsTest.cpp @@ -1,70 +1,60 @@ #include "Sample/RT/MatrixRTCoefficients.h" #include "Tests/GTestWrapper/google_test.h" -class MatrixRTCoefficientsTest : public ::testing::Test -{ +class MatrixRTCoefficientsTest : public ::testing::Test { protected: MatrixRTCoefficients mrtcDefault; }; -TEST_F(MatrixRTCoefficientsTest, T1plus) -{ +TEST_F(MatrixRTCoefficientsTest, T1plus) { Eigen::Vector2cd vector = mrtcDefault.T1plus(); EXPECT_EQ(complex_t(0.5, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficientsTest, T1min) -{ +TEST_F(MatrixRTCoefficientsTest, T1min) { Eigen::Vector2cd vector = mrtcDefault.T1min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(0.5, 0.0), vector(1)); } -TEST_F(MatrixRTCoefficientsTest, T2plus) -{ +TEST_F(MatrixRTCoefficientsTest, T2plus) { Eigen::Vector2cd vector = mrtcDefault.T2plus(); EXPECT_EQ(complex_t(0.5, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficientsTest, T2min) -{ +TEST_F(MatrixRTCoefficientsTest, T2min) { Eigen::Vector2cd vector = mrtcDefault.T2min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(0.5, 0.0), vector(1)); } -TEST_F(MatrixRTCoefficientsTest, R1plus) -{ +TEST_F(MatrixRTCoefficientsTest, R1plus) { Eigen::Vector2cd vector = mrtcDefault.R1plus(); EXPECT_EQ(complex_t(-0.5, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficientsTest, R1min) -{ +TEST_F(MatrixRTCoefficientsTest, R1min) { Eigen::Vector2cd vector = mrtcDefault.R1min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(-0.5, 0.0), vector(1)); } -TEST_F(MatrixRTCoefficientsTest, R2plus) -{ +TEST_F(MatrixRTCoefficientsTest, R2plus) { Eigen::Vector2cd vector = mrtcDefault.R2plus(); EXPECT_EQ(complex_t(-0.5, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficientsTest, R2min) -{ +TEST_F(MatrixRTCoefficientsTest, R2min) { Eigen::Vector2cd vector = mrtcDefault.R2min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(-0.5, 0.0), vector(1)); } -TEST_F(MatrixRTCoefficientsTest, getKz) -{ +TEST_F(MatrixRTCoefficientsTest, getKz) { Eigen::Vector2cd vector = mrtcDefault.getKz(); EXPECT_EQ(complex_t(0.0, 0.0), vector(0)); EXPECT_EQ(complex_t(0.0, 0.0), vector(1)); diff --git a/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficients_v2Test.cpp b/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficients_v2Test.cpp index a51fdb237d40ce97e36cca6a19a47ea94f276f3f..0fa5397e86bfe38e71e0354e79db25bd31f8ba97 100644 --- a/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficients_v2Test.cpp +++ b/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficients_v2Test.cpp @@ -1,70 +1,60 @@ #include "Sample/RT/MatrixRTCoefficients_v2.h" #include "Tests/GTestWrapper/google_test.h" -class MatrixRTCoefficients_v2Test : public ::testing::Test -{ +class MatrixRTCoefficients_v2Test : public ::testing::Test { protected: MatrixRTCoefficients_v2 mrtcDefault{-1., {0., 0.}, kvector_t{0.0, 0.0, 0.0}}; }; -TEST_F(MatrixRTCoefficients_v2Test, T1plus) -{ +TEST_F(MatrixRTCoefficients_v2Test, T1plus) { Eigen::Vector2cd vector = mrtcDefault.T1plus(); EXPECT_EQ(complex_t(0.5, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficients_v2Test, T1min) -{ +TEST_F(MatrixRTCoefficients_v2Test, T1min) { Eigen::Vector2cd vector = mrtcDefault.T1min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(0.5, 0.0), vector(1)); } -TEST_F(MatrixRTCoefficients_v2Test, T2plus) -{ +TEST_F(MatrixRTCoefficients_v2Test, T2plus) { Eigen::Vector2cd vector = mrtcDefault.T2plus(); EXPECT_EQ(complex_t(0.5, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficients_v2Test, T2min) -{ +TEST_F(MatrixRTCoefficients_v2Test, T2min) { Eigen::Vector2cd vector = mrtcDefault.T2min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(0.5, 0.0), vector(1)); } -TEST_F(MatrixRTCoefficients_v2Test, R1plus) -{ +TEST_F(MatrixRTCoefficients_v2Test, R1plus) { Eigen::Vector2cd vector = mrtcDefault.R1plus(); EXPECT_EQ(complex_t(-0.5, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficients_v2Test, R1min) -{ +TEST_F(MatrixRTCoefficients_v2Test, R1min) { Eigen::Vector2cd vector = mrtcDefault.R1min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(-0.5, 0.0), vector(1)); } -TEST_F(MatrixRTCoefficients_v2Test, R2plus) -{ +TEST_F(MatrixRTCoefficients_v2Test, R2plus) { Eigen::Vector2cd vector = mrtcDefault.R2plus(); EXPECT_EQ(complex_t(-0.5, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficients_v2Test, R2min) -{ +TEST_F(MatrixRTCoefficients_v2Test, R2min) { Eigen::Vector2cd vector = mrtcDefault.R2min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(-0.5, 0.0), vector(1)); } -TEST_F(MatrixRTCoefficients_v2Test, getKz) -{ +TEST_F(MatrixRTCoefficients_v2Test, getKz) { Eigen::Vector2cd vector = mrtcDefault.getKz(); EXPECT_EQ(complex_t(0.0, 0.0), vector(0)); EXPECT_EQ(complex_t(0.0, 0.0), vector(1)); diff --git a/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficients_v3Test.cpp b/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficients_v3Test.cpp index 2036a974fc13e88ffc64ac9c6096a76df7ba1de5..e237eb7ba99880cb71b9575364b84710308a0501 100644 --- a/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficients_v3Test.cpp +++ b/Tests/UnitTests/Core/Fresnel/MatrixRTCoefficients_v3Test.cpp @@ -1,70 +1,60 @@ #include "Sample/RT/MatrixRTCoefficients_v3.h" #include "Tests/GTestWrapper/google_test.h" -class MatrixRTCoefficients_v3Test : public ::testing::Test -{ +class MatrixRTCoefficients_v3Test : public ::testing::Test { protected: MatrixRTCoefficients_v3 mrtcDefault{-1., {0., 0.}, kvector_t{0.0, 0.0, 0.0}, 0.}; }; -TEST_F(MatrixRTCoefficients_v3Test, T1plus) -{ +TEST_F(MatrixRTCoefficients_v3Test, T1plus) { Eigen::Vector2cd vector = mrtcDefault.T1plus(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficients_v3Test, T1min) -{ +TEST_F(MatrixRTCoefficients_v3Test, T1min) { Eigen::Vector2cd vector = mrtcDefault.T1min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(1.0, 0.0), vector(1)); } -TEST_F(MatrixRTCoefficients_v3Test, T2plus) -{ +TEST_F(MatrixRTCoefficients_v3Test, T2plus) { Eigen::Vector2cd vector = mrtcDefault.T2plus(); EXPECT_EQ(complex_t(1.0, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficients_v3Test, T2min) -{ +TEST_F(MatrixRTCoefficients_v3Test, T2min) { Eigen::Vector2cd vector = mrtcDefault.T2min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficients_v3Test, R1plus) -{ +TEST_F(MatrixRTCoefficients_v3Test, R1plus) { Eigen::Vector2cd vector = mrtcDefault.R1plus(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficients_v3Test, R1min) -{ +TEST_F(MatrixRTCoefficients_v3Test, R1min) { Eigen::Vector2cd vector = mrtcDefault.R1min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(-1.0, 0.0), vector(1)); } -TEST_F(MatrixRTCoefficients_v3Test, R2plus) -{ +TEST_F(MatrixRTCoefficients_v3Test, R2plus) { Eigen::Vector2cd vector = mrtcDefault.R2plus(); EXPECT_EQ(complex_t(-1.0, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficients_v3Test, R2min) -{ +TEST_F(MatrixRTCoefficients_v3Test, R2min) { Eigen::Vector2cd vector = mrtcDefault.R2min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(0.0, vector(1)); } -TEST_F(MatrixRTCoefficients_v3Test, getKz) -{ +TEST_F(MatrixRTCoefficients_v3Test, getKz) { Eigen::Vector2cd vector = mrtcDefault.getKz(); EXPECT_EQ(complex_t(0.0, 0.0), vector(0)); EXPECT_EQ(complex_t(0.0, 0.0), vector(1)); diff --git a/Tests/UnitTests/Core/Fresnel/ScalarRTCoefficientsTest.cpp b/Tests/UnitTests/Core/Fresnel/ScalarRTCoefficientsTest.cpp index 272ad316c70fc055dcfb8effe93834e72e606e06..7bf6b4ef5e1985f11b1bcf6b67e22e5d7a3a4380 100644 --- a/Tests/UnitTests/Core/Fresnel/ScalarRTCoefficientsTest.cpp +++ b/Tests/UnitTests/Core/Fresnel/ScalarRTCoefficientsTest.cpp @@ -1,8 +1,7 @@ #include "Sample/RT/ScalarRTCoefficients.h" #include "Tests/GTestWrapper/google_test.h" -class ScalarRTCoefficientsTest : public ::testing::Test -{ +class ScalarRTCoefficientsTest : public ::testing::Test { protected: ScalarRTCoefficientsTest(); @@ -10,15 +9,13 @@ protected: ScalarRTCoefficients scrtCustom; }; -ScalarRTCoefficientsTest::ScalarRTCoefficientsTest() -{ +ScalarRTCoefficientsTest::ScalarRTCoefficientsTest() { scrtCustom.kz = complex_t(1.0, 1.0); scrtCustom.t_r(0) = complex_t(0.0, 0.5); scrtCustom.t_r(1) = complex_t(1.0, 0.5); } -TEST_F(ScalarRTCoefficientsTest, T1plus) -{ +TEST_F(ScalarRTCoefficientsTest, T1plus) { Eigen::Vector2cd vector = scrtDefault.T1plus(); EXPECT_EQ(complex_t(0.0, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); @@ -28,8 +25,7 @@ TEST_F(ScalarRTCoefficientsTest, T1plus) EXPECT_EQ(0.0, vector2(1)); } -TEST_F(ScalarRTCoefficientsTest, T1min) -{ +TEST_F(ScalarRTCoefficientsTest, T1min) { Eigen::Vector2cd vector = scrtDefault.T1min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(1.0, 0.0), vector(1)); @@ -39,8 +35,7 @@ TEST_F(ScalarRTCoefficientsTest, T1min) EXPECT_EQ(complex_t(0.0, 0.5), vector2(1)); } -TEST_F(ScalarRTCoefficientsTest, T2plus) -{ +TEST_F(ScalarRTCoefficientsTest, T2plus) { Eigen::Vector2cd vector = scrtDefault.T2plus(); EXPECT_EQ(complex_t(1.0, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); @@ -50,8 +45,7 @@ TEST_F(ScalarRTCoefficientsTest, T2plus) EXPECT_EQ(0.0, vector2(1)); } -TEST_F(ScalarRTCoefficientsTest, T2min) -{ +TEST_F(ScalarRTCoefficientsTest, T2min) { Eigen::Vector2cd vector = scrtDefault.T2min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(0.0, 0.0), vector(1)); @@ -61,8 +55,7 @@ TEST_F(ScalarRTCoefficientsTest, T2min) EXPECT_EQ(complex_t(0.0, 0.0), vector2(1)); } -TEST_F(ScalarRTCoefficientsTest, R1plus) -{ +TEST_F(ScalarRTCoefficientsTest, R1plus) { Eigen::Vector2cd vector = scrtDefault.R1plus(); EXPECT_EQ(complex_t(0.0, 0.0), vector(0)); EXPECT_EQ(0.0, vector(1)); @@ -72,8 +65,7 @@ TEST_F(ScalarRTCoefficientsTest, R1plus) EXPECT_EQ(0.0, vector2(1)); } -TEST_F(ScalarRTCoefficientsTest, R1min) -{ +TEST_F(ScalarRTCoefficientsTest, R1min) { Eigen::Vector2cd vector = scrtDefault.R1min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(0.0, 0.0), vector(1)); @@ -83,8 +75,7 @@ TEST_F(ScalarRTCoefficientsTest, R1min) EXPECT_EQ(complex_t(1.0, 0.5), vector2(1)); } -TEST_F(ScalarRTCoefficientsTest, R2plus) -{ +TEST_F(ScalarRTCoefficientsTest, R2plus) { Eigen::Vector2cd vector = scrtDefault.R2plus(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(0.0, vector(1)); @@ -94,8 +85,7 @@ TEST_F(ScalarRTCoefficientsTest, R2plus) EXPECT_EQ(0.0, vector2(1)); } -TEST_F(ScalarRTCoefficientsTest, R2min) -{ +TEST_F(ScalarRTCoefficientsTest, R2min) { Eigen::Vector2cd vector = scrtDefault.R2min(); EXPECT_EQ(0.0, vector(0)); EXPECT_EQ(complex_t(0.0, 0.0), vector(1)); @@ -105,8 +95,7 @@ TEST_F(ScalarRTCoefficientsTest, R2min) EXPECT_EQ(complex_t(0.0, 0.0), vector2(1)); } -TEST_F(ScalarRTCoefficientsTest, getKz) -{ +TEST_F(ScalarRTCoefficientsTest, getKz) { Eigen::Vector2cd vector = scrtDefault.getKz(); EXPECT_EQ(complex_t(0.0, 0.0), vector(0)); EXPECT_EQ(complex_t(0.0, 0.0), vector(1)); @@ -116,8 +105,7 @@ TEST_F(ScalarRTCoefficientsTest, getKz) EXPECT_EQ(complex_t(1.0, 1.0), vector2(1)); } -TEST_F(ScalarRTCoefficientsTest, getScalar) -{ +TEST_F(ScalarRTCoefficientsTest, getScalar) { EXPECT_EQ(complex_t(1.0, 0.0), scrtDefault.getScalarT()); EXPECT_EQ(complex_t(0.0, 0.0), scrtDefault.getScalarR()); EXPECT_EQ(complex_t(0.0, 0.0), scrtDefault.getScalarKz()); diff --git a/Tests/UnitTests/Core/Fresnel/SpecularMagneticOldTest.cpp b/Tests/UnitTests/Core/Fresnel/SpecularMagneticOldTest.cpp index ec27fdcc8bec35d7c787550861729d625b98f50a..bbcd0cd712bf2f42555d1a3f4c17cbe750a2e0e0 100644 --- a/Tests/UnitTests/Core/Fresnel/SpecularMagneticOldTest.cpp +++ b/Tests/UnitTests/Core/Fresnel/SpecularMagneticOldTest.cpp @@ -8,12 +8,9 @@ #include "Sample/Specular/SpecularScalarTanhStrategy.h" #include "Tests/GTestWrapper/google_test.h" -class SpecularMagneticOldTest : public ::testing::Test -{ -}; +class SpecularMagneticOldTest : public ::testing::Test {}; -TEST_F(SpecularMagneticOldTest, initial) -{ +TEST_F(SpecularMagneticOldTest, initial) { MultiLayer mLayer; kvector_t v; @@ -28,8 +25,7 @@ TEST_F(SpecularMagneticOldTest, initial) std::make_unique<SpecularMagneticOldStrategy>()->Execute(sample.slices(), v); } -TEST_F(SpecularMagneticOldTest, zerofield) -{ +TEST_F(SpecularMagneticOldTest, zerofield) { double eps = 1e-10; kvector_t substr_field(0.0, 0.0, 0.0); diff --git a/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp b/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp index 97f85d95698dfd0b588bffd631c7088ebe50b0a5..bff76f55318ac388cbeca38d3bfc359b64ee6715 100644 --- a/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp +++ b/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp @@ -13,8 +13,7 @@ constexpr double eps = 1e-10; -class SpecularMagneticTest : public ::testing::Test -{ +class SpecularMagneticTest : public ::testing::Test { protected: std::unique_ptr<ProcessedSample> sample_zerofield(); std::unique_ptr<ProcessedSample> sample_degenerate(); @@ -25,8 +24,7 @@ protected: template <typename Strategy> void testcase_zerofield(std::vector<double>&& angles); }; -template <> void SpecularMagneticTest::test_degenerate<SpecularMagneticNewTanhStrategy>() -{ +template <> void SpecularMagneticTest::test_degenerate<SpecularMagneticNewTanhStrategy>() { kvector_t v; Eigen::Vector2cd T1p{0.0, 0.0}; @@ -54,8 +52,7 @@ template <> void SpecularMagneticTest::test_degenerate<SpecularMagneticNewTanhSt //! Compares results with scalar case template <typename Strategy> -void SpecularMagneticTest::testZeroField(const kvector_t& k, const ProcessedSample& sample) -{ +void SpecularMagneticTest::testZeroField(const kvector_t& k, const ProcessedSample& sample) { auto coeffs_scalar = std::make_unique<SpecularScalarTanhStrategy>()->Execute( sample.slices(), KzComputation::computeKzFromRefIndices(sample.slices(), k)); auto coeffs_zerofield = std::make_unique<Strategy>()->Execute( @@ -81,21 +78,18 @@ void SpecularMagneticTest::testZeroField(const kvector_t& k, const ProcessedSamp } } -std::unique_ptr<ProcessedSample> SpecularMagneticTest::sample_degenerate() -{ +std::unique_ptr<ProcessedSample> SpecularMagneticTest::sample_degenerate() { MultiLayer mLayer; Material air = HomogeneousMaterial("Vacuum", 0, 1.0); mLayer.addLayer(Layer(air, 0 * Units::nm)); return std::make_unique<ProcessedSample>(mLayer, SimulationOptions()); } -TEST_F(SpecularMagneticTest, degenerate_new) -{ +TEST_F(SpecularMagneticTest, degenerate_new) { test_degenerate<SpecularMagneticNewTanhStrategy>(); } -std::unique_ptr<ProcessedSample> SpecularMagneticTest::sample_zerofield() -{ +std::unique_ptr<ProcessedSample> SpecularMagneticTest::sample_zerofield() { MultiLayer multi_layer_scalar; Material substr_material_scalar = HomogeneousMaterial("Substrate", 7e-6, 2e-8); Layer vacuum_layer(HomogeneousMaterial("Vacuum", 0.0, 0.0)); @@ -110,8 +104,7 @@ std::unique_ptr<ProcessedSample> SpecularMagneticTest::sample_zerofield() } template <typename Strategy> -void SpecularMagneticTest::testcase_zerofield(std::vector<double>&& angles) -{ +void SpecularMagneticTest::testcase_zerofield(std::vector<double>&& angles) { for (auto& angle : angles) { auto sample = sample_zerofield(); kvector_t k = vecOfLambdaAlphaPhi(1.0, angle * Units::deg, 0.0); @@ -119,12 +112,10 @@ void SpecularMagneticTest::testcase_zerofield(std::vector<double>&& angles) } } -TEST_F(SpecularMagneticTest, zerofield) -{ +TEST_F(SpecularMagneticTest, zerofield) { testcase_zerofield<SpecularMagneticStrategy>({-0.1, -2.0, -10.0}); } -TEST_F(SpecularMagneticTest, zerofield_new) -{ +TEST_F(SpecularMagneticTest, zerofield_new) { testcase_zerofield<SpecularMagneticNewTanhStrategy>({-0.0, -1.e-9, -1.e-5, -0.1, -2.0, -10.0}); } diff --git a/Tests/UnitTests/Core/Fresnel/SpecularScanTest.cpp b/Tests/UnitTests/Core/Fresnel/SpecularScanTest.cpp index 232db21e4e307b7a149b701d7a92f2901b07f0a2..4c35f9afbfea82b8cf6405e07a43eef74aa9f5e9 100644 --- a/Tests/UnitTests/Core/Fresnel/SpecularScanTest.cpp +++ b/Tests/UnitTests/Core/Fresnel/SpecularScanTest.cpp @@ -9,12 +9,9 @@ #include "Param/Distrib/RangedDistributions.h" #include "Tests/GTestWrapper/google_test.h" -class SpecularScanTest : public ::testing::Test -{ -}; +class SpecularScanTest : public ::testing::Test {}; -TEST_F(SpecularScanTest, AngularScanInit) -{ +TEST_F(SpecularScanTest, AngularScanInit) { auto check = [](const AngularSpecScan& scan, const IAxis& axis) { EXPECT_EQ(scan.wavelength(), 0.1); EXPECT_EQ(axis, *scan.coordinateAxis()); @@ -40,8 +37,7 @@ TEST_F(SpecularScanTest, AngularScanInit) check(scan4, fixed_axis); } -TEST_F(SpecularScanTest, AngularScanWithFootprint) -{ +TEST_F(SpecularScanTest, AngularScanWithFootprint) { AngularSpecScan scan(0.1, std::vector<double>{0.1, 0.2, 0.3}); EXPECT_EQ(scan.footprintFactor(), nullptr); @@ -60,8 +56,7 @@ TEST_F(SpecularScanTest, AngularScanWithFootprint) EXPECT_EQ(scan.footprint(0, 1), std::vector<double>{1.0}); } -TEST_F(SpecularScanTest, FootprintAndWavelengthResolution) -{ +TEST_F(SpecularScanTest, FootprintAndWavelengthResolution) { AngularSpecScan scan(0.1, std::vector<double>{0.1, 0.2, 0.3}); auto scan_res = std::unique_ptr<ScanResolution>( ScanResolution::scanRelativeResolution(RangedDistributionGate(3, 2.0), 0.1)); @@ -88,8 +83,7 @@ TEST_F(SpecularScanTest, FootprintAndWavelengthResolution) EXPECT_DOUBLE_EQ(expected_part[i], actual[i]); } -TEST_F(SpecularScanTest, FootprintAndAllResolutions) -{ +TEST_F(SpecularScanTest, FootprintAndAllResolutions) { AngularSpecScan scan(0.1, std::vector<double>{0.1, 0.2, 0.3}); auto wl_res = std::unique_ptr<ScanResolution>( ScanResolution::scanRelativeResolution(RangedDistributionGate(2, 2.0), 0.1)); @@ -123,8 +117,7 @@ TEST_F(SpecularScanTest, FootprintAndAllResolutions) EXPECT_DOUBLE_EQ(expected_part[i], actual[i]); } -TEST_F(SpecularScanTest, QScanInit) -{ +TEST_F(SpecularScanTest, QScanInit) { auto check = [](const QSpecScan& scan, const IAxis& axis) { EXPECT_EQ(axis, *scan.coordinateAxis()); EXPECT_EQ(scan.numberOfSimulationElements(), axis.size()); @@ -149,8 +142,7 @@ TEST_F(SpecularScanTest, QScanInit) check(scan4, fixed_axis); } -TEST_F(SpecularScanTest, AngularScanClone) -{ +TEST_F(SpecularScanTest, AngularScanClone) { AngularSpecScan scan(0.1, std::vector<double>{0.1, 0.2, 0.3}); std::unique_ptr<AngularSpecScan> scan_clone(scan.clone()); @@ -172,8 +164,7 @@ TEST_F(SpecularScanTest, AngularScanClone) EXPECT_NE(dynamic_cast<const FootprintGauss*>(scan_clone2->footprintFactor()), nullptr); } -TEST_F(SpecularScanTest, QScanClone) -{ +TEST_F(SpecularScanTest, QScanClone) { QSpecScan scan(std::vector<double>{0.1, 0.2, 0.3}); std::unique_ptr<QSpecScan> scan_clone(scan.clone()); @@ -182,8 +173,7 @@ TEST_F(SpecularScanTest, QScanClone) EXPECT_EQ(scan_clone->footprintFactor(), nullptr); } -TEST_F(SpecularScanTest, GenerateSimElements) -{ +TEST_F(SpecularScanTest, GenerateSimElements) { AngularSpecScan scan(0.1, std::vector<double>{0.0, 0.2, 0.3}); const Instrument instrument; std::vector<SpecularSimulationElement> sim_elements = @@ -202,8 +192,7 @@ TEST_F(SpecularScanTest, GenerateSimElements) EXPECT_TRUE(sim_elements2[i].isCalculated()); } -TEST_F(SpecularScanTest, ErrorInput) -{ +TEST_F(SpecularScanTest, ErrorInput) { EXPECT_THROW(AngularSpecScan(-0.1, std::vector<double>{0.0, 0.2, 0.3}), std::runtime_error); EXPECT_THROW(AngularSpecScan(0.1, std::vector<double>{0.1, 0.3, 0.2}), std::runtime_error); EXPECT_THROW(QSpecScan(std::vector<double>{-0.01, 0.2, 0.3}), std::runtime_error); diff --git a/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.cpp b/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.cpp index c8a154e98e1210a704255ef0e08cc19a81f0478e..2a5fb3a6d31a79b4c035b65d93b29126bb8fa626 100644 --- a/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.cpp +++ b/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.cpp @@ -15,8 +15,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <iostream> -class SpecularSimulationTest : public ::testing::Test -{ +class SpecularSimulationTest : public ::testing::Test { protected: SpecularSimulationTest(); @@ -26,8 +25,7 @@ protected: MultiLayer multilayer; }; -SpecularSimulationTest::SpecularSimulationTest() -{ +SpecularSimulationTest::SpecularSimulationTest() { Material mat0 = HomogeneousMaterial("ambience", 0.0, 0.0); Material mat1 = HomogeneousMaterial("PartA", 5e-6, 0.0); Material mat2 = HomogeneousMaterial("substrate", 15e-6, 0.0); @@ -41,8 +39,7 @@ SpecularSimulationTest::SpecularSimulationTest() multilayer.addLayer(layer2); } -TEST_F(SpecularSimulationTest, InitialState) -{ +TEST_F(SpecularSimulationTest, InitialState) { SpecularSimulation sim; ASSERT_THROW(sim.runSimulation(), std::runtime_error); ASSERT_THROW(sim.coordinateAxis(), std::runtime_error); @@ -50,8 +47,7 @@ TEST_F(SpecularSimulationTest, InitialState) ASSERT_THROW(sim.result(), std::runtime_error); } -std::unique_ptr<SpecularSimulation> SpecularSimulationTest::defaultSimulation() -{ +std::unique_ptr<SpecularSimulation> SpecularSimulationTest::defaultSimulation() { auto result = std::make_unique<SpecularSimulation>(); AngularSpecScan scan(1.0, FixedBinAxis("axis", 10, 0.0 * Units::deg, 2.0 * Units::deg)); result->setScan(scan); @@ -59,16 +55,14 @@ std::unique_ptr<SpecularSimulation> SpecularSimulationTest::defaultSimulation() return result; } -void SpecularSimulationTest::checkBeamState(const SpecularSimulation& sim) -{ +void SpecularSimulationTest::checkBeamState(const SpecularSimulation& sim) { const auto* inclination = sim.instrument().beam().parameter("InclinationAngle"); const auto test_limits = RealLimits::limited(-M_PI_2, M_PI_2); EXPECT_EQ(test_limits, inclination->limits()); EXPECT_EQ(0.0, inclination->value()); } -TEST_F(SpecularSimulationTest, CloneOfEmpty) -{ +TEST_F(SpecularSimulationTest, CloneOfEmpty) { SpecularSimulation sim; std::unique_ptr<SpecularSimulation> clone(sim.clone()); @@ -81,8 +75,7 @@ TEST_F(SpecularSimulationTest, CloneOfEmpty) checkBeamState(*clone); } -TEST_F(SpecularSimulationTest, SetAngularScan) -{ +TEST_F(SpecularSimulationTest, SetAngularScan) { SpecularSimulation sim; AngularSpecScan scan(1.0, std::vector<double>{1.0 * Units::deg, 3.0 * Units::deg}); sim.setScan(scan); @@ -128,8 +121,7 @@ TEST_F(SpecularSimulationTest, SetAngularScan) checkBeamState(sim); } -TEST_F(SpecularSimulationTest, SetQScan) -{ +TEST_F(SpecularSimulationTest, SetQScan) { SpecularSimulation sim; QSpecScan scan(std::vector<double>{1.0, 3.0}); @@ -162,8 +154,7 @@ TEST_F(SpecularSimulationTest, SetQScan) checkBeamState(sim); } -TEST_F(SpecularSimulationTest, ConstructSimulation) -{ +TEST_F(SpecularSimulationTest, ConstructSimulation) { auto sim = defaultSimulation(); EXPECT_EQ(3u, sim->sample()->numberOfLayers()); @@ -188,8 +179,7 @@ TEST_F(SpecularSimulationTest, ConstructSimulation) checkBeamState(*sim); } -TEST_F(SpecularSimulationTest, SimulationClone) -{ +TEST_F(SpecularSimulationTest, SimulationClone) { auto sim = defaultSimulation(); std::unique_ptr<SpecularSimulation> clone(sim->clone()); @@ -214,8 +204,7 @@ TEST_F(SpecularSimulationTest, SimulationClone) checkBeamState(*clone2); } -TEST_F(SpecularSimulationTest, AddingBeamDistributions) -{ +TEST_F(SpecularSimulationTest, AddingBeamDistributions) { auto sim = defaultSimulation(); DistributionGaussian distribution(1.0, 2.0); @@ -241,8 +230,7 @@ TEST_F(SpecularSimulationTest, AddingBeamDistributions) checkBeamState(*sim); } -TEST_F(SpecularSimulationTest, OutOfRangeAngles) -{ +TEST_F(SpecularSimulationTest, OutOfRangeAngles) { auto sim = defaultSimulation(); auto& beam = sim->instrument().beam(); beam.parameter("InclinationAngle")->setValue(-0.2 * Units::deg); diff --git a/Tests/UnitTests/Core/Other/BeamFootprintTest.cpp b/Tests/UnitTests/Core/Other/BeamFootprintTest.cpp index 96899d2c7dcea08f92245486cfe414424a04b791..10834f167f171a05f289dc8c06165a5d66725d27 100644 --- a/Tests/UnitTests/Core/Other/BeamFootprintTest.cpp +++ b/Tests/UnitTests/Core/Other/BeamFootprintTest.cpp @@ -7,12 +7,9 @@ #include <limits> #include <memory> -class BeamFootprintTest : public ::testing::Test -{ -}; +class BeamFootprintTest : public ::testing::Test {}; -TEST_F(BeamFootprintTest, ErroneousArguments) -{ +TEST_F(BeamFootprintTest, ErroneousArguments) { EXPECT_THROW(std::make_unique<FootprintGauss>(-1.0), std::runtime_error); EXPECT_THROW(std::make_unique<FootprintSquare>(-1.0), std::runtime_error); @@ -23,8 +20,7 @@ TEST_F(BeamFootprintTest, ErroneousArguments) EXPECT_EQ(0.0, square_ff.calculate(-90.0 * Units::deg)); } -TEST_F(BeamFootprintTest, CalcForCornerCases) -{ +TEST_F(BeamFootprintTest, CalcForCornerCases) { FootprintGauss gaussian_ff(0.0); EXPECT_EQ(1.0, gaussian_ff.calculate(0.0)); EXPECT_EQ(1.0, gaussian_ff.calculate(90.0 * Units::deg)); @@ -44,8 +40,7 @@ TEST_F(BeamFootprintTest, CalcForCornerCases) EXPECT_EQ(0.0, square_ff2.calculate(90.0 * Units::deg)); } -TEST_F(BeamFootprintTest, CalcForRegularCases) -{ +TEST_F(BeamFootprintTest, CalcForRegularCases) { FootprintGauss gaussian_ff(1.0 / std::sqrt(2.0)); EXPECT_EQ(0.0, gaussian_ff.calculate(0.0)); @@ -57,8 +52,7 @@ TEST_F(BeamFootprintTest, CalcForRegularCases) EXPECT_EQ(0.5, square_ff.calculate(90.0 * Units::deg)); } -TEST_F(BeamFootprintTest, Clone) -{ +TEST_F(BeamFootprintTest, Clone) { FootprintGauss gaussian_ff(1.0); std::unique_ptr<FootprintGauss> gaussian_clone(gaussian_ff.clone()); diff --git a/Tests/UnitTests/Core/Other/BeamTest.cpp b/Tests/UnitTests/Core/Other/BeamTest.cpp index f3e3b2e43c4ae274297650b87e62cc42925d884c..2b09a8f21bcaa1181ae85fe1b2d9035090e7b99b 100644 --- a/Tests/UnitTests/Core/Other/BeamTest.cpp +++ b/Tests/UnitTests/Core/Other/BeamTest.cpp @@ -8,12 +8,9 @@ #include <memory> -class BeamTest : public ::testing::Test -{ -}; +class BeamTest : public ::testing::Test {}; -TEST_F(BeamTest, BeamInitialState) -{ +TEST_F(BeamTest, BeamInitialState) { Beam beam = Beam::horizontalBeam(); EXPECT_DOUBLE_EQ(M_TWOPI, beam.getCentralK()[0]); EXPECT_EQ(0.0, beam.getCentralK()[1]); @@ -28,8 +25,7 @@ TEST_F(BeamTest, BeamInitialState) // EXPECT_EQ(complex_t(0.5, 0.0), beam.getPolarization()(1, 1)); } -TEST_F(BeamTest, BeamAssignment) -{ +TEST_F(BeamTest, BeamAssignment) { kvector_t polarization(0.0, 0.0, 0.2); std::unique_ptr<Beam> P_beam{new Beam(1.0, 1.0, 1.0, 2.0)}; @@ -49,8 +45,7 @@ TEST_F(BeamTest, BeamAssignment) */ } -TEST_F(BeamTest, BeamPolarization) -{ +TEST_F(BeamTest, BeamPolarization) { Beam beam = Beam::horizontalBeam(); kvector_t polarization(0.1, -0.2, 0.4); beam.setPolarization(polarization); @@ -61,8 +56,7 @@ TEST_F(BeamTest, BeamPolarization) EXPECT_NEAR(0.4, bloch_vector.z(), 1e-8); } -TEST_F(BeamTest, FootprintBehaviour) -{ +TEST_F(BeamTest, FootprintBehaviour) { Beam beam = Beam::horizontalBeam(); EXPECT_EQ(nullptr, beam.footprintFactor()); EXPECT_THROW(beam.setWidthRatio(1.0), std::runtime_error); diff --git a/Tests/UnitTests/Core/Other/ChiSquaredModuleTest.cpp b/Tests/UnitTests/Core/Other/ChiSquaredModuleTest.cpp index a72d71d796b37e6572c0fb8406f49842ebfeab6b..68b9b93b4af76eeef5c3d023cc909f515c77cfa7 100644 --- a/Tests/UnitTests/Core/Other/ChiSquaredModuleTest.cpp +++ b/Tests/UnitTests/Core/Other/ChiSquaredModuleTest.cpp @@ -5,8 +5,7 @@ // TODO revise test -class ChiSquaredModuleTest : public ::testing::Test -{ +class ChiSquaredModuleTest : public ::testing::Test { protected: ChiSquaredModule m_chi_empty; ChiSquaredModule m_chi_default; @@ -14,14 +13,12 @@ protected: OutputData<double> m_simul_data; }; -TEST_F(ChiSquaredModuleTest, InitialState) -{ +TEST_F(ChiSquaredModuleTest, InitialState) { EXPECT_TRUE(dynamic_cast<const VarianceSimFunction*>(m_chi_empty.varianceFunction())); EXPECT_EQ(nullptr, m_chi_empty.getIntensityFunction()); } -TEST_F(ChiSquaredModuleTest, CloneOfEmpty) -{ +TEST_F(ChiSquaredModuleTest, CloneOfEmpty) { ChiSquaredModule* clone_of_empty = m_chi_empty.clone(); EXPECT_TRUE(dynamic_cast<const VarianceSimFunction*>(clone_of_empty->varianceFunction())); EXPECT_EQ(nullptr, clone_of_empty->getIntensityFunction()); diff --git a/Tests/UnitTests/Core/Other/CumulativeValueTest.cpp b/Tests/UnitTests/Core/Other/CumulativeValueTest.cpp index e3b86aa6d1952a63c918663b742d19086f7955b9..c938e9ba07dee55e5f115e0a98249af78d1f8725 100644 --- a/Tests/UnitTests/Core/Other/CumulativeValueTest.cpp +++ b/Tests/UnitTests/Core/Other/CumulativeValueTest.cpp @@ -1,12 +1,9 @@ #include "Device/Data/CumulativeValue.h" #include "Tests/GTestWrapper/google_test.h" -class CumulativeValueTest : public ::testing::Test -{ -}; +class CumulativeValueTest : public ::testing::Test {}; -TEST_F(CumulativeValueTest, InitialState) -{ +TEST_F(CumulativeValueTest, InitialState) { CumulativeValue cv; EXPECT_EQ(0, cv.getNumberOfEntries()); EXPECT_EQ(0.0, cv.getContent()); @@ -14,8 +11,7 @@ TEST_F(CumulativeValueTest, InitialState) EXPECT_EQ(0.0, cv.getRMS()); } -TEST_F(CumulativeValueTest, AddValue) -{ +TEST_F(CumulativeValueTest, AddValue) { CumulativeValue cv1; cv1.add(1.0); EXPECT_EQ(1, cv1.getNumberOfEntries()); @@ -32,8 +28,7 @@ TEST_F(CumulativeValueTest, AddValue) EXPECT_EQ(0.0, cv2.getRMS()); } -TEST_F(CumulativeValueTest, AddValues) -{ +TEST_F(CumulativeValueTest, AddValues) { CumulativeValue cv1; cv1.add(1.0); cv1.add(3.0); @@ -49,8 +44,7 @@ TEST_F(CumulativeValueTest, AddValues) EXPECT_EQ(0.0, cv1.getRMS()); } -TEST_F(CumulativeValueTest, AddValuesWithWeights) -{ +TEST_F(CumulativeValueTest, AddValuesWithWeights) { CumulativeValue cv1; cv1.add(1.0, 3.0); cv1.add(3.0); @@ -67,8 +61,7 @@ TEST_F(CumulativeValueTest, AddValuesWithWeights) EXPECT_DOUBLE_EQ(1.0, cv1.getRMS()); } -TEST_F(CumulativeValueTest, Comparison) -{ +TEST_F(CumulativeValueTest, Comparison) { CumulativeValue cv1, cv2; cv1.add(1.0); cv2.add(2.0); diff --git a/Tests/UnitTests/Core/Other/FileSystemUtilsTest.cpp b/Tests/UnitTests/Core/Other/FileSystemUtilsTest.cpp index 51911792704472e06895df86610ab0c8556980b3..f7fbf332f7b31c98c1d5e9a3c9619f9d4cdd9132 100644 --- a/Tests/UnitTests/Core/Other/FileSystemUtilsTest.cpp +++ b/Tests/UnitTests/Core/Other/FileSystemUtilsTest.cpp @@ -1,40 +1,33 @@ #include "Base/Utils/FileSystemUtils.h" #include "Tests/GTestWrapper/google_test.h" -class FileSystemUtilsTest : public ::testing::Test -{ -}; +class FileSystemUtilsTest : public ::testing::Test {}; -TEST_F(FileSystemUtilsTest, extention) -{ +TEST_F(FileSystemUtilsTest, extention) { EXPECT_EQ(FileSystemUtils::extension(""), ""); EXPECT_EQ(FileSystemUtils::extension("/home/james/file.txt"), ".txt"); EXPECT_EQ(FileSystemUtils::extension("/home/james/file.txt.gz"), ".gz"); } -TEST_F(FileSystemUtilsTest, extentions) -{ +TEST_F(FileSystemUtilsTest, extentions) { EXPECT_EQ(FileSystemUtils::extensions(""), ""); EXPECT_EQ(FileSystemUtils::extensions("/home/james/file.txt"), ".txt"); EXPECT_EQ(FileSystemUtils::extensions("/home/james/file.txt.gz"), ".txt.gz"); } -TEST_F(FileSystemUtilsTest, filename) -{ +TEST_F(FileSystemUtilsTest, filename) { EXPECT_EQ(FileSystemUtils::filename(""), ""); EXPECT_EQ(FileSystemUtils::filename("/home/james/file.txt"), "file.txt"); EXPECT_EQ(FileSystemUtils::filename("/home/james/file"), "file"); } -TEST_F(FileSystemUtilsTest, stem) -{ +TEST_F(FileSystemUtilsTest, stem) { EXPECT_EQ(FileSystemUtils::stem(""), ""); EXPECT_EQ(FileSystemUtils::stem("/home/james/filename.txt"), "filename"); EXPECT_EQ(FileSystemUtils::stem("/home/james/filename.txt.gz"), "filename.txt"); } -TEST_F(FileSystemUtilsTest, stem_ext) -{ +TEST_F(FileSystemUtilsTest, stem_ext) { EXPECT_EQ(FileSystemUtils::stem_ext(""), ""); EXPECT_EQ(FileSystemUtils::stem_ext("/home/james/filename.txt"), "filename"); EXPECT_EQ(FileSystemUtils::stem_ext("/home/james/filename.txt.gz"), "filename"); diff --git a/Tests/UnitTests/Core/Other/FourierTransformTest.cpp b/Tests/UnitTests/Core/Other/FourierTransformTest.cpp index 8ed5b13f5abe52abebcfac19a247ae4a2d7d91a3..9e8c1574e20315cb98bea9aeb8633cede9734812 100644 --- a/Tests/UnitTests/Core/Other/FourierTransformTest.cpp +++ b/Tests/UnitTests/Core/Other/FourierTransformTest.cpp @@ -3,13 +3,10 @@ #include "Device/Data/OutputData.h" #include "Tests/GTestWrapper/google_test.h" -class FourierTransformTest : public ::testing::Test -{ -}; +class FourierTransformTest : public ::testing::Test {}; // Testing implementation of 1D FT with with low freuency centering -TEST_F(FourierTransformTest, fft1DTest) -{ +TEST_F(FourierTransformTest, fft1DTest) { std::vector<double> signal_odd({0, 0, 1, 0, 0, 1, 1}); // odd # input size std::vector<double> signal_even({0, 0, 1, 0, 0, 1, 1, 2}); // even # input size std::vector<double> result_odd, result_even; @@ -36,8 +33,7 @@ TEST_F(FourierTransformTest, fft1DTest) // Testing implementation of 2D FT with low freuency centering for the following: // 3x5 input of all zeros -TEST_F(FourierTransformTest, fft2DTest1) -{ +TEST_F(FourierTransformTest, fft2DTest1) { std::vector<std::vector<double>> signal({{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}); std::vector<std::vector<double>> result; std::vector<std::vector<double>> expected_result( @@ -53,8 +49,7 @@ TEST_F(FourierTransformTest, fft2DTest1) } // 4x5 input of all zeros except for 1 element -TEST_F(FourierTransformTest, fft2DTest2) -{ +TEST_F(FourierTransformTest, fft2DTest2) { std::vector<std::vector<double>> signal( {{0, 0, 0, 0, 0}, {0, 0, 2, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}); std::vector<std::vector<double>> result; @@ -71,8 +66,7 @@ TEST_F(FourierTransformTest, fft2DTest2) } // 6x6 input of all ones except for 1 element -TEST_F(FourierTransformTest, fft2DTest3) -{ +TEST_F(FourierTransformTest, fft2DTest3) { std::vector<std::vector<double>> signal({{1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, @@ -97,8 +91,7 @@ TEST_F(FourierTransformTest, fft2DTest3) } // 3x5 input with 1 row of all zeros -TEST_F(FourierTransformTest, fft2DTest4) -{ +TEST_F(FourierTransformTest, fft2DTest4) { std::vector<std::vector<double>> signal({{1, 88, 0, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 0, 0, 0}}); std::vector<std::vector<double>> result; std::vector<std::vector<double>> expected_result( @@ -116,8 +109,7 @@ TEST_F(FourierTransformTest, fft2DTest4) } // 4x4 input -TEST_F(FourierTransformTest, fft2DTest5) -{ +TEST_F(FourierTransformTest, fft2DTest5) { std::vector<std::vector<double>> signal( {{1, 0, 0, 5}, {1, 0, 0, 0}, {0, 1, 1, 1}, {0, 1, 1, 1}}); std::vector<std::vector<double>> result; @@ -137,8 +129,7 @@ TEST_F(FourierTransformTest, fft2DTest5) } // 7x7 input -TEST_F(FourierTransformTest, fft2DTest6) -{ +TEST_F(FourierTransformTest, fft2DTest6) { std::vector<std::vector<double>> signal{ {1., 0., 0., 0., 0., 0., 0.}, {1., 0., 0., 0., 0., 0., 0.}, {1., 0., 5., 0., 0., 0., 0.}, {1., 0., 0., 0., 0., 0., 0.}, {1., 0., 0., 0., 0., 5., 0.}, {1., 0., 0., 0., 0., 0., 0.}, diff --git a/Tests/UnitTests/Core/Other/GISASSimulationTest.cpp b/Tests/UnitTests/Core/Other/GISASSimulationTest.cpp index 544401b375aef90a9af97ed9238e9c8c47e305e5..2d2f58e417fb91d0eb5bddab0c5314fd1ef1d373 100644 --- a/Tests/UnitTests/Core/Other/GISASSimulationTest.cpp +++ b/Tests/UnitTests/Core/Other/GISASSimulationTest.cpp @@ -3,12 +3,9 @@ #include "Sample/SampleBuilderEngine/ISampleBuilder.h" #include "Tests/GTestWrapper/google_test.h" -class GISASSimulationTest : public ::testing::Test -{ -}; +class GISASSimulationTest : public ::testing::Test {}; -TEST_F(GISASSimulationTest, SimulationInitialState) -{ +TEST_F(GISASSimulationTest, SimulationInitialState) { GISASSimulation simulation; EXPECT_EQ(nullptr, simulation.sample()); EXPECT_EQ(0u, simulation.intensityMapSize()); @@ -16,8 +13,7 @@ TEST_F(GISASSimulationTest, SimulationInitialState) EXPECT_EQ(1u, simulation.getChildren().size()); } -TEST_F(GISASSimulationTest, SimulationConstruction) -{ +TEST_F(GISASSimulationTest, SimulationConstruction) { GISASSimulation simulation; simulation.setSample(MultiLayer()); EXPECT_NE(nullptr, simulation.sample()); @@ -32,8 +28,7 @@ TEST_F(GISASSimulationTest, SimulationConstruction) EXPECT_EQ(2u, simulation.getChildren().size()); } -TEST_F(GISASSimulationTest, SimulationClone1) -{ +TEST_F(GISASSimulationTest, SimulationClone1) { GISASSimulation simulation; auto p_clone = simulation.clone(); EXPECT_EQ(nullptr, p_clone->sample()); @@ -43,8 +38,7 @@ TEST_F(GISASSimulationTest, SimulationClone1) delete p_clone; } -TEST_F(GISASSimulationTest, SimulationClone2) -{ +TEST_F(GISASSimulationTest, SimulationClone2) { GISASSimulation simulation; simulation.setSample(MultiLayer()); simulation.setDetectorParameters(10, -2.0, 2.0, 20, 0.0, 2.0); diff --git a/Tests/UnitTests/Core/Other/InstrumentTest.cpp b/Tests/UnitTests/Core/Other/InstrumentTest.cpp index 133a23c4a8e5999dcc417f3519d550f99eff7d4e..9385e174c43041817b63a4790268c5a9d43e60b3 100644 --- a/Tests/UnitTests/Core/Other/InstrumentTest.cpp +++ b/Tests/UnitTests/Core/Other/InstrumentTest.cpp @@ -3,8 +3,7 @@ #include "Device/Data/OutputData.h" #include "Tests/GTestWrapper/google_test.h" -class InstrumentTest : public ::testing::Test -{ +class InstrumentTest : public ::testing::Test { protected: InstrumentTest(); @@ -12,19 +11,16 @@ protected: OutputData<double> m_data; }; -InstrumentTest::InstrumentTest() -{ +InstrumentTest::InstrumentTest() { m_data.addAxis("phi_f", 10, 0., 10.); m_data.addAxis("theta_f", 20, 0., 20.); } -TEST_F(InstrumentTest, InstrumentInitialState) -{ +TEST_F(InstrumentTest, InstrumentInitialState) { EXPECT_EQ(1.0, m_instrument.getBeamIntensity()); } -TEST_F(InstrumentTest, BeamManipulation) -{ +TEST_F(InstrumentTest, BeamManipulation) { double lambda(1), alpha(-1), phi(1); double k = M_TWOPI / lambda; double x = k * std::cos(alpha) * std::cos(phi); @@ -39,8 +35,7 @@ TEST_F(InstrumentTest, BeamManipulation) EXPECT_EQ(double(10), m_instrument.getBeamIntensity()); } -TEST_F(InstrumentTest, InstrumentClone) -{ +TEST_F(InstrumentTest, InstrumentClone) { Instrument clone(m_instrument); EXPECT_EQ(size_t(0), clone.getDetectorDimension()); EXPECT_EQ(1.0, clone.getBeamIntensity()); diff --git a/Tests/UnitTests/Core/Other/LayerFillLimitsTest.cpp b/Tests/UnitTests/Core/Other/LayerFillLimitsTest.cpp index 45e9fdbfdad633ac443c510716b77b2041f63c98..4ad1f644eeaf174fa36e3fad18e597503314f6d6 100644 --- a/Tests/UnitTests/Core/Other/LayerFillLimitsTest.cpp +++ b/Tests/UnitTests/Core/Other/LayerFillLimitsTest.cpp @@ -2,8 +2,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <stdexcept> -class LayerFillLimitsTest : public ::testing::Test -{ +class LayerFillLimitsTest : public ::testing::Test { protected: LayerFillLimitsTest(); @@ -11,21 +10,18 @@ protected: std::vector<double> layers_bottomz; }; -LayerFillLimitsTest::LayerFillLimitsTest() : m_fill_limits({}) -{ +LayerFillLimitsTest::LayerFillLimitsTest() : m_fill_limits({}) { std::vector<double> layers_bottomz = {0, -5, -20}; m_fill_limits = LayerFillLimits(layers_bottomz); } -TEST_F(LayerFillLimitsTest, LayerFillLimitsEmptyConstructor) -{ +TEST_F(LayerFillLimitsTest, LayerFillLimitsEmptyConstructor) { LayerFillLimits layer_limits({}); EXPECT_EQ(1u, layer_limits.layerZLimits().size()); EXPECT_EQ(layer_limits.layerZLimits()[0], ZLimits()); } -TEST_F(LayerFillLimitsTest, LayerFillLimitsConstructor) -{ +TEST_F(LayerFillLimitsTest, LayerFillLimitsConstructor) { std::vector<ZLimits> limits = m_fill_limits.layerZLimits(); EXPECT_EQ(4u, limits.size()); EXPECT_EQ(limits[0], ZLimits()); @@ -34,8 +30,7 @@ TEST_F(LayerFillLimitsTest, LayerFillLimitsConstructor) EXPECT_EQ(limits[3], ZLimits()); } -TEST_F(LayerFillLimitsTest, LayerFillLimitsWrongUpdate) -{ +TEST_F(LayerFillLimitsTest, LayerFillLimitsWrongUpdate) { EXPECT_THROW(m_fill_limits.update({1, 0}), std::runtime_error); std::vector<ZLimits> limits = m_fill_limits.layerZLimits(); EXPECT_EQ(4u, limits.size()); @@ -45,8 +40,7 @@ TEST_F(LayerFillLimitsTest, LayerFillLimitsWrongUpdate) EXPECT_EQ(limits[3], ZLimits()); } -TEST_F(LayerFillLimitsTest, LayerFillLimitsUpdate) -{ +TEST_F(LayerFillLimitsTest, LayerFillLimitsUpdate) { m_fill_limits.update({1, 1.5}); std::vector<ZLimits> limits = m_fill_limits.layerZLimits(); EXPECT_EQ(4u, limits.size()); diff --git a/Tests/UnitTests/Core/Other/MaterialTest.cpp b/Tests/UnitTests/Core/Other/MaterialTest.cpp index 79562f2f11e80269ecca5baa7254e49f0673ce6d..fd27aeb37895f576db6a6e31390e5f849d5b73e5 100644 --- a/Tests/UnitTests/Core/Other/MaterialTest.cpp +++ b/Tests/UnitTests/Core/Other/MaterialTest.cpp @@ -8,12 +8,9 @@ #include "Sample/Scattering/Rotations.h" #include "Tests/GTestWrapper/google_test.h" -class MaterialTest : public ::testing::Test -{ -}; +class MaterialTest : public ::testing::Test {}; -TEST_F(MaterialTest, MaterialConstruction) -{ +TEST_F(MaterialTest, MaterialConstruction) { complex_t material_data = complex_t(0.0, 2.0); complex_t refIndex = complex_t(1.0 - material_data.real(), material_data.imag()); kvector_t magnetism = kvector_t(3.0, 4.0, 5.0); @@ -47,8 +44,7 @@ TEST_F(MaterialTest, MaterialConstruction) EXPECT_EQ(default_magnetism, material6.magnetization()); } -TEST_F(MaterialTest, MaterialTransform) -{ +TEST_F(MaterialTest, MaterialTransform) { complex_t material_data = complex_t(1.0, 0.0); complex_t refIndex = complex_t(1.0 - material_data.real(), material_data.imag()); kvector_t magnetism = kvector_t(1.0, 0.0, 0.0); @@ -67,8 +63,7 @@ TEST_F(MaterialTest, MaterialTransform) EXPECT_EQ(transformed_mag, material4.magnetization()); } -TEST_F(MaterialTest, DefaultMaterials) -{ +TEST_F(MaterialTest, DefaultMaterials) { Material material = HomogeneousMaterial(); const double dummy_wavelength = 1.0; @@ -86,8 +81,7 @@ TEST_F(MaterialTest, DefaultMaterials) EXPECT_FALSE(material.typeID() == MaterialBySLD().typeID()); } -TEST_F(MaterialTest, ComputationTest) -{ +TEST_F(MaterialTest, ComputationTest) { // Reference data for Fe taken from // https://sld-calculator.appspot.com // http://www.ati.ac.at/~neutropt/scattering/table.html @@ -139,8 +133,7 @@ TEST_F(MaterialTest, ComputationTest) EXPECT_NEAR(subtrSLD.imag(), subtrSLDWlIndep.imag(), 1e-10); } -TEST_F(MaterialTest, AveragedMaterialTest) -{ +TEST_F(MaterialTest, AveragedMaterialTest) { kvector_t magnetization = kvector_t{1.0, 0.0, 0.0}; const Material material = HomogeneousMaterial("Material", 0.5, 0.5, magnetization); const std::vector<HomogeneousRegion> regions = {HomogeneousRegion{0.25, material}, @@ -173,8 +166,7 @@ TEST_F(MaterialTest, AveragedMaterialTest) EXPECT_TRUE(material_avr3.typeID() == MATERIAL_TYPES::MaterialBySLD); } -TEST_F(MaterialTest, TypeIdsTest) -{ +TEST_F(MaterialTest, TypeIdsTest) { Material material = MaterialBySLD("Material", 1.0, 1.0); Material material2 = HomogeneousMaterial("Material", 1.0, 1.0); EXPECT_TRUE(material.typeID() == MATERIAL_TYPES::MaterialBySLD); @@ -184,8 +176,7 @@ TEST_F(MaterialTest, TypeIdsTest) EXPECT_TRUE(material.typeID() == material3.typeID()); } -TEST_F(MaterialTest, MaterialComparison) -{ +TEST_F(MaterialTest, MaterialComparison) { Material material = MaterialBySLD("Material", 1.0, 1.0); Material material2 = HomogeneousMaterial("Material", 1.0, 1.0); EXPECT_TRUE(material == material); @@ -204,8 +195,7 @@ TEST_F(MaterialTest, MaterialComparison) EXPECT_TRUE(HomogeneousMaterial() != MaterialBySLD()); } -TEST_F(MaterialTest, MaterialCopy) -{ +TEST_F(MaterialTest, MaterialCopy) { complex_t material_data = complex_t(0.0, 2.0); complex_t refIndex = complex_t(1.0 - material_data.real(), material_data.imag()); kvector_t magnetism = kvector_t(3.0, 4.0, 5.0); @@ -217,8 +207,7 @@ TEST_F(MaterialTest, MaterialCopy) EXPECT_TRUE(material == copy); } -TEST_F(MaterialTest, MaterialMove) -{ +TEST_F(MaterialTest, MaterialMove) { complex_t material_data = complex_t(0.0, 2.0); complex_t refIndex = complex_t(1.0 - material_data.real(), material_data.imag()); kvector_t magnetism = kvector_t(3.0, 4.0, 5.0); diff --git a/Tests/UnitTests/Core/Other/OrderedMapTest.cpp b/Tests/UnitTests/Core/Other/OrderedMapTest.cpp index 09f2972acff0c25559d262937938028d698990c5..89cec6aa7283c243cd1d434093f42c7df0e333f0 100644 --- a/Tests/UnitTests/Core/Other/OrderedMapTest.cpp +++ b/Tests/UnitTests/Core/Other/OrderedMapTest.cpp @@ -1,12 +1,9 @@ #include "Core/Export/OrderedMap.h" #include "Tests/GTestWrapper/google_test.h" -class OrderedMapTest : public ::testing::Test -{ -}; +class OrderedMapTest : public ::testing::Test {}; -TEST_F(OrderedMapTest, OrderedMapInsert) -{ +TEST_F(OrderedMapTest, OrderedMapInsert) { OrderedMap<int, std::string> omap; EXPECT_EQ(size_t(0), omap.size()); @@ -31,8 +28,7 @@ TEST_F(OrderedMapTest, OrderedMapInsert) EXPECT_EQ(size_t(0), omap.size()); } -TEST_F(OrderedMapTest, OrderedMapErase) -{ +TEST_F(OrderedMapTest, OrderedMapErase) { OrderedMap<std::string, double> omap; std::vector<std::string> keys = {"ccc", "bbb", "aaa"}; @@ -76,8 +72,7 @@ TEST_F(OrderedMapTest, OrderedMapErase) EXPECT_EQ(size_t(1), omap.size()); } -TEST_F(OrderedMapTest, OrderedMapGetValue) -{ +TEST_F(OrderedMapTest, OrderedMapGetValue) { OrderedMap<const std::string*, std::string*> omap; std::unique_ptr<std::string> key1(new std::string("key1")); @@ -96,8 +91,7 @@ TEST_F(OrderedMapTest, OrderedMapGetValue) EXPECT_EQ(omap.value(key3.get()), val3.get()); } -TEST_F(OrderedMapTest, OrderedMapFind) -{ +TEST_F(OrderedMapTest, OrderedMapFind) { OrderedMap<const std::string*, std::string> omap; std::unique_ptr<std::string> n1(new std::string("named1")); @@ -122,8 +116,7 @@ TEST_F(OrderedMapTest, OrderedMapFind) EXPECT_EQ(omap.find(n4.get()), omap.end()); } -TEST_F(OrderedMapTest, OrderedMapReInsert) -{ +TEST_F(OrderedMapTest, OrderedMapReInsert) { std::unique_ptr<std::string> P_n1(new std::string("named1")); std::unique_ptr<std::string> P_n2(new std::string("named2")); std::unique_ptr<std::string> P_n3(new std::string("named3")); diff --git a/Tests/UnitTests/Core/Other/RotationTest.cpp b/Tests/UnitTests/Core/Other/RotationTest.cpp index 36e12bd137579d200f63c9bc02b817a26f4e9a55..1b05e63a344f2741e5801b3afde677cb8f99cbc8 100644 --- a/Tests/UnitTests/Core/Other/RotationTest.cpp +++ b/Tests/UnitTests/Core/Other/RotationTest.cpp @@ -4,12 +4,9 @@ #include <memory> -class RotationTest : public ::testing::Test -{ -}; +class RotationTest : public ::testing::Test {}; -TEST_F(RotationTest, XRotations) -{ +TEST_F(RotationTest, XRotations) { double angle = 1.0; RotationX rot(angle); auto rot_matrix = rot.getTransform3D(); @@ -19,8 +16,7 @@ TEST_F(RotationTest, XRotations) EXPECT_DOUBLE_EQ(p_rot_cast->getAngle(), angle); } -TEST_F(RotationTest, YRotations) -{ +TEST_F(RotationTest, YRotations) { double angle = 1.0; RotationY rot(angle); auto rot_matrix = rot.getTransform3D(); @@ -30,8 +26,7 @@ TEST_F(RotationTest, YRotations) EXPECT_DOUBLE_EQ(p_rot_cast->getAngle(), angle); } -TEST_F(RotationTest, ZRotations) -{ +TEST_F(RotationTest, ZRotations) { double angle = 1.0; RotationZ rot(angle); auto rot_matrix = rot.getTransform3D(); @@ -41,8 +36,7 @@ TEST_F(RotationTest, ZRotations) EXPECT_DOUBLE_EQ(p_rot_cast->getAngle(), angle); } -TEST_F(RotationTest, EulerRotations) -{ +TEST_F(RotationTest, EulerRotations) { double alpha = 1.0; double beta = 0.2; double gamma = -0.5; diff --git a/Tests/UnitTests/Core/Other/SampleBuilderNodeTest.cpp b/Tests/UnitTests/Core/Other/SampleBuilderNodeTest.cpp index 4e0f905692ef7d017cc6990474ac1027e193bdf7..15359219a1257ef697880840c0fdf0fc1cba2679 100644 --- a/Tests/UnitTests/Core/Other/SampleBuilderNodeTest.cpp +++ b/Tests/UnitTests/Core/Other/SampleBuilderNodeTest.cpp @@ -9,23 +9,19 @@ #define EXPECT_ASSERT_TRIGGERED(condition) EXPECT_THROW((condition), std::runtime_error) -class SampleBuilderNodeTest : public ::testing::Test -{ +class SampleBuilderNodeTest : public ::testing::Test { public: //! Returns test multilayer. - static std::unique_ptr<MultiLayer> testMultiLayer(double length) - { + static std::unique_ptr<MultiLayer> testMultiLayer(double length) { std::unique_ptr<MultiLayer> result(new MultiLayer); result->setCrossCorrLength(length); // used to check following cloning return result; } //! Test sample builder - class TestBuilder : public ISampleBuilder - { + class TestBuilder : public ISampleBuilder { public: - explicit TestBuilder(double length = 42.0) : m_length(length) - { + explicit TestBuilder(double length = 42.0) : m_length(length) { setName("TestBuilder"); registerParameter("length", &m_length); } @@ -37,8 +33,7 @@ public: //! Checks children and pool parameters. -TEST_F(SampleBuilderNodeTest, builderParameters) -{ +TEST_F(SampleBuilderNodeTest, builderParameters) { SampleBuilderNode builderNode; // initial state @@ -73,8 +68,7 @@ TEST_F(SampleBuilderNodeTest, builderParameters) //! Checks assignment operator. -TEST_F(SampleBuilderNodeTest, assignmentOperator) -{ +TEST_F(SampleBuilderNodeTest, assignmentOperator) { SampleBuilderNode builderNode; std::shared_ptr<ISampleBuilder> builder(new SampleBuilderNodeTest::TestBuilder(33.0)); builderNode.setSBN(builder); diff --git a/Tests/UnitTests/Core/Other/SampleProviderTest.cpp b/Tests/UnitTests/Core/Other/SampleProviderTest.cpp index 1761748b364bd25a6fa7ecbdf288ba2ff14bd887..45e0201e57deefcb424fc8d532a4d2338ef6e5d2 100644 --- a/Tests/UnitTests/Core/Other/SampleProviderTest.cpp +++ b/Tests/UnitTests/Core/Other/SampleProviderTest.cpp @@ -6,29 +6,24 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class SampleProviderTest : public ::testing::Test -{ +class SampleProviderTest : public ::testing::Test { public: //! Returns test multilayer. - static std::unique_ptr<MultiLayer> testMultiLayer(double length) - { + static std::unique_ptr<MultiLayer> testMultiLayer(double length) { std::unique_ptr<MultiLayer> result(new MultiLayer); result->setCrossCorrLength(length); // used to check following cloning return result; } //! Test class playing the role of SampleContainer's parent - class TestSimulation : public INode - { + class TestSimulation : public INode { public: - TestSimulation() - { + TestSimulation() { setName("TestSimulation"); registerChild(&m_provider); } - TestSimulation(const TestSimulation& other) : INode(), m_provider(other.m_provider) - { + TestSimulation(const TestSimulation& other) : INode(), m_provider(other.m_provider) { setName("TestSimulation"); registerChild(&m_provider); } @@ -42,11 +37,9 @@ public: }; //! Test sample builder - class TestBuilder : public ISampleBuilder - { + class TestBuilder : public ISampleBuilder { public: - explicit TestBuilder(double length = 42.0) : m_length(length) - { + explicit TestBuilder(double length = 42.0) : m_length(length) { setName("TestBuilder"); registerParameter("length", &m_length); } @@ -58,8 +51,7 @@ public: //! Test initial state, assignment operator. -TEST_F(SampleProviderTest, initialState) -{ +TEST_F(SampleProviderTest, initialState) { SampleProvider provider; EXPECT_EQ(provider.sample(), nullptr); EXPECT_EQ(provider.getChildren().size(), 0u); @@ -78,8 +70,7 @@ TEST_F(SampleProviderTest, initialState) //! Testing sample builder assignment. -TEST_F(SampleProviderTest, sampleBuilder) -{ +TEST_F(SampleProviderTest, sampleBuilder) { // Setting sample first SampleProvider provider; provider.setSample(*SampleProviderTest::testMultiLayer(42.0)); @@ -113,8 +104,7 @@ TEST_F(SampleProviderTest, sampleBuilder) //! Test parentship of container and sample in simulation context. -TEST_F(SampleProviderTest, sampleInSimulationContext) -{ +TEST_F(SampleProviderTest, sampleInSimulationContext) { SampleProviderTest::TestSimulation sim; SampleProvider& provider = sim.m_provider; provider.setSample(*SampleProviderTest::testMultiLayer(42.0)); @@ -147,8 +137,7 @@ TEST_F(SampleProviderTest, sampleInSimulationContext) //! Test parentship of container and builder in simulation context. -TEST_F(SampleProviderTest, builderInSimulationContext) -{ +TEST_F(SampleProviderTest, builderInSimulationContext) { SampleProviderTest::TestSimulation sim; SampleProvider& provider = sim.m_provider; diff --git a/Tests/UnitTests/Core/Other/Shape2DTest.cpp b/Tests/UnitTests/Core/Other/Shape2DTest.cpp index 991f84e50748d4d1c07d5bf27c908e5b23e0e56f..647250e4a4971657a1e38006aeaa44d31d432621 100644 --- a/Tests/UnitTests/Core/Other/Shape2DTest.cpp +++ b/Tests/UnitTests/Core/Other/Shape2DTest.cpp @@ -7,12 +7,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class Shape2DTest : public ::testing::Test -{ -}; +class Shape2DTest : public ::testing::Test {}; -TEST_F(Shape2DTest, Rectangle) -{ +TEST_F(Shape2DTest, Rectangle) { Rectangle rect(-4.0, -2.0, 4.0, 2.0); EXPECT_DOUBLE_EQ(32.0, rect.getArea()); EXPECT_TRUE(rect.contains(0.0, 0.0)); @@ -42,8 +39,7 @@ TEST_F(Shape2DTest, Rectangle) EXPECT_FALSE(clone->contains(binx2, biny2)); } -TEST_F(Shape2DTest, Ellipse) -{ +TEST_F(Shape2DTest, Ellipse) { Ellipse ellipse(10.0, 1.0, 8.0, 4.0); EXPECT_TRUE(ellipse.contains(10.0, 1.0)); EXPECT_TRUE(ellipse.contains(18.0, 1.0)); @@ -66,8 +62,7 @@ TEST_F(Shape2DTest, Ellipse) EXPECT_TRUE(clone->contains(7.0, 3.0)); } -TEST_F(Shape2DTest, Line) -{ +TEST_F(Shape2DTest, Line) { Line line(0.0, 0.0, 1.0, 0.0); EXPECT_TRUE(line.contains(0.0, 0.0)); EXPECT_TRUE(line.contains(0.5, 0.0)); @@ -83,8 +78,7 @@ TEST_F(Shape2DTest, Line) EXPECT_FALSE(clone->contains(Bin1D(0.51, 1.0), Bin1D(0.0, 0.49))); } -TEST_F(Shape2DTest, VerticalLine) -{ +TEST_F(Shape2DTest, VerticalLine) { VerticalLine line(1.0); EXPECT_TRUE(line.contains(1.0, 0.0)); EXPECT_FALSE(line.contains(1.01, 0.0)); @@ -93,8 +87,7 @@ TEST_F(Shape2DTest, VerticalLine) EXPECT_FALSE(line.contains(Bin1D(1.01, 2.0), Bin1D(0.0, 1.0))); } -TEST_F(Shape2DTest, HorizontalLine) -{ +TEST_F(Shape2DTest, HorizontalLine) { HorizontalLine line(1.0); EXPECT_TRUE(line.contains(0.0, 1.0)); EXPECT_FALSE(line.contains(0.0, 1.01)); diff --git a/Tests/UnitTests/Core/Other/SimulationResultTest.cpp b/Tests/UnitTests/Core/Other/SimulationResultTest.cpp index 6f2c3bcfd6caffff8dc88eabd3bec3dcb83ccba9..76c4a36d9defbf358a34dc8b9540f43140014eae 100644 --- a/Tests/UnitTests/Core/Other/SimulationResultTest.cpp +++ b/Tests/UnitTests/Core/Other/SimulationResultTest.cpp @@ -1,12 +1,9 @@ #include "Core/Simulation/GISASSimulation.h" #include "Tests/GTestWrapper/google_test.h" -class SimulationResultTest : public ::testing::Test -{ -}; +class SimulationResultTest : public ::testing::Test {}; -TEST_F(SimulationResultTest, initialState) -{ +TEST_F(SimulationResultTest, initialState) { SimulationResult simres; SimulationResult other; @@ -15,8 +12,7 @@ TEST_F(SimulationResultTest, initialState) EXPECT_THROW(SimulationResult another(other), std::runtime_error); } -TEST_F(SimulationResultTest, accessToEmptySimulation) -{ +TEST_F(SimulationResultTest, accessToEmptySimulation) { const int nx(5), ny(4); GISASSimulation simulation; @@ -34,8 +30,7 @@ TEST_F(SimulationResultTest, accessToEmptySimulation) EXPECT_EQ(data->totalSum(), 0.0); } -TEST_F(SimulationResultTest, accessToEmptyRoiSimulation) -{ +TEST_F(SimulationResultTest, accessToEmptyRoiSimulation) { const int nx(5), ny(4); GISASSimulation simulation; diff --git a/Tests/UnitTests/Core/Other/SpectrumTest.cpp b/Tests/UnitTests/Core/Other/SpectrumTest.cpp index 827d0316c79f0be5deee1ec7e181494c4166cbcb..61a29e150f42c0d02a775c4545a34ac0a093c25c 100644 --- a/Tests/UnitTests/Core/Other/SpectrumTest.cpp +++ b/Tests/UnitTests/Core/Other/SpectrumTest.cpp @@ -3,12 +3,9 @@ #include <iostream> #include <tspectrum.h> -class SpectrumTest : public ::testing::Test -{ -}; +class SpectrumTest : public ::testing::Test {}; -TEST_F(SpectrumTest, arrayPeaks) -{ +TEST_F(SpectrumTest, arrayPeaks) { std::vector<std::vector<double>> data = {{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, @@ -23,8 +20,7 @@ TEST_F(SpectrumTest, arrayPeaks) EXPECT_NEAR(peaks[0].second, 4.0, 0.01); // cols } -TEST_F(SpectrumTest, histogramPeaks) -{ +TEST_F(SpectrumTest, histogramPeaks) { std::vector<std::vector<double>> data = {{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, diff --git a/Tests/UnitTests/Core/Other/TRangeTest.cpp b/Tests/UnitTests/Core/Other/TRangeTest.cpp index e4d66cc996dde4236555e43fdd91c03bb3fe89ac..fed37dbf783b726915968625eb239beb2ba136b8 100644 --- a/Tests/UnitTests/Core/Other/TRangeTest.cpp +++ b/Tests/UnitTests/Core/Other/TRangeTest.cpp @@ -2,8 +2,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <algorithm> -class TRangeTest : public ::testing::Test -{ +class TRangeTest : public ::testing::Test { protected: TRangeTest(); virtual ~TRangeTest(); @@ -16,8 +15,7 @@ protected: const TSampledRange<double>* doubleSampledRange; }; -TRangeTest::TRangeTest() -{ +TRangeTest::TRangeTest() { intRange = new TRange<int>(1, 100); floatRange = new TRange<float>(101.0f, 200.0f); doubleRange = new TRange<double>(201.0, 300.0); @@ -27,8 +25,7 @@ TRangeTest::TRangeTest() doubleSampledRange = new TSampledRange<double>(6000u, 201.0, 300.0); } -TRangeTest::~TRangeTest() -{ +TRangeTest::~TRangeTest() { delete intRange; delete floatRange; delete doubleRange; @@ -37,29 +34,25 @@ TRangeTest::~TRangeTest() delete doubleSampledRange; } -TEST_F(TRangeTest, TRangeTestLowerBound) -{ +TEST_F(TRangeTest, TRangeTestLowerBound) { EXPECT_EQ(1, intRange->getLowerBound()); EXPECT_EQ(101.0f, floatRange->getLowerBound()); EXPECT_EQ(201.0, doubleRange->getLowerBound()); } -TEST_F(TRangeTest, TRangeTestUpperBound) -{ +TEST_F(TRangeTest, TRangeTestUpperBound) { EXPECT_EQ(100, intRange->getUpperBound()); EXPECT_EQ(200.0f, floatRange->getUpperBound()); EXPECT_EQ(300.0, doubleRange->getUpperBound()); } -TEST_F(TRangeTest, TRangeTestDifference) -{ +TEST_F(TRangeTest, TRangeTestDifference) { EXPECT_EQ(99, intRange->getDifference()); EXPECT_EQ(99.0f, floatRange->getDifference()); EXPECT_EQ(99.0, doubleRange->getDifference()); } -TEST_F(TRangeTest, TRangeTestInRange) -{ +TEST_F(TRangeTest, TRangeTestInRange) { EXPECT_TRUE(intRange->inRange(1)); EXPECT_TRUE(floatRange->inRange(101.0f)); EXPECT_TRUE(doubleRange->inRange(201.0)); @@ -81,8 +74,7 @@ TEST_F(TRangeTest, TRangeTestInRange) EXPECT_FALSE(doubleRange->inRange(301.0)); } -TEST_F(TRangeTest, TSampledRangeNSamples) -{ +TEST_F(TRangeTest, TSampledRangeNSamples) { EXPECT_EQ(4000u, intSampledRange->getNSamples()); EXPECT_EQ(5000u, floatSampledRange->getNSamples()); EXPECT_EQ(6000u, doubleSampledRange->getNSamples()); diff --git a/Tests/UnitTests/Core/Other/ThreadInfoTest.cpp b/Tests/UnitTests/Core/Other/ThreadInfoTest.cpp index e597751bbe1befc82a111d5d6fb8364f9900e646..8eaf5bc6704fa4508b392735ca456ec43564fd46 100644 --- a/Tests/UnitTests/Core/Other/ThreadInfoTest.cpp +++ b/Tests/UnitTests/Core/Other/ThreadInfoTest.cpp @@ -1,12 +1,9 @@ #include "Base/Utils/ThreadInfo.h" #include "Tests/GTestWrapper/google_test.h" -class ThreadInfoTest : public ::testing::Test -{ -}; +class ThreadInfoTest : public ::testing::Test {}; -TEST_F(ThreadInfoTest, DefaultValues) -{ +TEST_F(ThreadInfoTest, DefaultValues) { ThreadInfo thread_info; EXPECT_EQ(1u, thread_info.n_batches); EXPECT_EQ(0u, thread_info.current_batch); diff --git a/Tests/UnitTests/Core/Other/ZLimitsTest.cpp b/Tests/UnitTests/Core/Other/ZLimitsTest.cpp index 3ee1e72f57bdbc1ffbc4015625477bb9a4bf11a3..3b11c6df492e824589f30fb91b0b1847d5e4bd6f 100644 --- a/Tests/UnitTests/Core/Other/ZLimitsTest.cpp +++ b/Tests/UnitTests/Core/Other/ZLimitsTest.cpp @@ -2,19 +2,15 @@ #include "Tests/GTestWrapper/google_test.h" #include <stdexcept> -class ZLimitsTest : public ::testing::Test -{ -}; +class ZLimitsTest : public ::testing::Test {}; -TEST_F(ZLimitsTest, ZLimitsDefaultConstructor) -{ +TEST_F(ZLimitsTest, ZLimitsDefaultConstructor) { ZLimits limits; EXPECT_TRUE(limits.lowerLimit().m_limitless); EXPECT_TRUE(limits.upperLimit().m_limitless); } -TEST_F(ZLimitsTest, ZLimitsMinMaxConstructor) -{ +TEST_F(ZLimitsTest, ZLimitsMinMaxConstructor) { ZLimits limits{-4.0, 1.5}; EXPECT_FALSE(limits.lowerLimit().m_limitless); EXPECT_EQ(-4.0, limits.lowerLimit().m_value); @@ -28,8 +24,7 @@ TEST_F(ZLimitsTest, ZLimitsMinMaxConstructor) EXPECT_THROW(limits = ZLimits(-4.0, -5.0), std::runtime_error); } -TEST_F(ZLimitsTest, ZLimitsOneSidedLimitConstructor) -{ +TEST_F(ZLimitsTest, ZLimitsOneSidedLimitConstructor) { ZLimits limits1{{true, -4.0}, {true, 1.5}}; ZLimits limits2{{false, -4.0}, {true, 1.5}}; ZLimits limits3{{true, -4.0}, {false, 1.5}}; @@ -52,8 +47,7 @@ TEST_F(ZLimitsTest, ZLimitsOneSidedLimitConstructor) EXPECT_THROW(ZLimits limits8({false, -4.0}, {false, -5.0}), std::runtime_error); } -TEST_F(ZLimitsTest, ZLimitsIsFinite) -{ +TEST_F(ZLimitsTest, ZLimitsIsFinite) { ZLimits limitless; ZLimits poslimit({false, 0}, {true, 0}); ZLimits neglimit({true, 0}, {false, -1}); @@ -64,8 +58,7 @@ TEST_F(ZLimitsTest, ZLimitsIsFinite) EXPECT_TRUE(finite.isFinite()); } -TEST_F(ZLimitsTest, ZLimitsConvexHull) -{ +TEST_F(ZLimitsTest, ZLimitsConvexHull) { ZLimits limitless; ZLimits poslimit1({false, 0}, {true, 0}); ZLimits poslimit2({false, 4}, {true, 0}); diff --git a/Tests/UnitTests/Core/Parameters/DistributionHandlerTest.cpp b/Tests/UnitTests/Core/Parameters/DistributionHandlerTest.cpp index 77da509f59afeb85b748c41db5f75d5273c4539f..d241ad3f286cdf0d6545fc47210e7b73a7e319c4 100644 --- a/Tests/UnitTests/Core/Parameters/DistributionHandlerTest.cpp +++ b/Tests/UnitTests/Core/Parameters/DistributionHandlerTest.cpp @@ -4,15 +4,13 @@ #include "Tests/GTestWrapper/google_test.h" #include <cmath> -class DistributionHandlerTest : public ::testing::Test -{ +class DistributionHandlerTest : public ::testing::Test { protected: DistributionHandlerTest() : m_value(99.0) {} double m_value; }; -TEST_F(DistributionHandlerTest, DistributionHandlerConstructor) -{ +TEST_F(DistributionHandlerTest, DistributionHandlerConstructor) { DistributionHandler handler; DistributionGate distribution(1.0, 2.0); std::string paraName = "value"; diff --git a/Tests/UnitTests/Core/Parameters/DistributionsTest.cpp b/Tests/UnitTests/Core/Parameters/DistributionsTest.cpp index d67bf22a09ed5a55d3cdae008cb93f661a9566e4..a04db0f30dc5dce312c45fa92dbe70301c304d43 100644 --- a/Tests/UnitTests/Core/Parameters/DistributionsTest.cpp +++ b/Tests/UnitTests/Core/Parameters/DistributionsTest.cpp @@ -7,12 +7,9 @@ #include <cmath> #include <memory> -class DistributionsTest : public ::testing::Test -{ -}; +class DistributionsTest : public ::testing::Test {}; -TEST_F(DistributionsTest, DistributionGateDefaultConstructor) -{ +TEST_F(DistributionsTest, DistributionGateDefaultConstructor) { std::unique_ptr<DistributionGate> P_distr_gate{new DistributionGate()}; EXPECT_EQ(0.5, P_distr_gate->getMean()); EXPECT_EQ(0.0, P_distr_gate->lowerBound()); @@ -30,8 +27,7 @@ TEST_F(DistributionsTest, DistributionGateDefaultConstructor) EXPECT_EQ(1, list2[1]); } -TEST_F(DistributionsTest, DistributionGateConstructor) -{ +TEST_F(DistributionsTest, DistributionGateConstructor) { // Throw error when m_min > m_max: EXPECT_THROW(DistributionGate(1.1, 1.0), Exceptions::ClassInitializationException); @@ -68,8 +64,7 @@ TEST_F(DistributionsTest, DistributionGateConstructor) EXPECT_EQ(samples[2].weight, 1. / 3.); } -TEST_F(DistributionsTest, DistributionGateParameters) -{ +TEST_F(DistributionsTest, DistributionGateParameters) { DistributionGate gate(2.0, 3.0); EXPECT_EQ(gate.lowerBound(), gate.parameter("Min")->value()); EXPECT_EQ(gate.upperBound(), gate.parameter("Max")->value()); @@ -86,8 +81,7 @@ TEST_F(DistributionsTest, DistributionGateParameters) EXPECT_EQ(gate.parameter("Max")->unit(), ""); } -TEST_F(DistributionsTest, DistributionGateClone) -{ +TEST_F(DistributionsTest, DistributionGateClone) { DistributionGate gate(2.0, 3.0); DistributionGate* clone = gate.clone(); EXPECT_EQ(gate.getMean(), clone->getMean()); @@ -98,8 +92,7 @@ TEST_F(DistributionsTest, DistributionGateClone) // -------------------------------------------------------------------------- // -TEST_F(DistributionsTest, DistributionLorentzDefaultConstructor) -{ +TEST_F(DistributionsTest, DistributionLorentzDefaultConstructor) { std::unique_ptr<DistributionLorentz> P_distr_lorentz{new DistributionLorentz()}; EXPECT_EQ(0.0, P_distr_lorentz->getMean()); EXPECT_EQ(1.0, P_distr_lorentz->getHWHM()); @@ -113,8 +106,7 @@ TEST_F(DistributionsTest, DistributionLorentzDefaultConstructor) EXPECT_EQ(2, list2[1]); } -TEST_F(DistributionsTest, DistributionLorentzConstructor) -{ +TEST_F(DistributionsTest, DistributionLorentzConstructor) { // When HWHM == 0.0, only one sample is generated (the mean): DistributionLorentz distr1(1.0, 0.0); std::vector<double> list1 = distr1.equidistantPoints(5, 0.0); @@ -135,8 +127,7 @@ TEST_F(DistributionsTest, DistributionLorentzConstructor) EXPECT_EQ(3, list3[1]); } -TEST_F(DistributionsTest, DistributionLorentzParameters) -{ +TEST_F(DistributionsTest, DistributionLorentzParameters) { DistributionLorentz lorentz(2.0, 3.0); EXPECT_EQ(lorentz.getMean(), lorentz.parameter("Mean")->value()); EXPECT_EQ(lorentz.getHWHM(), lorentz.parameter("HWHM")->value()); @@ -149,16 +140,14 @@ TEST_F(DistributionsTest, DistributionLorentzParameters) EXPECT_EQ(lorentz.parameter("HWHM")->unit(), "rad"); } -TEST_F(DistributionsTest, DistributionLorentzClone) -{ +TEST_F(DistributionsTest, DistributionLorentzClone) { std::unique_ptr<DistributionLorentz> P_distr_lorentz{new DistributionLorentz(1.0, 2.0)}; std::unique_ptr<DistributionLorentz> P_clone{P_distr_lorentz->clone()}; EXPECT_EQ(1.0, P_clone->getMean()); EXPECT_EQ(2.0, P_clone->getHWHM()); } -TEST_F(DistributionsTest, DistributionLorentzSamples) -{ +TEST_F(DistributionsTest, DistributionLorentzSamples) { DistributionLorentz distr(1.0, 0.1); const int nbr_samples(3); @@ -193,8 +182,7 @@ TEST_F(DistributionsTest, DistributionLorentzSamples) // -------------------------------------------------------------------------- // -TEST_F(DistributionsTest, DistributionGaussianDefaultConstructor) -{ +TEST_F(DistributionsTest, DistributionGaussianDefaultConstructor) { std::unique_ptr<DistributionGaussian> P_distr_gauss{new DistributionGaussian()}; EXPECT_EQ(0.0, P_distr_gauss->getMean()); EXPECT_EQ(1.0, P_distr_gauss->getStdDev()); @@ -208,8 +196,7 @@ TEST_F(DistributionsTest, DistributionGaussianDefaultConstructor) EXPECT_EQ(2, list2[1]); } -TEST_F(DistributionsTest, DistributionGaussianConstructor) -{ +TEST_F(DistributionsTest, DistributionGaussianConstructor) { // When std_dev == 0.0, only one sample is generated (the mean): DistributionGaussian distr1(1.0, 0.0); std::vector<double> list1 = distr1.equidistantPoints(5, 0.0); @@ -230,8 +217,7 @@ TEST_F(DistributionsTest, DistributionGaussianConstructor) EXPECT_EQ(3, list3[1]); } -TEST_F(DistributionsTest, DistributionGaussianParameters) -{ +TEST_F(DistributionsTest, DistributionGaussianParameters) { DistributionGaussian gaussian(2.0, 3.0); EXPECT_EQ(gaussian.getMean(), gaussian.parameter("Mean")->value()); EXPECT_EQ(gaussian.getStdDev(), gaussian.parameter("StdDev")->value()); @@ -244,8 +230,7 @@ TEST_F(DistributionsTest, DistributionGaussianParameters) EXPECT_EQ(gaussian.parameter("StdDev")->unit(), "rad"); } -TEST_F(DistributionsTest, DistributionGaussianClone) -{ +TEST_F(DistributionsTest, DistributionGaussianClone) { std::unique_ptr<DistributionGaussian> P_distr_gauss{new DistributionGaussian(1.0, 1.0)}; std::unique_ptr<DistributionGaussian> P_clone{P_distr_gauss->clone()}; EXPECT_EQ(1.0, P_clone->getMean()); @@ -262,8 +247,7 @@ TEST_F(DistributionsTest, DistributionGaussianClone) // -------------------------------------------------------------------------- // -TEST_F(DistributionsTest, DistributionLogNormalConstructorWithTwoParameter) -{ +TEST_F(DistributionsTest, DistributionLogNormalConstructorWithTwoParameter) { std::unique_ptr<DistributionLogNormal> P_distr_lognormal{new DistributionLogNormal(1.0, 1.0)}; EXPECT_EQ(1.0, P_distr_lognormal->getMedian()); EXPECT_EQ(1.0, P_distr_lognormal->getScalePar()); @@ -278,8 +262,7 @@ TEST_F(DistributionsTest, DistributionLogNormalConstructorWithTwoParameter) EXPECT_EQ(std::exp(-2) + std::exp(2) - std::exp(-2), list2[1]); } -TEST_F(DistributionsTest, DistributionLogNormalParameters) -{ +TEST_F(DistributionsTest, DistributionLogNormalParameters) { DistributionLogNormal logNormal(2.0, 3.0); EXPECT_EQ(logNormal.getMedian(), logNormal.parameter("Median")->value()); EXPECT_EQ(logNormal.getScalePar(), logNormal.parameter("ScaleParameter")->value()); @@ -292,8 +275,7 @@ TEST_F(DistributionsTest, DistributionLogNormalParameters) EXPECT_EQ(logNormal.parameter("ScaleParameter")->unit(), ""); } -TEST_F(DistributionsTest, DistributionLogNormalClone) -{ +TEST_F(DistributionsTest, DistributionLogNormalClone) { std::unique_ptr<DistributionLogNormal> P_distr_lognormal{new DistributionLogNormal(1.0, 1.0)}; std::unique_ptr<DistributionLogNormal> P_clone{P_distr_lognormal->clone()}; EXPECT_EQ(1.0, P_distr_lognormal->getMedian()); @@ -311,8 +293,7 @@ TEST_F(DistributionsTest, DistributionLogNormalClone) // -------------------------------------------------------------------------- // -TEST_F(DistributionsTest, DistributionCosineDefaultConstructor) -{ +TEST_F(DistributionsTest, DistributionCosineDefaultConstructor) { std::unique_ptr<DistributionCosine> P_distr_cosine{new DistributionCosine()}; EXPECT_EQ(0.0, P_distr_cosine->getMean()); EXPECT_EQ(1.0, P_distr_cosine->getSigma()); @@ -327,8 +308,7 @@ TEST_F(DistributionsTest, DistributionCosineDefaultConstructor) EXPECT_EQ(M_PI, list2[1]); } -TEST_F(DistributionsTest, DistributionCosineConstructor) -{ +TEST_F(DistributionsTest, DistributionCosineConstructor) { // When sigma == 0.0, only one sample is generated (the mean): DistributionCosine distr1(1.0, 0.0); std::vector<double> list1 = distr1.equidistantPoints(5, 0.0); @@ -350,8 +330,7 @@ TEST_F(DistributionsTest, DistributionCosineConstructor) EXPECT_EQ(1 + M_PI, list3[1]); } -TEST_F(DistributionsTest, DistributionCosineParameters) -{ +TEST_F(DistributionsTest, DistributionCosineParameters) { DistributionCosine cosine(2.0, 3.0); EXPECT_EQ(cosine.getMean(), cosine.parameter("Mean")->value()); EXPECT_EQ(cosine.getSigma(), cosine.parameter("Sigma")->value()); @@ -364,8 +343,7 @@ TEST_F(DistributionsTest, DistributionCosineParameters) EXPECT_EQ(cosine.parameter("Sigma")->unit(), "rad"); } -TEST_F(DistributionsTest, DistributionCosineClone) -{ +TEST_F(DistributionsTest, DistributionCosineClone) { std::unique_ptr<DistributionCosine> P_distr_cosine{new DistributionCosine(1.0, 1.0)}; std::unique_ptr<DistributionCosine> P_clone{P_distr_cosine->clone()}; EXPECT_EQ(1.0, P_clone->getMean()); diff --git a/Tests/UnitTests/Core/Parameters/FTDistributionsTest.cpp b/Tests/UnitTests/Core/Parameters/FTDistributionsTest.cpp index 9bce403deaeb89e3b373a2f12da3d364e251be3e..7354116b55a26bf19f4d0b5a3e25634769131a5d 100644 --- a/Tests/UnitTests/Core/Parameters/FTDistributionsTest.cpp +++ b/Tests/UnitTests/Core/Parameters/FTDistributionsTest.cpp @@ -4,14 +4,11 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class FTDistributionsTest : public ::testing::Test -{ -}; +class FTDistributionsTest : public ::testing::Test {}; // test 1D -TEST_F(FTDistributionsTest, FTDistribution1DCauchyConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution1DCauchyConstructor) { std::unique_ptr<IFTDistribution1D> P_1d_cauchy{new FTDistribution1DCauchy(1.0)}; EXPECT_EQ(1.0, P_1d_cauchy->omega()); EXPECT_NEAR(0.961538, P_1d_cauchy->evaluate(0.2), 0.000001); @@ -20,8 +17,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DCauchyConstructor) EXPECT_EQ(7.0, P_1d_cauchy->omega()); } -TEST_F(FTDistributionsTest, FTDistribution1DCauchyClone) -{ +TEST_F(FTDistributionsTest, FTDistribution1DCauchyClone) { std::unique_ptr<IFTDistribution1D> P_1d_cauchy{new FTDistribution1DCauchy(5.0)}; std::unique_ptr<IFTDistribution1D> P_clone{P_1d_cauchy->clone()}; @@ -29,15 +25,13 @@ TEST_F(FTDistributionsTest, FTDistribution1DCauchyClone) EXPECT_NEAR(0.5, P_clone->evaluate(0.2), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution1DGaussConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution1DGaussConstructor) { std::unique_ptr<IFTDistribution1D> P_1d_gauss{new FTDistribution1DGauss(1.0)}; EXPECT_EQ(1.0, P_1d_gauss->omega()); EXPECT_NEAR(0.9801987, P_1d_gauss->evaluate(0.2), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution1DGaussClone) -{ +TEST_F(FTDistributionsTest, FTDistribution1DGaussClone) { std::unique_ptr<IFTDistribution1D> P_1d_gauss{new FTDistribution1DGauss(5.0)}; std::unique_ptr<IFTDistribution1D> P_clone{P_1d_gauss->clone()}; @@ -45,15 +39,13 @@ TEST_F(FTDistributionsTest, FTDistribution1DGaussClone) EXPECT_NEAR(0.6065307, P_clone->evaluate(0.2), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution1DGateConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution1DGateConstructor) { std::unique_ptr<IFTDistribution1D> P_1d_gate{new FTDistribution1DGate(1.0)}; EXPECT_EQ(1.0, P_1d_gate->omega()); EXPECT_NEAR(0.993347, P_1d_gate->evaluate(0.2), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution1DGateClone) -{ +TEST_F(FTDistributionsTest, FTDistribution1DGateClone) { std::unique_ptr<IFTDistribution1D> P_1d_gate{new FTDistribution1DGate(5.0)}; std::unique_ptr<IFTDistribution1D> P_clone{P_1d_gate->clone()}; @@ -61,15 +53,13 @@ TEST_F(FTDistributionsTest, FTDistribution1DGateClone) EXPECT_NEAR(0.841471, P_clone->evaluate(0.2), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution1DTriangleConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution1DTriangleConstructor) { std::unique_ptr<IFTDistribution1D> P_1d_triangle{new FTDistribution1DTriangle(1.0)}; EXPECT_EQ(1.0, P_1d_triangle->omega()); EXPECT_NEAR(0.996671, P_1d_triangle->evaluate(0.2), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution1DTriangleClone) -{ +TEST_F(FTDistributionsTest, FTDistribution1DTriangleClone) { std::unique_ptr<IFTDistribution1D> P_1d_triangle{new FTDistribution1DTriangle(5.0)}; std::unique_ptr<IFTDistribution1D> P_clone{P_1d_triangle->clone()}; @@ -77,15 +67,13 @@ TEST_F(FTDistributionsTest, FTDistribution1DTriangleClone) EXPECT_NEAR(0.919395, P_clone->evaluate(0.2), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution1DCosineConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution1DCosineConstructor) { std::unique_ptr<IFTDistribution1D> P_1d_cosine{new FTDistribution1DCosine(1.0)}; EXPECT_EQ(1.0, P_1d_cosine->omega()); EXPECT_NEAR(0.997389, P_1d_cosine->evaluate(0.2), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution1DCosineClone) -{ +TEST_F(FTDistributionsTest, FTDistribution1DCosineClone) { std::unique_ptr<IFTDistribution1D> P_1d_cosine{new FTDistribution1DCosine(5.0)}; std::unique_ptr<IFTDistribution1D> P_clone{P_1d_cosine->clone()}; @@ -93,15 +81,13 @@ TEST_F(FTDistributionsTest, FTDistribution1DCosineClone) EXPECT_NEAR(0.936342, P_clone->evaluate(0.2), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution1DVoigtConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution1DVoigtConstructor) { std::unique_ptr<IFTDistribution1D> P_1d_voigt{new FTDistribution1DVoigt(1.0, 1.7)}; EXPECT_EQ(1.0, P_1d_voigt->omega()); EXPECT_NEAR(0.993261, P_1d_voigt->evaluate(0.2), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution1DVoigtClone) -{ +TEST_F(FTDistributionsTest, FTDistribution1DVoigtClone) { std::unique_ptr<IFTDistribution1D> P_1d_voigt{new FTDistribution1DVoigt(5.0, -5.6)}; std::unique_ptr<IFTDistribution1D> P_clone{P_1d_voigt->clone()}; @@ -111,8 +97,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DVoigtClone) // test 2D -TEST_F(FTDistributionsTest, FTDistribution2DCauchyConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution2DCauchyConstructor) { std::unique_ptr<IFTDistribution2D> P_2d_cauchy{new FTDistribution2DCauchy(1.0, 2.0, 0)}; EXPECT_EQ(1.0, P_2d_cauchy->omegaX()); EXPECT_EQ(2.0, P_2d_cauchy->omegaY()); @@ -132,8 +117,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DCauchyConstructor) EXPECT_EQ(5.3, P_2d_cauchy->omegaY()); } -TEST_F(FTDistributionsTest, FTDistribution2DCauchyClone) -{ +TEST_F(FTDistributionsTest, FTDistribution2DCauchyClone) { std::unique_ptr<IFTDistribution2D> P_2d_cauchy{new FTDistribution2DCauchy(5.0, 2.3, 0)}; std::unique_ptr<IFTDistribution2D> P_clone{P_2d_cauchy->clone()}; @@ -144,8 +128,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DCauchyClone) EXPECT_NEAR(0.165121078, P_clone->evaluate(0.2, 0.5), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution2DGaussConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution2DGaussConstructor) { std::unique_ptr<IFTDistribution2D> P_2d_gauss{new FTDistribution2DGauss(1.0, 2.0, 0)}; EXPECT_EQ(1.0, P_2d_gauss->omegaX()); EXPECT_EQ(2.0, P_2d_gauss->omegaY()); @@ -154,8 +137,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DGaussConstructor) EXPECT_NEAR(0.5945205, P_2d_gauss->evaluate(0.2, 0.5), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution2DGaussClone) -{ +TEST_F(FTDistributionsTest, FTDistribution2DGaussClone) { std::unique_ptr<IFTDistribution2D> P_2d_gauss{new FTDistribution2DGauss(5.0, 2.3, 0)}; std::unique_ptr<IFTDistribution2D> P_clone{P_2d_gauss->clone()}; @@ -166,8 +148,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DGaussClone) EXPECT_NEAR(0.3130945, P_clone->evaluate(0.2, 0.5), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution2DGateConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution2DGateConstructor) { std::unique_ptr<IFTDistribution2D> P_2d_gate{new FTDistribution2DGate(1.0, 2.0, 0)}; EXPECT_EQ(1.0, P_2d_gate->omegaX()); EXPECT_EQ(2.0, P_2d_gate->omegaY()); @@ -176,8 +157,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DGateConstructor) EXPECT_NEAR(0.875513, P_2d_gate->evaluate(0.2, 0.5), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution2DGateClone) -{ +TEST_F(FTDistributionsTest, FTDistribution2DGateClone) { std::unique_ptr<IFTDistribution2D> P_2d_gate{new FTDistribution2DGate(5.0, 2.3, 0)}; std::unique_ptr<IFTDistribution2D> P_clone{P_2d_gate->clone()}; @@ -188,8 +168,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DGateClone) EXPECT_NEAR(0.736461, P_clone->evaluate(0.2, 0.5), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution2DConeConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution2DConeConstructor) { std::unique_ptr<IFTDistribution2D> P_2d_cone{new FTDistribution2DCone(1.0, 2.0, 0)}; EXPECT_EQ(1.0, P_2d_cone->omegaX()); EXPECT_EQ(2.0, P_2d_cone->omegaY()); @@ -198,8 +177,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DConeConstructor) EXPECT_NEAR(0.924374, P_2d_cone->evaluate(0.2, 0.5), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution2DConeClone) -{ +TEST_F(FTDistributionsTest, FTDistribution2DConeClone) { std::unique_ptr<IFTDistribution2D> P_2d_cone{new FTDistribution2DCone(5.0, 2.3, 0)}; std::unique_ptr<IFTDistribution2D> P_clone{P_2d_cone->clone()}; @@ -210,8 +188,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DConeClone) EXPECT_NEAR(0.837410, P_clone->evaluate(0.2, 0.5), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution2DVoigtConstructor) -{ +TEST_F(FTDistributionsTest, FTDistribution2DVoigtConstructor) { std::unique_ptr<IFTDistribution2D> P_2d_voigt{new FTDistribution2DVoigt(1.0, 2.0, 0, 3.5)}; EXPECT_EQ(1.0, P_2d_voigt->omegaX()); EXPECT_EQ(2.0, P_2d_voigt->omegaY()); @@ -220,8 +197,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DVoigtConstructor) EXPECT_NEAR(1.2228072, P_2d_voigt->evaluate(0.2, 0.5), 0.000001); } -TEST_F(FTDistributionsTest, FTDistribution2DVoigtClone) -{ +TEST_F(FTDistributionsTest, FTDistribution2DVoigtClone) { std::unique_ptr<IFTDistribution2D> P_2d_voigt{new FTDistribution2DVoigt(5.0, 2.3, 0, -5.6)}; std::unique_ptr<IFTDistribution2D> P_clone{P_2d_voigt->clone()}; diff --git a/Tests/UnitTests/Core/Parameters/IParameterizedTest.cpp b/Tests/UnitTests/Core/Parameters/IParameterizedTest.cpp index 610b9a1d319736b9dbfe9645a5e9c389eaaef87f..94c500eb4ae725d380ee2eccb93b8d42ea8307e3 100644 --- a/Tests/UnitTests/Core/Parameters/IParameterizedTest.cpp +++ b/Tests/UnitTests/Core/Parameters/IParameterizedTest.cpp @@ -2,16 +2,13 @@ #include "Tests/GTestWrapper/google_test.h" #include <stdexcept> -class IParameterizedTest : public ::testing::Test -{ +class IParameterizedTest : public ::testing::Test { protected: IParameterized m_initial_object; - class ParameterizedObject : public IParameterized - { + class ParameterizedObject : public IParameterized { public: - ParameterizedObject() : m_real_par1(0), m_real_par2(0) - { + ParameterizedObject() : m_real_par1(0), m_real_par2(0) { setName("Parameterized"); registerParameter("par1", &m_real_par1); registerParameter("par2", &m_real_par2); @@ -24,8 +21,7 @@ protected: // TODO enable tests -TEST_F(IParameterizedTest, InitialState) -{ +TEST_F(IParameterizedTest, InitialState) { /* TEMPORARILY DISABLED getParameterPool() EXPECT_EQ( size_t(0), m_initial_object.getParameterPool()->size() ); IParameterized obj2(m_initial_object); @@ -33,8 +29,7 @@ TEST_F(IParameterizedTest, InitialState) */ } -TEST_F(IParameterizedTest, DealingWithPool) -{ +TEST_F(IParameterizedTest, DealingWithPool) { /* TEMPORARILY DISABLED getParameterPool() EXPECT_EQ( size_t(2), m_parameterized.getParameterPool()->size()); IParameterizedTest::ParameterizedObject obj2 = m_parameterized; @@ -49,8 +44,7 @@ TEST_F(IParameterizedTest, DealingWithPool) */ } -TEST_F(IParameterizedTest, SetParameterValue) -{ +TEST_F(IParameterizedTest, SetParameterValue) { // m_parameterized.m_real_par1 = 1.0; // m_parameterized.m_real_par2 = 2.0; // m_parameterized.setParameterValue("par1", 3.0); diff --git a/Tests/UnitTests/Core/Parameters/ParameterDistributionTest.cpp b/Tests/UnitTests/Core/Parameters/ParameterDistributionTest.cpp index 2a2828394299a43e5d8441840c772f22b5830c54..afe6941162dab09bd0510c6ea8d6094ca9d1aed4 100644 --- a/Tests/UnitTests/Core/Parameters/ParameterDistributionTest.cpp +++ b/Tests/UnitTests/Core/Parameters/ParameterDistributionTest.cpp @@ -5,12 +5,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <cmath> -class ParameterDistributionTest : public ::testing::Test -{ -}; +class ParameterDistributionTest : public ::testing::Test {}; -TEST_F(ParameterDistributionTest, ParameterDistributionConstructor) -{ +TEST_F(ParameterDistributionTest, ParameterDistributionConstructor) { std::string name = "MainParameterName"; DistributionGate distribution(1.0, 2.0); EXPECT_THROW(ParameterDistribution(name, distribution, 1, -1.0), @@ -45,8 +42,7 @@ TEST_F(ParameterDistributionTest, ParameterDistributionConstructor) EXPECT_EQ(pardistr3.getLinkedParameterNames().size(), size_t(0)); } -TEST_F(ParameterDistributionTest, ParameterDistributionCopyConstructor) -{ +TEST_F(ParameterDistributionTest, ParameterDistributionCopyConstructor) { DistributionGate distribution(1.0, 2.0); std::string name = "MainParameterName"; ParameterDistribution pardistr(name, distribution, 5, 2.0, RealLimits::limited(1.0, 2.0)); @@ -68,8 +64,7 @@ TEST_F(ParameterDistributionTest, ParameterDistributionCopyConstructor) EXPECT_EQ(pardistr.getMaxValue(), pcopy.getMaxValue()); } -TEST_F(ParameterDistributionTest, ParameterDistributionAssignment) -{ +TEST_F(ParameterDistributionTest, ParameterDistributionAssignment) { DistributionGate distribution(1.0, 2.0); std::string name = "MainParameterName"; ParameterDistribution pardistr(name, distribution, 5, 2.0, RealLimits::limited(1.0, 2.0)); @@ -91,8 +86,7 @@ TEST_F(ParameterDistributionTest, ParameterDistributionAssignment) EXPECT_EQ(pardistr.getMaxValue(), pcopy.getMaxValue()); } -TEST_F(ParameterDistributionTest, GenerateSamples) -{ +TEST_F(ParameterDistributionTest, GenerateSamples) { const double mean(1.0); const double sigma(0.8); DistributionGaussian distribution(mean, sigma); @@ -131,8 +125,7 @@ TEST_F(ParameterDistributionTest, GenerateSamples) //! Tests if main parameter name is related to angles. -TEST_F(ParameterDistributionTest, isAngleRelated) -{ +TEST_F(ParameterDistributionTest, isAngleRelated) { EXPECT_FALSE(ParameterUtils::isAngleRelated("Some")); EXPECT_TRUE(ParameterUtils::isAngleRelated("InclinationAngle")); EXPECT_TRUE(ParameterUtils::isAngleRelated("*/Beam/InclinationAngle")); diff --git a/Tests/UnitTests/Core/Parameters/ParameterPatternTest.cpp b/Tests/UnitTests/Core/Parameters/ParameterPatternTest.cpp index 0cd4d2e35faed8e876327fbd36ef3fbd5ed54672..35c710fef4ad5c9e80a1c99ffb6252b6992ce4a8 100644 --- a/Tests/UnitTests/Core/Parameters/ParameterPatternTest.cpp +++ b/Tests/UnitTests/Core/Parameters/ParameterPatternTest.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <string> -class ParameterPatternTest : public ::testing::Test -{ -}; +class ParameterPatternTest : public ::testing::Test {}; -TEST_F(ParameterPatternTest, declarationTest) -{ +TEST_F(ParameterPatternTest, declarationTest) { ParameterPattern p1; EXPECT_EQ("", p1.toStdString()); @@ -15,8 +12,7 @@ TEST_F(ParameterPatternTest, declarationTest) EXPECT_EQ("/home", p2.toStdString()); } -TEST_F(ParameterPatternTest, beginsWithTest) -{ +TEST_F(ParameterPatternTest, beginsWithTest) { ParameterPattern p1("Downloads"); EXPECT_EQ("/Downloads", p1.toStdString()); @@ -24,8 +20,7 @@ TEST_F(ParameterPatternTest, beginsWithTest) EXPECT_EQ("Desktop", p1.toStdString()); } -TEST_F(ParameterPatternTest, addTest) -{ +TEST_F(ParameterPatternTest, addTest) { ParameterPattern p1("Desktop"); EXPECT_EQ("/Desktop", p1.toStdString()); @@ -39,8 +34,7 @@ TEST_F(ParameterPatternTest, addTest) EXPECT_EQ("user", p1.toStdString()); } -TEST_F(ParameterPatternTest, copyTest) -{ +TEST_F(ParameterPatternTest, copyTest) { ParameterPattern p1("Desktop"); p1.add("BornAgain").add("Core").add("Tests"); EXPECT_EQ("/Desktop/BornAgain/Core/Tests", p1.toStdString()); diff --git a/Tests/UnitTests/Core/Parameters/ParameterPoolTest.cpp b/Tests/UnitTests/Core/Parameters/ParameterPoolTest.cpp index 14d856997c534e07071366a077f3cd43cfc44c41..83ea71f1442d6873d6193ee8ccf53e404834fe66 100644 --- a/Tests/UnitTests/Core/Parameters/ParameterPoolTest.cpp +++ b/Tests/UnitTests/Core/Parameters/ParameterPoolTest.cpp @@ -3,19 +3,15 @@ #include "Param/Base/RealParameter.h" #include "Tests/GTestWrapper/google_test.h" -class ParameterPoolTest : public ::testing::Test -{ -}; +class ParameterPoolTest : public ::testing::Test {}; -TEST_F(ParameterPoolTest, initialState) -{ +TEST_F(ParameterPoolTest, initialState) { ParameterPool pool; EXPECT_EQ(pool.size(), 0u); EXPECT_EQ(pool.parameterNames().size(), 0u); } -TEST_F(ParameterPoolTest, addParameter) -{ +TEST_F(ParameterPoolTest, addParameter) { double par1(1.0), par2(2.0); ParameterPool pool; RealParameter* rp1 = new RealParameter("rp1", &par1); @@ -44,8 +40,7 @@ TEST_F(ParameterPoolTest, addParameter) EXPECT_EQ(pool.size(), 0u); } -TEST_F(ParameterPoolTest, matchedParameters) -{ +TEST_F(ParameterPoolTest, matchedParameters) { double par1(1.0), par2(2.0), par3(3.0); ParameterPool pool; RealParameter* rp1 = new RealParameter("par1", &par1); @@ -66,8 +61,7 @@ TEST_F(ParameterPoolTest, matchedParameters) EXPECT_THROW(pool.getUniqueMatch("*par*"), Exceptions::RuntimeErrorException); } -TEST_F(ParameterPoolTest, setValue) -{ +TEST_F(ParameterPoolTest, setValue) { double par1(1.0), par2(2.0), par3(3.0); ParameterPool pool; @@ -94,8 +88,7 @@ TEST_F(ParameterPoolTest, setValue) Exceptions::RuntimeErrorException); } -TEST_F(ParameterPoolTest, clone) -{ +TEST_F(ParameterPoolTest, clone) { double par1(1.0), par2(2.0), par3(3.0); ParameterPool* pool = new ParameterPool; pool->addParameter(new RealParameter("par1", &par1)); @@ -113,8 +106,7 @@ TEST_F(ParameterPoolTest, clone) EXPECT_EQ(double(3.0), clone->parameter("par3")->value()); } -TEST_F(ParameterPoolTest, copyToExternalPool) -{ +TEST_F(ParameterPoolTest, copyToExternalPool) { double par1(1.0), par2(2.0); ParameterPool* pool = new ParameterPool; pool->addParameter(new RealParameter("par1", &par1)); @@ -136,8 +128,7 @@ TEST_F(ParameterPoolTest, copyToExternalPool) EXPECT_EQ(externalPool.parameterNames(), names); } -TEST_F(ParameterPoolTest, removeParameter) -{ +TEST_F(ParameterPoolTest, removeParameter) { double par1(1.0), par2(2.0); ParameterPool pool; pool.addParameter(new RealParameter("par1", &par1)); diff --git a/Tests/UnitTests/Core/Parameters/RangedDistributionTest.cpp b/Tests/UnitTests/Core/Parameters/RangedDistributionTest.cpp index 5fa99ee2d39da5080fe971ab3d93133cf3cfb8e1..b176eb50da052ba0c055465e9df0cd4f13ffde0c 100644 --- a/Tests/UnitTests/Core/Parameters/RangedDistributionTest.cpp +++ b/Tests/UnitTests/Core/Parameters/RangedDistributionTest.cpp @@ -3,8 +3,7 @@ #include "Param/Varia/ParameterSample.h" #include "Tests/GTestWrapper/google_test.h" -class RangedDistributionTest : public ::testing::Test -{ +class RangedDistributionTest : public ::testing::Test { protected: void checkDefaults(const RangedDistribution& distr); @@ -17,15 +16,13 @@ protected: template <class T> void checkZeroWidth(); }; -void RangedDistributionTest::checkDefaults(const RangedDistribution& distr) -{ +void RangedDistributionTest::checkDefaults(const RangedDistribution& distr) { EXPECT_EQ(distr.nSamples(), 5u); EXPECT_EQ(distr.sigmaFactor(), 2.0); EXPECT_EQ(distr.limits(), RealLimits::limitless()); } -template <class T> void RangedDistributionTest::checkThrows() -{ +template <class T> void RangedDistributionTest::checkThrows() { EXPECT_THROW(T(0, 1.0, 0.0, 1.0), std::runtime_error); EXPECT_THROW(T(1, 1.0, 1.0, -1.0), std::runtime_error); EXPECT_THROW(T(1, 1.0, 1.0, -1.0), std::runtime_error); @@ -37,8 +34,7 @@ template <class T> void RangedDistributionTest::checkThrows() EXPECT_NO_THROW(T(2, 0.1)); } -template <class T> void RangedDistributionTest::checkStandardSampling() -{ +template <class T> void RangedDistributionTest::checkStandardSampling() { T distr(3, 1.0); const double mean = 1.0; @@ -69,8 +65,7 @@ template <class T> void RangedDistributionTest::checkStandardSampling() EXPECT_EQ(samples_2.size(), 3u); } -template <class T> void RangedDistributionTest::checkPrinting(std::string expected_name) -{ +template <class T> void RangedDistributionTest::checkPrinting(std::string expected_name) { T distr(3, 1.0); std::stringstream print_ref; print_ref << " distribution = ba." << expected_name << "(3, 1.0)"; @@ -85,8 +80,7 @@ template <class T> void RangedDistributionTest::checkPrinting(std::string expect EXPECT_EQ(print_ref2.str(), actual); } -template <class T> void RangedDistributionTest::checkZeroWidth() -{ +template <class T> void RangedDistributionTest::checkZeroWidth() { T distr(/*n_samples = */ 10, /*sigma_factor = */ 3.0); const std::vector<ParameterSample>& samples = distr.generateSamples(1.0, 0.0); EXPECT_EQ(distr.nSamples(), samples.size()); @@ -109,8 +103,7 @@ template <class T> void RangedDistributionTest::checkZeroWidth() } } -TEST_F(RangedDistributionTest, GateDistribution) -{ +TEST_F(RangedDistributionTest, GateDistribution) { checkDefaults(RangedDistributionGate()); checkThrows<RangedDistributionGate>(); checkStandardSampling<RangedDistributionGate>(); @@ -118,8 +111,7 @@ TEST_F(RangedDistributionTest, GateDistribution) checkZeroWidth<RangedDistributionGate>(); } -TEST_F(RangedDistributionTest, LorentzDistribution) -{ +TEST_F(RangedDistributionTest, LorentzDistribution) { checkDefaults(RangedDistributionLorentz()); checkThrows<RangedDistributionLorentz>(); checkStandardSampling<RangedDistributionLorentz>(); @@ -127,8 +119,7 @@ TEST_F(RangedDistributionTest, LorentzDistribution) checkZeroWidth<RangedDistributionLorentz>(); } -TEST_F(RangedDistributionTest, GaussianDistribution) -{ +TEST_F(RangedDistributionTest, GaussianDistribution) { checkDefaults(RangedDistributionGaussian()); checkThrows<RangedDistributionGaussian>(); checkStandardSampling<RangedDistributionGaussian>(); @@ -136,8 +127,7 @@ TEST_F(RangedDistributionTest, GaussianDistribution) checkZeroWidth<RangedDistributionGaussian>(); } -TEST_F(RangedDistributionTest, LogNormalDistribution) -{ +TEST_F(RangedDistributionTest, LogNormalDistribution) { checkDefaults(RangedDistributionLogNormal()); checkThrows<RangedDistributionLogNormal>(); checkStandardSampling<RangedDistributionLogNormal>(); @@ -148,8 +138,7 @@ TEST_F(RangedDistributionTest, LogNormalDistribution) EXPECT_THROW(log_norm.distribution(-1.0, 1.0), std::runtime_error); } -TEST_F(RangedDistributionTest, CosineDistribution) -{ +TEST_F(RangedDistributionTest, CosineDistribution) { checkDefaults(RangedDistributionCosine()); checkThrows<RangedDistributionCosine>(); checkStandardSampling<RangedDistributionCosine>(); diff --git a/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp b/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp index f4fcfa903ae5aa24e2a0acb2eab323b7c693aaf1..1c88fdc73c5a7b55d3505fb5dcf61b616215b7fe 100644 --- a/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp +++ b/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp @@ -4,12 +4,9 @@ #include <iostream> #include <stdexcept> -class RealParameterTest : public ::testing::Test -{ -}; +class RealParameterTest : public ::testing::Test {}; -TEST_F(RealParameterTest, simpleConstructor) -{ +TEST_F(RealParameterTest, simpleConstructor) { double value(42.0); std::unique_ptr<RealParameter> par(new RealParameter("name", &value)); EXPECT_EQ(par->value(), value); @@ -19,8 +16,7 @@ TEST_F(RealParameterTest, simpleConstructor) EXPECT_FALSE(par->isNull()); } -TEST_F(RealParameterTest, dataComparison) -{ +TEST_F(RealParameterTest, dataComparison) { double value(1.0); RealParameter par1("name1", &value); RealParameter par2("name2", &value); @@ -33,8 +29,7 @@ TEST_F(RealParameterTest, dataComparison) EXPECT_FALSE(par3.hasSameData(par1)); } -TEST_F(RealParameterTest, extendedConstructor) -{ +TEST_F(RealParameterTest, extendedConstructor) { double value(42.0); bool is_changed(false); RealParameter par( @@ -51,8 +46,7 @@ TEST_F(RealParameterTest, extendedConstructor) EXPECT_EQ(par.value(), new_value); } -TEST_F(RealParameterTest, clone) -{ +TEST_F(RealParameterTest, clone) { double value(42.0); bool is_changed(false); std::unique_ptr<RealParameter> par(new RealParameter( diff --git a/Tests/UnitTests/Core/Parameters/ScanResolutionTest.cpp b/Tests/UnitTests/Core/Parameters/ScanResolutionTest.cpp index 3921d2a18f5767af5457ae7ec964a44da6346c83..c9d169bd52589840543df5cc14186fc441bed422 100644 --- a/Tests/UnitTests/Core/Parameters/ScanResolutionTest.cpp +++ b/Tests/UnitTests/Core/Parameters/ScanResolutionTest.cpp @@ -3,15 +3,13 @@ #include "Tests/GTestWrapper/google_test.h" #include <cmath> -class ScanResolutionTest : public ::testing::Test -{ +class ScanResolutionTest : public ::testing::Test { protected: using DistrOutput = std::vector<std::vector<ParameterSample>>; void compareResults(const DistrOutput& lhs, const DistrOutput& rhs); }; -void ScanResolutionTest::compareResults(const DistrOutput& lhs, const DistrOutput& rhs) -{ +void ScanResolutionTest::compareResults(const DistrOutput& lhs, const DistrOutput& rhs) { EXPECT_EQ(lhs.size(), rhs.size()); for (size_t i = 0; i < lhs.size(); ++i) { EXPECT_EQ(lhs[i].size(), rhs[i].size()); @@ -22,8 +20,7 @@ void ScanResolutionTest::compareResults(const DistrOutput& lhs, const DistrOutpu } } -TEST_F(ScanResolutionTest, RelativeSingleValued) -{ +TEST_F(ScanResolutionTest, RelativeSingleValued) { RangedDistributionGate distr(3, 1.0); std::unique_ptr<ScanResolution> resolution(ScanResolution::scanRelativeResolution(distr, 0.1)); @@ -44,8 +41,7 @@ TEST_F(ScanResolutionTest, RelativeSingleValued) EXPECT_THROW(resolution->generateSamples(std::vector<double>()), std::runtime_error); } -TEST_F(ScanResolutionTest, AbsoluteSingleValued) -{ +TEST_F(ScanResolutionTest, AbsoluteSingleValued) { RangedDistributionGate distr(3, 1.0); std::unique_ptr<ScanResolution> resolution(ScanResolution::scanAbsoluteResolution(distr, 0.1)); @@ -66,8 +62,7 @@ TEST_F(ScanResolutionTest, AbsoluteSingleValued) EXPECT_THROW(resolution->generateSamples(std::vector<double>()), std::runtime_error); } -TEST_F(ScanResolutionTest, RelativeVectorValued) -{ +TEST_F(ScanResolutionTest, RelativeVectorValued) { RangedDistributionGate distr(3, 1.0); EXPECT_THROW(ScanResolution::scanRelativeResolution(distr, std::vector<double>()), std::runtime_error); @@ -92,8 +87,7 @@ TEST_F(ScanResolutionTest, RelativeVectorValued) EXPECT_THROW(resolution->generateSamples(std::vector<double>(10, 1.0)), std::runtime_error); } -TEST_F(ScanResolutionTest, AbsoluteVectorValued) -{ +TEST_F(ScanResolutionTest, AbsoluteVectorValued) { RangedDistributionGate distr(3, 1.0); EXPECT_THROW(ScanResolution::scanAbsoluteResolution(distr, std::vector<double>()), std::runtime_error); diff --git a/Tests/UnitTests/Core/Sample/CrystalTest.cpp b/Tests/UnitTests/Core/Sample/CrystalTest.cpp index 586ff6db1cd96f31d1171f652cef4147b70c894f..9bde040131bb877553587efe4c6aca48fdc1cb9d 100644 --- a/Tests/UnitTests/Core/Sample/CrystalTest.cpp +++ b/Tests/UnitTests/Core/Sample/CrystalTest.cpp @@ -3,12 +3,9 @@ #include "Sample/Particle/ParticleComposition.h" #include "Tests/GTestWrapper/google_test.h" -class CrystalTest : public ::testing::Test -{ -}; +class CrystalTest : public ::testing::Test {}; -TEST_F(CrystalTest, getChildren) -{ +TEST_F(CrystalTest, getChildren) { Lattice3D lattice = bake::HexagonalLattice(1.0, 2.0); ParticleComposition composition; Crystal crystal(composition, lattice); diff --git a/Tests/UnitTests/Core/Sample/FormFactorBasicTest.cpp b/Tests/UnitTests/Core/Sample/FormFactorBasicTest.cpp index 45e3dbc608bd2d76cc388d331f68435fb39b7211..403f507cb7e875f894221d468fdfb92f704784dc 100644 --- a/Tests/UnitTests/Core/Sample/FormFactorBasicTest.cpp +++ b/Tests/UnitTests/Core/Sample/FormFactorBasicTest.cpp @@ -4,11 +4,9 @@ #include "Sample/Scattering/Rotations.h" #include "Tests/GTestWrapper/google_test.h" -class FormFactorBasicTest : public ::testing::Test -{ +class FormFactorBasicTest : public ::testing::Test { protected: - void test_eps_q(const IBornFF* p, cvector_t qdir, double eps) - { + void test_eps_q(const IBornFF* p, cvector_t qdir, double eps) { cvector_t q = eps * qdir; complex_t ff = p->evaluate_for_q(q); // std::cout<<"q="<<q<<" -> "<<std::setprecision(16)<<" ff0="<<V<<", ff ="<<ff<<"\n"; @@ -19,16 +17,14 @@ protected: EXPECT_GT(real(ff), V * (1 - std::max(3e-16, 2 * eps * R * eps * R))); EXPECT_LT(std::abs(imag(ff)), 2 * eps * V * R); } - void test_small_q(const IBornFF* p, complex_t x, complex_t y, complex_t z) - { + void test_small_q(const IBornFF* p, complex_t x, complex_t y, complex_t z) { cvector_t q(x, y, z); test_eps_q(p, q, 1e-14); test_eps_q(p, q, 1e-11); test_eps_q(p, q, 1e-8); test_eps_q(p, q, 1e-5); } - void test_ff(const IBornFF* p) - { + void test_ff(const IBornFF* p) { complex_t ff0 = p->evaluate_for_q(cvector_t(0., 0., 0.)); EXPECT_EQ(imag(ff0), 0.); V = real(ff0); @@ -63,8 +59,7 @@ protected: double V, R; }; -TEST_F(FormFactorBasicTest, AnisoPyramid) -{ +TEST_F(FormFactorBasicTest, AnisoPyramid) { double length = 12.; double height = 5.; double width = 14.; @@ -86,8 +81,7 @@ TEST_F(FormFactorBasicTest, AnisoPyramid) test_ff(&particle); } -TEST_F(FormFactorBasicTest, HemiEllipsoid) -{ +TEST_F(FormFactorBasicTest, HemiEllipsoid) { double radiusx = 6.; double radiusy = 7.; double height = 5.; @@ -103,8 +97,7 @@ TEST_F(FormFactorBasicTest, HemiEllipsoid) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Box) -{ +TEST_F(FormFactorBasicTest, Box) { double length = 6.; double height = 5.; double width = 7.; @@ -128,8 +121,7 @@ TEST_F(FormFactorBasicTest, Box) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Cone) -{ +TEST_F(FormFactorBasicTest, Cone) { double radius = 6.; double height = 5.; double alpha = 0.8; @@ -149,8 +141,7 @@ TEST_F(FormFactorBasicTest, Cone) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Cone6) -{ +TEST_F(FormFactorBasicTest, Cone6) { double base_edge = 6.; double height = 5.; double alpha = 0.8; @@ -168,8 +159,7 @@ TEST_F(FormFactorBasicTest, Cone6) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Cuboctahedron) -{ +TEST_F(FormFactorBasicTest, Cuboctahedron) { double length = 10.; double height = 4; double height_ratio = .7; @@ -194,8 +184,7 @@ TEST_F(FormFactorBasicTest, Cuboctahedron) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Cylinder) -{ +TEST_F(FormFactorBasicTest, Cylinder) { double radius = 3.; double height = 5.; double volume = M_PI * radius * radius * height; @@ -225,8 +214,7 @@ TEST_F(FormFactorBasicTest, Cylinder) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Dodecahedron) -{ +TEST_F(FormFactorBasicTest, Dodecahedron) { double edge = 3.; double volume = (15 + 7 * sqrt(5)) / 4 * pow(edge, 3); @@ -240,8 +228,7 @@ TEST_F(FormFactorBasicTest, Dodecahedron) test_ff(&particle); } -TEST_F(FormFactorBasicTest, EllipsoidalCylinder) -{ +TEST_F(FormFactorBasicTest, EllipsoidalCylinder) { double radiusx = 3.; double radiusy = 5.; double height = 4; @@ -258,8 +245,7 @@ TEST_F(FormFactorBasicTest, EllipsoidalCylinder) test_ff(&particle); } -TEST_F(FormFactorBasicTest, CantellatedCube) -{ +TEST_F(FormFactorBasicTest, CantellatedCube) { double L = 10.; double t = 2.; // side length of removed trirectangular tetrahedron at each vertex double volume = L * L * L - 6 * L * t * t + 16 * t * t * t / 3; @@ -275,8 +261,7 @@ TEST_F(FormFactorBasicTest, CantellatedCube) test_ff(&particle); } -TEST_F(FormFactorBasicTest, FullSphere) -{ +TEST_F(FormFactorBasicTest, FullSphere) { double radius = 5.; double volume = 4. / 3. * M_PI * radius * radius * radius; @@ -289,8 +274,7 @@ TEST_F(FormFactorBasicTest, FullSphere) test_ff(&particle); } -TEST_F(FormFactorBasicTest, FullSpheroid) -{ +TEST_F(FormFactorBasicTest, FullSpheroid) { double radius = 3.; double height = 5.; double volume = 2. / 3. * M_PI * radius * radius * height; @@ -305,8 +289,7 @@ TEST_F(FormFactorBasicTest, FullSpheroid) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Icosahedron) -{ +TEST_F(FormFactorBasicTest, Icosahedron) { double edge = 7.; double volume = 5 * (3 + sqrt(5)) / 12 * pow(edge, 3); @@ -320,8 +303,7 @@ TEST_F(FormFactorBasicTest, Icosahedron) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Prism3) -{ +TEST_F(FormFactorBasicTest, Prism3) { double height = 4.; double base_edge = 6.; double volume = sqrt(3.) / 4. * height * base_edge * base_edge; @@ -336,8 +318,7 @@ TEST_F(FormFactorBasicTest, Prism3) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Prism6) -{ +TEST_F(FormFactorBasicTest, Prism6) { double height = 4.; double base_edge = 3.; double volume = 3. * sqrt(3.) / 2. * height * base_edge * base_edge; @@ -352,8 +333,7 @@ TEST_F(FormFactorBasicTest, Prism6) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Pyramid) -{ +TEST_F(FormFactorBasicTest, Pyramid) { double height = 4.; double base_edge = 10.; double alpha = 0.8; @@ -373,8 +353,7 @@ TEST_F(FormFactorBasicTest, Pyramid) test_ff(&particle); } -TEST_F(FormFactorBasicTest, TruncatedSphere) -{ +TEST_F(FormFactorBasicTest, TruncatedSphere) { double radius = 5.; double height = 3.; double HdivR = height / radius; @@ -390,8 +369,7 @@ TEST_F(FormFactorBasicTest, TruncatedSphere) test_ff(&particle); } -TEST_F(FormFactorBasicTest, TruncatedSpheroid) -{ +TEST_F(FormFactorBasicTest, TruncatedSpheroid) { double radius = 3.; double height = 5.; double flattening = 1.5; @@ -408,8 +386,7 @@ TEST_F(FormFactorBasicTest, TruncatedSpheroid) test_ff(&particle); } -TEST_F(FormFactorBasicTest, Tetrahedron) -{ +TEST_F(FormFactorBasicTest, Tetrahedron) { double base_edge = 16.; double height = 4.; double alpha = 0.8; @@ -427,8 +404,7 @@ TEST_F(FormFactorBasicTest, Tetrahedron) test_ff(&particle); } -TEST_F(FormFactorBasicTest, CosineRippleBox) -{ +TEST_F(FormFactorBasicTest, CosineRippleBox) { double width = 20.; double height = 4.; double length = 100.0; @@ -445,8 +421,7 @@ TEST_F(FormFactorBasicTest, CosineRippleBox) test_ff(&particle); } -TEST_F(FormFactorBasicTest, TruncatedCube) -{ +TEST_F(FormFactorBasicTest, TruncatedCube) { double length = 15.; double t = 6.; // side length of removed trirectangular tetrahedron at each vertex double volume = length * length * length - 4. / 3. * t * t * t; @@ -461,8 +436,7 @@ TEST_F(FormFactorBasicTest, TruncatedCube) test_ff(&particle); } -TEST_F(FormFactorBasicTest, SawtoothRippleBox) -{ +TEST_F(FormFactorBasicTest, SawtoothRippleBox) { double width = 20.; double height = 4.; double length = 100.0; diff --git a/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp b/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp index b8407cb7e09afd5a19db08e1bd1b25e0f982be2a..5e58f3e344a793d2e13d2a1032a5e754f6c72b66 100644 --- a/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp +++ b/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp @@ -4,12 +4,9 @@ #include "Sample/HardParticle/FormFactorDot.h" #include "Tests/GTestWrapper/google_test.h" -class FormFactorCoherentSumTest : public ::testing::Test -{ -}; +class FormFactorCoherentSumTest : public ::testing::Test {}; -TEST_F(FormFactorCoherentSumTest, RelAbundance) -{ +TEST_F(FormFactorCoherentSumTest, RelAbundance) { const double epsilon = 1e-12; FormFactorDot ff(5.0); FormFactorCoherentSum ffw(1.0); diff --git a/Tests/UnitTests/Core/Sample/INodeTest.cpp b/Tests/UnitTests/Core/Sample/INodeTest.cpp index 0425dfbd1d8959de312ee3f2148977adc0bf703d..eb2a96c070e6be1a109a9a1f5fafea9f64381ae6 100644 --- a/Tests/UnitTests/Core/Sample/INodeTest.cpp +++ b/Tests/UnitTests/Core/Sample/INodeTest.cpp @@ -6,41 +6,34 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -namespace -{ +namespace { const std::string test_class_name = "TestClass"; const std::string another_test_class_name = "AnotherTestClass"; const double test_par1_value(1.0); } // namespace -class INodeTest : public ::testing::Test -{ +class INodeTest : public ::testing::Test { public: - class TestClass : public INode - { + class TestClass : public INode { public: TestClass(const std::string& name = test_class_name, double value = test_par1_value) - : m_parameter1(value) - { + : m_parameter1(value) { setName(name); registerParameter("par1", &m_parameter1); } - virtual ~TestClass() - { + virtual ~TestClass() { for (auto child : m_nodes) delete child; } void accept(INodeVisitor* visitor) const final { visitor->visit(this); } - void appendChild(INode* node) - { + void appendChild(INode* node) { m_nodes.push_back(node); registerChild(node); } - virtual std::vector<const INode*> getChildren() const - { + virtual std::vector<const INode*> getChildren() const { return {m_nodes.begin(), m_nodes.end()}; } @@ -49,15 +42,13 @@ public: }; }; -TEST_F(INodeTest, initialState) -{ +TEST_F(INodeTest, initialState) { INodeTest::TestClass node; EXPECT_EQ(node.getChildren().size(), 0u); EXPECT_EQ(node.parent(), nullptr); } -TEST_F(INodeTest, appendChild) -{ +TEST_F(INodeTest, appendChild) { INodeTest::TestClass node; INodeTest::TestClass* child0 = new INodeTest::TestClass(); @@ -73,8 +64,7 @@ TEST_F(INodeTest, appendChild) //! Checks change of parentship on insert/detach. -TEST_F(INodeTest, parentship) -{ +TEST_F(INodeTest, parentship) { INodeTest::TestClass node; EXPECT_EQ(node.parent(), nullptr); @@ -85,8 +75,7 @@ TEST_F(INodeTest, parentship) //! Checks the display name. -TEST_F(INodeTest, displayName) -{ +TEST_F(INodeTest, displayName) { INodeTest::TestClass node; // Adding first child and checking its displayName @@ -109,8 +98,7 @@ TEST_F(INodeTest, displayName) //! Checking the path of the node, which is a path composed of node's displayName and //! the displayName of parent. -TEST_F(INodeTest, nodePath) -{ +TEST_F(INodeTest, nodePath) { INodeTest::TestClass root("root"); EXPECT_EQ(NodeUtils::nodePath(root), "/root"); @@ -139,8 +127,7 @@ TEST_F(INodeTest, nodePath) //! Checking parameter tree for INode structure. -TEST_F(INodeTest, createParameterTree) -{ +TEST_F(INodeTest, createParameterTree) { INodeTest::TestClass root("root"); std::unique_ptr<ParameterPool> pool(root.createParameterTree()); @@ -159,8 +146,7 @@ TEST_F(INodeTest, createParameterTree) //! Checking parameter tree for INode structure (for one of children). -TEST_F(INodeTest, createChildParameterTree) -{ +TEST_F(INodeTest, createChildParameterTree) { INodeTest::TestClass root("root"); INodeTest::TestClass* child = new INodeTest::TestClass("child", 1.0); root.appendChild(child); diff --git a/Tests/UnitTests/Core/Sample/Lattice2DTest.cpp b/Tests/UnitTests/Core/Sample/Lattice2DTest.cpp index 37a0a14bd16dbbed45362d2008e45d13b999d4e3..ecb3ad78ab300218a9d6adcba40b5a7246451547 100644 --- a/Tests/UnitTests/Core/Sample/Lattice2DTest.cpp +++ b/Tests/UnitTests/Core/Sample/Lattice2DTest.cpp @@ -1,12 +1,9 @@ #include "Sample/Lattice/Lattice2D.h" #include "Tests/GTestWrapper/google_test.h" -class Lattice2DTest : public ::testing::Test -{ -}; +class Lattice2DTest : public ::testing::Test {}; -TEST_F(Lattice2DTest, basicLattice) -{ +TEST_F(Lattice2DTest, basicLattice) { const double length1(1.0), length2(2.0), angle(3.0), rotangle(0.7); BasicLattice2D lattice(length1, length2, angle, rotangle); EXPECT_EQ(lattice.length1(), length1); @@ -26,8 +23,7 @@ TEST_F(Lattice2DTest, basicLattice) EXPECT_EQ(lattice.rotationAngle(), new_value); } -TEST_F(Lattice2DTest, basicLatticeClone) -{ +TEST_F(Lattice2DTest, basicLatticeClone) { const double length1(1.0), length2(2.0), angle(3.0), xi(4.0); BasicLattice2D lattice(length1, length2, angle, xi); @@ -38,8 +34,7 @@ TEST_F(Lattice2DTest, basicLatticeClone) EXPECT_EQ(clone->rotationAngle(), xi); } -TEST_F(Lattice2DTest, squareLatticeClone) -{ +TEST_F(Lattice2DTest, squareLatticeClone) { const double length(1.0), xi(4.0); SquareLattice2D lattice(length, xi); @@ -58,8 +53,7 @@ TEST_F(Lattice2DTest, squareLatticeClone) EXPECT_EQ(clone->rotationAngle(), new_value); } -TEST_F(Lattice2DTest, hexagonalLatticeClone) -{ +TEST_F(Lattice2DTest, hexagonalLatticeClone) { const double length(1.0), xi(4.0); HexagonalLattice2D lattice(length, xi); @@ -78,10 +72,8 @@ TEST_F(Lattice2DTest, hexagonalLatticeClone) EXPECT_EQ(clone->rotationAngle(), new_value); } -TEST_F(Lattice2DTest, onChange) -{ - class Parent : public INode - { +TEST_F(Lattice2DTest, onChange) { + class Parent : public INode { public: Parent() : m_changed(false) {} void accept(INodeVisitor* visitor) const final { visitor->visit(this); } diff --git a/Tests/UnitTests/Core/Sample/LatticeTest.cpp b/Tests/UnitTests/Core/Sample/LatticeTest.cpp index 1d73ccb0e115f35a4dbde744d6b2bf6e1f90d49e..2a463883ea89d7c27b253fa4490ec240fb212ada 100644 --- a/Tests/UnitTests/Core/Sample/LatticeTest.cpp +++ b/Tests/UnitTests/Core/Sample/LatticeTest.cpp @@ -4,13 +4,10 @@ #include "Sample/Lattice/Lattice3D.h" #include "Tests/GTestWrapper/google_test.h" -class LatticeTest : public ::testing::Test -{ -}; +class LatticeTest : public ::testing::Test {}; // tests the declaration of Lattice object, copy constructor and the getBasisVector_() functions -TEST_F(LatticeTest, declarationTest) -{ +TEST_F(LatticeTest, declarationTest) { kvector_t a1(1, 0, 0), a2(0, 1, 0), a3(0, 0, 1); Lattice3D l1(a1, a2, a3); @@ -37,8 +34,7 @@ TEST_F(LatticeTest, declarationTest) } // tests volume of the unit cell -TEST_F(LatticeTest, volumeTest) -{ +TEST_F(LatticeTest, volumeTest) { kvector_t a1(4, 0, 0), a2(0, 2.1, 0), a3(0, 0, 1); Lattice3D l1(a1, a2, a3); @@ -46,8 +42,7 @@ TEST_F(LatticeTest, volumeTest) } // tests whether reciprocal lattice basis vectors have been initialized or not -TEST_F(LatticeTest, reciprocalTest) -{ +TEST_F(LatticeTest, reciprocalTest) { kvector_t a1(1, 0, 0), a2(0, 1, 0), a3(0, 0, 1); Lattice3D l1(a1, a2, a3); @@ -69,8 +64,7 @@ TEST_F(LatticeTest, reciprocalTest) } // tests whether Lattice has been transformed correctly -TEST_F(LatticeTest, transformTest) -{ +TEST_F(LatticeTest, transformTest) { kvector_t a1(1, 0, 0), a2(0, 1, 0), a3(0, 0, 1); Lattice3D l1(a1, a2, a3); @@ -90,8 +84,7 @@ TEST_F(LatticeTest, transformTest) } // tests the nearest REC. LATTICE point to a given REC. SPACE vector -TEST_F(LatticeTest, NearestReciprocalLatticeVectorCoordinatesTest) -{ +TEST_F(LatticeTest, NearestReciprocalLatticeVectorCoordinatesTest) { kvector_t a1(1, 0, 0), a2(0, 1, 0), a3(0, 0, 1); Lattice3D l1(a1, a2, a3); @@ -106,8 +99,7 @@ TEST_F(LatticeTest, NearestReciprocalLatticeVectorCoordinatesTest) // tests the list of REC. LATTICE vectors (in REC. SPACE coords) computed within a specified // radius of a given REC. SPACE vector -TEST_F(LatticeTest, reciprocalLatticeVectorsWithinRadiusTest) -{ +TEST_F(LatticeTest, reciprocalLatticeVectorsWithinRadiusTest) { kvector_t a1(1, 0, 0), a2(0, 1, 0), a3(0, 0, 1); Lattice3D l1(a1, a2, a3); @@ -131,8 +123,7 @@ TEST_F(LatticeTest, reciprocalLatticeVectorsWithinRadiusTest) } // tests FCC lattice creation -TEST_F(LatticeTest, FCCLatticeTest) -{ +TEST_F(LatticeTest, FCCLatticeTest) { // creates FCC lattice onto a new Lattice instance l1 Lattice3D l1 = bake::FCCLattice(1); @@ -144,8 +135,7 @@ TEST_F(LatticeTest, FCCLatticeTest) } // tests hexagonal lattice creation -TEST_F(LatticeTest, HexagonalLattice2DTest) -{ +TEST_F(LatticeTest, HexagonalLattice2DTest) { Lattice3D l1 = bake::HexagonalLattice(1, 4); kvector_t tri1(1, 0.0, 0.0); @@ -159,8 +149,7 @@ TEST_F(LatticeTest, HexagonalLattice2DTest) // tests whether basis and reciprocal vectors are returned correctly when the basis // vectors are manually changed using the setVectorValue method -TEST_F(LatticeTest, onChangeTest) -{ +TEST_F(LatticeTest, onChangeTest) { kvector_t a1(1, 0, 0), a2(0, 1, 0), a3(0, 0, 1); Lattice3D l1(a1, a2, a3); diff --git a/Tests/UnitTests/Core/Sample/LayerInterfaceTest.cpp b/Tests/UnitTests/Core/Sample/LayerInterfaceTest.cpp index ca54f9154da1ec5c06f1ef86f25232d13252803d..91d5a784f459bf4bd694bc4ce52860ebcc32942e 100644 --- a/Tests/UnitTests/Core/Sample/LayerInterfaceTest.cpp +++ b/Tests/UnitTests/Core/Sample/LayerInterfaceTest.cpp @@ -5,12 +5,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class LayerInterfaceTest : public ::testing::Test -{ -}; +class LayerInterfaceTest : public ::testing::Test {}; -TEST_F(LayerInterfaceTest, createSmoothInterface) -{ +TEST_F(LayerInterfaceTest, createSmoothInterface) { std::unique_ptr<Layer> layer0(new Layer(HomogeneousMaterial("Vacuum", 0.0, 0.0))); std::unique_ptr<Layer> layer1(new Layer(HomogeneousMaterial("Vacuum", 0.0, 0.0))); @@ -23,8 +20,7 @@ TEST_F(LayerInterfaceTest, createSmoothInterface) EXPECT_EQ(interface->getChildren().size(), 0u); } -TEST_F(LayerInterfaceTest, createRoughInterface) -{ +TEST_F(LayerInterfaceTest, createRoughInterface) { std::unique_ptr<Layer> layer0(new Layer(HomogeneousMaterial("Vacuum", 0.0, 0.0))); std::unique_ptr<Layer> layer1(new Layer(HomogeneousMaterial("Vacuum", 0.0, 0.0))); diff --git a/Tests/UnitTests/Core/Sample/LayerRoughnessTest.cpp b/Tests/UnitTests/Core/Sample/LayerRoughnessTest.cpp index 4e8745cc7ea72c2a3c8330fe6301e41fab156c14..1eb5055b071c95709b3fd093e8e3e11990180eac 100644 --- a/Tests/UnitTests/Core/Sample/LayerRoughnessTest.cpp +++ b/Tests/UnitTests/Core/Sample/LayerRoughnessTest.cpp @@ -2,12 +2,9 @@ #include "Param/Varia/ParameterPattern.h" #include "Tests/GTestWrapper/google_test.h" -class LayerRoughnessTest : public ::testing::Test -{ -}; +class LayerRoughnessTest : public ::testing::Test {}; -TEST_F(LayerRoughnessTest, LayerRoughnessInitial) -{ +TEST_F(LayerRoughnessTest, LayerRoughnessInitial) { // test with default parameter LayerRoughness roughness; EXPECT_EQ(0.0, roughness.getSigma()); @@ -32,8 +29,7 @@ TEST_F(LayerRoughnessTest, LayerRoughnessInitial) } // test clone LayerRoughness -TEST_F(LayerRoughnessTest, LayerRoughnessClone) -{ +TEST_F(LayerRoughnessTest, LayerRoughnessClone) { LayerRoughness original(3.1, 3.2, 3.3); LayerRoughness* clone = original.clone(); @@ -44,8 +40,7 @@ TEST_F(LayerRoughnessTest, LayerRoughnessClone) } // test parameter pool -TEST_F(LayerRoughnessTest, LayerRoughnessPool) -{ +TEST_F(LayerRoughnessTest, LayerRoughnessPool) { LayerRoughness roughnessPool; EXPECT_EQ(0.0, roughnessPool.getSigma()); EXPECT_EQ(0.0, roughnessPool.getHurstParameter()); diff --git a/Tests/UnitTests/Core/Sample/LayerTest.cpp b/Tests/UnitTests/Core/Sample/LayerTest.cpp index fec9a13b3ee69cc7ca6e2fe8a3a3d75d3267781e..df6b0ff8e90b993cd916f619eacea4edfd11afa6 100644 --- a/Tests/UnitTests/Core/Sample/LayerTest.cpp +++ b/Tests/UnitTests/Core/Sample/LayerTest.cpp @@ -4,12 +4,9 @@ #include "Sample/Material/MaterialFactoryFuncs.h" #include "Tests/GTestWrapper/google_test.h" -class LayerTest : public ::testing::Test -{ -}; +class LayerTest : public ::testing::Test {}; -TEST_F(LayerTest, LayerGetAndSet) -{ +TEST_F(LayerTest, LayerGetAndSet) { Material vacuum = HomogeneousMaterial("Vacuum", 0, 0); Layer layer(vacuum, 10 * Units::nm); EXPECT_EQ(vacuum, *layer.material()); @@ -28,8 +25,7 @@ TEST_F(LayerTest, LayerGetAndSet) EXPECT_EQ(clone->numberOfLayouts(), 0u); } -TEST_F(LayerTest, LayerAndDecoration) -{ +TEST_F(LayerTest, LayerAndDecoration) { Material vacuum = HomogeneousMaterial("Vacuum", 0, 0); std::unique_ptr<ParticleLayout> layout1(new ParticleLayout()); @@ -42,8 +38,7 @@ TEST_F(LayerTest, LayerAndDecoration) EXPECT_EQ(layer.numberOfLayouts(), 2u); } -TEST_F(LayerTest, getChildren) -{ +TEST_F(LayerTest, getChildren) { Layer layer(HomogeneousMaterial("Vacuum", 0.0, 0.0)); std::vector<const INode*> children = layer.getChildren(); diff --git a/Tests/UnitTests/Core/Sample/MesoCrystalTest.cpp b/Tests/UnitTests/Core/Sample/MesoCrystalTest.cpp index 601e1e108a70afa93179c6c81df4878933529fd6..3677f8ef5837e38e93d743f83a8104cce1051628 100644 --- a/Tests/UnitTests/Core/Sample/MesoCrystalTest.cpp +++ b/Tests/UnitTests/Core/Sample/MesoCrystalTest.cpp @@ -6,12 +6,9 @@ #include "Sample/Scattering/Rotations.h" #include "Tests/GTestWrapper/google_test.h" -class MesoCrystalTest : public ::testing::Test -{ -}; +class MesoCrystalTest : public ::testing::Test {}; -TEST_F(MesoCrystalTest, getChildren) -{ +TEST_F(MesoCrystalTest, getChildren) { Lattice3D lattice = bake::HexagonalLattice(1.0, 2.0); ParticleComposition composition; Crystal crystal(composition, lattice); diff --git a/Tests/UnitTests/Core/Sample/MultiLayerTest.cpp b/Tests/UnitTests/Core/Sample/MultiLayerTest.cpp index 205f801c17ab78bafcf63341bf60e4c936b25e2b..97c0ffe640c5c2a24cbf5f1584a3a2becb4ade08 100644 --- a/Tests/UnitTests/Core/Sample/MultiLayerTest.cpp +++ b/Tests/UnitTests/Core/Sample/MultiLayerTest.cpp @@ -13,8 +13,7 @@ using MultiLayerUtils::LayerBottomInterface; using MultiLayerUtils::LayerThickness; using MultiLayerUtils::LayerTopInterface; -class MultiLayerTest : public ::testing::Test -{ +class MultiLayerTest : public ::testing::Test { protected: MultiLayerTest() // The following delta, beta are all unphysical. Values don't matter here. @@ -25,11 +24,8 @@ protected: , topLayer(air, 0 * Units::nm) , layer1(iron, 20 * Units::nm) , layer2(chromium, 40 * Units::nm) - , substrate(stone, 0 * Units::nm) - { - } - void set_four() - { + , substrate(stone, 0 * Units::nm) {} + void set_four() { mLayer.addLayer(topLayer); mLayer.addLayer(layer1); mLayer.addLayer(layer2); @@ -41,8 +37,7 @@ protected: Layer topLayer, layer1, layer2, substrate; }; -TEST_F(MultiLayerTest, BasicProperty) -{ +TEST_F(MultiLayerTest, BasicProperty) { // check default properties EXPECT_EQ(0.0, mLayer.crossCorrLength()); EXPECT_EQ(size_t(0), mLayer.numberOfLayers()); @@ -61,8 +56,7 @@ TEST_F(MultiLayerTest, BasicProperty) EXPECT_EQ(size_t(4), mLayer.numberOfLayers()); } -TEST_F(MultiLayerTest, LayerThicknesses) -{ +TEST_F(MultiLayerTest, LayerThicknesses) { set_four(); // check layer thickness @@ -72,8 +66,7 @@ TEST_F(MultiLayerTest, LayerThicknesses) EXPECT_EQ(0.0, LayerThickness(mLayer, 3)); } -TEST_F(MultiLayerTest, CheckAllLayers) -{ +TEST_F(MultiLayerTest, CheckAllLayers) { set_four(); // check individual layer @@ -90,8 +83,7 @@ TEST_F(MultiLayerTest, CheckAllLayers) EXPECT_EQ(0, got3->thickness()); } -TEST_F(MultiLayerTest, LayerInterfaces) -{ +TEST_F(MultiLayerTest, LayerInterfaces) { set_four(); // check interfaces @@ -125,8 +117,7 @@ TEST_F(MultiLayerTest, LayerInterfaces) EXPECT_TRUE(nullptr == interfaceBottomNull); } -TEST_F(MultiLayerTest, Clone) -{ +TEST_F(MultiLayerTest, Clone) { set_four(); MultiLayer* mLayerClone = mLayer.clone(); @@ -187,8 +178,7 @@ TEST_F(MultiLayerTest, Clone) delete mLayerClone; } -TEST_F(MultiLayerTest, WithRoughness) -{ +TEST_F(MultiLayerTest, WithRoughness) { // LayerRoughness(double sigma, double hurstParameter, double lateralCorrLength); LayerRoughness lr(1.1, -7.3, 0.1); mLayer.addLayer(topLayer); @@ -209,8 +199,7 @@ TEST_F(MultiLayerTest, WithRoughness) EXPECT_EQ(0.1, roughness0->getLatteralCorrLength()); } -TEST_F(MultiLayerTest, CloneWithRoughness) -{ +TEST_F(MultiLayerTest, CloneWithRoughness) { LayerRoughness lr0(-2.1, 7.3, 12.1); LayerRoughness lr1(1.1, -7.3, 0.1); @@ -239,8 +228,7 @@ TEST_F(MultiLayerTest, CloneWithRoughness) delete mLayerClone; } -TEST_F(MultiLayerTest, MultiLayerCompositeTest) -{ +TEST_F(MultiLayerTest, MultiLayerCompositeTest) { MultiLayer mLayer; kvector_t magnetic_field(0.0, 0.0, 0.0); Material magMaterial0 = HomogeneousMaterial("MagMat0", 6e-4, 2e-8, magnetic_field); diff --git a/Tests/UnitTests/Core/Sample/MultilayerAveragingTest.cpp b/Tests/UnitTests/Core/Sample/MultilayerAveragingTest.cpp index 72cf6995b3d71543d7b637ce241776ed56fda11e..5ccbbbc8b887031bcac4b30e4a54caabe9c1ad46 100644 --- a/Tests/UnitTests/Core/Sample/MultilayerAveragingTest.cpp +++ b/Tests/UnitTests/Core/Sample/MultilayerAveragingTest.cpp @@ -9,20 +9,16 @@ #include "Sample/RT/SimulationOptions.h" #include "Tests/GTestWrapper/google_test.h" -class MultilayerAveragingTest : public ::testing::Test -{ +class MultilayerAveragingTest : public ::testing::Test { protected: MultilayerAveragingTest() : vacuum(HomogeneousMaterial("vac", 0.0, 0.0)) - , stone(HomogeneousMaterial("stone", 4e-4, 8e-7)) - { - } + , stone(HomogeneousMaterial("stone", 4e-4, 8e-7)) {} const Material vacuum, stone; }; -TEST_F(MultilayerAveragingTest, AverageMultilayer) -{ +TEST_F(MultilayerAveragingTest, AverageMultilayer) { // particles FormFactorCylinder cylinder_ff(1.0, 3.0); Particle particle(stone, cylinder_ff); diff --git a/Tests/UnitTests/Core/Sample/ParticleCompositionTest.cpp b/Tests/UnitTests/Core/Sample/ParticleCompositionTest.cpp index c1e1f1a99ea9182a898a0ffaddc1133024080778..06981649f197e2fc1ba13506112a7a564fdf83b9 100644 --- a/Tests/UnitTests/Core/Sample/ParticleCompositionTest.cpp +++ b/Tests/UnitTests/Core/Sample/ParticleCompositionTest.cpp @@ -6,20 +6,16 @@ #include "Sample/Scattering/Rotations.h" #include "Tests/GTestWrapper/google_test.h" -class ParticleCompositionTest : public ::testing::Test -{ -}; +class ParticleCompositionTest : public ::testing::Test {}; -TEST_F(ParticleCompositionTest, ParticleCompositionDefaultConstructor) -{ +TEST_F(ParticleCompositionTest, ParticleCompositionDefaultConstructor) { std::unique_ptr<ParticleComposition> composition(new ParticleComposition()); std::vector<kvector_t> positions; positions.push_back(kvector_t(0.0, 0.0, 0.0)); EXPECT_EQ(0u, composition->nbrParticles()); } -TEST_F(ParticleCompositionTest, ParticleCompositionClone) -{ +TEST_F(ParticleCompositionTest, ParticleCompositionClone) { ParticleComposition composition; kvector_t position = kvector_t(1.0, 1.0, 1.0); Material material = HomogeneousMaterial("Vacuum", 0.0, 0.0); @@ -34,8 +30,7 @@ TEST_F(ParticleCompositionTest, ParticleCompositionClone) EXPECT_EQ(p_particle->position(), position); } -TEST_F(ParticleCompositionTest, getChildren) -{ +TEST_F(ParticleCompositionTest, getChildren) { Material material = HomogeneousMaterial("Vacuum", 0.0, 0.0); ParticleComposition composition; diff --git a/Tests/UnitTests/Core/Sample/ParticleCoreShellTest.cpp b/Tests/UnitTests/Core/Sample/ParticleCoreShellTest.cpp index 1274ecd80d6b8b93e9a8d1ba7e9a9dfe73d66b5c..b6e72346e4e0ca7f13dd703c34fabb362ed53123 100644 --- a/Tests/UnitTests/Core/Sample/ParticleCoreShellTest.cpp +++ b/Tests/UnitTests/Core/Sample/ParticleCoreShellTest.cpp @@ -7,8 +7,7 @@ #include "Sample/Scattering/Rotations.h" #include "Tests/GTestWrapper/google_test.h" -class ParticleCoreShellTest : public ::testing::Test -{ +class ParticleCoreShellTest : public ::testing::Test { protected: ParticleCoreShellTest(); virtual ~ParticleCoreShellTest(); @@ -16,8 +15,7 @@ protected: ParticleCoreShell* m_coreshell; }; -ParticleCoreShellTest::ParticleCoreShellTest() : m_coreshell(nullptr) -{ +ParticleCoreShellTest::ParticleCoreShellTest() : m_coreshell(nullptr) { Material mat = HomogeneousMaterial("Ag", 1.245e-5, 5.419e-7); Particle core(mat); Particle shell(mat); @@ -25,27 +23,23 @@ ParticleCoreShellTest::ParticleCoreShellTest() : m_coreshell(nullptr) m_coreshell = new ParticleCoreShell(shell, core, position); } -ParticleCoreShellTest::~ParticleCoreShellTest() -{ +ParticleCoreShellTest::~ParticleCoreShellTest() { delete m_coreshell; } -TEST_F(ParticleCoreShellTest, InitialState) -{ +TEST_F(ParticleCoreShellTest, InitialState) { EXPECT_EQ(nullptr, m_coreshell->createFormFactor()); EXPECT_EQ(nullptr, m_coreshell->rotation()); } -TEST_F(ParticleCoreShellTest, Clone) -{ +TEST_F(ParticleCoreShellTest, Clone) { ParticleCoreShell* p_clone = m_coreshell->clone(); EXPECT_EQ(nullptr, p_clone->createFormFactor()); EXPECT_EQ(nullptr, p_clone->rotation()); delete p_clone; } -TEST_F(ParticleCoreShellTest, ComplexCoreShellClone) -{ +TEST_F(ParticleCoreShellTest, ComplexCoreShellClone) { Material mCore = HomogeneousMaterial("Ag", 1.245e-5, 5.419e-7); Material mShell = HomogeneousMaterial("AgO2", 8.600e-6, 3.442e-7); @@ -68,8 +62,7 @@ TEST_F(ParticleCoreShellTest, ComplexCoreShellClone) EXPECT_EQ(clone->coreParticle()->position(), relative_pos); } -TEST_F(ParticleCoreShellTest, getChildren) -{ +TEST_F(ParticleCoreShellTest, getChildren) { Material mat = HomogeneousMaterial("mat", 0.0, 0.0); Particle core(mat, FormFactorBox(1.0, 1.0, 1.0)); Particle shell(mat, FormFactorFullSphere(1.0)); diff --git a/Tests/UnitTests/Core/Sample/ParticleDistributionTest.cpp b/Tests/UnitTests/Core/Sample/ParticleDistributionTest.cpp index b367b4a0cc0caa9b8f30b68dffaecabe34de60c6..451fb3d54747f128b70c97e5ccf5ccb6c2c85083 100644 --- a/Tests/UnitTests/Core/Sample/ParticleDistributionTest.cpp +++ b/Tests/UnitTests/Core/Sample/ParticleDistributionTest.cpp @@ -7,16 +7,14 @@ #include "Sample/Particle/Particle.h" #include "Tests/GTestWrapper/google_test.h" -class ParticleDistributionTest : public ::testing::Test -{ +class ParticleDistributionTest : public ::testing::Test { protected: ~ParticleDistributionTest(); }; ParticleDistributionTest::~ParticleDistributionTest() = default; -TEST_F(ParticleDistributionTest, getChildren) -{ +TEST_F(ParticleDistributionTest, getChildren) { Particle particle(HomogeneousMaterial("Vacuum", 0.0, 0.0), FormFactorFullSphere(1.0)); ParameterDistribution parameter("name", DistributionGate(1.0, 2.0), 5, 0.0, 1.0); ParticleDistribution distr(particle, parameter); @@ -26,8 +24,7 @@ TEST_F(ParticleDistributionTest, getChildren) EXPECT_EQ(children.size(), 2u); } -TEST_F(ParticleDistributionTest, mainParameterUnits) -{ +TEST_F(ParticleDistributionTest, mainParameterUnits) { Material mat = HomogeneousMaterial("Vacuum", 0.0, 0.0); DistributionGate gate(1.0, 2.0); diff --git a/Tests/UnitTests/Core/Sample/ParticleLayoutTest.cpp b/Tests/UnitTests/Core/Sample/ParticleLayoutTest.cpp index 53e2b7596c25a97ffcabe1d6724f1553e2200471..041688ce80db7d8177978572ff1aebe49e55e1c2 100644 --- a/Tests/UnitTests/Core/Sample/ParticleLayoutTest.cpp +++ b/Tests/UnitTests/Core/Sample/ParticleLayoutTest.cpp @@ -7,8 +7,7 @@ #include "Sample/Particle/Particle.h" #include "Tests/GTestWrapper/google_test.h" -class ParticleLayoutTest : public ::testing::Test -{ +class ParticleLayoutTest : public ::testing::Test { protected: ~ParticleLayoutTest(); @@ -16,8 +15,7 @@ protected: ParticleLayoutTest::~ParticleLayoutTest() = default; -TEST_F(ParticleLayoutTest, ParticleLayoutInitial) -{ +TEST_F(ParticleLayoutTest, ParticleLayoutInitial) { ParticleLayout particleDecoration; auto p_iff = INodeUtils::OnlyChildOfType<IInterferenceFunction>(particleDecoration); auto particles = INodeUtils::ChildNodesOfType<IAbstractParticle>(particleDecoration); @@ -25,8 +23,7 @@ TEST_F(ParticleLayoutTest, ParticleLayoutInitial) EXPECT_EQ(nullptr, p_iff); } -TEST_F(ParticleLayoutTest, ParticleLayoutInitByValue) -{ +TEST_F(ParticleLayoutTest, ParticleLayoutInitByValue) { Particle particle(HomogeneousMaterial()); ParticleLayout particleDecoration(particle, 2.0); @@ -40,8 +37,7 @@ TEST_F(ParticleLayoutTest, ParticleLayoutInitByValue) EXPECT_EQ(2.0, particleDecoration.getTotalAbundance()); } -TEST_F(ParticleLayoutTest, ParticleLayoutAddParticle) -{ +TEST_F(ParticleLayoutTest, ParticleLayoutAddParticle) { ParticleLayout particleDecoration; Particle particle1(HomogeneousMaterial()); @@ -77,8 +73,7 @@ TEST_F(ParticleLayoutTest, ParticleLayoutAddParticle) EXPECT_EQ(4.2, p_particle4->abundance()); } -TEST_F(ParticleLayoutTest, ParticleLayoutAbundanceFraction) -{ +TEST_F(ParticleLayoutTest, ParticleLayoutAbundanceFraction) { ParticleLayout particleDecoration; Particle particle1(HomogeneousMaterial()); @@ -96,8 +91,7 @@ TEST_F(ParticleLayoutTest, ParticleLayoutAbundanceFraction) EXPECT_EQ(8.0, particleDecoration.getTotalAbundance()); } -TEST_F(ParticleLayoutTest, ParticleLayoutClone) -{ +TEST_F(ParticleLayoutTest, ParticleLayoutClone) { ParticleLayout particleDecoration; Particle particle1(HomogeneousMaterial()); @@ -150,8 +144,7 @@ TEST_F(ParticleLayoutTest, ParticleLayoutClone) EXPECT_TRUE(nullptr != p_iff); } -TEST_F(ParticleLayoutTest, ParticleLayoutInterferenceFunction) -{ +TEST_F(ParticleLayoutTest, ParticleLayoutInterferenceFunction) { ParticleLayout particleDecoration; InterferenceFunctionNone iff_none; @@ -161,8 +154,7 @@ TEST_F(ParticleLayoutTest, ParticleLayoutInterferenceFunction) EXPECT_TRUE(nullptr != p_iff); } -TEST_F(ParticleLayoutTest, getChildren) -{ +TEST_F(ParticleLayoutTest, getChildren) { ParticleLayout layout; std::vector<const INode*> children = layout.getChildren(); EXPECT_EQ(children.size(), 0u); diff --git a/Tests/UnitTests/Core/Sample/ParticleTest.cpp b/Tests/UnitTests/Core/Sample/ParticleTest.cpp index 72fdee5690c559c26738157cd44f9ceb480ccaf3..b0f580c36132843ee2cb571ba582710bad5eb69d 100644 --- a/Tests/UnitTests/Core/Sample/ParticleTest.cpp +++ b/Tests/UnitTests/Core/Sample/ParticleTest.cpp @@ -7,12 +7,9 @@ #include "Sample/Scattering/Rotations.h" #include "Tests/GTestWrapper/google_test.h" -class ParticleTest : public ::testing::Test -{ -}; +class ParticleTest : public ::testing::Test {}; -TEST_F(ParticleTest, Clone) -{ +TEST_F(ParticleTest, Clone) { Material mat = HomogeneousMaterial("Any", 1e-4, 1e-6); Particle particle(mat); std::unique_ptr<Particle> clone(particle.clone()); @@ -21,8 +18,7 @@ TEST_F(ParticleTest, Clone) EXPECT_EQ(nullptr, clone->rotation()); } -TEST_F(ParticleTest, Constructors) -{ +TEST_F(ParticleTest, Constructors) { Material mat = HomogeneousMaterial("Vacuum", 0, 0); FormFactorFullSphere sphere(1.0); RotationZ transform(45. * Units::deg); @@ -45,8 +41,7 @@ TEST_F(ParticleTest, Constructors) EXPECT_TRUE(dynamic_cast<FormFactorDecoratorMaterial*>(p3->createFormFactor())); } -TEST_F(ParticleTest, setters) -{ +TEST_F(ParticleTest, setters) { Material mat = HomogeneousMaterial("Any", 10e-2, 10e-5); FormFactorFullSphere sphere(2.1); RotationY transform(45. * Units::deg); @@ -63,8 +58,7 @@ TEST_F(ParticleTest, setters) EXPECT_TRUE(nullptr != particle2->rotation()); } -TEST_F(ParticleTest, getChildren) -{ +TEST_F(ParticleTest, getChildren) { Material mat = HomogeneousMaterial("Vacuum", 0, 0); FormFactorFullSphere sphere(2.1); diff --git a/Tests/UnitTests/Core/Sample/RTTest.cpp b/Tests/UnitTests/Core/Sample/RTTest.cpp index 17b79bc07804c3398a9f01b94b250296e021a150..3bb1b3f74e2383e4578e00aeef82ea32ff262146 100644 --- a/Tests/UnitTests/Core/Sample/RTTest.cpp +++ b/Tests/UnitTests/Core/Sample/RTTest.cpp @@ -10,18 +10,15 @@ #include "Sample/Specular/SpecularScalarTanhStrategy.h" #include "Tests/GTestWrapper/google_test.h" -class RTTest : public ::testing::Test -{ +class RTTest : public ::testing::Test { protected: - void printCoeffs(const std::vector<ScalarRTCoefficients>& coeffs) - { // for debug phases + void printCoeffs(const std::vector<ScalarRTCoefficients>& coeffs) { // for debug phases for (size_t i = 0; i < coeffs.size(); ++i) { const ScalarRTCoefficients& coeff = coeffs[i]; std::cout << i << " " << coeff.t_r(0) << " " << coeff.t_r(1) << "\n"; } } - void compareCoeffs(const ScalarRTCoefficients& coeff1, const ScalarRTCoefficients& coeff2) - { + void compareCoeffs(const ScalarRTCoefficients& coeff1, const ScalarRTCoefficients& coeff2) { EXPECT_NEAR(abs(coeff1.t_r(0)), abs(coeff2.t_r(0)), 5e-14); EXPECT_NEAR(coeff1.t_r(0).real(), coeff2.t_r(0).real(), 1e-10); EXPECT_NEAR(coeff1.t_r(0).imag(), coeff2.t_r(0).imag(), 1e-10); @@ -29,8 +26,7 @@ protected: EXPECT_NEAR(coeff1.t_r(1).real(), coeff2.t_r(1).real(), 1e-10); EXPECT_NEAR(coeff1.t_r(1).imag(), coeff2.t_r(1).imag(), 1e-10); } - std::vector<ScalarRTCoefficients> getCoeffs(ISpecularStrategy::coeffs_t&& inputCoeffs) - { + std::vector<ScalarRTCoefficients> getCoeffs(ISpecularStrategy::coeffs_t&& inputCoeffs) { std::vector<ScalarRTCoefficients> result; for (auto& coeff : inputCoeffs) result.push_back(*dynamic_cast<const ScalarRTCoefficients*>(coeff.get())); @@ -48,8 +44,7 @@ protected: std::vector<ScalarRTCoefficients> coeffs1, coeffs2; }; -TEST_F(RTTest, SplitLayer) -{ +TEST_F(RTTest, SplitLayer) { const int n = 40; sample1.addLayer(topLayer); @@ -78,8 +73,7 @@ TEST_F(RTTest, SplitLayer) compareCoeffs(coeffs1.back(), coeffs2.back()); } -TEST_F(RTTest, SplitBilayers) -{ +TEST_F(RTTest, SplitBilayers) { // With exaggerated values of #layers, layer thickness, and absorption // so that we also test correct handling of floating-point overflow. const int n = 250; @@ -123,8 +117,7 @@ TEST_F(RTTest, SplitBilayers) EXPECT_EQ(complex_t(), coeffs2[coeffs2.size() - 2].t_r(1)); } -TEST_F(RTTest, Overflow) -{ +TEST_F(RTTest, Overflow) { // Text extra thick layers to also provoke an overflow in the new algorithm const int n = 5; diff --git a/Tests/UnitTests/Core/SimulationElement/DepthProbeElementTest.cpp b/Tests/UnitTests/Core/SimulationElement/DepthProbeElementTest.cpp index a7f444718ced3444e12a0bcc044f83b3c77db9e6..cf568a7896099c650d57078652804012fdf8ab9c 100644 --- a/Tests/UnitTests/Core/SimulationElement/DepthProbeElementTest.cpp +++ b/Tests/UnitTests/Core/SimulationElement/DepthProbeElementTest.cpp @@ -2,8 +2,7 @@ #include "Base/Axis/FixedBinAxis.h" #include "Tests/GTestWrapper/google_test.h" -class DepthProbeElementTest : public ::testing::Test -{ +class DepthProbeElementTest : public ::testing::Test { protected: DepthProbeElementTest(); DepthProbeElement createDefaultElement(); @@ -13,20 +12,17 @@ protected: std::unique_ptr<FixedBinAxis> m_z_positions; }; -DepthProbeElementTest::DepthProbeElementTest() : m_z_positions(new FixedBinAxis("z", 10, 0.0, 10.0)) -{ -} +DepthProbeElementTest::DepthProbeElementTest() + : m_z_positions(new FixedBinAxis("z", 10, 0.0, 10.0)) {} -DepthProbeElement DepthProbeElementTest::createDefaultElement() -{ +DepthProbeElement DepthProbeElementTest::createDefaultElement() { const double wavelength = 1.0; const double angle = 2.0; return DepthProbeElement(wavelength, angle, m_z_positions.get()); } void DepthProbeElementTest::compareEqualElements(const DepthProbeElement& lhs, - const DepthProbeElement& rhs) -{ + const DepthProbeElement& rhs) { EXPECT_EQ(lhs.getWavelength(), rhs.getWavelength()); EXPECT_EQ(lhs.getAlphaI(), rhs.getAlphaI()); bool intensity_comparison_result = (lhs.getIntensities() == rhs.getIntensities()).min(); @@ -35,8 +31,7 @@ void DepthProbeElementTest::compareEqualElements(const DepthProbeElement& lhs, EXPECT_EQ(lhs.isCalculated(), rhs.isCalculated()); } -TEST_F(DepthProbeElementTest, InitialState) -{ +TEST_F(DepthProbeElementTest, InitialState) { const double wavelength = 1.0; const double angle = 2.0; const double phi = 0.0; @@ -51,8 +46,7 @@ TEST_F(DepthProbeElementTest, InitialState) EXPECT_TRUE(element.isCalculated()); } -TEST_F(DepthProbeElementTest, CopyMoveAssign) -{ +TEST_F(DepthProbeElementTest, CopyMoveAssign) { auto element = createDefaultElement(); element.setCalculationFlag(false); diff --git a/Tests/UnitTests/Core/SimulationElement/PolarizationHandlerTest.cpp b/Tests/UnitTests/Core/SimulationElement/PolarizationHandlerTest.cpp index 5f3aea1b56d48e0ce46754f5c6e61effb8e50372..a2d82a077fe898a8e3e62ccf47cffb8a8ac033bc 100644 --- a/Tests/UnitTests/Core/SimulationElement/PolarizationHandlerTest.cpp +++ b/Tests/UnitTests/Core/SimulationElement/PolarizationHandlerTest.cpp @@ -1,8 +1,7 @@ #include "Base/Pixel/PolarizationHandler.h" #include "Tests/GTestWrapper/google_test.h" -class PolarizationHandlerTest : public ::testing::Test -{ +class PolarizationHandlerTest : public ::testing::Test { protected: PolarizationHandlerTest(); @@ -14,26 +13,21 @@ private: }; PolarizationHandlerTest::PolarizationHandlerTest() - : identity(Eigen::Matrix2cd::Identity()), test_matrix(testMatrix()) -{ -} + : identity(Eigen::Matrix2cd::Identity()), test_matrix(testMatrix()) {} -Eigen::Matrix2cd PolarizationHandlerTest::testMatrix() -{ +Eigen::Matrix2cd PolarizationHandlerTest::testMatrix() { Eigen::Matrix2cd result; result << 0, 1, 1, 0; return result; } -TEST_F(PolarizationHandlerTest, InitialState) -{ +TEST_F(PolarizationHandlerTest, InitialState) { PolarizationHandler handler; EXPECT_EQ(identity / 2.0, handler.getPolarization()); EXPECT_EQ(identity, handler.getAnalyzerOperator()); } -TEST_F(PolarizationHandlerTest, SettersGetters) -{ +TEST_F(PolarizationHandlerTest, SettersGetters) { PolarizationHandler handler; handler.setAnalyzerOperator(test_matrix); EXPECT_EQ(test_matrix, handler.getAnalyzerOperator()); @@ -41,8 +35,7 @@ TEST_F(PolarizationHandlerTest, SettersGetters) EXPECT_EQ(test_matrix, handler.getPolarization()); } -TEST_F(PolarizationHandlerTest, Swap) -{ +TEST_F(PolarizationHandlerTest, Swap) { PolarizationHandler handler; PolarizationHandler handler2; @@ -64,8 +57,7 @@ TEST_F(PolarizationHandlerTest, Swap) EXPECT_EQ(test_matrix, handler.getPolarization()); } -TEST_F(PolarizationHandlerTest, CopyMoveAssign) -{ +TEST_F(PolarizationHandlerTest, CopyMoveAssign) { PolarizationHandler handler; handler.setPolarization(test_matrix); diff --git a/Tests/UnitTests/Core/SimulationElement/SimulationElementTest.cpp b/Tests/UnitTests/Core/SimulationElement/SimulationElementTest.cpp index 202133f74d778fd5757e58a65d4d7f440e28747a..3987b77fcbdd8563b8e9c90f2ef662297d44e737 100644 --- a/Tests/UnitTests/Core/SimulationElement/SimulationElementTest.cpp +++ b/Tests/UnitTests/Core/SimulationElement/SimulationElementTest.cpp @@ -5,8 +5,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -namespace -{ +namespace { const Bin1D alpha_bin(0.0 * Units::deg, 1.0 * Units::deg); const Bin1D phi_bin(-0.5 * Units::deg, 0.5 * Units::deg); const double wavelength = 42.0; @@ -14,23 +13,19 @@ const double alpha_i = 0.2 * Units::deg; const double phi_i = 0.0 * Units::deg; } // namespace -class SimulationElementTest : public ::testing::Test -{ +class SimulationElementTest : public ::testing::Test { public: - std::unique_ptr<IPixel> createPixel() const - { + std::unique_ptr<IPixel> createPixel() const { return std::make_unique<SphericalPixel>(alpha_bin, phi_bin); } - std::unique_ptr<SimulationElement> createElement() const - { + std::unique_ptr<SimulationElement> createElement() const { return std::make_unique<SimulationElement>(wavelength, alpha_i, phi_i, createPixel(), Eigen::Matrix2cd{}, Eigen::Matrix2cd{}, false); } }; -TEST_F(SimulationElementTest, basicConstructor) -{ +TEST_F(SimulationElementTest, basicConstructor) { SimulationElement element(wavelength, alpha_i, phi_i, createPixel(), {}, {}, false); EXPECT_EQ(element.getWavelength(), wavelength); EXPECT_EQ(element.getAlphaI(), alpha_i); @@ -43,8 +38,7 @@ TEST_F(SimulationElementTest, basicConstructor) EXPECT_FALSE(element.isSpecular()); } -TEST_F(SimulationElementTest, setIntensity) -{ +TEST_F(SimulationElementTest, setIntensity) { auto element = createElement(); EXPECT_EQ(element->getIntensity(), 0.0); element->addIntensity(1.0); @@ -53,8 +47,7 @@ TEST_F(SimulationElementTest, setIntensity) EXPECT_EQ(element->getIntensity(), 42.0); } -TEST_F(SimulationElementTest, copyConstructor) -{ +TEST_F(SimulationElementTest, copyConstructor) { auto orig = createElement(); SimulationElement element(*orig); EXPECT_EQ(orig->getWavelength(), element.getWavelength()); @@ -73,8 +66,7 @@ TEST_F(SimulationElementTest, copyConstructor) EXPECT_EQ(orig->isSpecular(), element.isSpecular()); } -TEST_F(SimulationElementTest, moveConstruction) -{ +TEST_F(SimulationElementTest, moveConstruction) { SimulationElement for_move(1.0, 2.0, 3.0, createPixel(), {}, {}, false); SimulationElement orig(1.0, 2.0, 3.0, createPixel(), {}, {}, false); SimulationElement element(std::move(for_move)); diff --git a/Tests/UnitTests/GUI/Comparators.cpp b/Tests/UnitTests/GUI/Comparators.cpp index 053004986b9a784c9f91554ee5c02213b5dfa4aa..9a6c555d5f069aa1f941578a3701cd8186504dfa 100644 --- a/Tests/UnitTests/GUI/Comparators.cpp +++ b/Tests/UnitTests/GUI/Comparators.cpp @@ -5,14 +5,12 @@ bool Comparators::m_is_registered = false; -void Comparators::registerComparators() -{ +void Comparators::registerComparators() { QMetaType::registerComparators<ComboProperty>(); QMetaType::registerComparators<ExternalProperty>(); m_is_registered = true; } -bool Comparators::registered() -{ +bool Comparators::registered() { return m_is_registered; } diff --git a/Tests/UnitTests/GUI/Comparators.h b/Tests/UnitTests/GUI/Comparators.h index fce8cd0edf380533de8a6932a65c7b4027ff5c55..9ac194a7fedce4dcb1b120b4efaff691c5b069b1 100644 --- a/Tests/UnitTests/GUI/Comparators.h +++ b/Tests/UnitTests/GUI/Comparators.h @@ -4,8 +4,7 @@ //! Helper class to register custom variants comparators and to report //! unit tests if comparators should be tested. -class Comparators -{ +class Comparators { public: static void registerComparators(); static bool registered(); diff --git a/Tests/UnitTests/GUI/TestAxesItems.cpp b/Tests/UnitTests/GUI/TestAxesItems.cpp index b06a9882de4a43011f4d4372b4b1978ab91d859b..9952464baa05efbfb7cb73396654af00913a85ec 100644 --- a/Tests/UnitTests/GUI/TestAxesItems.cpp +++ b/Tests/UnitTests/GUI/TestAxesItems.cpp @@ -7,12 +7,9 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include "Tests/GTestWrapper/google_test.h" -class TestAxesItems : public ::testing::Test -{ -}; +class TestAxesItems : public ::testing::Test {}; -TEST_F(TestAxesItems, transformFromDomain) -{ +TEST_F(TestAxesItems, transformFromDomain) { BasicAxisItem item; // transform domain axis without scale factor diff --git a/Tests/UnitTests/GUI/TestComboProperty.cpp b/Tests/UnitTests/GUI/TestComboProperty.cpp index 1f68070ad118494c4311cc838d744175b2de27a6..b3857229cc93b1fd5ff00a0c439f746a0b1006f8 100644 --- a/Tests/UnitTests/GUI/TestComboProperty.cpp +++ b/Tests/UnitTests/GUI/TestComboProperty.cpp @@ -3,17 +3,14 @@ #include "Tests/UnitTests/GUI/Comparators.h" #include "Tests/UnitTests/GUI/Utils.h" -class TestComboProperty : public ::testing::Test -{ +class TestComboProperty : public ::testing::Test { public: - ComboProperty propertyFromXML(const QString& buffer) - { + ComboProperty propertyFromXML(const QString& buffer) { return GuiUnittestUtils::propertyFromXML<ComboProperty>(buffer); } }; -TEST_F(TestComboProperty, initialState) -{ +TEST_F(TestComboProperty, initialState) { ComboProperty combo; EXPECT_EQ(combo.getValue(), ""); EXPECT_EQ(combo.getValues(), QStringList()); @@ -23,8 +20,7 @@ TEST_F(TestComboProperty, initialState) EXPECT_EQ(combo.selectedIndices(), QVector<int>()); } -TEST_F(TestComboProperty, factoryMethods) -{ +TEST_F(TestComboProperty, factoryMethods) { // initialization from list sets values only, no index selected QStringList expected = QStringList() << "a1" << "a2"; @@ -35,8 +31,7 @@ TEST_F(TestComboProperty, factoryMethods) EXPECT_EQ(combo.selectedIndices(), QVector<int>()); } -TEST_F(TestComboProperty, setValues) -{ +TEST_F(TestComboProperty, setValues) { // seting values through stream QStringList expectedValues = QStringList() << "a1" << "a2"; @@ -67,8 +62,7 @@ TEST_F(TestComboProperty, setValues) EXPECT_EQ(combo.selectedIndices(), QVector<int>({1})); } -TEST_F(TestComboProperty, setCurrentIndex) -{ +TEST_F(TestComboProperty, setCurrentIndex) { ComboProperty combo; EXPECT_EQ(combo.currentIndex(), -1); @@ -86,8 +80,7 @@ TEST_F(TestComboProperty, setCurrentIndex) EXPECT_EQ(combo.selectedIndices(), QVector<int>({0})); } -TEST_F(TestComboProperty, stringOfValues) -{ +TEST_F(TestComboProperty, stringOfValues) { QStringList expectedValues = QStringList() << "a1" << "a2"; ComboProperty combo = ComboProperty() << expectedValues; @@ -114,8 +107,7 @@ TEST_F(TestComboProperty, stringOfValues) EXPECT_EQ(combo.selectedIndices(), QVector<int>({1})); } -TEST_F(TestComboProperty, selectedIndices) -{ +TEST_F(TestComboProperty, selectedIndices) { QStringList expectedValues = QStringList() << "a1" << "a2" << "a3"; @@ -157,8 +149,7 @@ TEST_F(TestComboProperty, selectedIndices) EXPECT_EQ(combo.selectedValues(), QStringList({"a1", "a3"})); } -TEST_F(TestComboProperty, stringOfSelections) -{ +TEST_F(TestComboProperty, stringOfSelections) { ComboProperty combo; EXPECT_EQ(combo.stringOfSelections(), ""); @@ -190,8 +181,7 @@ TEST_F(TestComboProperty, stringOfSelections) EXPECT_EQ(combo.stringOfSelections(), "0"); } -TEST_F(TestComboProperty, comboEquality) -{ +TEST_F(TestComboProperty, comboEquality) { ComboProperty c1; ComboProperty c2; EXPECT_TRUE(c1 == c2); @@ -236,8 +226,7 @@ TEST_F(TestComboProperty, comboEquality) //! Check equality of ComboPeroperty's variants. //! If comparators are not registered, the behavior is undefined. -TEST_F(TestComboProperty, variantEquality) -{ +TEST_F(TestComboProperty, variantEquality) { ComboProperty c1 = ComboProperty() << "a1" << "a2"; ComboProperty c2 = ComboProperty() << "a1" @@ -265,8 +254,7 @@ TEST_F(TestComboProperty, variantEquality) } } -TEST_F(TestComboProperty, comboXML) -{ +TEST_F(TestComboProperty, comboXML) { // Writing combo to XML ComboProperty combo = ComboProperty() << "a1" << "a2" diff --git a/Tests/UnitTests/GUI/TestComponentProxyModel.cpp b/Tests/UnitTests/GUI/TestComponentProxyModel.cpp index 09a7f550270d63d814ef24c65bf4b3eff4cbc993..23afef97b8e14021dfe587c5169a6d8f4d2f33cd 100644 --- a/Tests/UnitTests/GUI/TestComponentProxyModel.cpp +++ b/Tests/UnitTests/GUI/TestComponentProxyModel.cpp @@ -12,14 +12,11 @@ #include <QDebug> #include <QSignalSpy> -class TestComponentProxyModel : public ::testing::Test -{ -}; +class TestComponentProxyModel : public ::testing::Test {}; //! Empty proxy model. -TEST_F(TestComponentProxyModel, test_emptyModel) -{ +TEST_F(TestComponentProxyModel, test_emptyModel) { ComponentProxyModel proxy; EXPECT_EQ(proxy.rowCount(QModelIndex()), 0); EXPECT_EQ(proxy.columnCount(QModelIndex()), static_cast<int>(SessionFlags::MAX_COLUMNS)); @@ -28,8 +25,7 @@ TEST_F(TestComponentProxyModel, test_emptyModel) //! Set empty model to proxy. -TEST_F(TestComponentProxyModel, test_setModel) -{ +TEST_F(TestComponentProxyModel, test_setModel) { SessionModel model("TestModel"); ComponentProxyModel proxy; @@ -44,8 +40,7 @@ TEST_F(TestComponentProxyModel, test_setModel) //! Set model to proxy. Model already contains simple item. -TEST_F(TestComponentProxyModel, test_setModelWithItem) -{ +TEST_F(TestComponentProxyModel, test_setModelWithItem) { SessionModel model("TestModel"); model.insertNewItem("Property"); @@ -60,8 +55,7 @@ TEST_F(TestComponentProxyModel, test_setModelWithItem) //! Set model to proxy. Model already contains VectorItem. -TEST_F(TestComponentProxyModel, test_setModelWithVector) -{ +TEST_F(TestComponentProxyModel, test_setModelWithVector) { const int ncols = static_cast<int>(SessionFlags::MAX_COLUMNS); SessionModel model("TestModel"); @@ -153,8 +147,7 @@ TEST_F(TestComponentProxyModel, test_setModelWithVector) //! Set model to proxy. Model already contains two PropertyItems. Checking data() method. -TEST_F(TestComponentProxyModel, test_displayRole) -{ +TEST_F(TestComponentProxyModel, test_displayRole) { SessionModel model("TestModel"); SessionItem* item1 = model.insertNewItem("Property"); item1->setValue(1.0); @@ -173,8 +166,7 @@ TEST_F(TestComponentProxyModel, test_displayRole) //! Set model with item to proxy. Changing the data on source and checking change propagation. -TEST_F(TestComponentProxyModel, test_setData) -{ +TEST_F(TestComponentProxyModel, test_setData) { SessionModel model("TestModel"); SessionItem* item = model.insertNewItem("Property"); item->setValue(1.0); @@ -214,8 +206,7 @@ TEST_F(TestComponentProxyModel, test_setData) //! Checks norification of proxy model then source inserts rows. -TEST_F(TestComponentProxyModel, test_insertRows) -{ +TEST_F(TestComponentProxyModel, test_insertRows) { SessionModel model("TestModel"); ComponentProxyModel proxy; @@ -235,8 +226,7 @@ TEST_F(TestComponentProxyModel, test_insertRows) //! Checking the mapping of ComponentProxyStrategy in the case of ParticleItem inserted in //! the source. -TEST_F(TestComponentProxyModel, test_componentStrategy) -{ +TEST_F(TestComponentProxyModel, test_componentStrategy) { SessionModel model("TestModel"); ComponentProxyModel proxy; @@ -280,8 +270,7 @@ TEST_F(TestComponentProxyModel, test_componentStrategy) //! the source. We are changing Particle's form factor back and forth and checking for change //! in GroupProperty. -TEST_F(TestComponentProxyModel, test_componentStrategyFormFactorChanges) -{ +TEST_F(TestComponentProxyModel, test_componentStrategyFormFactorChanges) { SessionModel model("TestModel"); ComponentProxyModel proxy; @@ -312,8 +301,7 @@ TEST_F(TestComponentProxyModel, test_componentStrategyFormFactorChanges) //! Checking setRootIndex: proxy model should contain only items corresponding //! to rootIndex and its children. Adding simple PropertyItem. -TEST_F(TestComponentProxyModel, test_setRootPropertyItem) -{ +TEST_F(TestComponentProxyModel, test_setRootPropertyItem) { const int ncols = static_cast<int>(SessionFlags::MAX_COLUMNS); SessionModel model("TestModel"); @@ -349,8 +337,7 @@ TEST_F(TestComponentProxyModel, test_setRootPropertyItem) //! to rootIndex and its children. Adding MultiLayer with two layers and setting rootIndex //! to one of the layer. -TEST_F(TestComponentProxyModel, test_setRootIndexLayer) -{ +TEST_F(TestComponentProxyModel, test_setRootIndexLayer) { SessionModel model("TestModel"); diff --git a/Tests/UnitTests/GUI/TestComponentUtils.cpp b/Tests/UnitTests/GUI/TestComponentUtils.cpp index 8f2dfb0c0fe5583f828ab3f027bf65b590fe708f..6312ada316278c1adf0d416b6cc39fb46b68cb1b 100644 --- a/Tests/UnitTests/GUI/TestComponentUtils.cpp +++ b/Tests/UnitTests/GUI/TestComponentUtils.cpp @@ -5,14 +5,11 @@ #include "Tests/GTestWrapper/google_test.h" #include <QDebug> -class TestComponentUtils : public ::testing::Test -{ -}; +class TestComponentUtils : public ::testing::Test {}; //! Testing component items of particle item. -TEST_F(TestComponentUtils, test_componentItems) -{ +TEST_F(TestComponentUtils, test_componentItems) { SessionModel model("TestModel"); SessionItem* particle = model.insertNewItem("Particle"); @@ -31,8 +28,7 @@ TEST_F(TestComponentUtils, test_componentItems) EXPECT_EQ(itemList, expectedList); } -TEST_F(TestComponentUtils, test_componentItemsFFChange) -{ +TEST_F(TestComponentUtils, test_componentItemsFFChange) { SessionModel model("TestModel"); SessionItem* particle = model.insertNewItem("Particle"); diff --git a/Tests/UnitTests/GUI/TestCsvImportAssistant.cpp b/Tests/UnitTests/GUI/TestCsvImportAssistant.cpp index 0799e7c9d3c858f5820f3ad64f6c2f9c28547f2a..a9b50e52221334c47b3afb85301e56d5b00c4f60 100644 --- a/Tests/UnitTests/GUI/TestCsvImportAssistant.cpp +++ b/Tests/UnitTests/GUI/TestCsvImportAssistant.cpp @@ -8,8 +8,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <vector> -class TestCsvImportAssistant : public ::testing::Test -{ +class TestCsvImportAssistant : public ::testing::Test { protected: const std::string m_testFilename = "tm_TestCsvImportAssistant.txt"; const std::vector<std::vector<double>> m_testVector = { @@ -18,16 +17,14 @@ protected: const QString testFilename() { return QString::fromStdString(m_testFilename); } - void writeTestFile() - { + void writeTestFile() { remove(m_testFilename.c_str()); OutputDataWriter* writer = OutputDataWriteFactory::getWriter(m_testFilename); OutputData<double>* data = ArrayUtils::createData(m_testVector).release(); writer->writeOutputData(*data); } - void writeTestFile(size_t nRows, size_t nCols) - { + void writeTestFile(size_t nRows, size_t nCols) { remove(m_testFilename.c_str()); std::ofstream myfile; myfile.open(m_testFilename); @@ -40,8 +37,7 @@ protected: myfile.close(); } - OutputData<double>* readTestFile() - { + OutputData<double>* readTestFile() { OutputDataReader* reader = OutputDataReadFactory::getReader(m_testFilename); OutputData<double>* data = reader->getOutputData(); return data; @@ -49,8 +45,7 @@ protected: }; //! Testing component items of particle item. -TEST_F(TestCsvImportAssistant, test_readFile) -{ +TEST_F(TestCsvImportAssistant, test_readFile) { /* * The file to read looks like this ['-' symbols added to clarify what is going on]. * It has originaly ten columns, not four (The separator is a space). diff --git a/Tests/UnitTests/GUI/TestCsvImportData.cpp b/Tests/UnitTests/GUI/TestCsvImportData.cpp index 700aca046c1cb6efe88445e5aafcc3248b42b5ff..1aebd15c00c779209522747559b1a623ad1e4a7d 100644 --- a/Tests/UnitTests/GUI/TestCsvImportData.cpp +++ b/Tests/UnitTests/GUI/TestCsvImportData.cpp @@ -1,12 +1,9 @@ #include "GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h" #include "Tests/GTestWrapper/google_test.h" -class TestCsvImportData : public ::testing::Test -{ -}; +class TestCsvImportData : public ::testing::Test {}; -TEST_F(TestCsvImportData, test_setting_data) -{ +TEST_F(TestCsvImportData, test_setting_data) { csv::DataArray test_data{{"1.0", "2.0"}, {"3.0", "4.0"}, {"5.0", "6.0"}}; CsvImportData model; @@ -25,8 +22,7 @@ TEST_F(TestCsvImportData, test_setting_data) EXPECT_EQ(model.nCols(), 0u); } -TEST_F(TestCsvImportData, test_data_columns) -{ +TEST_F(TestCsvImportData, test_data_columns) { CsvImportData model; EXPECT_EQ(model.column(CsvImportData::Intensity), -1); EXPECT_EQ(model.column(CsvImportData::Coordinate), -1); @@ -72,8 +68,7 @@ TEST_F(TestCsvImportData, test_data_columns) EXPECT_EQ(model.values(1), result1); } -TEST_F(TestCsvImportData, test_multpiliers) -{ +TEST_F(TestCsvImportData, test_multpiliers) { CsvImportData model; EXPECT_EQ(model.multiplier(CsvImportData::Intensity), 1.0); EXPECT_EQ(model.multiplier(CsvImportData::Coordinate), 1.0); @@ -98,8 +93,7 @@ TEST_F(TestCsvImportData, test_multpiliers) EXPECT_EQ(result[2], "12"); } -TEST_F(TestCsvImportData, test_labels) -{ +TEST_F(TestCsvImportData, test_labels) { CsvImportData model; EXPECT_EQ(model.columnLabel(CsvImportData::Intensity), QString()); EXPECT_EQ(model.columnLabel(CsvImportData::Coordinate), QString()); @@ -124,8 +118,7 @@ TEST_F(TestCsvImportData, test_labels) EXPECT_EQ(model.columnLabel(CsvImportData::Coordinate).toStdString(), std::string()); } -TEST_F(TestCsvImportData, test_format_check) -{ +TEST_F(TestCsvImportData, test_format_check) { CsvImportData model; EXPECT_TRUE(model.checkData().empty()); diff --git a/Tests/UnitTests/GUI/TestDataItemViews.cpp b/Tests/UnitTests/GUI/TestDataItemViews.cpp index 6f43f29d634826044da54d1a54dced4673dee508..898f59d6437ca253fa8f8910fc229eebd9048574 100644 --- a/Tests/UnitTests/GUI/TestDataItemViews.cpp +++ b/Tests/UnitTests/GUI/TestDataItemViews.cpp @@ -10,22 +10,19 @@ #include "Tests/GTestWrapper/google_test.h" #include "Tests/UnitTests/GUI/Utils.h" -class TestDataItemViews : public ::testing::Test -{ +class TestDataItemViews : public ::testing::Test { public: DataItem* insertNewDataItem(SessionModel& model, double val); }; -DataItem* TestDataItemViews::insertNewDataItem(SessionModel& model, double val) -{ +DataItem* TestDataItemViews::insertNewDataItem(SessionModel& model, double val) { DataItem* item = dynamic_cast<DataItem*>(model.insertNewItem("SpecularData")); auto data = GuiUnittestUtils::createData(val, GuiUnittestUtils::DIM::D1); item->setOutputData(data.release()); return item; } -TEST_F(TestDataItemViews, testDataLinking) -{ +TEST_F(TestDataItemViews, testDataLinking) { SessionModel model("TempModel"); auto view_item = dynamic_cast<DataPropertyContainer*>(model.insertNewItem("DataPropertyContainer")); @@ -37,8 +34,7 @@ TEST_F(TestDataItemViews, testDataLinking) EXPECT_EQ(stored_items[0]->dataItem(), item); } -TEST_F(TestDataItemViews, testLinkingSeveralItems) -{ +TEST_F(TestDataItemViews, testLinkingSeveralItems) { SessionModel model("TempModel"); auto view_item = dynamic_cast<DataPropertyContainer*>(model.insertNewItem("DataPropertyContainer")); @@ -56,8 +52,7 @@ TEST_F(TestDataItemViews, testLinkingSeveralItems) EXPECT_EQ(stored_items[2]->dataItem(), item3); } -TEST_F(TestDataItemViews, testColors) -{ +TEST_F(TestDataItemViews, testColors) { SessionModel model("TempModel"); auto view_item = dynamic_cast<DataPropertyContainer*>(model.insertNewItem("DataPropertyContainer")); @@ -93,8 +88,7 @@ TEST_F(TestDataItemViews, testColors) EXPECT_EQ(getColorName(stored_items[6]), "Black"); } -TEST_F(TestDataItemViews, testBrokenLink) -{ +TEST_F(TestDataItemViews, testBrokenLink) { SessionModel model("TempModel"); auto view_item = dynamic_cast<DataPropertyContainer*>(model.insertNewItem("DataPropertyContainer")); @@ -110,8 +104,7 @@ TEST_F(TestDataItemViews, testBrokenLink) EXPECT_THROW(view_item->propertyItem(0)->dataItem(), GUIHelpers::Error); } -TEST_F(TestDataItemViews, testWrongHostingModel) -{ +TEST_F(TestDataItemViews, testWrongHostingModel) { SessionModel model("TempModel"); DataItem* item = insertNewDataItem(model, 0.0); auto view_item = @@ -127,8 +120,7 @@ TEST_F(TestDataItemViews, testWrongHostingModel) EXPECT_EQ(stored_items[0]->dataItem(), item); } -TEST_F(TestDataItemViews, testSavingLinkedData) -{ +TEST_F(TestDataItemViews, testSavingLinkedData) { const QString projectDir("test_savingLinkedData"); GuiUnittestUtils::create_dir(projectDir); const QString projectFileName(projectDir + "/document.pro"); diff --git a/Tests/UnitTests/GUI/TestDataItems.cpp b/Tests/UnitTests/GUI/TestDataItems.cpp index 8b977ca14fd65180511ef36c912150a38b79c2f9..490aaa8af4b5418d75c4d7469e3bb7f2750451e0 100644 --- a/Tests/UnitTests/GUI/TestDataItems.cpp +++ b/Tests/UnitTests/GUI/TestDataItems.cpp @@ -3,14 +3,12 @@ #include "Tests/GTestWrapper/google_test.h" #include <QTest> -class TestDataItems : public ::testing::Test -{ +class TestDataItems : public ::testing::Test { public: void testItemClock(QString type); }; -void TestDataItems::testItemClock(QString model_type) -{ +void TestDataItems::testItemClock(QString model_type) { SessionModel model("TempModel"); DataItem* item = dynamic_cast<DataItem*>(model.insertNewItem(model_type)); @@ -34,12 +32,10 @@ void TestDataItems::testItemClock(QString model_type) EXPECT_TRUE(time2.msecsTo(time3) > nap_time / 2); } -TEST_F(TestDataItems, testSpecularItemClock) -{ +TEST_F(TestDataItems, testSpecularItemClock) { testItemClock("SpecularData"); } -TEST_F(TestDataItems, testIntensityItemClock) -{ +TEST_F(TestDataItems, testIntensityItemClock) { testItemClock("IntensityData"); } diff --git a/Tests/UnitTests/GUI/TestDetectorItems.cpp b/Tests/UnitTests/GUI/TestDetectorItems.cpp index d1a2155fe8d01aa6fbedfb348891016d1efe3613..29b7aa9566cbd907394ed5c769d93d56b3af1a15 100644 --- a/Tests/UnitTests/GUI/TestDetectorItems.cpp +++ b/Tests/UnitTests/GUI/TestDetectorItems.cpp @@ -8,12 +8,9 @@ #include "GUI/coregui/Models/RectangularDetectorItem.h" #include "Tests/GTestWrapper/google_test.h" -class TestDetectorItems : public ::testing::Test -{ -}; +class TestDetectorItems : public ::testing::Test {}; -TEST_F(TestDetectorItems, test_detectorAlignment) -{ +TEST_F(TestDetectorItems, test_detectorAlignment) { InstrumentModel model; SessionItem* detector = model.insertNewItem("RectangularDetector"); @@ -32,8 +29,7 @@ TEST_F(TestDetectorItems, test_detectorAlignment) EXPECT_FALSE(detector->getItem(RectangularDetectorItem::P_NORMAL)->isVisible()); } -TEST_F(TestDetectorItems, test_resolutionFunction) -{ +TEST_F(TestDetectorItems, test_resolutionFunction) { InstrumentModel model; GISASInstrumentItem* instrument = dynamic_cast<GISASInstrumentItem*>(model.insertNewItem("GISASInstrument")); diff --git a/Tests/UnitTests/GUI/TestExternalProperty.cpp b/Tests/UnitTests/GUI/TestExternalProperty.cpp index f9b3133261342d5c68613d85783ecf6d7e87147a..f3798a8d17660ef4860ae39d3eca9e6815fc44dd 100644 --- a/Tests/UnitTests/GUI/TestExternalProperty.cpp +++ b/Tests/UnitTests/GUI/TestExternalProperty.cpp @@ -3,17 +3,14 @@ #include "Tests/UnitTests/GUI/Comparators.h" #include "Tests/UnitTests/GUI/Utils.h" -class TestExternalProperty : public ::testing::Test -{ +class TestExternalProperty : public ::testing::Test { public: - ExternalProperty propertyFromXML(const QString& buffer) - { + ExternalProperty propertyFromXML(const QString& buffer) { return GuiUnittestUtils::propertyFromXML<ExternalProperty>(buffer); } }; -TEST_F(TestExternalProperty, test_initialState) -{ +TEST_F(TestExternalProperty, test_initialState) { ExternalProperty property; EXPECT_FALSE(property.isValid()); EXPECT_FALSE(property.color().isValid()); @@ -35,8 +32,7 @@ TEST_F(TestExternalProperty, test_initialState) //! Testing equality operators. -TEST_F(TestExternalProperty, test_equalityOperators) -{ +TEST_F(TestExternalProperty, test_equalityOperators) { ExternalProperty prop1; ExternalProperty prop2; @@ -55,8 +51,7 @@ TEST_F(TestExternalProperty, test_equalityOperators) //! Testing equality operators for QVariants based on ExternalProperty. //! If comparators are not registered, the behavior is undefined -TEST_F(TestExternalProperty, test_variantEquality) -{ +TEST_F(TestExternalProperty, test_variantEquality) { ExternalProperty prop1; ExternalProperty prop2; @@ -73,8 +68,7 @@ TEST_F(TestExternalProperty, test_variantEquality) } } -TEST_F(TestExternalProperty, test_toXML) -{ +TEST_F(TestExternalProperty, test_toXML) { QString expected; // empty property to XML diff --git a/Tests/UnitTests/GUI/TestFTDistributionItems.cpp b/Tests/UnitTests/GUI/TestFTDistributionItems.cpp index fd2eb0b838234934fb6e81825a019a6fd2ec754a..818f533cadfefbb7125b03fc1f3a6724b8d8b635 100644 --- a/Tests/UnitTests/GUI/TestFTDistributionItems.cpp +++ b/Tests/UnitTests/GUI/TestFTDistributionItems.cpp @@ -1,12 +1,9 @@ #include "GUI/coregui/Models/FTDistributionItems.h" #include "Tests/GTestWrapper/google_test.h" -class TestFTDistributionItems : public ::testing::Test -{ -}; +class TestFTDistributionItems : public ::testing::Test {}; -TEST_F(TestFTDistributionItems, test_FTDistribution1DCauchy) -{ +TEST_F(TestFTDistributionItems, test_FTDistribution1DCauchy) { // to domain FTDistribution1DCauchyItem item; item.setItemValue(FTDistribution1DItem::P_OMEGA, 2.0); diff --git a/Tests/UnitTests/GUI/TestFitParameterModel.cpp b/Tests/UnitTests/GUI/TestFitParameterModel.cpp index 0fdd9445b78859c221928b7200ac4de686b0d39b..550076389eaefb4810bab2f7d73065ad00cf645e 100644 --- a/Tests/UnitTests/GUI/TestFitParameterModel.cpp +++ b/Tests/UnitTests/GUI/TestFitParameterModel.cpp @@ -4,12 +4,9 @@ #include "GUI/coregui/Models/JobModel.h" #include "Tests/GTestWrapper/google_test.h" -class TestFitParameterModel : public ::testing::Test -{ -}; +class TestFitParameterModel : public ::testing::Test {}; -TEST_F(TestFitParameterModel, test_InitialState) -{ +TEST_F(TestFitParameterModel, test_InitialState) { JobModel source; SessionItem* fitSuiteItem = source.insertNewItem("FitSuite"); SessionItem* container = source.insertNewItem("FitParameterContainer", fitSuiteItem->index(), @@ -22,8 +19,7 @@ TEST_F(TestFitParameterModel, test_InitialState) EXPECT_EQ(container, proxy.itemForIndex(QModelIndex())); } -TEST_F(TestFitParameterModel, test_addFitParameter) -{ +TEST_F(TestFitParameterModel, test_addFitParameter) { JobModel source; SessionItem* fitSuiteItem = source.insertNewItem("FitSuite"); SessionItem* container = source.insertNewItem("FitParameterContainer", fitSuiteItem->index(), @@ -126,8 +122,7 @@ TEST_F(TestFitParameterModel, test_addFitParameter) EXPECT_EQ(index, proxy.indexOfItem(fitPar1->getItem(FitParameterItem::P_START_VALUE))); } -TEST_F(TestFitParameterModel, test_addFitParameterAndLink) -{ +TEST_F(TestFitParameterModel, test_addFitParameterAndLink) { JobModel source; SessionItem* fitSuiteItem = source.insertNewItem("FitSuite"); SessionItem* container = source.insertNewItem("FitParameterContainer", fitSuiteItem->index(), @@ -189,8 +184,7 @@ TEST_F(TestFitParameterModel, test_addFitParameterAndLink) EXPECT_EQ(proxy.itemForIndex(linkIndex), link1->getItem(FitParameterLinkItem::P_LINK)); } -TEST_F(TestFitParameterModel, test_addTwoFitParameterAndLinks) -{ +TEST_F(TestFitParameterModel, test_addTwoFitParameterAndLinks) { JobModel source; SessionItem* fitSuiteItem = source.insertNewItem("FitSuite"); SessionItem* container = source.insertNewItem("FitParameterContainer", fitSuiteItem->index(), diff --git a/Tests/UnitTests/GUI/TestFormFactorItems.cpp b/Tests/UnitTests/GUI/TestFormFactorItems.cpp index 3caf55bac263eddbaa92d1d5d0f98aa9f98adc02..d62ea78251bcd9cf4f055295a6f9d69a67a2ad0e 100644 --- a/Tests/UnitTests/GUI/TestFormFactorItems.cpp +++ b/Tests/UnitTests/GUI/TestFormFactorItems.cpp @@ -4,12 +4,9 @@ #include "Sample/HardParticle/FormFactorAnisoPyramid.h" #include "Tests/GTestWrapper/google_test.h" -class TestFormFactorItems : public ::testing::Test -{ -}; +class TestFormFactorItems : public ::testing::Test {}; -TEST_F(TestFormFactorItems, test_AnisoPyramidItem) -{ +TEST_F(TestFormFactorItems, test_AnisoPyramidItem) { // to domain AnisoPyramidItem item; item.setItemValue(AnisoPyramidItem::P_LENGTH, 20.0); diff --git a/Tests/UnitTests/GUI/TestGUI.cpp b/Tests/UnitTests/GUI/TestGUI.cpp index 758ffbef2a4314feab2b711150b0adbccf73e7c3..db3d11a7547af5615c48a48ded665c17dc180cb6 100644 --- a/Tests/UnitTests/GUI/TestGUI.cpp +++ b/Tests/UnitTests/GUI/TestGUI.cpp @@ -3,8 +3,7 @@ #include <QAbstractItemModel> #include <QCoreApplication> -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { QCoreApplication app(argc, argv); Q_UNUSED(app); diff --git a/Tests/UnitTests/GUI/TestGUICoreObjectCorrespondence.cpp b/Tests/UnitTests/GUI/TestGUICoreObjectCorrespondence.cpp index cbccf1f51b80183081de02164f0a934b6536e40c..d10319e51b91b4d6fd06ec27381f3e8c12a72749 100644 --- a/Tests/UnitTests/GUI/TestGUICoreObjectCorrespondence.cpp +++ b/Tests/UnitTests/GUI/TestGUICoreObjectCorrespondence.cpp @@ -6,12 +6,10 @@ #include "Sample/HardParticle/HardParticles.h" #include "Tests/GTestWrapper/google_test.h" -class TestGUICoreObjectCorrespondence : public ::testing::Test -{ +class TestGUICoreObjectCorrespondence : public ::testing::Test { public: void GUICoreObjectCorrespondence(const SessionItem& gui_object, - const IParameterized& core_object) - { + const IParameterized& core_object) { // First check if names correspond: EXPECT_EQ(gui_object.displayName(), QString::fromStdString(core_object.getName())); @@ -23,169 +21,145 @@ public: } }; -TEST_F(TestGUICoreObjectCorrespondence, test_AnisoPyramid) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_AnisoPyramid) { AnisoPyramidItem gui_anisopyramid; FormFactorAnisoPyramid core_anisopyramid(1.0, 2.0, 0.1, 45.0 * Units::deg); GUICoreObjectCorrespondence(gui_anisopyramid, core_anisopyramid); } -TEST_F(TestGUICoreObjectCorrespondence, test_Box) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Box) { BoxItem gui_box; FormFactorBox core_box(1.0, 1.5, 3.0); GUICoreObjectCorrespondence(gui_box, core_box); } -TEST_F(TestGUICoreObjectCorrespondence, test_Cone) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Cone) { ConeItem gui_cone; FormFactorCone core_cone(1.0, 0.2, 45.0 * Units::deg); GUICoreObjectCorrespondence(gui_cone, core_cone); } -TEST_F(TestGUICoreObjectCorrespondence, test_Cone6) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Cone6) { Cone6Item gui_cone6; FormFactorCone6 core_cone6(1.0, 0.2, 45.0 * Units::deg); GUICoreObjectCorrespondence(gui_cone6, core_cone6); } -TEST_F(TestGUICoreObjectCorrespondence, test_Cuboctahedron) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Cuboctahedron) { CuboctahedronItem gui_cuboctahedron; FormFactorCuboctahedron core_cuboctahedron(1.0, 0.4, 1.0, 45.0 * Units::deg); GUICoreObjectCorrespondence(gui_cuboctahedron, core_cuboctahedron); } -TEST_F(TestGUICoreObjectCorrespondence, test_Cylinder) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Cylinder) { CylinderItem gui_cylinder; FormFactorCylinder core_cylinder(1.0, 3.0); GUICoreObjectCorrespondence(gui_cylinder, core_cylinder); } -TEST_F(TestGUICoreObjectCorrespondence, test_Dodecahedron) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Dodecahedron) { DodecahedronItem gui_dodecahedron; FormFactorDodecahedron core_dodecahedron(3.0); GUICoreObjectCorrespondence(gui_dodecahedron, core_dodecahedron); } -TEST_F(TestGUICoreObjectCorrespondence, test_Dot) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Dot) { DotItem gui_dot; FormFactorDot core_dot(5.0); GUICoreObjectCorrespondence(gui_dot, core_dot); } -TEST_F(TestGUICoreObjectCorrespondence, test_EllipsoidalCylinder) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_EllipsoidalCylinder) { EllipsoidalCylinderItem gui_ellcylinder; FormFactorEllipsoidalCylinder core_ellcylinder(2.0, 1.0, 1.0); GUICoreObjectCorrespondence(gui_ellcylinder, core_ellcylinder); } -TEST_F(TestGUICoreObjectCorrespondence, test_FullSphere) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_FullSphere) { FullSphereItem gui_sphere; FormFactorFullSphere core_sphere(1.0); GUICoreObjectCorrespondence(gui_sphere, core_sphere); } -TEST_F(TestGUICoreObjectCorrespondence, test_FullSpheroid) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_FullSpheroid) { FullSpheroidItem gui_spheroid; FormFactorFullSpheroid core_spheroid(1.0, 2.0); GUICoreObjectCorrespondence(gui_spheroid, core_spheroid); } -TEST_F(TestGUICoreObjectCorrespondence, test_HemiEllipsoid) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_HemiEllipsoid) { HemiEllipsoidItem gui_hemiellipsoid; FormFactorHemiEllipsoid core_hemiellipsoid(2.0, 1.0, 0.5); GUICoreObjectCorrespondence(gui_hemiellipsoid, core_hemiellipsoid); } -TEST_F(TestGUICoreObjectCorrespondence, test_Icosahedron) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Icosahedron) { IcosahedronItem gui_icosahedron; FormFactorIcosahedron core_icosahedron(8.0); GUICoreObjectCorrespondence(gui_icosahedron, core_icosahedron); } -TEST_F(TestGUICoreObjectCorrespondence, test_Prism3) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Prism3) { Prism3Item gui_prism3; FormFactorPrism3 core_prism3(1.0, 2.0); GUICoreObjectCorrespondence(gui_prism3, core_prism3); } -TEST_F(TestGUICoreObjectCorrespondence, test_Prism6) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Prism6) { Prism6Item gui_prism6; FormFactorPrism6 core_prism6(1.0, 2.0); GUICoreObjectCorrespondence(gui_prism6, core_prism6); } -TEST_F(TestGUICoreObjectCorrespondence, test_Pyramid) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Pyramid) { PyramidItem gui_pyramid; FormFactorPyramid core_pyramid(1.0, 0.2, 45.0 * Units::deg); GUICoreObjectCorrespondence(gui_pyramid, core_pyramid); } -TEST_F(TestGUICoreObjectCorrespondence, test_CosineRippleBox) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_CosineRippleBox) { CosineRippleBoxItem gui_ripple1; FormFactorCosineRippleBox core_ripple1(10.0, 2.0, 1.0); GUICoreObjectCorrespondence(gui_ripple1, core_ripple1); } -TEST_F(TestGUICoreObjectCorrespondence, test_SawtoothRippleBox) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_SawtoothRippleBox) { SawtoothRippleBoxItem gui_ripple2; FormFactorSawtoothRippleBox core_ripple2(10.0, 2.0, 1.0, 0.1); GUICoreObjectCorrespondence(gui_ripple2, core_ripple2); } -TEST_F(TestGUICoreObjectCorrespondence, test_Tetrahedron) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_Tetrahedron) { TetrahedronItem gui_tetrahedron; FormFactorTetrahedron core_tetrahedron(1.0, 0.1, 45.0 * Units::deg); GUICoreObjectCorrespondence(gui_tetrahedron, core_tetrahedron); } -TEST_F(TestGUICoreObjectCorrespondence, test_TruncatedCube) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_TruncatedCube) { TruncatedCubeItem gui_trunccube; FormFactorTruncatedCube core_trunccube(2.0, 0.2); GUICoreObjectCorrespondence(gui_trunccube, core_trunccube); } -TEST_F(TestGUICoreObjectCorrespondence, test_TruncatedSphere) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_TruncatedSphere) { TruncatedSphereItem gui_truncsphere; FormFactorTruncatedSphere core_truncsphere(1.0, 0.5, 0); GUICoreObjectCorrespondence(gui_truncsphere, core_truncsphere); } -TEST_F(TestGUICoreObjectCorrespondence, test_TruncatedSpheroid) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_TruncatedSpheroid) { TruncatedSpheroidItem gui_truncspheroid; FormFactorTruncatedSpheroid core_truncspheroid(1.0, 1.5, 1.5, 0); GUICoreObjectCorrespondence(gui_truncspheroid, core_truncspheroid); } -TEST_F(TestGUICoreObjectCorrespondence, test_RadialParacrystal) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_RadialParacrystal) { InterferenceFunctionRadialParaCrystalItem gui_radialparacrystal; InterferenceFunctionRadialParaCrystal core_radialparacrystal(10.0, 1e-6); GUICoreObjectCorrespondence(gui_radialparacrystal, core_radialparacrystal); } -TEST_F(TestGUICoreObjectCorrespondence, test_1DLattice) -{ +TEST_F(TestGUICoreObjectCorrespondence, test_1DLattice) { InterferenceFunction1DLatticeItem gui_1d_lattice; InterferenceFunction1DLattice core_1d_lattice(20.0, 0.0); GUICoreObjectCorrespondence(gui_1d_lattice, core_1d_lattice); diff --git a/Tests/UnitTests/GUI/TestGUIHelpers.cpp b/Tests/UnitTests/GUI/TestGUIHelpers.cpp index fd7a0fa4ab334416e4ea98aedd369ae4b2679d9c..1598ccdeb3a19ae46a271120b44be0bc7d4c9fa1 100644 --- a/Tests/UnitTests/GUI/TestGUIHelpers.cpp +++ b/Tests/UnitTests/GUI/TestGUIHelpers.cpp @@ -1,12 +1,9 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include "Tests/GTestWrapper/google_test.h" -class TestGUIHelpers : public ::testing::Test -{ -}; +class TestGUIHelpers : public ::testing::Test {}; -TEST_F(TestGUIHelpers, test_VersionString) -{ +TEST_F(TestGUIHelpers, test_VersionString) { int vmajor(0), vminor(0), vpatch(0); EXPECT_EQ(true, GUIHelpers::parseVersion("1.5.0", vmajor, vminor, vpatch)); diff --git a/Tests/UnitTests/GUI/TestGroupItem.cpp b/Tests/UnitTests/GUI/TestGroupItem.cpp index 869cebd9b42854c20ed47735218b5f1b80422bce..a57a4fe86f1f7be31f2a52034e00df2dae382fe8 100644 --- a/Tests/UnitTests/GUI/TestGroupItem.cpp +++ b/Tests/UnitTests/GUI/TestGroupItem.cpp @@ -6,12 +6,9 @@ #include "Tests/GTestWrapper/google_test.h" #include "Tests/UnitTests/GUI/Utils.h" -class TestGroupItem : public ::testing::Test -{ -}; +class TestGroupItem : public ::testing::Test {}; -TEST_F(TestGroupItem, test_groupInfo) -{ +TEST_F(TestGroupItem, test_groupInfo) { GroupInfo info("Group"); info.add("BBB", "b_label"); info.add("AAA", "a_label"); @@ -49,8 +46,7 @@ TEST_F(TestGroupItem, test_groupInfo) EXPECT_THROW(info.add("CCC2", "c_label2"), GUIHelpers::Error); } -TEST_F(TestGroupItem, test_CreateGroup) -{ +TEST_F(TestGroupItem, test_CreateGroup) { SessionModel model("TestModel"); GroupInfo groupInfo = SessionItemUtils::GetGroupInfo("Form Factor"); @@ -103,8 +99,7 @@ TEST_F(TestGroupItem, test_CreateGroup) //! Checking that GroupProperty stays functional if displayName of currentItem is changed. -TEST_F(TestGroupItem, test_groupPropertyWithDisplayNames) -{ +TEST_F(TestGroupItem, test_groupPropertyWithDisplayNames) { GroupInfo groupInfo = SessionItemUtils::GetGroupInfo("Distribution group"); GroupItem groupItem; diff --git a/Tests/UnitTests/GUI/TestLayerItems.cpp b/Tests/UnitTests/GUI/TestLayerItems.cpp index 44b8baa280eac246316b5d8a4753b6432b7fea65..068b12de3af7933a85833f42e1563d3f457d561b 100644 --- a/Tests/UnitTests/GUI/TestLayerItems.cpp +++ b/Tests/UnitTests/GUI/TestLayerItems.cpp @@ -6,14 +6,11 @@ #include "GUI/coregui/Views/MaterialEditor/ExternalProperty.h" #include "Tests/GTestWrapper/google_test.h" -class TestLayerItems : public ::testing::Test -{ -}; +class TestLayerItems : public ::testing::Test {}; //! Checking default material of the layer. -TEST_F(TestLayerItems, test_LayerDefaultMaterial) -{ +TEST_F(TestLayerItems, test_LayerDefaultMaterial) { ApplicationModels models; auto layer = models.sampleModel()->insertNewItem("Layer"); auto materials = models.materialModel()->topItems(); diff --git a/Tests/UnitTests/GUI/TestLayerRoughnessItems.cpp b/Tests/UnitTests/GUI/TestLayerRoughnessItems.cpp index 16bbda8dd0514f77a83c4745d50038e3f63d2031..53ccb380ad48d4ae390fdcba41b23725f04e5149 100644 --- a/Tests/UnitTests/GUI/TestLayerRoughnessItems.cpp +++ b/Tests/UnitTests/GUI/TestLayerRoughnessItems.cpp @@ -3,12 +3,9 @@ #include "GUI/coregui/Models/TransformToDomain.h" #include "Tests/GTestWrapper/google_test.h" -class TestLayerRoughnessItems : public ::testing::Test -{ -}; +class TestLayerRoughnessItems : public ::testing::Test {}; -TEST_F(TestLayerRoughnessItems, test_LayerRoughnessToDomain) -{ +TEST_F(TestLayerRoughnessItems, test_LayerRoughnessToDomain) { LayerBasicRoughnessItem roughnessItem; roughnessItem.setItemValue(LayerBasicRoughnessItem::P_SIGMA, 10.0); roughnessItem.setItemValue(LayerBasicRoughnessItem::P_HURST, 20.0); @@ -27,8 +24,7 @@ TEST_F(TestLayerRoughnessItems, test_LayerRoughnessToDomain) EXPECT_TRUE(TransformToDomain::createLayerRoughness(zeroRoughnessItem) == nullptr); } -TEST_F(TestLayerRoughnessItems, test_LayerRoughnessFromDomain) -{ +TEST_F(TestLayerRoughnessItems, test_LayerRoughnessFromDomain) { LayerRoughness roughness(10.0, 20.0, 30.0); LayerBasicRoughnessItem roughnessItem; TransformFromDomain::setRoughnessItem(&roughnessItem, roughness); diff --git a/Tests/UnitTests/GUI/TestLinkInstrument.cpp b/Tests/UnitTests/GUI/TestLinkInstrument.cpp index 1cef32a366474d3b3f5e2729ce055f6ea35f926e..5c00c1c92f23dae81b37547cd68ad83df2c51708 100644 --- a/Tests/UnitTests/GUI/TestLinkInstrument.cpp +++ b/Tests/UnitTests/GUI/TestLinkInstrument.cpp @@ -12,14 +12,11 @@ #include <QSignalSpy> #include <QTest> -class TestLinkInstrument : public ::testing::Test -{ -}; +class TestLinkInstrument : public ::testing::Test {}; //! Checks that LinkInstrumentManager listens instrument model. -TEST_F(TestLinkInstrument, test_linkInstrumentManager) -{ +TEST_F(TestLinkInstrument, test_linkInstrumentManager) { InstrumentModel instrumentModel; RealDataModel realDataModel; LinkInstrumentManager manager; @@ -49,8 +46,7 @@ TEST_F(TestLinkInstrument, test_linkInstrumentManager) EXPECT_EQ(manager.instrumentComboIndex(identifier), -1); } -TEST_F(TestLinkInstrument, test_canLinkToInstrument) -{ +TEST_F(TestLinkInstrument, test_canLinkToInstrument) { InstrumentModel instrumentModel; RealDataModel realDataModel; LinkInstrumentManager manager; diff --git a/Tests/UnitTests/GUI/TestMapperCases.cpp b/Tests/UnitTests/GUI/TestMapperCases.cpp index c0436e1343bc80f993623aab7b7cafbba2396148..cde15a5d278b79a3bfe08962507b91b3833074a4 100644 --- a/Tests/UnitTests/GUI/TestMapperCases.cpp +++ b/Tests/UnitTests/GUI/TestMapperCases.cpp @@ -10,12 +10,9 @@ using SessionItemUtils::ParentRow; -class TestMapperCases : public ::testing::Test -{ -}; +class TestMapperCases : public ::testing::Test {}; -TEST_F(TestMapperCases, test_ParticeleCompositionUpdate) -{ +TEST_F(TestMapperCases, test_ParticeleCompositionUpdate) { SampleModel model; SessionItem* multilayer = model.insertNewItem("MultiLayer"); SessionItem* layer = model.insertNewItem("Layer", multilayer->index()); @@ -35,8 +32,7 @@ TEST_F(TestMapperCases, test_ParticeleCompositionUpdate) delete composition; } -TEST_F(TestMapperCases, test_SimulationOptionsComputationToggle) -{ +TEST_F(TestMapperCases, test_SimulationOptionsComputationToggle) { DocumentModel model; model.insertNewItem("SimulationOptions"); diff --git a/Tests/UnitTests/GUI/TestMapperForItem.cpp b/Tests/UnitTests/GUI/TestMapperForItem.cpp index dba7ae688cb23901b3c64789e202190af947978c..433326b545ae574d727c622fcbde4ce5b3197896 100644 --- a/Tests/UnitTests/GUI/TestMapperForItem.cpp +++ b/Tests/UnitTests/GUI/TestMapperForItem.cpp @@ -8,8 +8,7 @@ using SessionItemUtils::ParentRow; //! Test Widget which logs calling activity of ModelMapper -class Widget -{ +class Widget { public: Widget() : m_onPropertyChangeCount(0) @@ -17,12 +16,9 @@ public: , m_onParentChangeCount(0) , m_onChildrenChangeCount(0) , m_onSiblingsChangeCount(0) - , m_onAboutToRemoveChild(0) - { - } + , m_onAboutToRemoveChild(0) {} - void clear() - { + void clear() { m_onPropertyChangeCount = 0; m_onChildPropertyChangeCount = 0; m_onParentChangeCount = 0; @@ -33,8 +29,7 @@ public: m_reported_names.clear(); } - void subscribe(ModelMapper* mapper, bool with_subscription = false) - { + void subscribe(ModelMapper* mapper, bool with_subscription = false) { clear(); void* caller = (with_subscription ? this : 0); @@ -54,21 +49,18 @@ public: caller); } - void onPropertyChange(const QString& name) - { + void onPropertyChange(const QString& name) { m_reported_names.append(name); m_onPropertyChangeCount++; } - void onChildPropertyChange(SessionItem* item, const QString& name) - { + void onChildPropertyChange(SessionItem* item, const QString& name) { m_reported_items.append(item); m_reported_names.append(name); m_onChildPropertyChangeCount++; } - void onParentChange(SessionItem* item) - { + void onParentChange(SessionItem* item) { m_reported_items.append(item); m_onParentChangeCount++; } @@ -79,8 +71,7 @@ public: void unsubscribe(ModelMapper* mapper) { mapper->unsubscribe(this); } - void onAboutToRemoveChild(SessionItem* item) - { + void onAboutToRemoveChild(SessionItem* item) { m_reported_items.append(item); m_onAboutToRemoveChild++; } @@ -95,13 +86,11 @@ public: QStringList m_reported_names; }; -class TestMapperForItem : public ::testing::Test -{ +class TestMapperForItem : public ::testing::Test { public: TestMapperForItem() : m_mapped_item(0) {} - void setItem(SessionItem* item, Widget* widget = 0, bool with_subscription = false) - { + void setItem(SessionItem* item, Widget* widget = 0, bool with_subscription = false) { m_mapped_item = item; m_mapper.reset(new ModelMapper); m_mapper->setItem(item); @@ -113,8 +102,7 @@ public: std::unique_ptr<ModelMapper> m_mapper; }; -TEST_F(TestMapperForItem, test_initialCondition) -{ +TEST_F(TestMapperForItem, test_initialCondition) { Widget w; EXPECT_EQ(w.m_onPropertyChangeCount, 0); EXPECT_EQ(w.m_onChildPropertyChangeCount, 0); @@ -127,8 +115,7 @@ TEST_F(TestMapperForItem, test_initialCondition) EXPECT_TRUE(!m_mapper); } -TEST_F(TestMapperForItem, test_onPropertyChange) -{ +TEST_F(TestMapperForItem, test_onPropertyChange) { Widget w; SampleModel model; SessionItem* multilayer = model.insertNewItem("MultiLayer"); @@ -187,8 +174,7 @@ TEST_F(TestMapperForItem, test_onPropertyChange) && (w.m_reported_names[0] == MultiLayerItem::P_CROSS_CORR_LENGTH)); } -TEST_F(TestMapperForItem, test_onParentChange) -{ +TEST_F(TestMapperForItem, test_onParentChange) { Widget w; SampleModel model; SessionItem* multilayer = model.insertNewItem("MultiLayer"); @@ -205,8 +191,7 @@ TEST_F(TestMapperForItem, test_onParentChange) EXPECT_EQ(w.m_onChildrenChangeCount, 0); } -TEST_F(TestMapperForItem, test_onChildrenChange) -{ +TEST_F(TestMapperForItem, test_onChildrenChange) { Widget w; SampleModel model; SessionItem* multilayer = model.insertNewItem("MultiLayer"); @@ -225,8 +210,7 @@ TEST_F(TestMapperForItem, test_onChildrenChange) EXPECT_EQ(w.m_reported_names.size(), 2); } -TEST_F(TestMapperForItem, test_onSiblingsChange) -{ +TEST_F(TestMapperForItem, test_onSiblingsChange) { Widget w; SampleModel model; SessionItem* multilayer = model.insertNewItem("MultiLayer"); @@ -250,8 +234,7 @@ TEST_F(TestMapperForItem, test_onSiblingsChange) EXPECT_EQ(w.m_onSiblingsChangeCount, 2); } -TEST_F(TestMapperForItem, test_Subscription) -{ +TEST_F(TestMapperForItem, test_Subscription) { Widget w; SampleModel model; SessionItem* multilayer = model.insertNewItem("MultiLayer"); @@ -279,8 +262,7 @@ TEST_F(TestMapperForItem, test_Subscription) EXPECT_EQ(w.m_onPropertyChangeCount, 2); } -TEST_F(TestMapperForItem, test_TwoWidgetsSubscription) -{ +TEST_F(TestMapperForItem, test_TwoWidgetsSubscription) { Widget w1, w2; SampleModel model; SessionItem* multilayer = model.insertNewItem("MultiLayer"); @@ -303,8 +285,7 @@ TEST_F(TestMapperForItem, test_TwoWidgetsSubscription) EXPECT_EQ(w2.m_onPropertyChangeCount, 2); } -TEST_F(TestMapperForItem, test_AboutToRemoveChild) -{ +TEST_F(TestMapperForItem, test_AboutToRemoveChild) { Widget w; SampleModel model; SessionItem* container = model.insertNewItem("ProjectionContainer"); diff --git a/Tests/UnitTests/GUI/TestMaterialModel.cpp b/Tests/UnitTests/GUI/TestMaterialModel.cpp index 60d47f4ce15b0e90a3928c068c3ca57fc533c2a8..5ef22903fe3aedd1c44dcb7d26cf2d9de010d8bf 100644 --- a/Tests/UnitTests/GUI/TestMaterialModel.cpp +++ b/Tests/UnitTests/GUI/TestMaterialModel.cpp @@ -4,12 +4,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <memory> -class TestMaterialModel : public ::testing::Test -{ -}; +class TestMaterialModel : public ::testing::Test {}; -TEST_F(TestMaterialModel, addRefractiveMaterial) -{ +TEST_F(TestMaterialModel, addRefractiveMaterial) { std::unique_ptr<MaterialModel> model(new MaterialModel); EXPECT_EQ(model->rowCount(QModelIndex()), 0); @@ -28,8 +25,7 @@ TEST_F(TestMaterialModel, addRefractiveMaterial) EXPECT_EQ(materialData->getItemValue(MaterialRefractiveDataItem::P_BETA), beta); } -TEST_F(TestMaterialModel, addSLDMaterial) -{ +TEST_F(TestMaterialModel, addSLDMaterial) { std::unique_ptr<MaterialModel> model(new MaterialModel); EXPECT_EQ(model->rowCount(QModelIndex()), 0); @@ -48,8 +44,7 @@ TEST_F(TestMaterialModel, addSLDMaterial) EXPECT_EQ(materialData->getItemValue(MaterialSLDDataItem::P_SLD_IMAG), sld_imag); } -TEST_F(TestMaterialModel, cloneMaterial) -{ +TEST_F(TestMaterialModel, cloneMaterial) { std::unique_ptr<MaterialModel> model(new MaterialModel); EXPECT_EQ(model->rowCount(QModelIndex()), 0); @@ -78,8 +73,7 @@ TEST_F(TestMaterialModel, cloneMaterial) //! Checks the method which returns MaterialItem from known identifier. -TEST_F(TestMaterialModel, materialFromIdentifier) -{ +TEST_F(TestMaterialModel, materialFromIdentifier) { MaterialModel model; auto material1 = model.addRefractiveMaterial("aaa", 1.0, 2.0); auto material2 = model.addRefractiveMaterial("bbb", 3.0, 4.0); @@ -90,8 +84,7 @@ TEST_F(TestMaterialModel, materialFromIdentifier) //! Checks the method which returns MaterialItem from material name. -TEST_F(TestMaterialModel, test_materialFromName) -{ +TEST_F(TestMaterialModel, test_materialFromName) { MaterialModel model; auto material1 = model.addRefractiveMaterial("aaa", 1.0, 2.0); auto material2 = model.addRefractiveMaterial("bbb", 3.0, 4.0); @@ -102,8 +95,7 @@ TEST_F(TestMaterialModel, test_materialFromName) //! Checks the method which construct MaterialProperty from MaterialItem. -TEST_F(TestMaterialModel, test_materialPropertyFromMaterial) -{ +TEST_F(TestMaterialModel, test_materialPropertyFromMaterial) { MaterialModel model; auto material = model.addRefractiveMaterial("Something", 1.0, 2.0); @@ -115,8 +107,7 @@ TEST_F(TestMaterialModel, test_materialPropertyFromMaterial) //! Default MaterialProperty construction. -TEST_F(TestMaterialModel, defaultMaterialProperty) -{ +TEST_F(TestMaterialModel, defaultMaterialProperty) { MaterialModel model; // testing default material property from MaterialItemUtils diff --git a/Tests/UnitTests/GUI/TestMaterialPropertyController.cpp b/Tests/UnitTests/GUI/TestMaterialPropertyController.cpp index 5c84a85ba0b0193e57ce702bf32b0a050525bc38..7f6e4a915a89ba05b956ae7f81a60e37f529b8e9 100644 --- a/Tests/UnitTests/GUI/TestMaterialPropertyController.cpp +++ b/Tests/UnitTests/GUI/TestMaterialPropertyController.cpp @@ -6,9 +6,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <QtTest> -class TestMaterialPropertyController : public ::testing::Test -{ -}; +class TestMaterialPropertyController : public ::testing::Test {}; // TEST_F(TestMaterialPropertyController, test_ControllerForLayer) //{ @@ -59,8 +57,7 @@ class TestMaterialPropertyController : public ::testing::Test //! Test MaterialProperty update in sample items when working on model clone. -TEST_F(TestMaterialPropertyController, test_ControllerInEditorContext) -{ +TEST_F(TestMaterialPropertyController, test_ControllerInEditorContext) { MaterialModel materialModel; auto mat1 = materialModel.addRefractiveMaterial("name1", 1.0, 2.0); auto mat2 = materialModel.addRefractiveMaterial("name2", 1.0, 2.0); diff --git a/Tests/UnitTests/GUI/TestMessageService.cpp b/Tests/UnitTests/GUI/TestMessageService.cpp index 3ed72f0fb48b708d569484f1f350f17d827ebf96..ca343abe64ce8305444cd13547ad2cfa56865b92 100644 --- a/Tests/UnitTests/GUI/TestMessageService.cpp +++ b/Tests/UnitTests/GUI/TestMessageService.cpp @@ -5,8 +5,7 @@ #include <QObject> #include <QString> -namespace -{ +namespace { const QString senderName1("senderName1"); const QString senderName2("senderName2"); @@ -20,18 +19,15 @@ const QString messageType3("messageType3"); const QString description3("description3"); } // namespace -class TestMessageService : public ::testing::Test -{ +class TestMessageService : public ::testing::Test { public: - class Sender : public QObject - { + class Sender : public QObject { public: explicit Sender(const QString& name) { setObjectName(name); } }; }; -TEST_F(TestMessageService, guiMessage) -{ +TEST_F(TestMessageService, guiMessage) { GUIMessage message(senderName1, messageType1, description1); EXPECT_EQ(message.senderName(), senderName1); @@ -39,14 +35,12 @@ TEST_F(TestMessageService, guiMessage) EXPECT_EQ(message.messageDescription(), description1); } -TEST_F(TestMessageService, initialState) -{ +TEST_F(TestMessageService, initialState) { MessageService svc; EXPECT_TRUE(svc.messages().isEmpty()); } -TEST_F(TestMessageService, sendMessage) -{ +TEST_F(TestMessageService, sendMessage) { MessageService svc; Sender sender(senderName1); @@ -70,8 +64,7 @@ TEST_F(TestMessageService, sendMessage) EXPECT_EQ(svc.senderList().size(), 1); } -TEST_F(TestMessageService, twoSenders) -{ +TEST_F(TestMessageService, twoSenders) { MessageService svc; Sender sender1(senderName1); Sender sender2(senderName2); @@ -98,8 +91,7 @@ TEST_F(TestMessageService, twoSenders) EXPECT_TRUE(svc.senderList().contains(senderName2)); } -TEST_F(TestMessageService, messageCount) -{ +TEST_F(TestMessageService, messageCount) { MessageService svc; Sender sender1(senderName1); Sender sender2(senderName2); @@ -124,8 +116,7 @@ TEST_F(TestMessageService, messageCount) EXPECT_EQ(svc.messageCount(&sender3), 0); } -TEST_F(TestMessageService, warningAndErrorCount) -{ +TEST_F(TestMessageService, warningAndErrorCount) { MessageService svc; Sender sender1(senderName1); Sender sender2(senderName2); diff --git a/Tests/UnitTests/GUI/TestModelUtils.cpp b/Tests/UnitTests/GUI/TestModelUtils.cpp index 4735e92a07707920638d289acb6357cc45175269..b80b8aa7a3a0f6cf051b19836a85e21a126b9b41 100644 --- a/Tests/UnitTests/GUI/TestModelUtils.cpp +++ b/Tests/UnitTests/GUI/TestModelUtils.cpp @@ -5,12 +5,10 @@ #include "Tests/GTestWrapper/google_test.h" #include <QVector> -class TestModelUtils : public ::testing::Test -{ +class TestModelUtils : public ::testing::Test { public: //! Returns true if model contains given item using iterate_if procedure. - bool modelContainsItem(SessionModel* model, SessionItem* selectedItem) - { + bool modelContainsItem(SessionModel* model, SessionItem* selectedItem) { bool result = false; ModelUtils::iterate_if(QModelIndex(), model, [&](const QModelIndex& index) -> bool { SessionItem* item = model->itemForIndex(index); @@ -24,8 +22,7 @@ public: //! Testing top item names. -TEST_F(TestModelUtils, test_topItemNames) -{ +TEST_F(TestModelUtils, test_topItemNames) { SessionModel model("TestModel"); // testing empty list @@ -50,8 +47,7 @@ TEST_F(TestModelUtils, test_topItemNames) //! Testing iteration over empty model. -TEST_F(TestModelUtils, test_emptyModel) -{ +TEST_F(TestModelUtils, test_emptyModel) { SessionModel model("TestModel"); QVector<QModelIndex> indices; @@ -64,8 +60,7 @@ TEST_F(TestModelUtils, test_emptyModel) //! Testing iteration over the model with one VectorItem inserted. -TEST_F(TestModelUtils, test_vectorItem) -{ +TEST_F(TestModelUtils, test_vectorItem) { SessionModel model("TestModel"); SessionItem* vectorItem = model.insertNewItem("Vector"); @@ -90,8 +85,7 @@ TEST_F(TestModelUtils, test_vectorItem) //! Tests iteration when some children is invisible. -TEST_F(TestModelUtils, test_iterateIf) -{ +TEST_F(TestModelUtils, test_iterateIf) { SessionModel model("TestModel"); SessionItem* multilayer = model.insertNewItem("MultiLayer"); SessionItem* layer = model.insertNewItem("Layer", model.indexOfItem(multilayer)); diff --git a/Tests/UnitTests/GUI/TestMultiLayerItem.cpp b/Tests/UnitTests/GUI/TestMultiLayerItem.cpp index fccb821a07d11247623be56314c41ef8d005c78a..28cf0726217c331283f079561d1c91591390152d 100644 --- a/Tests/UnitTests/GUI/TestMultiLayerItem.cpp +++ b/Tests/UnitTests/GUI/TestMultiLayerItem.cpp @@ -3,16 +3,13 @@ #include "GUI/coregui/Models/SampleModel.h" #include "Tests/GTestWrapper/google_test.h" -class TestMultiLayerItem : public ::testing::Test -{ -}; +class TestMultiLayerItem : public ::testing::Test {}; //! Testing layer appearance (enabled, disabled) in a MultiLayer made of two default layers. //! //! In two layer system top and bottom layers should have disabled thickness and roughness. -TEST_F(TestMultiLayerItem, test_twoLayerSystem) -{ +TEST_F(TestMultiLayerItem, test_twoLayerSystem) { SampleModel model; auto multilayer = model.insertNewItem("MultiLayer"); @@ -40,8 +37,7 @@ TEST_F(TestMultiLayerItem, test_twoLayerSystem) //! //! In three layer system middle layer's thickness/roughness should be enabled. -TEST_F(TestMultiLayerItem, test_threeLayerSystem) -{ +TEST_F(TestMultiLayerItem, test_threeLayerSystem) { SampleModel model; auto multilayer = model.insertNewItem("MultiLayer"); @@ -75,8 +71,7 @@ TEST_F(TestMultiLayerItem, test_threeLayerSystem) //! In three layer system, the moving of middle layer on top should lead to the disabling //! of roughness/thickness. -TEST_F(TestMultiLayerItem, test_movingMiddleLayerOnTop) -{ +TEST_F(TestMultiLayerItem, test_movingMiddleLayerOnTop) { SampleModel model; auto multilayer = model.insertNewItem("MultiLayer"); @@ -123,8 +118,7 @@ TEST_F(TestMultiLayerItem, test_movingMiddleLayerOnTop) //! //! If top layer was moved to canvas, its thickness and roughness should be reenabled. -TEST_F(TestMultiLayerItem, test_movingLayerOnCanvas) -{ +TEST_F(TestMultiLayerItem, test_movingLayerOnCanvas) { SampleModel model; auto multilayer = model.insertNewItem("MultiLayer"); diff --git a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp index 50448f25d1eab04905c3d281b60522e8c5dd9879..8ce10cd811f33c99df461f302c233c2741a2fb32 100644 --- a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp +++ b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp @@ -16,15 +16,13 @@ #include <QTest> #include <memory> -class TestOutputDataIOService : public ::testing::Test -{ +class TestOutputDataIOService : public ::testing::Test { protected: TestOutputDataIOService(); OutputData<double> m_data; }; -TestOutputDataIOService::TestOutputDataIOService() -{ +TestOutputDataIOService::TestOutputDataIOService() { FixedBinAxis axis0("x", 10, 0.0, 1.0); FixedBinAxis axis1("y", 10, -1.0, 1.0); m_data.addAxis(axis0); @@ -33,8 +31,7 @@ TestOutputDataIOService::TestOutputDataIOService() //! Test methods for retrieving nonXML data. -TEST_F(TestOutputDataIOService, test_nonXMLData) -{ +TEST_F(TestOutputDataIOService, test_nonXMLData) { ApplicationModels models; // initial state @@ -86,8 +83,7 @@ TEST_F(TestOutputDataIOService, test_nonXMLData) //! Tests OutputDataSaveInfo class intended for storing info about the last save. -TEST_F(TestOutputDataIOService, test_OutputDataSaveInfo) -{ +TEST_F(TestOutputDataIOService, test_OutputDataSaveInfo) { SessionModel model("TempModel"); DataItem* item = dynamic_cast<DataItem*>(model.insertNewItem("IntensityData")); @@ -107,8 +103,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataSaveInfo) //! Tests OutputDataDirHistory class intended for storing save history of several //! IntensityDataItems in a directory. -TEST_F(TestOutputDataIOService, test_OutputDataDirHistory) -{ +TEST_F(TestOutputDataIOService, test_OutputDataDirHistory) { SessionModel model("TempModel"); DataItem* item1 = dynamic_cast<DataItem*>(model.insertNewItem("IntensityData")); @@ -144,8 +139,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataDirHistory) //! Tests OutputDataIOHistory class (save info for several independent directories). -TEST_F(TestOutputDataIOService, test_OutputDataIOHistory) -{ +TEST_F(TestOutputDataIOService, test_OutputDataIOHistory) { SessionModel model("TempModel"); DataItem* item1 = dynamic_cast<DataItem*>(model.insertNewItem("IntensityData")); @@ -185,8 +179,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataIOHistory) //! Testing saving abilities of OutputDataIOService class. -TEST_F(TestOutputDataIOService, test_OutputDataIOService) -{ +TEST_F(TestOutputDataIOService, test_OutputDataIOService) { const QString projectDir("test_OutputDataIOService"); GuiUnittestUtils::create_dir(projectDir); @@ -242,8 +235,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataIOService) EXPECT_FALSE(ProjectUtils::exists(fname2)); } -TEST_F(TestOutputDataIOService, test_RealDataItemWithNativeData) -{ +TEST_F(TestOutputDataIOService, test_RealDataItemWithNativeData) { ApplicationModels models; // initial state diff --git a/Tests/UnitTests/GUI/TestParaCrystalItems.cpp b/Tests/UnitTests/GUI/TestParaCrystalItems.cpp index 65b9195171979bded6d1b2d78b9c05d427252239..2897b69d3edddb46268c2ddb6ee86716de42e8b1 100644 --- a/Tests/UnitTests/GUI/TestParaCrystalItems.cpp +++ b/Tests/UnitTests/GUI/TestParaCrystalItems.cpp @@ -8,12 +8,9 @@ #include "Sample/Aggregate/InterferenceFunction2DParaCrystal.h" #include "Tests/GTestWrapper/google_test.h" -class TestParaCrystalItems : public ::testing::Test -{ -}; +class TestParaCrystalItems : public ::testing::Test {}; -TEST_F(TestParaCrystalItems, test_Para2D_fromToDomain) -{ +TEST_F(TestParaCrystalItems, test_Para2D_fromToDomain) { double length1(10.0), length2(20.0), angle(45.0), xi(90.0); double damping_length(1000.0), domain_size1(50.0), domain_size2(100.0); @@ -72,8 +69,7 @@ TEST_F(TestParaCrystalItems, test_Para2D_fromToDomain) EXPECT_EQ(domain->lattice().rotationAngle(), orig.lattice().rotationAngle()); } -TEST_F(TestParaCrystalItems, test_Inference2DRotationAngleToggle) -{ +TEST_F(TestParaCrystalItems, test_Inference2DRotationAngleToggle) { SampleModel model; SessionItem* multilayer = model.insertNewItem("MultiLayer"); SessionItem* layer = model.insertNewItem("Layer", multilayer->index()); diff --git a/Tests/UnitTests/GUI/TestParameterTreeUtils.cpp b/Tests/UnitTests/GUI/TestParameterTreeUtils.cpp index 69ae77034a0de73a81901e32fa37d1b9e3621f99..3a71abfb380c7dccf35ba1c316d4342bad4e8dfb 100644 --- a/Tests/UnitTests/GUI/TestParameterTreeUtils.cpp +++ b/Tests/UnitTests/GUI/TestParameterTreeUtils.cpp @@ -7,8 +7,7 @@ #include "GUI/coregui/Models/VectorItem.h" #include "Tests/GTestWrapper/google_test.h" -namespace -{ +namespace { const QStringList expectedParticleParameterNames = { "Particle/Cylinder/Radius", "Particle/Cylinder/Height", "Particle/Abundance", "Particle/Position Offset/X", "Particle/Position Offset/Y", "Particle/Position Offset/Z"}; @@ -19,14 +18,11 @@ const QStringList expectedParticleParameterTranslations = { } // namespace -class TestParameterTreeUtils : public ::testing::Test -{ -}; +class TestParameterTreeUtils : public ::testing::Test {}; //! Tests parameter names of given item. -TEST_F(TestParameterTreeUtils, test_parameterTreeNames) -{ +TEST_F(TestParameterTreeUtils, test_parameterTreeNames) { SampleModel model; SessionItem* layer = model.insertNewItem("Layer"); @@ -38,8 +34,7 @@ TEST_F(TestParameterTreeUtils, test_parameterTreeNames) //! Tests translated parameter names of given item. -TEST_F(TestParameterTreeUtils, test_parameterTranslatedNames) -{ +TEST_F(TestParameterTreeUtils, test_parameterTranslatedNames) { SampleModel model; SessionItem* particle = model.insertNewItem("Particle"); @@ -50,8 +45,7 @@ TEST_F(TestParameterTreeUtils, test_parameterTranslatedNames) //! Tests translated parameter names of given item. -TEST_F(TestParameterTreeUtils, test_linkItemFromParameterName) -{ +TEST_F(TestParameterTreeUtils, test_linkItemFromParameterName) { SampleModel model; SessionItem* particle = model.insertNewItem("Particle"); diff --git a/Tests/UnitTests/GUI/TestParticleCoreShell.cpp b/Tests/UnitTests/GUI/TestParticleCoreShell.cpp index 1496ca23b72641f4ac510520bddb0d2b759aa883..ac042b316ba252274fd0f328e13608e62e9ed033 100644 --- a/Tests/UnitTests/GUI/TestParticleCoreShell.cpp +++ b/Tests/UnitTests/GUI/TestParticleCoreShell.cpp @@ -10,12 +10,9 @@ using namespace SessionItemUtils; -class TestParticleCoreShell : public ::testing::Test -{ -}; +class TestParticleCoreShell : public ::testing::Test {}; -TEST_F(TestParticleCoreShell, test_moveCoreAndShell) -{ +TEST_F(TestParticleCoreShell, test_moveCoreAndShell) { SampleModel model; SessionItem* coreshell = model.insertNewItem("ParticleCoreShell"); SessionItem* particle1 = model.insertNewItem("Particle"); @@ -49,8 +46,7 @@ TEST_F(TestParticleCoreShell, test_moveCoreAndShell) //! Checking that adding and removing core/shell leads to enabling/disabling of their position //! and abundance properties. -TEST_F(TestParticleCoreShell, test_propertyAppearance) -{ +TEST_F(TestParticleCoreShell, test_propertyAppearance) { SampleModel model; // empty coreshell particle @@ -99,8 +95,7 @@ TEST_F(TestParticleCoreShell, test_propertyAppearance) //! Checking that abundance gets disabled in particle distribution context. -TEST_F(TestParticleCoreShell, test_distributionContext) -{ +TEST_F(TestParticleCoreShell, test_distributionContext) { SampleModel model; // coreshell particle @@ -124,8 +119,7 @@ TEST_F(TestParticleCoreShell, test_distributionContext) //! Checking that abundance gets disabled in particle composition context. -TEST_F(TestParticleCoreShell, test_compositionContext) -{ +TEST_F(TestParticleCoreShell, test_compositionContext) { SampleModel model; // coreshell particle diff --git a/Tests/UnitTests/GUI/TestParticleDistributionItem.cpp b/Tests/UnitTests/GUI/TestParticleDistributionItem.cpp index 362ac5da53dea04fbd4928d8a73e92bf7c1682c7..4c217773f1e75ef92cdc26c84745a714043776e5 100644 --- a/Tests/UnitTests/GUI/TestParticleDistributionItem.cpp +++ b/Tests/UnitTests/GUI/TestParticleDistributionItem.cpp @@ -14,8 +14,7 @@ #include "Tests/GTestWrapper/google_test.h" #include <QXmlStreamWriter> -namespace -{ +namespace { const QStringList expectedCylinderParams = {"None", "Particle/Cylinder/Radius", "Particle/Cylinder/Height", @@ -32,12 +31,9 @@ const QStringList expectedBoxParams = {"None", "Particle/Position Offset/Z"}; } // namespace -class TestParticleDistributionItem : public ::testing::Test -{ -}; +class TestParticleDistributionItem : public ::testing::Test {}; -TEST_F(TestParticleDistributionItem, test_InitialState) -{ +TEST_F(TestParticleDistributionItem, test_InitialState) { SampleModel model; SessionItem* distItem = model.insertNewItem("ParticleDistribution"); @@ -67,8 +63,7 @@ TEST_F(TestParticleDistributionItem, test_InitialState) EXPECT_EQ(prop.getValue(), ""); } -TEST_F(TestParticleDistributionItem, test_AddParticle) -{ +TEST_F(TestParticleDistributionItem, test_AddParticle) { SampleModel model; SessionItem* dist = model.insertNewItem("ParticleDistribution"); @@ -112,8 +107,7 @@ TEST_F(TestParticleDistributionItem, test_AddParticle) //! Values available for linking should depend on main parameter. -TEST_F(TestParticleDistributionItem, test_MainLinkedCorrelation) -{ +TEST_F(TestParticleDistributionItem, test_MainLinkedCorrelation) { SampleModel model; SessionItem* dist = model.insertNewItem("ParticleDistribution"); model.insertNewItem("Particle", dist->index()); @@ -173,8 +167,7 @@ TEST_F(TestParticleDistributionItem, test_MainLinkedCorrelation) EXPECT_EQ(linkedCombo.selectedValues(), QStringList("Particle/Cylinder/Height")); } -TEST_F(TestParticleDistributionItem, test_FromDomain) -{ +TEST_F(TestParticleDistributionItem, test_FromDomain) { const std::string pattern("/Particle/Cylinder/Radius"); // creating domain distribution @@ -210,8 +203,7 @@ TEST_F(TestParticleDistributionItem, test_FromDomain) //! Constructing from domain distribution with linked parameter defined -TEST_F(TestParticleDistributionItem, test_FromDomainLinked) -{ +TEST_F(TestParticleDistributionItem, test_FromDomainLinked) { const std::string pattern("/Particle/Cylinder/Radius"); const std::string linked("/Particle/Cylinder/Height"); @@ -256,8 +248,7 @@ TEST_F(TestParticleDistributionItem, test_FromDomainLinked) EXPECT_EQ(linkedProp.getValue(), expectedLinked.at(0)); } -TEST_F(TestParticleDistributionItem, test_FromDomainWithLimits) -{ +TEST_F(TestParticleDistributionItem, test_FromDomainWithLimits) { const std::string pattern("/Particle/Cylinder/Radius"); // creating domain distribution @@ -287,8 +278,7 @@ TEST_F(TestParticleDistributionItem, test_FromDomainWithLimits) EXPECT_EQ(limitsItem->createRealLimits(), domainLimits); } -TEST_F(TestParticleDistributionItem, test_Clone) -{ +TEST_F(TestParticleDistributionItem, test_Clone) { std::unique_ptr<MaterialModel> P_materialModel(new MaterialModel()); SampleModel model1; diff --git a/Tests/UnitTests/GUI/TestParticleItem.cpp b/Tests/UnitTests/GUI/TestParticleItem.cpp index 76d71cc61391f3dd7529776c9958e80592506802..4bfe600c595a97af80b28d6ad7889a00fa66d26e 100644 --- a/Tests/UnitTests/GUI/TestParticleItem.cpp +++ b/Tests/UnitTests/GUI/TestParticleItem.cpp @@ -8,12 +8,9 @@ using namespace SessionItemUtils; -class TestParticleItem : public ::testing::Test -{ -}; +class TestParticleItem : public ::testing::Test {}; -TEST_F(TestParticleItem, test_InitialState) -{ +TEST_F(TestParticleItem, test_InitialState) { SampleModel model; SessionItem* item = model.insertNewItem("Particle"); @@ -28,8 +25,7 @@ TEST_F(TestParticleItem, test_InitialState) EXPECT_EQ(group->children().size(), 1); } -TEST_F(TestParticleItem, test_compositionContext) -{ +TEST_F(TestParticleItem, test_compositionContext) { SampleModel model; SessionItem* particle = model.insertNewItem("Particle"); particle->setItemValue(ParticleItem::P_ABUNDANCE, 0.2); @@ -48,8 +44,7 @@ TEST_F(TestParticleItem, test_compositionContext) delete particle; } -TEST_F(TestParticleItem, test_distributionContext) -{ +TEST_F(TestParticleItem, test_distributionContext) { SampleModel model; SessionItem* particle = model.insertNewItem("Particle"); particle->setItemValue(ParticleItem::P_ABUNDANCE, 0.2); diff --git a/Tests/UnitTests/GUI/TestParticleLayoutItem.h b/Tests/UnitTests/GUI/TestParticleLayoutItem.h index 3bc1803ad43afd095681a20343dc863be036b1c4..a9f9d0531099ef4a7ecbe3d8d1e67fbb51259e9d 100644 --- a/Tests/UnitTests/GUI/TestParticleLayoutItem.h +++ b/Tests/UnitTests/GUI/TestParticleLayoutItem.h @@ -9,16 +9,13 @@ #include "GUI/coregui/Models/SessionItemUtils.h" #include "Tests/UnitTests/utilities/google_test.h" -class TestParticleLayoutItem : public ::testing::Test -{ -}; +class TestParticleLayoutItem : public ::testing::Test {}; using namespace SessionItemUtils; //! Checks enabled/disabled status of TotalSurfaceDensity when adding interference function items. -TEST_F(TestParticleLayoutItem, densityAppearance) -{ +TEST_F(TestParticleLayoutItem, densityAppearance) { SampleModel model; auto layout = dynamic_cast<ParticleLayoutItem*>(model.insertNewItem("ParticleLayout")); @@ -54,8 +51,7 @@ TEST_F(TestParticleLayoutItem, densityAppearance) //! a) on interference function attachment //! b) on lattice parameter adjustments -TEST_F(TestParticleLayoutItem, densityValue) -{ +TEST_F(TestParticleLayoutItem, densityValue) { SampleModel model; auto layout = dynamic_cast<ParticleLayoutItem*>(model.insertNewItem("ParticleLayout")); diff --git a/Tests/UnitTests/GUI/TestProjectDocument.cpp b/Tests/UnitTests/GUI/TestProjectDocument.cpp index c7a482f9102d6e695428d408cc1771465802188b..fb2decc63c27edae8b333b384441b7fee02d6624 100644 --- a/Tests/UnitTests/GUI/TestProjectDocument.cpp +++ b/Tests/UnitTests/GUI/TestProjectDocument.cpp @@ -13,19 +13,16 @@ #include <QFileInfo> #include <QSignalSpy> -class TestProjectDocument : public ::testing::Test -{ +class TestProjectDocument : public ::testing::Test { protected: //! helper method to modify something in a model - void modify_models(ApplicationModels* models) - { + void modify_models(ApplicationModels* models) { auto instrument = models->instrumentModel()->instrumentItem(); instrument->setItemValue(InstrumentItem::P_IDENTIFIER, GUIHelpers::createUuid()); } }; -TEST_F(TestProjectDocument, test_documentFlags) -{ +TEST_F(TestProjectDocument, test_documentFlags) { ProjectFlags::DocumentStatus flags; EXPECT_FALSE(flags.testFlag(ProjectFlags::STATUS_OK)); EXPECT_FALSE(flags.testFlag(ProjectFlags::STATUS_WARNING)); @@ -54,8 +51,7 @@ TEST_F(TestProjectDocument, test_documentFlags) EXPECT_FALSE(document.hasErrors()); } -TEST_F(TestProjectDocument, test_projectDocument) -{ +TEST_F(TestProjectDocument, test_projectDocument) { const QString projectDir("test_projectDocument"); GuiUnittestUtils::create_dir(projectDir); const QString projectFileName(projectDir + "/document.pro"); @@ -96,8 +92,7 @@ TEST_F(TestProjectDocument, test_projectDocument) EXPECT_TRUE(info.exists()); } -TEST_F(TestProjectDocument, test_projectDocumentWithData) -{ +TEST_F(TestProjectDocument, test_projectDocumentWithData) { const QString projectDir("test_projectDocumentWithData"); GuiUnittestUtils::create_dir(projectDir); diff --git a/Tests/UnitTests/GUI/TestProjectUtils.cpp b/Tests/UnitTests/GUI/TestProjectUtils.cpp index 8dd95ad3f44643e22557a0f621effcffee27bbe1..719d116eedfae0372de662547adf7a0e0ac80cec 100644 --- a/Tests/UnitTests/GUI/TestProjectUtils.cpp +++ b/Tests/UnitTests/GUI/TestProjectUtils.cpp @@ -6,12 +6,10 @@ #include <QTextStream> #include <iostream> -class TestProjectUtils : public ::testing::Test -{ +class TestProjectUtils : public ::testing::Test { protected: //! Helper function to create test file in a given directory (directory should exist). - void createTestFile(const QString& dirname, const QString& fileName) - { + void createTestFile(const QString& dirname, const QString& fileName) { QString filename = dirname.isEmpty() ? fileName : dirname + "/" + fileName; QFile file(filename); @@ -25,8 +23,7 @@ protected: } }; -TEST_F(TestProjectUtils, test_nonXMLDataInDir) -{ +TEST_F(TestProjectUtils, test_nonXMLDataInDir) { const QString projectDir = "test_ProjectUtils"; QDir dir(projectDir); @@ -70,8 +67,7 @@ TEST_F(TestProjectUtils, test_nonXMLDataInDir) //! Test substraction of two lists (scenario: old files on disk vs new files). -TEST_F(TestProjectUtils, test_stringListSubstraction) -{ +TEST_F(TestProjectUtils, test_stringListSubstraction) { QStringList oldFiles = QStringList() << "a.int.gz" << "b.int.gz" << "c.int.gz"; diff --git a/Tests/UnitTests/GUI/TestPropertyRepeater.cpp b/Tests/UnitTests/GUI/TestPropertyRepeater.cpp index 0ebc829017bcc0f4d2d6f9e1b78a5fbce5df8fe9..cc424ff547157f9e003aa487ad537f64d87e66ad 100644 --- a/Tests/UnitTests/GUI/TestPropertyRepeater.cpp +++ b/Tests/UnitTests/GUI/TestPropertyRepeater.cpp @@ -4,28 +4,22 @@ #include "GUI/coregui/Views/IntensityDataWidgets/PropertyRepeater.h" #include "Tests/GTestWrapper/google_test.h" -namespace -{ +namespace { -IntensityDataItem* createData(SessionModel& model) -{ +IntensityDataItem* createData(SessionModel& model) { return dynamic_cast<IntensityDataItem*>(model.insertNewItem("IntensityData")); } -BasicAxisItem* createAxis(SessionModel& model) -{ +BasicAxisItem* createAxis(SessionModel& model) { return dynamic_cast<BasicAxisItem*>(model.insertNewItem("BasicAxis")); } } // namespace -class TestPropertyRepeater : public ::testing::Test -{ -}; +class TestPropertyRepeater : public ::testing::Test {}; //! Repeater handles two items. -TEST_F(TestPropertyRepeater, test_twoItems) -{ +TEST_F(TestPropertyRepeater, test_twoItems) { SessionModel model("test"); auto item1 = createAxis(model); @@ -56,8 +50,7 @@ TEST_F(TestPropertyRepeater, test_twoItems) //! Repeater handles three items. -TEST_F(TestPropertyRepeater, test_threeItems) -{ +TEST_F(TestPropertyRepeater, test_threeItems) { SessionModel model("test"); auto item1 = createAxis(model); @@ -82,8 +75,7 @@ TEST_F(TestPropertyRepeater, test_threeItems) //! Checking repeater in "repeat childs properties" mode -TEST_F(TestPropertyRepeater, test_repeatAll) -{ +TEST_F(TestPropertyRepeater, test_repeatAll) { SessionModel model("test"); auto item1 = createData(model); diff --git a/Tests/UnitTests/GUI/TestProxyModelStrategy.cpp b/Tests/UnitTests/GUI/TestProxyModelStrategy.cpp index f0b6062de508259634fcdfdc00a061277720cfd8..691d37e454839acfd888bd8c615956492d7ba44d 100644 --- a/Tests/UnitTests/GUI/TestProxyModelStrategy.cpp +++ b/Tests/UnitTests/GUI/TestProxyModelStrategy.cpp @@ -7,14 +7,11 @@ #include "GUI/coregui/Models/VectorItem.h" #include "Tests/GTestWrapper/google_test.h" -class TestProxyModelStrategy : public ::testing::Test -{ -}; +class TestProxyModelStrategy : public ::testing::Test {}; //! Checking the mapping in the case of PropertyItem inserted in the source. -TEST_F(TestProxyModelStrategy, test_identityStrategy) -{ +TEST_F(TestProxyModelStrategy, test_identityStrategy) { SessionModel model("TestModel"); ComponentProxyModel proxy; IndentityProxyStrategy strategy; @@ -63,8 +60,7 @@ TEST_F(TestProxyModelStrategy, test_identityStrategy) //! Checking the mapping in the case of ParticleItem inserted in the source. -TEST_F(TestProxyModelStrategy, test_identityStrategyParticle) -{ +TEST_F(TestProxyModelStrategy, test_identityStrategyParticle) { SessionModel model("TestModel"); ComponentProxyModel proxy; IndentityProxyStrategy strategy; @@ -94,8 +90,7 @@ TEST_F(TestProxyModelStrategy, test_identityStrategyParticle) //! Checking the mapping of ComponentProxyStrategy in the case of ParticleItem inserted in //! the source. -TEST_F(TestProxyModelStrategy, test_componentStrategyParticle) -{ +TEST_F(TestProxyModelStrategy, test_componentStrategyParticle) { SessionModel model("TestModel"); ComponentProxyModel proxy; ComponentProxyStrategy strategy; @@ -134,8 +129,7 @@ TEST_F(TestProxyModelStrategy, test_componentStrategyParticle) //! Checking setRootIndex: proxy model should contain only items corresponding //! to rootIndex and its children. -TEST_F(TestProxyModelStrategy, test_setRootIndex) -{ +TEST_F(TestProxyModelStrategy, test_setRootIndex) { SessionModel model("TestModel"); ComponentProxyModel proxy; ComponentProxyStrategy strategy; diff --git a/Tests/UnitTests/GUI/TestRealSpaceBuilderUtils.cpp b/Tests/UnitTests/GUI/TestRealSpaceBuilderUtils.cpp index 1d0d90bac9b5e5d47cf347febdb70512de55c417..edb358c8b485ccb7175f4494774ad7d10102c5df 100644 --- a/Tests/UnitTests/GUI/TestRealSpaceBuilderUtils.cpp +++ b/Tests/UnitTests/GUI/TestRealSpaceBuilderUtils.cpp @@ -11,12 +11,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <QObject> -class TestRealSpaceBuilderUtils : public ::testing::Test -{ -}; +class TestRealSpaceBuilderUtils : public ::testing::Test {}; -TEST_F(TestRealSpaceBuilderUtils, test_RealSpaceModelandParticle) -{ +TEST_F(TestRealSpaceBuilderUtils, test_RealSpaceModelandParticle) { RealSpaceModel realSpaceModel; auto cylinder3D = std::make_unique<RealSpace::Particles::Cylinder>(5, 10); @@ -30,8 +27,7 @@ TEST_F(TestRealSpaceBuilderUtils, test_RealSpaceModelandParticle) // realSpaceModel.add(cylinder3D.release()); } -TEST_F(TestRealSpaceBuilderUtils, test_computeCumulativeAbundances) -{ +TEST_F(TestRealSpaceBuilderUtils, test_computeCumulativeAbundances) { SampleModel sampleModel; auto layout = dynamic_cast<ParticleLayoutItem*>(sampleModel.insertNewItem("ParticleLayout")); @@ -51,8 +47,7 @@ TEST_F(TestRealSpaceBuilderUtils, test_computeCumulativeAbundances) EXPECT_EQ(RealSpaceBuilderUtils::computeCumulativeAbundances(*layout).last(), 10.0); } -TEST_F(TestRealSpaceBuilderUtils, test_Particle3DContainer) -{ +TEST_F(TestRealSpaceBuilderUtils, test_Particle3DContainer) { Particle3DContainer p1; EXPECT_EQ(p1.containerSize(), 0u); @@ -164,8 +159,7 @@ TEST_F(TestRealSpaceBuilderUtils, test_Particle3DContainer) // The normal raw instances p1, p2 etc. get deleted by the destructor of Particle3DContainer } -TEST_F(TestRealSpaceBuilderUtils, test_singleParticle3DContainer) -{ +TEST_F(TestRealSpaceBuilderUtils, test_singleParticle3DContainer) { ApplicationModels models; SampleModel* sampleModel = models.sampleModel(); @@ -189,8 +183,7 @@ TEST_F(TestRealSpaceBuilderUtils, test_singleParticle3DContainer) EXPECT_FALSE(singleParticle3DContainer.particle3DBlend(0u)); } -TEST_F(TestRealSpaceBuilderUtils, test_particle3DContainerVector) -{ +TEST_F(TestRealSpaceBuilderUtils, test_particle3DContainerVector) { ApplicationModels models; SampleModel* sampleModel = models.sampleModel(); diff --git a/Tests/UnitTests/GUI/TestSaveService.cpp b/Tests/UnitTests/GUI/TestSaveService.cpp index 7a8569c8e8c3f8bf49433f0119098f701afca83f..31af23b77bd5d50530e8b0b4678910dc65d89e95 100644 --- a/Tests/UnitTests/GUI/TestSaveService.cpp +++ b/Tests/UnitTests/GUI/TestSaveService.cpp @@ -14,12 +14,10 @@ #include "Tests/UnitTests/GUI/Utils.h" #include <QSignalSpy> -class TestSaveService : public ::testing::Test -{ +class TestSaveService : public ::testing::Test { protected: // helper method to modify something in a model - void modify_models(ApplicationModels* models) - { + void modify_models(ApplicationModels* models) { auto instrument = models->instrumentModel()->instrumentItem(); instrument->setItemValue(InstrumentItem::P_IDENTIFIER, GUIHelpers::createUuid()); } @@ -29,8 +27,7 @@ protected: //! Testing AutosaveController. It watches ProjectDocument and sends autosaveRequest() when //! number of document changes has been accumulated. -TEST_F(TestSaveService, test_autoSaveController) -{ +TEST_F(TestSaveService, test_autoSaveController) { const QString projectDir("test_autoSaveController"); GuiUnittestUtils::create_dir(projectDir); @@ -80,8 +77,7 @@ TEST_F(TestSaveService, test_autoSaveController) //! AutosaveController shouldn't trigger autosaveRequest() if document has no name. -TEST_F(TestSaveService, test_autoSaveControllerNewDocument) -{ +TEST_F(TestSaveService, test_autoSaveControllerNewDocument) { ApplicationModels models; std::unique_ptr<ProjectDocument> document(new ProjectDocument); document->setApplicationModels(&models); @@ -102,8 +98,7 @@ TEST_F(TestSaveService, test_autoSaveControllerNewDocument) //! Testing SaveService on simple documents (no heavy data). //! SaveService should be able to save project file and send documentSaved() signal. -TEST_F(TestSaveService, test_saveService) -{ +TEST_F(TestSaveService, test_saveService) { const QString projectDir("test_saveService"); GuiUnittestUtils::create_dir(projectDir); const QString projectFileName(projectDir + "/document.pro"); @@ -133,8 +128,7 @@ TEST_F(TestSaveService, test_saveService) //! SaveService should be able to save project file (in main thread) and project nonXML //! in second thread. -TEST_F(TestSaveService, test_saveServiceWithData) -{ +TEST_F(TestSaveService, test_saveServiceWithData) { const QString projectDir("test_saveServiceWithData"); GuiUnittestUtils::create_dir(projectDir); const QString projectFileName(projectDir + "/document.pro"); @@ -168,8 +162,7 @@ TEST_F(TestSaveService, test_saveServiceWithData) //! Testing SaveService when autosave is enabled. -TEST_F(TestSaveService, test_autosaveEnabled) -{ +TEST_F(TestSaveService, test_autosaveEnabled) { const QString projectDir("test_autosaveEnabled"); GuiUnittestUtils::create_dir(projectDir); const QString projectFileName(projectDir + "/document.pro"); diff --git a/Tests/UnitTests/GUI/TestSavingSpecularData.cpp b/Tests/UnitTests/GUI/TestSavingSpecularData.cpp index 779a568b7b1a324e4fba9c79d533afc2f9d08e69..5b02ce5709fffd31f5199b753fccb6170d581d4e 100644 --- a/Tests/UnitTests/GUI/TestSavingSpecularData.cpp +++ b/Tests/UnitTests/GUI/TestSavingSpecularData.cpp @@ -18,8 +18,7 @@ #include "Tests/UnitTests/GUI/Utils.h" #include <QTest> -class TestSavingSpecularData : public ::testing::Test -{ +class TestSavingSpecularData : public ::testing::Test { public: TestSavingSpecularData(); @@ -33,34 +32,29 @@ protected: }; TestSavingSpecularData::TestSavingSpecularData() - : m_axis(new PointwiseAxis("x", std::vector<double>{0.1, 0.2, 1.0})) -{ -} + : m_axis(new PointwiseAxis("x", std::vector<double>{0.1, 0.2, 1.0})) {} -SpecularInstrumentItem* TestSavingSpecularData::createSpecularInstrument(ApplicationModels& models) -{ +SpecularInstrumentItem* +TestSavingSpecularData::createSpecularInstrument(ApplicationModels& models) { return dynamic_cast<SpecularInstrumentItem*>( models.instrumentModel()->insertNewItem("SpecularInstrument")); } -PointwiseAxisItem* TestSavingSpecularData::createPointwiseAxisItem(SessionModel& model) -{ +PointwiseAxisItem* TestSavingSpecularData::createPointwiseAxisItem(SessionModel& model) { auto instrument_item = dynamic_cast<SpecularInstrumentItem*>(model.insertNewItem("SpecularInstrument")); return dynamic_cast<PointwiseAxisItem*>( getAxisGroup(instrument_item)->getChildOfType("PointwiseAxis")); } -GroupItem* TestSavingSpecularData::getAxisGroup(SpecularInstrumentItem* instrument) -{ +GroupItem* TestSavingSpecularData::getAxisGroup(SpecularInstrumentItem* instrument) { auto axis_item = instrument->getItem(SpecularInstrumentItem::P_BEAM) ->getItem(BeamItem::P_INCLINATION_ANGLE) ->getItem(SpecularBeamInclinationItem::P_ALPHA_AXIS); return dynamic_cast<GroupItem*>(axis_item); } -bool TestSavingSpecularData::isSame(const QString& filename, const IAxis* axis) -{ +bool TestSavingSpecularData::isSame(const QString& filename, const IAxis* axis) { std::unique_ptr<OutputData<double>> dataOnDisk( IntensityDataIOFactory::readOutputData(filename.toStdString())); OutputData<double> refData; @@ -68,8 +62,7 @@ bool TestSavingSpecularData::isSame(const QString& filename, const IAxis* axis) return GuiUnittestUtils::isTheSame(*dataOnDisk, refData); } -TEST_F(TestSavingSpecularData, test_SpecularInsturment) -{ +TEST_F(TestSavingSpecularData, test_SpecularInsturment) { ApplicationModels models; // initial state @@ -100,8 +93,7 @@ TEST_F(TestSavingSpecularData, test_SpecularInsturment) EXPECT_EQ(dataItems.size(), 1); } -TEST_F(TestSavingSpecularData, test_InstrumentInJobItem) -{ +TEST_F(TestSavingSpecularData, test_InstrumentInJobItem) { ApplicationModels models; // adding JobItem @@ -137,8 +129,7 @@ TEST_F(TestSavingSpecularData, test_InstrumentInJobItem) EXPECT_EQ(dataItems.indexOf(dataItem), 0); } -TEST_F(TestSavingSpecularData, test_setLastModified) -{ +TEST_F(TestSavingSpecularData, test_setLastModified) { SessionModel model("TempModel"); auto item = createPointwiseAxisItem(model); @@ -158,8 +149,7 @@ TEST_F(TestSavingSpecularData, test_setLastModified) EXPECT_TRUE(info.wasModifiedSinceLastSave()); } -TEST_F(TestSavingSpecularData, test_DirHistory) -{ +TEST_F(TestSavingSpecularData, test_DirHistory) { SessionModel model("TempModel"); auto item1 = createPointwiseAxisItem(model); item1->init(*m_axis, "Degrees"); @@ -192,8 +182,7 @@ TEST_F(TestSavingSpecularData, test_DirHistory) } //! Testing saving abilities of OutputDataIOService class. -TEST_F(TestSavingSpecularData, test_OutputDataIOService) -{ +TEST_F(TestSavingSpecularData, test_OutputDataIOService) { const QString projectDir("test_SpecularDataSave"); GuiUnittestUtils::create_dir(projectDir); @@ -252,8 +241,7 @@ TEST_F(TestSavingSpecularData, test_OutputDataIOService) EXPECT_FALSE(ProjectUtils::exists(fname2)); } -TEST_F(TestSavingSpecularData, test_CopyInstrumentToJobItem) -{ +TEST_F(TestSavingSpecularData, test_CopyInstrumentToJobItem) { const QString projectDir("test_SpecularDataSave2"); GuiUnittestUtils::create_dir(projectDir); diff --git a/Tests/UnitTests/GUI/TestScientificSpinBox.cpp b/Tests/UnitTests/GUI/TestScientificSpinBox.cpp index a1bdee7fa3c9dfe741e47042eb225dcd9ac99195..b2446dcdcd48bad4167b82df5c1433cbee4355fa 100644 --- a/Tests/UnitTests/GUI/TestScientificSpinBox.cpp +++ b/Tests/UnitTests/GUI/TestScientificSpinBox.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <limits> -class TestScientificSpinBox : public ::testing::Test -{ -}; +class TestScientificSpinBox : public ::testing::Test {}; -TEST_F(TestScientificSpinBox, testValueFromText) -{ +TEST_F(TestScientificSpinBox, testValueFromText) { QLocale locale(QLocale::C); locale.setNumberOptions(QLocale::RejectGroupSeparator); @@ -52,8 +49,7 @@ TEST_F(TestScientificSpinBox, testValueFromText) EXPECT_EQ(0.012, to_value_2("0.012")); } -TEST_F(TestScientificSpinBox, testTextFromValue) -{ +TEST_F(TestScientificSpinBox, testTextFromValue) { int decimals = 3; auto to_string = [&decimals](double val) { return ScientificSpinBox::toString(val, decimals); }; @@ -100,8 +96,7 @@ TEST_F(TestScientificSpinBox, testTextFromValue) EXPECT_EQ("1.26556e+12", to_string(1.265556e+12).toStdString()); } -TEST_F(TestScientificSpinBox, testRound) -{ +TEST_F(TestScientificSpinBox, testRound) { auto round_3 = [](double val) { return ScientificSpinBox::round(val, 3); }; EXPECT_DOUBLE_EQ(1.232e-12, round_3(1.2323e-12)); EXPECT_DOUBLE_EQ(0.1232, round_3(0.12323)); diff --git a/Tests/UnitTests/GUI/TestSessionItem.cpp b/Tests/UnitTests/GUI/TestSessionItem.cpp index f599460b1c7b4b5d9fa56394191bb79421811c9a..547d712e3c11b9280464106a07e5486db4f46df1 100644 --- a/Tests/UnitTests/GUI/TestSessionItem.cpp +++ b/Tests/UnitTests/GUI/TestSessionItem.cpp @@ -4,12 +4,9 @@ #define EXPECT_ASSERT_TRIGGERED(condition) EXPECT_THROW((condition), std::runtime_error) -class TestSessionItem : public ::testing::Test -{ -}; +class TestSessionItem : public ::testing::Test {}; -TEST_F(TestSessionItem, initialState) -{ +TEST_F(TestSessionItem, initialState) { const QString modeltype = "This is the model type"; std::unique_ptr<SessionItem> item(new SessionItem(modeltype)); EXPECT_TRUE(item->modelType() == modeltype); @@ -18,8 +15,7 @@ TEST_F(TestSessionItem, initialState) // TODO add some more tests for children, roles, tags ... } -TEST_F(TestSessionItem, defaultTag) -{ +TEST_F(TestSessionItem, defaultTag) { const QString modelType = "TestItem"; std::unique_ptr<SessionItem> item(new SessionItem(modelType)); @@ -32,8 +28,7 @@ TEST_F(TestSessionItem, defaultTag) EXPECT_EQ(item->numberOfChildren(), 0); } -TEST_F(TestSessionItem, singleTagAndItems) -{ +TEST_F(TestSessionItem, singleTagAndItems) { const QString tag1 = "TAG1"; const QString modelType = "TestItem"; @@ -96,8 +91,7 @@ TEST_F(TestSessionItem, singleTagAndItems) EXPECT_EQ(item->getItem(tag1, 2), child2); } -TEST_F(TestSessionItem, insertAndTake) -{ +TEST_F(TestSessionItem, insertAndTake) { const QString tag1 = "TAG1"; const QString modelType = "TestItem"; @@ -121,8 +115,7 @@ TEST_F(TestSessionItem, insertAndTake) delete first; } -TEST_F(TestSessionItem, tagWithLimits) -{ +TEST_F(TestSessionItem, tagWithLimits) { const QString tag1 = "TAG1"; const QString modelType = "TestItem"; const int maxItems(3); @@ -140,8 +133,7 @@ TEST_F(TestSessionItem, tagWithLimits) EXPECT_ASSERT_TRIGGERED(item->insertItem(-1, extra, tag1)); } -TEST_F(TestSessionItem, tagsAndModelTypes) -{ +TEST_F(TestSessionItem, tagsAndModelTypes) { const QString tag1 = "tag1"; const QString tag2 = "tag2"; const QString modelType1 = "ModelType1"; @@ -178,8 +170,7 @@ TEST_F(TestSessionItem, tagsAndModelTypes) EXPECT_EQ(item->getItems(tag2), expected2); } -TEST_F(TestSessionItem, takeRow) -{ +TEST_F(TestSessionItem, takeRow) { const QString tag1 = "tag1"; const QString tag2 = "tag2"; const QString modelType1 = "ModelType1"; @@ -222,8 +213,7 @@ TEST_F(TestSessionItem, takeRow) EXPECT_EQ(item->getItems(tag2), expected2); } -TEST_F(TestSessionItem, dataRoles) -{ +TEST_F(TestSessionItem, dataRoles) { std::unique_ptr<SessionItem> item(new SessionItem("Some model type")); item->setRoleProperty(Qt::DisplayRole, 1234); EXPECT_TRUE(item->roleProperty(Qt::DisplayRole) == 1234); @@ -238,8 +228,7 @@ TEST_F(TestSessionItem, dataRoles) } } -TEST_F(TestSessionItem, modelTypes) -{ +TEST_F(TestSessionItem, modelTypes) { const QString model1 = "modeltype 1"; const QString model2 = "modeltype 2"; const QString model3 = "modeltype 3"; diff --git a/Tests/UnitTests/GUI/TestSessionItemController.cpp b/Tests/UnitTests/GUI/TestSessionItemController.cpp index 2aa0c065398523a11aebfb45ed65accc914e7763..fc3bfe72c19f7fd9e0b3ebeebb7bc0f3a520ce22 100644 --- a/Tests/UnitTests/GUI/TestSessionItemController.cpp +++ b/Tests/UnitTests/GUI/TestSessionItemController.cpp @@ -5,14 +5,11 @@ #include "Tests/UnitTests/GUI/TestSessionItemControllerHelper.h" #include <QObject> -class TestSessionItemController : public ::testing::Test -{ -}; +class TestSessionItemController : public ::testing::Test {}; //! Testing helper classes which will be used for controller testing. -TEST_F(TestSessionItemController, test_InitialState) -{ +TEST_F(TestSessionItemController, test_InitialState) { TestListener listener; EXPECT_EQ(listener.m_onItemDestroyedCount, 0); EXPECT_EQ(listener.m_onPropertyChangeCount, 0); @@ -35,8 +32,7 @@ TEST_F(TestSessionItemController, test_InitialState) //! Setting item and doing nothing. -TEST_F(TestSessionItemController, test_setItem) -{ +TEST_F(TestSessionItemController, test_setItem) { TestListener listener; TestObject object(&listener); SessionModel model("TestModel"); @@ -51,8 +47,7 @@ TEST_F(TestSessionItemController, test_setItem) //! Setting item and subscribing to it. -TEST_F(TestSessionItemController, test_setItemAndSubscribeItem) -{ +TEST_F(TestSessionItemController, test_setItemAndSubscribeItem) { TestListener listener; TestObject object(&listener); SessionModel model("TestModel"); @@ -68,8 +63,7 @@ TEST_F(TestSessionItemController, test_setItemAndSubscribeItem) //! Setting item properties when widget is in hidden/shown state. -TEST_F(TestSessionItemController, test_onPropertyChange) -{ +TEST_F(TestSessionItemController, test_onPropertyChange) { TestListener listener; TestObject object(&listener); SessionModel model("TestModel"); @@ -115,8 +109,7 @@ TEST_F(TestSessionItemController, test_onPropertyChange) //! Deleting item when widget is visible. -TEST_F(TestSessionItemController, test_onItemDestroyWidgetVisible) -{ +TEST_F(TestSessionItemController, test_onItemDestroyWidgetVisible) { TestListener listener; TestObject object(&listener); SessionModel model("TestModel"); @@ -141,8 +134,7 @@ TEST_F(TestSessionItemController, test_onItemDestroyWidgetVisible) EXPECT_TRUE(object.currentItem() == nullptr); } -TEST_F(TestSessionItemController, test_onItemDestroyWidgetHidden) -{ +TEST_F(TestSessionItemController, test_onItemDestroyWidgetHidden) { TestListener listener; TestObject object(&listener); SessionModel model("TestModel"); @@ -174,8 +166,7 @@ TEST_F(TestSessionItemController, test_onItemDestroyWidgetHidden) //! Typical scenario when one item follows the other. -TEST_F(TestSessionItemController, test_onTwoItems) -{ +TEST_F(TestSessionItemController, test_onTwoItems) { TestListener listener; TestObject object(&listener); SessionModel model("TestModel"); @@ -208,8 +199,7 @@ TEST_F(TestSessionItemController, test_onTwoItems) //! Settings two items one after another, when widget stays hidden -TEST_F(TestSessionItemController, test_onTwoItemsWhenHidden) -{ +TEST_F(TestSessionItemController, test_onTwoItemsWhenHidden) { TestListener listener; TestObject object(&listener); SessionModel model("TestModel"); @@ -241,8 +231,7 @@ TEST_F(TestSessionItemController, test_onTwoItemsWhenHidden) //! Deleting the widget when item still alive. -TEST_F(TestSessionItemController, test_deleteWidget) -{ +TEST_F(TestSessionItemController, test_deleteWidget) { TestListener listener; TestObject* object = new TestObject(&listener); SessionModel model("TestModel"); diff --git a/Tests/UnitTests/GUI/TestSessionItemControllerHelper.cpp b/Tests/UnitTests/GUI/TestSessionItemControllerHelper.cpp index 373e333e7b6312c2cf7fd1b1837aa26c717e2a3b..f02515c228491e0d046df04e9faeb7adb292eee9 100644 --- a/Tests/UnitTests/GUI/TestSessionItemControllerHelper.cpp +++ b/Tests/UnitTests/GUI/TestSessionItemControllerHelper.cpp @@ -3,36 +3,29 @@ #include "GUI/coregui/Views/CommonWidgets/SessionItemController.h" TestListener::TestListener() - : m_onItemDestroyedCount(0), m_onPropertyChangeCount(0), m_onWidgetDestroyed(0) -{ -} + : m_onItemDestroyedCount(0), m_onPropertyChangeCount(0), m_onWidgetDestroyed(0) {} -void TestListener::clear() -{ +void TestListener::clear() { m_onItemDestroyedCount = 0; m_onPropertyChangeCount = 0; m_onWidgetDestroyed = 0; } TestObject::TestObject(TestListener* listener) - : m_listener(listener), m_controller(new SessionItemController(this)), m_is_subscribed(false) -{ + : m_listener(listener), m_controller(new SessionItemController(this)), m_is_subscribed(false) { m_controller->setSubscribeCallback([this]() { onSubscribe(); }); m_controller->setUnsubscribeCallback([this]() { onUnsubscribe(); }); } -TestObject::~TestObject() -{ +TestObject::~TestObject() { m_listener->m_onWidgetDestroyed++; } -void TestObject::setItem(SessionItem* item) -{ +void TestObject::setItem(SessionItem* item) { m_controller->setItem(item); } -void TestObject::onSubscribe() -{ +void TestObject::onSubscribe() { m_is_subscribed = true; currentItem()->mapper()->setOnPropertyChange( [this](const QString&) { m_listener->m_onPropertyChangeCount++; }, this); @@ -41,18 +34,15 @@ void TestObject::onSubscribe() [this](SessionItem*) { m_listener->m_onItemDestroyedCount++; }, this); } -SessionItem* TestObject::currentItem() -{ +SessionItem* TestObject::currentItem() { return m_controller->currentItem(); } -void TestObject::onUnsubscribe() -{ +void TestObject::onUnsubscribe() { m_is_subscribed = false; } -void TestObject::setVisible(bool isVisible) -{ +void TestObject::setVisible(bool isVisible) { if (isVisible) m_controller->subscribe(); else diff --git a/Tests/UnitTests/GUI/TestSessionItemControllerHelper.h b/Tests/UnitTests/GUI/TestSessionItemControllerHelper.h index 75cb608bcefb25165fd7b871dbb95906cd8b8c20..a8dced7d7953068604e6d7b6c2d698110e5e14af 100644 --- a/Tests/UnitTests/GUI/TestSessionItemControllerHelper.h +++ b/Tests/UnitTests/GUI/TestSessionItemControllerHelper.h @@ -10,8 +10,7 @@ class SessionItemController; //! Helper class to test object behaviour after their death. -class TestListener -{ +class TestListener { public: TestListener(); void clear(); @@ -22,8 +21,7 @@ public: //! Helper class to test SessionItemController usage in widget context. -class TestObject : public QObject -{ +class TestObject : public QObject { Q_OBJECT public: TestObject(TestListener* listener); diff --git a/Tests/UnitTests/GUI/TestSessionItemData.cpp b/Tests/UnitTests/GUI/TestSessionItemData.cpp index 8c465d7e5b918fa6caac0db8832ba3b4c1a534fd..5453262b8b2c59c5f4fc3359be79054a6085feef 100644 --- a/Tests/UnitTests/GUI/TestSessionItemData.cpp +++ b/Tests/UnitTests/GUI/TestSessionItemData.cpp @@ -3,19 +3,15 @@ #include "GUI/coregui/Views/MaterialEditor/ExternalProperty.h" #include "Tests/GTestWrapper/google_test.h" -class TestSessionItemData : public ::testing::Test -{ -}; +class TestSessionItemData : public ::testing::Test {}; -TEST_F(TestSessionItemData, initialState) -{ +TEST_F(TestSessionItemData, initialState) { SessionItemData itemData; EXPECT_TRUE(itemData.roles().isEmpty()); EXPECT_FALSE(itemData.data(Qt::DisplayRole).isValid()); } -TEST_F(TestSessionItemData, setData) -{ +TEST_F(TestSessionItemData, setData) { SessionItemData itemData; // setting DisplayRole diff --git a/Tests/UnitTests/GUI/TestSessionItemTags.cpp b/Tests/UnitTests/GUI/TestSessionItemTags.cpp index 3aa594d2ff170ed94d3c7f5d9f5281e89aead4f9..03ab07d0cd862af8d7d331c93ae17ef2eb240812 100644 --- a/Tests/UnitTests/GUI/TestSessionItemTags.cpp +++ b/Tests/UnitTests/GUI/TestSessionItemTags.cpp @@ -2,19 +2,15 @@ #include "GUI/coregui/utils/GUIHelpers.h" #include "Tests/GTestWrapper/google_test.h" -class TestSessionItemTags : public ::testing::Test -{ -}; +class TestSessionItemTags : public ::testing::Test {}; -TEST_F(TestSessionItemTags, initialState) -{ +TEST_F(TestSessionItemTags, initialState) { SessionItemTags tags; EXPECT_FALSE(tags.isValid(QString())); EXPECT_FALSE(tags.isValid("abc")); } -TEST_F(TestSessionItemTags, registerTag) -{ +TEST_F(TestSessionItemTags, registerTag) { SessionItemTags tags; // registering tag @@ -37,8 +33,7 @@ TEST_F(TestSessionItemTags, registerTag) EXPECT_EQ(tags.modelTypesForTag("tag2"), expected); } -TEST_F(TestSessionItemTags, modelTypesForTag) -{ +TEST_F(TestSessionItemTags, modelTypesForTag) { SessionItemTags tags; QStringList expected = QStringList() << "Particle" @@ -53,8 +48,7 @@ TEST_F(TestSessionItemTags, modelTypesForTag) EXPECT_EQ(tags.modelTypesForTag("tag3"), QStringList()); } -TEST_F(TestSessionItemTags, tagStartIndex) -{ +TEST_F(TestSessionItemTags, tagStartIndex) { SessionItemTags tags; // registering tags @@ -92,8 +86,7 @@ TEST_F(TestSessionItemTags, tagStartIndex) EXPECT_EQ(tags.tagStartIndex("tag2"), 0); } -TEST_F(TestSessionItemTags, indexFromTagRow) -{ +TEST_F(TestSessionItemTags, indexFromTagRow) { SessionItemTags tags; tags.registerTag("tag1", 0, -1, QStringList() << "Particle"); tags.registerTag("tag2", 0, 2, QStringList() << "Particle"); @@ -114,8 +107,7 @@ TEST_F(TestSessionItemTags, indexFromTagRow) EXPECT_EQ(tags.indexFromTagRow("tag2", 1), 4); } -TEST_F(TestSessionItemTags, tagFromIndex) -{ +TEST_F(TestSessionItemTags, tagFromIndex) { SessionItemTags tags; tags.registerTag("tag1", 0, -1, QStringList() << "Particle"); tags.registerTag("tag2", 0, 2, QStringList() << "Particle"); @@ -138,8 +130,7 @@ TEST_F(TestSessionItemTags, tagFromIndex) //! Testing the method calculating insert index. -TEST_F(TestSessionItemTags, insertIndexFromTagRow) -{ +TEST_F(TestSessionItemTags, insertIndexFromTagRow) { SessionItemTags tags; tags.registerTag("tag1", 0, -1, QStringList() << "Particle"); tags.registerTag("tag2", 0, 2, QStringList() << "Particle"); diff --git a/Tests/UnitTests/GUI/TestSessionItemUtils.cpp b/Tests/UnitTests/GUI/TestSessionItemUtils.cpp index 236443f19ff705526eb4c2cdf2426ebb0a680d58..b1e44ac34978b24513a327e21a4e758983740e99 100644 --- a/Tests/UnitTests/GUI/TestSessionItemUtils.cpp +++ b/Tests/UnitTests/GUI/TestSessionItemUtils.cpp @@ -5,14 +5,11 @@ #include "GUI/coregui/Views/MaterialEditor/ExternalProperty.h" #include "Tests/GTestWrapper/google_test.h" -class TestSessionItemUtils : public ::testing::Test -{ -}; +class TestSessionItemUtils : public ::testing::Test {}; //! Test SessionItemUtils::ParentVisibleRow utility method. -TEST_F(TestSessionItemUtils, test_ParentVisibleRow) -{ +TEST_F(TestSessionItemUtils, test_ParentVisibleRow) { SessionModel model("TestModel"); // 3 property items in root, all visible @@ -52,8 +49,7 @@ TEST_F(TestSessionItemUtils, test_ParentVisibleRow) //! Comparing types of variant. -TEST_F(TestSessionItemUtils, VariantType) -{ +TEST_F(TestSessionItemUtils, VariantType) { EXPECT_TRUE(SessionItemUtils::VariantType(QVariant::fromValue(1.0)) == SessionItemUtils::VariantType(QVariant::fromValue(2.0))); EXPECT_FALSE(SessionItemUtils::VariantType(QVariant::fromValue(1.0)) @@ -87,8 +83,7 @@ TEST_F(TestSessionItemUtils, VariantType) //! Comparing types of variant. -TEST_F(TestSessionItemUtils, CompatibleVariantTypes) -{ +TEST_F(TestSessionItemUtils, CompatibleVariantTypes) { QVariant undefined; QVariant comboProperty = QVariant::fromValue(ComboProperty()); QVariant externProperty = QVariant::fromValue(ExternalProperty()); @@ -108,8 +103,7 @@ TEST_F(TestSessionItemUtils, CompatibleVariantTypes) //! Test variant equality reported by SessionItemUtils::isTheSame -TEST_F(TestSessionItemUtils, IsTheSameVariant) -{ +TEST_F(TestSessionItemUtils, IsTheSameVariant) { // comparing undefined variants QVariant v1, v2; EXPECT_TRUE(SessionItemUtils::IsTheSame(v1, v2)); diff --git a/Tests/UnitTests/GUI/TestSessionModel.cpp b/Tests/UnitTests/GUI/TestSessionModel.cpp index d27e18727f3d1bbee887404910916939009788ef..011bc55637407bb52401992bf8c7e37dd7a7335c 100644 --- a/Tests/UnitTests/GUI/TestSessionModel.cpp +++ b/Tests/UnitTests/GUI/TestSessionModel.cpp @@ -10,14 +10,11 @@ #include <QXmlStreamWriter> #include <memory> -class TestSessionModel : public ::testing::Test -{ -}; +class TestSessionModel : public ::testing::Test {}; //! Testing SessionModel::setData notifications. -TEST_F(TestSessionModel, setData) -{ +TEST_F(TestSessionModel, setData) { SessionModel model("TestModel"); auto item = model.insertNewItem("Property"); @@ -41,8 +38,7 @@ TEST_F(TestSessionModel, setData) EXPECT_EQ(spy.count(), 1); } -TEST_F(TestSessionModel, SampleModelCopy) -{ +TEST_F(TestSessionModel, SampleModelCopy) { std::unique_ptr<MaterialModel> P_materialModel(new MaterialModel()); SampleModel model1; @@ -64,8 +60,7 @@ TEST_F(TestSessionModel, SampleModelCopy) EXPECT_EQ(buffer1, buffer2); } -TEST_F(TestSessionModel, SampleModelPartialCopy) -{ +TEST_F(TestSessionModel, SampleModelPartialCopy) { std::unique_ptr<MaterialModel> P_materialModel(new MaterialModel()); SampleModel model1; @@ -83,8 +78,7 @@ TEST_F(TestSessionModel, SampleModelPartialCopy) EXPECT_EQ(result->modelType(), multilayer1->modelType()); } -TEST_F(TestSessionModel, InstrumentModelCopy) -{ +TEST_F(TestSessionModel, InstrumentModelCopy) { InstrumentModel model1; SessionItem* instrument1 = model1.insertNewItem("GISASInstrument"); instrument1->setItemName("instrument1"); @@ -104,8 +98,7 @@ TEST_F(TestSessionModel, InstrumentModelCopy) EXPECT_EQ(buffer1, buffer2); } -TEST_F(TestSessionModel, InstrumentModelPartialCopy) -{ +TEST_F(TestSessionModel, InstrumentModelPartialCopy) { InstrumentModel model1; SessionItem* instrument1 = model1.insertNewItem("GISASInstrument"); instrument1->setItemName("instrument1"); @@ -121,8 +114,7 @@ TEST_F(TestSessionModel, InstrumentModelPartialCopy) //! Test if SessionItem can be copied from one model to another. Particularly, we test //! here if a MultiLayerItem can be copied from SampleModel to the JobItem of JobModel -TEST_F(TestSessionModel, copyItem) -{ +TEST_F(TestSessionModel, copyItem) { std::unique_ptr<MaterialModel> P_materialModel(new MaterialModel()); SampleModel sampleModel; @@ -144,8 +136,7 @@ TEST_F(TestSessionModel, copyItem) EXPECT_EQ(jobItem->sessionItemTags()->childCount(JobItem::T_INSTRUMENT), 1); } -TEST_F(TestSessionModel, moveItemFromRoot) -{ +TEST_F(TestSessionModel, moveItemFromRoot) { SessionModel model("TestModel"); auto poly = model.insertNewItem("PolygonMask"); auto point = model.insertNewItem("PolygonPoint"); @@ -169,8 +160,7 @@ TEST_F(TestSessionModel, moveItemFromRoot) EXPECT_EQ(poly->getItem(), nullptr); } -TEST_F(TestSessionModel, moveBetweenParents) -{ +TEST_F(TestSessionModel, moveBetweenParents) { SessionModel model("TestModel"); auto poly1 = model.insertNewItem("PolygonMask"); auto point11 = model.insertNewItem("PolygonPoint", model.indexOfItem(poly1)); @@ -187,8 +177,7 @@ TEST_F(TestSessionModel, moveBetweenParents) EXPECT_EQ(poly1->getItem(), point12); } -TEST_F(TestSessionModel, moveWithinSameParent) -{ +TEST_F(TestSessionModel, moveWithinSameParent) { SessionModel model("TestModel"); auto poly = model.insertNewItem("PolygonMask"); auto pA = model.insertNewItem("PolygonPoint", model.indexOfItem(poly)); diff --git a/Tests/UnitTests/GUI/TestSessionXML.cpp b/Tests/UnitTests/GUI/TestSessionXML.cpp index de8c008c3495df014e48ca86207f506336b9f4c6..d91e88bb7234e0b4eb80c74efcdea9d36fd2e7bb 100644 --- a/Tests/UnitTests/GUI/TestSessionXML.cpp +++ b/Tests/UnitTests/GUI/TestSessionXML.cpp @@ -6,31 +6,25 @@ #include <QXmlStreamWriter> #include <memory> -namespace -{ -QString itemToXML(SessionItem* item) -{ +namespace { +QString itemToXML(SessionItem* item) { QString result; QXmlStreamWriter writer(&result); SessionXML::writeTo(&writer, item); return result; } -void itemFromXML(QString buffer, SessionItem* item) -{ +void itemFromXML(QString buffer, SessionItem* item) { QXmlStreamReader reader(buffer); SessionXML::readItems(&reader, item); } } // namespace -class TestSessionXML : public ::testing::Test -{ -}; +class TestSessionXML : public ::testing::Test {}; //! Testing to/from xml: simple property item. -TEST_F(TestSessionXML, test_sessionItem) -{ +TEST_F(TestSessionXML, test_sessionItem) { QString expected; SessionModel source("TestModel"); @@ -53,8 +47,7 @@ TEST_F(TestSessionXML, test_sessionItem) //! Testing to/from xml: FullSphereItem -TEST_F(TestSessionXML, test_FullSphereItem) -{ +TEST_F(TestSessionXML, test_FullSphereItem) { // source model, to xml SessionModel source("TestModel"); SessionItem* sphere = source.insertNewItem("FullSphere"); @@ -86,8 +79,7 @@ TEST_F(TestSessionXML, test_FullSphereItem) EXPECT_EQ(buffer, itemToXML(target.rootItem())); } -TEST_F(TestSessionXML, test_twoFullSphereItems) -{ +TEST_F(TestSessionXML, test_twoFullSphereItems) { // source model, to xml SessionModel source("TestModel"); SessionItem* sphere1 = source.insertNewItem("FullSphere"); @@ -103,8 +95,7 @@ TEST_F(TestSessionXML, test_twoFullSphereItems) EXPECT_EQ(buffer, itemToXML(target.rootItem())); } -TEST_F(TestSessionXML, test_emptyMultiLayer) -{ +TEST_F(TestSessionXML, test_emptyMultiLayer) { SessionModel source("TestModel"); source.insertNewItem("MultiLayer"); QString buffer = itemToXML(source.rootItem()); @@ -116,8 +107,7 @@ TEST_F(TestSessionXML, test_emptyMultiLayer) EXPECT_EQ(buffer, itemToXML(target.rootItem())); } -TEST_F(TestSessionXML, test_Layer) -{ +TEST_F(TestSessionXML, test_Layer) { SessionModel source("TestModel"); source.insertNewItem("Layer"); QString buffer = itemToXML(source.rootItem()); @@ -129,8 +119,7 @@ TEST_F(TestSessionXML, test_Layer) EXPECT_EQ(buffer, itemToXML(target.rootItem())); } -TEST_F(TestSessionXML, test_Particle) -{ +TEST_F(TestSessionXML, test_Particle) { SessionModel source("TestModel"); source.insertNewItem("Particle"); QString buffer = itemToXML(source.rootItem()); @@ -142,8 +131,7 @@ TEST_F(TestSessionXML, test_Particle) EXPECT_EQ(buffer, itemToXML(target.rootItem())); } -TEST_F(TestSessionXML, test_ParticleWithFF) -{ +TEST_F(TestSessionXML, test_ParticleWithFF) { SessionModel source("TestModel"); SessionItem* particle = source.insertNewItem("Particle"); diff --git a/Tests/UnitTests/GUI/TestTranslations.cpp b/Tests/UnitTests/GUI/TestTranslations.cpp index 6e46f38070f713dbf271def872294cb86ac2d948..ab6437906b2f87a3b32cc6c28d4aec6ca2c891ae 100644 --- a/Tests/UnitTests/GUI/TestTranslations.cpp +++ b/Tests/UnitTests/GUI/TestTranslations.cpp @@ -8,12 +8,9 @@ #include "GUI/coregui/Models/VectorItem.h" #include "Tests/GTestWrapper/google_test.h" -class TestTranslations : public ::testing::Test -{ -}; +class TestTranslations : public ::testing::Test {}; -TEST_F(TestTranslations, test_TranslatePosition) -{ +TEST_F(TestTranslations, test_TranslatePosition) { SampleModel model; SessionItem* multilayer = model.insertNewItem("MultiLayer"); SessionItem* layer = model.insertNewItem("Layer", multilayer->index()); @@ -27,8 +24,7 @@ TEST_F(TestTranslations, test_TranslatePosition) "MultiLayer/Layer/ParticleLayout/Particle/PositionX"); } -TEST_F(TestTranslations, test_TranslateRotation) -{ +TEST_F(TestTranslations, test_TranslateRotation) { SampleModel model; SessionItem* multilayer = model.insertNewItem("MultiLayer"); SessionItem* layer = model.insertNewItem("Layer", multilayer->index()); @@ -46,8 +42,7 @@ TEST_F(TestTranslations, test_TranslateRotation) "MultiLayer/Layer/ParticleLayout/Particle/XRotation/Angle"); } -TEST_F(TestTranslations, test_BeamDistributionNone) -{ +TEST_F(TestTranslations, test_BeamDistributionNone) { SampleModel model; SessionItem* instrument = model.insertNewItem("GISASInstrument"); SessionItem* beam = instrument->getItem(Instrument2DItem::P_BEAM); diff --git a/Tests/UnitTests/GUI/TestUpdateTimer.cpp b/Tests/UnitTests/GUI/TestUpdateTimer.cpp index b440f7fc5344a6f3255ba36e4b5a5ac8e2d958ef..4a37ec7a8bfcad53738f7f55d45134d998aff7c4 100644 --- a/Tests/UnitTests/GUI/TestUpdateTimer.cpp +++ b/Tests/UnitTests/GUI/TestUpdateTimer.cpp @@ -2,12 +2,9 @@ #include "Tests/GTestWrapper/google_test.h" #include <QSignalSpy> -class TestUpdateTimer : public ::testing::Test -{ -}; +class TestUpdateTimer : public ::testing::Test {}; -TEST_F(TestUpdateTimer, test_updateTimerShort) -{ +TEST_F(TestUpdateTimer, test_updateTimerShort) { const int timer_interval(100); UpdateTimer timer(timer_interval); diff --git a/Tests/UnitTests/GUI/Utils.cpp b/Tests/UnitTests/GUI/Utils.cpp index b66cfb4280948999b6f54eb6f7e84f93e1cc38d0..d583cff18efaac20a193d9c6fa09571d12b9a317 100644 --- a/Tests/UnitTests/GUI/Utils.cpp +++ b/Tests/UnitTests/GUI/Utils.cpp @@ -21,22 +21,19 @@ #include "GUI/coregui/mainwindow/ProjectUtils.h" #include "GUI/coregui/utils/GUIHelpers.h" -namespace -{ +namespace { const int nxsize = 5; const int nysize = 10; } // namespace -void GuiUnittestUtils::create_dir(const QString& dir_name) -{ +void GuiUnittestUtils::create_dir(const QString& dir_name) { if (ProjectUtils::exists(dir_name)) ProjectUtils::removeRecursively(dir_name); GUIHelpers::createSubdir(".", dir_name); } -std::unique_ptr<OutputData<double>> GuiUnittestUtils::createData(double value, DIM n_dim) -{ +std::unique_ptr<OutputData<double>> GuiUnittestUtils::createData(double value, DIM n_dim) { std::unique_ptr<OutputData<double>> result(new OutputData<double>()); result->addAxis("x", nxsize, -1.0, 1.0); if (n_dim == DIM::D2) @@ -46,22 +43,19 @@ std::unique_ptr<OutputData<double>> GuiUnittestUtils::createData(double value, D } RealDataItem* GuiUnittestUtils::createRealData(const QString& name, SessionModel& model, - double value, DIM n_dim) -{ + double value, DIM n_dim) { RealDataItem* result = dynamic_cast<RealDataItem*>(model.insertNewItem("RealData")); result->setOutputData(createData(value, n_dim).release()); result->setItemValue(SessionItem::P_NAME, name); return result; } -bool GuiUnittestUtils::isTheSame(const OutputData<double>& data1, const OutputData<double>& data2) -{ +bool GuiUnittestUtils::isTheSame(const OutputData<double>& data1, const OutputData<double>& data2) { double diff = IntensityDataFunctions::getRelativeDifference(data1, data2); return diff < 1e-10; } -bool GuiUnittestUtils::isTheSame(const QString& fileName, const OutputData<double>& data) -{ +bool GuiUnittestUtils::isTheSame(const QString& fileName, const OutputData<double>& data) { std::unique_ptr<OutputData<double>> dataOnDisk( IntensityDataIOFactory::readOutputData(fileName.toStdString())); return isTheSame(*dataOnDisk, data); diff --git a/Tests/UnitTests/GUI/Utils.h b/Tests/UnitTests/GUI/Utils.h index c565ab1e1b1e3a4c2c63e83c584680059b0a9b51..5a7ac752b00fd5cb6a23fd9dd0ab443918e7a19c 100644 --- a/Tests/UnitTests/GUI/Utils.h +++ b/Tests/UnitTests/GUI/Utils.h @@ -24,8 +24,7 @@ template <class T> class OutputData; class RealDataItem; -namespace GuiUnittestUtils -{ +namespace GuiUnittestUtils { enum class DIM { D1 = 1, D2 = 2 }; //! Creates directory in current working directory. If such directory already exists, @@ -40,8 +39,7 @@ RealDataItem* createRealData(const QString& name, SessionModel& model, double va DIM n_dim = DIM::D2); //! Converts property to XML string -template <typename T> QString propertyToXML(const T& property) -{ +template <typename T> QString propertyToXML(const T& property) { QString result; QXmlStreamWriter writer(&result); SessionXML::writeVariant(&writer, property.variant(), /*role*/ 0); @@ -49,8 +47,7 @@ template <typename T> QString propertyToXML(const T& property) } //! Converts XML string to property -template <typename T> T propertyFromXML(const QString& buffer) -{ +template <typename T> T propertyFromXML(const QString& buffer) { std::unique_ptr<PropertyItem> item(new PropertyItem); QXmlStreamReader reader(buffer); diff --git a/Tests/UnitTests/Numeric/FormFactorSpecializationTest.cpp b/Tests/UnitTests/Numeric/FormFactorSpecializationTest.cpp index 78780f7997e62e6ffca8970f8045ce79ebae374e..594106b98f8b462a2398c578f4ad1a6495db1343 100644 --- a/Tests/UnitTests/Numeric/FormFactorSpecializationTest.cpp +++ b/Tests/UnitTests/Numeric/FormFactorSpecializationTest.cpp @@ -5,18 +5,15 @@ //! Compare form factor for particle shapes A and B, where A is given special //! parameter values so that it coincides with the more symmetric B. -class FFSpecializationTest : public testing::Test -{ +class FFSpecializationTest : public testing::Test { protected: - void run_test(IBornFF* p0, IBornFF* p1, double eps, double qmag1, double qmag2) - { + void run_test(IBornFF* p0, IBornFF* p1, double eps, double qmag1, double qmag2) { formFactorTest::run_test_for_many_q([&](cvector_t q) { test_ff_eq(q, p0, p1, eps); }, qmag1, qmag2); } private: - void test_ff_eq(cvector_t q, IBornFF* p0, IBornFF* p1, double eps) - { + void test_ff_eq(cvector_t q, IBornFF* p0, IBornFF* p1, double eps) { complex_t f0 = p0->evaluate_for_q(q); complex_t f1 = p1->evaluate_for_q(q); double avge = (std::abs(f0) + std::abs(f1)) / 2; @@ -27,40 +24,35 @@ private: const double eps_polyh = 7.5e-13; -TEST_F(FFSpecializationTest, TruncatedCubeAsBox) -{ +TEST_F(FFSpecializationTest, TruncatedCubeAsBox) { const double L = .5; FormFactorTruncatedCube p0(L, 0); FormFactorBox p1(L, L, L); run_test(&p0, &p1, eps_polyh, 1e-99, 5e2); } -TEST_F(FFSpecializationTest, AnisoPyramidAsPyramid) -{ +TEST_F(FFSpecializationTest, AnisoPyramidAsPyramid) { const double L = 1.5, H = .24, alpha = .6; FormFactorAnisoPyramid p0(L, L, H, alpha); FormFactorPyramid p1(L, H, alpha); run_test(&p0, &p1, eps_polyh, 1e-99, 50); } -TEST_F(FFSpecializationTest, Pyramid3AsPrism) -{ +TEST_F(FFSpecializationTest, Pyramid3AsPrism) { const double L = 1.8, H = .3; FormFactorTetrahedron p0(L, H, M_PI / 2); FormFactorPrism3 p1(L, H); run_test(&p0, &p1, eps_polyh, 1e-99, 50); } -TEST_F(FFSpecializationTest, PyramidAsBox) -{ +TEST_F(FFSpecializationTest, PyramidAsBox) { const double L = 1.8, H = .3; FormFactorPyramid p0(L, H, M_PI / 2); FormFactorBox p1(L, L, H); run_test(&p0, &p1, eps_polyh, 1e-99, 5e2); } -TEST_F(FFSpecializationTest, Cone6AsPrism) -{ +TEST_F(FFSpecializationTest, Cone6AsPrism) { const double L = .8, H = 1.13; FormFactorCone6 p0(L, H, M_PI / 2); FormFactorPrism6 p1(L, H); @@ -69,32 +61,28 @@ TEST_F(FFSpecializationTest, Cone6AsPrism) //*********** spheroids *************** -TEST_F(FFSpecializationTest, HemiEllipsoidAsTruncatedSphere) -{ +TEST_F(FFSpecializationTest, HemiEllipsoidAsTruncatedSphere) { const double R = 1.07; FormFactorHemiEllipsoid p0(R, R, R); FormFactorTruncatedSphere p1(R, R, 0); run_test(&p0, &p1, 1e-10, 1e-99, 5e2); } -TEST_F(FFSpecializationTest, EllipsoidalCylinderAsCylinder) -{ +TEST_F(FFSpecializationTest, EllipsoidalCylinderAsCylinder) { const double R = .8, H = 1.2; FormFactorEllipsoidalCylinder p0(R, R, H); FormFactorCylinder p1(R, H); run_test(&p0, &p1, 1e-11, 1e-99, 50); } -TEST_F(FFSpecializationTest, TruncatedSphereAsSphere) -{ +TEST_F(FFSpecializationTest, TruncatedSphereAsSphere) { const double R = 1.; FormFactorTruncatedSphere p0(R, 2 * R, 0); FormFactorFullSphere p1(R); run_test(&p0, &p1, 1e-11, .02, 5e1); } -TEST_F(FFSpecializationTest, SpheroidAsSphere) -{ +TEST_F(FFSpecializationTest, SpheroidAsSphere) { const double R = 1.; FormFactorFullSpheroid p0(R, 2 * R); FormFactorFullSphere p1(R); diff --git a/Tests/UnitTests/Numeric/FormFactorSymmetryTest.cpp b/Tests/UnitTests/Numeric/FormFactorSymmetryTest.cpp index 8be47a7bf7d365a74a5927299c987c68cd98e13c..de4b7ca6e296fa13f0453b181e12f92b66a10aad 100644 --- a/Tests/UnitTests/Numeric/FormFactorSymmetryTest.cpp +++ b/Tests/UnitTests/Numeric/FormFactorSymmetryTest.cpp @@ -5,13 +5,11 @@ //! Check that form factors are invariant when q is transformed according to particle symmetry. -class FFSymmetryTest : public testing::Test -{ +class FFSymmetryTest : public testing::Test { private: using transform_t = std::function<cvector_t(const cvector_t&)>; - void test_qq_eq(cvector_t q, IBornFF* p, transform_t trafo, double eps = 1e-12) - { + void test_qq_eq(cvector_t q, IBornFF* p, transform_t trafo, double eps = 1e-12) { complex_t f0 = p->evaluate_for_q(q); complex_t f1 = p->evaluate_for_q(trafo(q)); double avge = (std::abs(f0) + std::abs(f1)) / 2; @@ -20,8 +18,7 @@ private: } protected: - void run_test(IBornFF* p, transform_t trafo, double eps, double qmag1, double qmag2) - { + void run_test(IBornFF* p, transform_t trafo, double eps, double qmag1, double qmag2) { formFactorTest::run_test_for_many_q([&](cvector_t q) { test_qq_eq(q, p, trafo, eps); }, qmag1, qmag2); } @@ -29,16 +26,14 @@ protected: //*********** polyhedra *************** -TEST_F(FFSymmetryTest, Prism3) -{ +TEST_F(FFSymmetryTest, Prism3) { FormFactorPrism3 p(.83, .45); run_test( &p, [](const cvector_t& q) -> cvector_t { return q.rotatedZ(M_TWOPI / 3); }, 1e-12, 1e-99, 2e2); } -TEST_F(FFSymmetryTest, Prism6) -{ +TEST_F(FFSymmetryTest, Prism6) { FormFactorPrism6 p(1.33, .42); run_test( &p, [](const cvector_t& q) -> cvector_t { return q.rotatedZ(M_PI / 3); }, 1e-12, 1e-99, 50); @@ -47,8 +42,7 @@ TEST_F(FFSymmetryTest, Prism6) 1e-99, 50); } -TEST_F(FFSymmetryTest, Tetrahedron) -{ +TEST_F(FFSymmetryTest, Tetrahedron) { FormFactorTetrahedron p(8.43, .25, .53); run_test( &p, [](const cvector_t& q) -> cvector_t { return q.rotatedZ(M_TWOPI / 3); }, 6e-12, 1e-99, @@ -56,8 +50,7 @@ TEST_F(FFSymmetryTest, Tetrahedron) // Linux: 3e-12, relaxed for Mac } -TEST_F(FFSymmetryTest, Cone6_flat) -{ +TEST_F(FFSymmetryTest, Cone6_flat) { // TODO for larger q, imag(ff) is nan FormFactorCone6 p(4.3, .09, .1); run_test( @@ -65,8 +58,7 @@ TEST_F(FFSymmetryTest, Cone6_flat) 50); } -TEST_F(FFSymmetryTest, Cone6_steep) -{ +TEST_F(FFSymmetryTest, Cone6_steep) { FormFactorCone6 p(.23, 3.5, .999 * M_PI / 2); run_test( &p, [](const cvector_t& q) -> cvector_t { return q.rotatedZ(-M_PI / 3); }, 1e-11, 1e-99, @@ -75,8 +67,7 @@ TEST_F(FFSymmetryTest, Cone6_steep) //*********** spheroids *************** -TEST_F(FFSymmetryTest, HemiEllipsoid) -{ +TEST_F(FFSymmetryTest, HemiEllipsoid) { FormFactorHemiEllipsoid p(.53, .78, 1.3); run_test( &p, [](const cvector_t& q) -> cvector_t { return cvector_t(-q.x(), q.y(), q.z()); }, 1e-12, @@ -86,16 +77,14 @@ TEST_F(FFSymmetryTest, HemiEllipsoid) 1e-99, 2e2); } -TEST_F(FFSymmetryTest, TruncatedSphere) -{ +TEST_F(FFSymmetryTest, TruncatedSphere) { FormFactorTruncatedSphere p(.79, .34, 0); run_test( &p, [](const cvector_t& q) -> cvector_t { return q.rotatedZ(M_PI / 3.13698); }, 1e-10, 1e-99, 2e2); } -TEST_F(FFSymmetryTest, FullSpheroid) -{ +TEST_F(FFSymmetryTest, FullSpheroid) { FormFactorFullSpheroid p(.73, .36); run_test( &p, [](const cvector_t& q) -> cvector_t { return q.rotatedZ(.123); }, 1e-12, 1e-99, 2e2); diff --git a/Tests/UnitTests/Numeric/FormFactorTest.cpp b/Tests/UnitTests/Numeric/FormFactorTest.cpp index 00f0a6113b1f5939a4317108b3ed50dfc6d8fb5c..292b4e636766e9bf2481f574e518424fae071282 100644 --- a/Tests/UnitTests/Numeric/FormFactorTest.cpp +++ b/Tests/UnitTests/Numeric/FormFactorTest.cpp @@ -5,8 +5,7 @@ using ::testing::Combine; using ::testing::Values; using ::testing::internal::ParamGenerator; -namespace formFactorTest -{ +namespace formFactorTest { const complex_t I{0, 1}; @@ -24,8 +23,7 @@ auto qlist = testing::Combine( .1 + .1 * I, -.99 + .3 * I, .999, -.9999)); void run_test_for_many_q(std::function<void(cvector_t)> run_one_test, double qmag_min, - double qmag_max) -{ + double qmag_max) { ParamGenerator<std::tuple<cvector_t, cvector_t, double, complex_t>> gen = qlist; for (auto it : gen) { cvector_t qdir = std::get<0>(it); diff --git a/Tests/UnitTests/Numeric/FormFactorTest.h b/Tests/UnitTests/Numeric/FormFactorTest.h index ff468ffe369650ad2ee38bcc727227b069ddb7c3..c6b68138aa6b41931351f4a4772289af37674821 100644 --- a/Tests/UnitTests/Numeric/FormFactorTest.h +++ b/Tests/UnitTests/Numeric/FormFactorTest.h @@ -7,8 +7,7 @@ //! Facilities for FormFactorSpecializationTest and FormFactorSymmetryTest. -namespace formFactorTest -{ +namespace formFactorTest { void run_test_for_many_q(std::function<void(cvector_t)> run_one_test, double qmag_min, double qmag_max); }