diff --git a/App/AppOptions.cpp b/App/AppOptions.cpp index f93814bf74dd9264ff4eadb93e1ff0ffcfdafa7f..d7254a7b5a80ab50d85d119b0530f9651b550924 100644 --- a/App/AppOptions.cpp +++ b/App/AppOptions.cpp @@ -22,6 +22,7 @@ #include <iostream> namespace { + const char* geometry = "geometry"; const char* nohighdpi = "nohighdpi"; diff --git a/Base/Axis/ConstKBinAxis.cpp b/Base/Axis/ConstKBinAxis.cpp index c6d758e3efab6412a9685594164ae20f54109c78..85ce933856cb858e1c078ec28150012e198e17ce 100644 --- a/Base/Axis/ConstKBinAxis.cpp +++ b/Base/Axis/ConstKBinAxis.cpp @@ -34,9 +34,8 @@ ConstKBinAxis::ConstKBinAxis(const std::string& name, size_t nbins, double start std::vector<double> bin_boundaries; bin_boundaries.resize(m_nbins + 1, 0.0); - for (size_t i = 0; i < bin_boundaries.size(); ++i) { + for (size_t i = 0; i < bin_boundaries.size(); ++i) bin_boundaries[i] = std::asin(start_sin + step * i); - } setBinBoundaries(bin_boundaries); } @@ -62,9 +61,8 @@ void ConstKBinAxis::clip(double lower, double upper) size_t new_nbins = nbin2 - nbin1 + 1; std::vector<double> new_boundaries; std::vector<double> old_boundaries = binBoundaries(); - for (size_t i = 0; i < new_nbins + 1; ++i) { + for (size_t i = 0; i < new_nbins + 1; ++i) new_boundaries.push_back(old_boundaries[nbin1 + i]); - } m_nbins = new_nbins; m_start = new_boundaries.front(); diff --git a/Base/Axis/CustomBinAxis.cpp b/Base/Axis/CustomBinAxis.cpp index 31f74cdecd0077a6f479739ffdc5d54398af73d0..1297b0c564c501c433cfc5f66aa25bd2eddc9add 100644 --- a/Base/Axis/CustomBinAxis.cpp +++ b/Base/Axis/CustomBinAxis.cpp @@ -29,15 +29,13 @@ CustomBinAxis::CustomBinAxis(const std::string& name, size_t nbins, double start double step = (end_sin - start_sin) / (m_nbins - 1); // m_nbins-1 is intentionally m_bin_centers.resize(m_nbins, 0.0); - for (size_t i = 0; i < m_bin_centers.size(); ++i) { + for (size_t i = 0; i < m_bin_centers.size(); ++i) m_bin_centers[i] = std::asin(start_sin + i * step); - } std::vector<double> bin_boundaries; bin_boundaries.resize(m_nbins + 1, 0.0); - for (size_t i = 0; i < bin_boundaries.size(); ++i) { + for (size_t i = 0; i < bin_boundaries.size(); ++i) bin_boundaries[i] = std::asin(start_sin - step / 2. + step * i); - } setBinBoundaries(bin_boundaries); } diff --git a/Base/Element/IElement.h b/Base/Element/IElement.h index caa5fe2c06a9f0f8c669035b5dc0f7e4ae9795ba..73e1f2bef266bc2bedb94de82c43f592a4c78276 100644 --- a/Base/Element/IElement.h +++ b/Base/Element/IElement.h @@ -21,6 +21,7 @@ #define BORNAGAIN_BASE_ELEMENT_IELEMENT_H #include "Base/Element/PolMatrices.h" + //#include <heinz/Vectors3D.h> #include <memory> #include <utility> diff --git a/Base/Math/Bessel.h b/Base/Math/Bessel.h index da83f384eca0a9e14a8440d0189a7f2e32670069..841f9a5d17d1f71178fdada6fd97cf026b690022 100644 --- a/Base/Math/Bessel.h +++ b/Base/Math/Bessel.h @@ -50,6 +50,7 @@ complex_t J1(complex_t z); complex_t J1c(complex_t z); } // namespace Bessel + } // namespace Math #endif // BORNAGAIN_BASE_MATH_BESSEL_H diff --git a/Base/Math/Precomputed.h b/Base/Math/Precomputed.h index acda6ea611d7ec075e04e657232cb84f33b87f20..fc87f22d4afbddd76f1503f8722604c80af88750 100644 --- a/Base/Math/Precomputed.h +++ b/Base/Math/Precomputed.h @@ -51,6 +51,7 @@ constexpr std::array<double, N> generateReciprocalFactorialArray() { return internal::generateArrayHelper<internal::ReciprocalFactorial>(Indices{}); }; + } // namespace Math #endif // BORNAGAIN_BASE_MATH_PRECOMPUTED_H diff --git a/Base/Py/PyUtils.cpp b/Base/Py/PyUtils.cpp index 0c7b1d68fd12a19548ee437866ec12414c6ffb9b..c26735bd7e36f2952639dd4a8ff8734e59a63c53 100644 --- a/Base/Py/PyUtils.cpp +++ b/Base/Py/PyUtils.cpp @@ -39,13 +39,11 @@ std::vector<std::string> BaseUtils::Python::toVectorString(PyObject* obj) PyObject* value = PyTuple_GetItem(obj, i); result.push_back(toString(value)); } - } else if (PyList_Check(obj)) { for (Py_ssize_t i = 0; i < PyList_Size(obj); i++) { PyObject* value = PyList_GetItem(obj, i); result.push_back(toString(value)); } - } else throw std::runtime_error( "BaseUtils::Python::toVectorString() -> Error. Unexpected object."); diff --git a/Core/Computation/SpecularComputation.cpp b/Core/Computation/SpecularComputation.cpp index a774a44c8d19679634c3a9fdab3839558a9211d4..cfc5c80e03639e42b9629b6362d707acd6fabebd 100644 --- a/Core/Computation/SpecularComputation.cpp +++ b/Core/Computation/SpecularComputation.cpp @@ -49,7 +49,6 @@ void SpecularComputation::runProtected() const complex_t trace = (polarization * R.adjoint() * analyzer * R).trace(); ele.setIntensity(std::abs(trace)); - } else { const complex_t R = Compute::SpecularScalar::topLayerR(slices, kz_stack); ele.setIntensity(std::norm(R)); diff --git a/Core/Contrib/RoughMultiLayerContribution.cpp b/Core/Contrib/RoughMultiLayerContribution.cpp index 1b8cd1a27b5308e5ca00bb1801e31b22e46b9a96..2e5e691acce80eb29792ef17807fdcb50583ba5e 100644 --- a/Core/Contrib/RoughMultiLayerContribution.cpp +++ b/Core/Contrib/RoughMultiLayerContribution.cpp @@ -29,6 +29,7 @@ // Phys. Rev. B, vol. 51 (4), p. 2311 (1995) namespace { + complex_t h_plus(complex_t z) { return 0.5 * cerfcx(-mul_I(z) / std::sqrt(2.0)); @@ -37,6 +38,7 @@ complex_t h_min(complex_t z) { return 0.5 * cerfcx(mul_I(z) / std::sqrt(2.0)); } + } // namespace diff --git a/Core/Export/PyFmt2.cpp b/Core/Export/PyFmt2.cpp index 9f6e5e3b9e23a6c81b297a4d63c43f8f902792ac..87c9c50a738a323e6d25392e1dd5aeb5f373cb00 100644 --- a/Core/Export/PyFmt2.cpp +++ b/Core/Export/PyFmt2.cpp @@ -53,11 +53,9 @@ std::string representShape2D(const std::string& indent, const IShape2D* ishape, result << "]\n"; result << indent << "simulation.addMask(" << "ba.Polygon(points), " << Py::Fmt::printBool(mask_value) << ")\n"; - - } else if (dynamic_cast<const InfinitePlane*>(ishape)) { + } else if (dynamic_cast<const InfinitePlane*>(ishape)) result << indent << "simulation.maskAll()\n"; - - } else if (const auto* shape = dynamic_cast<const Ellipse*>(ishape)) { + else if (const auto* shape = dynamic_cast<const Ellipse*>(ishape)) { result << indent << "simulation.addMask("; result << "ba.Ellipse(" << printValueFunc(shape->getCenterX()) << ", " << printValueFunc(shape->getCenterY()) << ", " << printValueFunc(shape->getRadiusX()) @@ -85,7 +83,6 @@ std::string representShape2D(const std::string& indent, const IShape2D* ishape, result << indent << "simulation.addMask("; result << "ba.HorizontalLine(" << printValueFunc(shape->getYpos()) << "), " << Py::Fmt::printBool(mask_value) << ")\n"; - } else throw std::runtime_error("representShape2D(const IShape2D*) -> Error. Unknown shape"); @@ -103,9 +100,8 @@ std::string printAxis(const IAxis* axis, const std::string& unit) else if (const auto* a = dynamic_cast<const PointwiseAxis*>(axis); a) { result << "numpy.asarray(["; const std::vector<double>& points = a->binCenters(); - for (auto iter = points.begin(); iter != points.end() - 1; ++iter) { + for (auto iter = points.begin(); iter != points.end() - 1; ++iter) result << Py::Fmt::printValue(*iter, unit) << ","; - } result << Py::Fmt::printValue(points.back(), unit) << "])\n"; } else throw std::runtime_error("printAxis not implemented for current axis type"); diff --git a/Core/Export/PyFmtLimits.cpp b/Core/Export/PyFmtLimits.cpp index d347cbe3488cb35b8d7ba96ff33c29914a6d53ff..ecc0755634b8b4e8934f3e866be2ce91912516f2 100644 --- a/Core/Export/PyFmtLimits.cpp +++ b/Core/Export/PyFmtLimits.cpp @@ -23,17 +23,16 @@ std::string printRealLimits(const RealLimits& limits, const std::string& units) { std::ostringstream result; - if (limits.isLimitless()) { + if (limits.isLimitless()) result << "RealLimits()"; - } - else if (limits.isPositive()) { + else if (limits.isPositive()) result << "RealLimits.positive()"; - } - else if (limits.isNonnegative()) { + + else if (limits.isNonnegative()) result << "RealLimits.nonnegative()"; - } + else if (limits.isLowerLimited()) { result << "RealLimits.lowerLimited(" << Py::Fmt::printValue(limits.lowerLimit(), units) diff --git a/Core/Export/PyFmtLimits.h b/Core/Export/PyFmtLimits.h index 81bb4420a90293d8007aad6fcbc3a56cf880d6a5..6ddccd5b243d4eaac04a49c82804bfe06ca07abc 100644 --- a/Core/Export/PyFmtLimits.h +++ b/Core/Export/PyFmtLimits.h @@ -27,8 +27,10 @@ class RealLimits; //! Utility functions for writing Python code snippets. namespace Py::Fmt { + std::string printRealLimits(const RealLimits& limits, const std::string& units = ""); std::string printRealLimitsArg(const RealLimits& limits, const std::string& units = ""); + } // namespace Py::Fmt #endif // BORNAGAIN_CORE_EXPORT_PYFMTLIMITS_H diff --git a/Core/Export/SampleToPython.cpp b/Core/Export/SampleToPython.cpp index ee35508e9a78613b83043beb044327e25279b2a4..ea7d48ef82618255f50baec263e077f5e6e0d0a2 100644 --- a/Core/Export/SampleToPython.cpp +++ b/Core/Export/SampleToPython.cpp @@ -267,7 +267,6 @@ std::string SampleToPython::defineInterferences() const if (pdf->decayLength() != 0.0) result << indent() << key << "_pdf = ba." << pdf->pythonConstructor() << "\n" << indent() << key << ".setDecayFunction(" << key << "_pdf)\n"; - } else if (const auto* iff = dynamic_cast<const InterferenceRadialParaCrystal*>(s)) { result << indent() << key << " = ba.InterferenceRadialParaCrystal(" << Py::Fmt::printNm(iff->peakDistance()) << ", " @@ -286,7 +285,6 @@ std::string SampleToPython::defineInterferences() const if (pdf->omega() != 0.0) result << indent() << key << "_pdf = ba." << pdf->pythonConstructor() << "\n" << indent() << key << ".setProbabilityDistribution(" << key << "_pdf)\n"; - } else if (const auto* iff = dynamic_cast<const Interference2DLattice*>(s)) { const auto* lattice = NodeUtils::OnlyChildOfType<Lattice2D>(*iff); @@ -300,7 +298,6 @@ std::string SampleToPython::defineInterferences() const if (iff->integrationOverXi()) result << indent() << key << ".setIntegrationOverXi(True)\n"; - } else if (const auto* iff = dynamic_cast<const InterferenceFinite2DLattice*>(s)) { const auto* lattice = NodeUtils::OnlyChildOfType<Lattice2D>(*iff); @@ -310,7 +307,6 @@ std::string SampleToPython::defineInterferences() const if (iff->integrationOverXi()) result << indent() << key << ".setIntegrationOverXi(True)\n"; - } else if (const auto* iff = dynamic_cast<const Interference2DParaCrystal*>(s)) { const auto* lattice = NodeUtils::OnlyChildOfType<Lattice2D>(*iff); std::vector<double> domainSize = iff->domainSizes(); @@ -335,12 +331,10 @@ std::string SampleToPython::defineInterferences() const result << indent() << key << "_pdf_2 = ba." << pdf->pythonConstructor() << "\n"; result << indent() << key << ".setProbabilityDistributions(" << key << "_pdf_1, " << key << "_pdf_2)\n"; - } else if (const auto* lattice_hd = dynamic_cast<const InterferenceHardDisk*>(s)) { result << indent() << key << " = ba.InterferenceHardDisk(" << Py::Fmt::printNm(lattice_hd->radius()) << ", " << Py::Fmt::printDouble(lattice_hd->density()) << ")\n"; - } else ASSERT(0); @@ -429,9 +423,8 @@ std::string SampleToPython::defineParticleCompositions() const const std::string& key = m_objs->obj2key(s); result << indent() << key << " = ba.ParticleComposition()\n"; const auto particle_list = NodeUtils::ChildNodesOfType<IParticle>(*s); - for (const auto* particle : particle_list) { + for (const auto* particle : particle_list) result << indent() << key << ".addParticle(" << m_objs->obj2key(particle) << ")\n"; - } setRotationInformation(s, key, result); setPositionInformation(s, key, result); } diff --git a/Core/Fitting/FitObjective.h b/Core/Fitting/FitObjective.h index b8f96fee6f0438a63d7eda04145e9ae095dc0ea1..b10efec91c0a7c82f70fa8a0d1a51dd85c751581 100644 --- a/Core/Fitting/FitObjective.h +++ b/Core/Fitting/FitObjective.h @@ -29,8 +29,10 @@ class PyObserverCallback; class SimDataPair; class SimulationResult; namespace mumufit { + class MinimizerResult; class Parameters; + } // namespace mumufit //! Holds vector of SimDataPair%s (experimental data and simulation results) for use in fitting. diff --git a/Core/Fitting/FitStatus.h b/Core/Fitting/FitStatus.h index 5e308f02d4ff9c75ef97a2021ffa077502ffa171..3a8bec6f992656b5cbed61c5441e4bcf72a173bb 100644 --- a/Core/Fitting/FitStatus.h +++ b/Core/Fitting/FitStatus.h @@ -26,6 +26,7 @@ #include <vector> namespace mumufit { + class MinimizerResult; } class FitObjective; diff --git a/Core/Fitting/FitTypes.h b/Core/Fitting/FitTypes.h index 53363fe5ff95e55736627a28f42aa4d6fce6ee3b..05323d4836250c4e0d5b67ff1740c9cff875d7b0 100644 --- a/Core/Fitting/FitTypes.h +++ b/Core/Fitting/FitTypes.h @@ -25,6 +25,7 @@ class ISimulation; namespace mumufit { + class Parameters; } class FitObjective; diff --git a/Core/Fitting/ObjectiveMetric.cpp b/Core/Fitting/ObjectiveMetric.cpp index 78e4253b918ae104920d77a9a382d7ba945de296..05e4a60dcb592fa3317bf6334ac972a0912c0099 100644 --- a/Core/Fitting/ObjectiveMetric.cpp +++ b/Core/Fitting/ObjectiveMetric.cpp @@ -20,6 +20,7 @@ #include <limits> 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); @@ -52,6 +53,7 @@ void checkIntegrity(const std::vector<double>& sim_data, const std::vector<doubl checkIntegrity(sim_data, exp_data, weight_factors); } + } // namespace ObjectiveMetric::ObjectiveMetric(std::function<double(double)> norm) : m_norm(std::move(norm)) {} diff --git a/Core/Fitting/ObjectiveMetricUtils.cpp b/Core/Fitting/ObjectiveMetricUtils.cpp index 88add45ebe229d4a57e02a4016ed8fbddb7cf51f..9ed2cf093acd6aaacc72ea64725006549fc8ec3e 100644 --- a/Core/Fitting/ObjectiveMetricUtils.cpp +++ b/Core/Fitting/ObjectiveMetricUtils.cpp @@ -20,6 +20,7 @@ #include <sstream> 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; }; @@ -43,6 +44,7 @@ template <class U> std::vector<std::string> keys(const std::map<std::string, U>& result.push_back(item.first); return result; } + } // namespace std::function<double(double)> ObjectiveMetricUtils::l1Norm() diff --git a/Core/Fitting/SimDataPair.cpp b/Core/Fitting/SimDataPair.cpp index 121bd6c5142ce974105fec3f859993c3be6f5509..21240192d1fb216fa1092187ae579d69f8f7ab1b 100644 --- a/Core/Fitting/SimDataPair.cpp +++ b/Core/Fitting/SimDataPair.cpp @@ -138,9 +138,9 @@ void SimDataPair::execSimulation(const mumufit::Parameters& params) m_exp_data = convertData(*simulation, *m_raw_data); - if (containsUncertainties()) { + if (containsUncertainties()) m_uncertainties = convertData(*simulation, *m_raw_uncertainties); - } else { + else { const ICoordSystem& converter = m_sim_data.converter(); std::unique_ptr<OutputData<double>> dummy_array = converter.createOutputData(converter.defaultUnits()); diff --git a/Core/Scan/AlphaScan.cpp b/Core/Scan/AlphaScan.cpp index defe789ca046b8d1e30335dd02c724f559e2e2cb..8ac4a38d3cf95a7f95ebf549b18e38e6c2e934ef 100644 --- a/Core/Scan/AlphaScan.cpp +++ b/Core/Scan/AlphaScan.cpp @@ -22,6 +22,7 @@ #include "Resample/Element/SpecularElement.h" namespace { + std::vector<std::vector<double>> extractValues(std::vector<std::vector<ParameterSample>> samples, const std::function<double(const ParameterSample&)> extractor) diff --git a/Core/Scan/ScanResolution.cpp b/Core/Scan/ScanResolution.cpp index 9eb82986e626528a2c6818115c365393e273bbe1..8a9017acbcf0fcbbc8cb06fb83d81a9352be7a91 100644 --- a/Core/Scan/ScanResolution.cpp +++ b/Core/Scan/ScanResolution.cpp @@ -18,6 +18,7 @@ #include <utility> namespace { + void checkIfEmpty(const std::vector<double>& input); const std::string relative_resolution = "ScanRelativeResolution"; @@ -151,6 +152,7 @@ public: protected: std::string name() const override; }; + } // namespace ScanResolution::~ScanResolution() = default; @@ -196,6 +198,7 @@ ScanResolution::ScanResolution() = default; ScanResolution::ScanResolution(const IRangedDistribution& distr) : m_distr(distr.clone()) {} namespace { + ScanResolution::DistrOutput ScanSingleRelativeResolution::generateSamples(double mean, size_t n_times) const { @@ -358,4 +361,5 @@ void checkIfEmpty(const std::vector<double>& input) if (input.empty()) throw std::runtime_error("Error in ScanResolution: passed vector is empty"); } + } // namespace diff --git a/Core/Simulation/ISimulation.cpp b/Core/Simulation/ISimulation.cpp index 40cc300f05b4896aeee8e6ecf4dc45e93cc9b11c..a751c1e9dd2dbc90da2c0091d84509f20752be9c 100644 --- a/Core/Simulation/ISimulation.cpp +++ b/Core/Simulation/ISimulation.cpp @@ -202,10 +202,9 @@ void ISimulation::runSimulation() if (batch_size == 0) return; - if (param_combinations == 1) { + if (param_combinations == 1) runSingleSimulation(re_sample, batch_start, batch_size, 1.); - - } else { + else { // init callbacks for setting the parameter values for (const auto& distribution : m_distribution_handler.getDistributions()) { const auto* dc = const_cast<ParameterDistribution*>(&distribution); @@ -311,7 +310,6 @@ void ISimulation::runSingleSimulation(const ProcessedSample& re_sample, size_t b std::vector<std::unique_ptr<IComputation>> computations; for (size_t i_thread = 0; i_thread < n_threads; ++i_thread) { - const size_t thread_start = batch_start + startIndex(n_threads, i_thread, batch_size); const size_t thread_size = batchSize(n_threads, i_thread, batch_size); if (thread_size == 0) diff --git a/Device/Beam/Beam.cpp b/Device/Beam/Beam.cpp index 0e5a55cb364fffd3e93ad2f9dcb3722b928e5595..86f7ebf11a1d7bc70a2ef9d3517870c4fadf9400 100644 --- a/Device/Beam/Beam.cpp +++ b/Device/Beam/Beam.cpp @@ -52,9 +52,8 @@ Beam Beam::horizontalBeam() Beam::Beam(const Beam& other) : Beam(other.m_intensity, other.m_wavelength, other.direction()) { m_bloch_vector = other.m_bloch_vector; - if (other.m_shape_factor) { + if (other.m_shape_factor) m_shape_factor.reset(other.m_shape_factor->clone()); - } } Beam& Beam::operator=(const Beam& other) @@ -67,9 +66,9 @@ Beam& Beam::operator=(const Beam& other) m_alpha = other.m_alpha; m_phi = other.m_phi; m_bloch_vector = other.m_bloch_vector; - if (other.m_shape_factor) { + if (other.m_shape_factor) m_shape_factor.reset(other.m_shape_factor->clone()); - } else + else m_shape_factor.release(); return *this; } diff --git a/Device/Coord/AxisNames.h b/Device/Coord/AxisNames.h index 94d2f3663e9f44317e12e1be7920ec4ef136d480..e6fea13d69aae44f447d2adab9fdbdaec143edd9 100644 --- a/Device/Coord/AxisNames.h +++ b/Device/Coord/AxisNames.h @@ -38,6 +38,7 @@ const std::map<Axes::Coords, const char*> axisUnitLabel = {{Axes::Coords::UNDEFI //! @ingroup detector namespace DataUtils::AxisNames { + extern BA_DEVICE_API_ const std::map<Axes::Coords, std::string> sphericalAxis0; extern BA_DEVICE_API_ const std::map<Axes::Coords, std::string> sphericalAxis1; extern BA_DEVICE_API_ const std::map<Axes::Coords, std::string> rectangularAxis0; @@ -47,6 +48,7 @@ extern BA_DEVICE_API_ const std::map<Axes::Coords, std::string> offSpecularAxis1 extern BA_DEVICE_API_ const std::map<Axes::Coords, std::string> specAxis; extern BA_DEVICE_API_ const std::map<Axes::Coords, std::string> specAxisQ; extern BA_DEVICE_API_ const std::map<Axes::Coords, std::string> sampleDepthAxis; + } // namespace DataUtils::AxisNames #endif // BORNAGAIN_DEVICE_COORD_AXISNAMES_H diff --git a/Device/Coord/ICoordSystem.cpp b/Device/Coord/ICoordSystem.cpp index 34cf5c3d8f1c85e90b2d65891aeee498574aa7d9..df1b09bcdb96e8b2e711b16d96f6739c11e6ed8f 100644 --- a/Device/Coord/ICoordSystem.cpp +++ b/Device/Coord/ICoordSystem.cpp @@ -16,7 +16,6 @@ #include "Device/Coord/AxisNames.h" #include "Device/Data/OutputData.h" - ICoordSystem::~ICoordSystem() = default; std::unique_ptr<OutputData<double>> ICoordSystem::createOutputData(Axes::Coords units) const diff --git a/Device/Data/LLData.h b/Device/Data/LLData.h index 42906a975711625c2b8a1b865527ef11719f186d..445dc6b9c654696cf685ac24d1f98ea764eaee87 100644 --- a/Device/Data/LLData.h +++ b/Device/Data/LLData.h @@ -160,11 +160,10 @@ template <class T> LLData<T>& LLData<T>::operator/=(const LLData& right) if (std::abs(m_data_array[i] - right[i]) <= std::numeric_limits<double>::epsilon() * std::abs(right[i])) { ratio = 1.0; - } else if (std::abs(right[i]) <= std::numeric_limits<double>::min()) { + } else if (std::abs(right[i]) <= std::numeric_limits<double>::min()) ratio = double(m_data_array[i]) / std::numeric_limits<double>::min(); - } else { + else ratio = double(m_data_array[i] / right[i]); - } m_data_array[i] = (T)ratio; } return *this; diff --git a/Device/Data/OutputData.cpp b/Device/Data/OutputData.cpp index 7d9233da1566f2cdb90aa97cb165d376a3c6ef10..8ae2008e308add54424bb33f9c858c384f2cf58e 100644 --- a/Device/Data/OutputData.cpp +++ b/Device/Data/OutputData.cpp @@ -51,7 +51,6 @@ template <> PyObject* OutputData<double>::getArray() const axes_indices[0] + m_axes[0]->size() * (m_axes[1]->size() - 1 - axes_indices[1]); array_buffer[offset] = (*this)[index]; } - } else { for (size_t index = 0; index < getAllocatedSize(); ++index) *array_buffer++ = (*this)[index]; diff --git a/Device/Detector/RectangularDetector.cpp b/Device/Detector/RectangularDetector.cpp index 859a154fee052e0f8d1b7b9dc160797a7dd43f8f..0e647027fd67009aae825e2eb388ae7c6c986bd8 100644 --- a/Device/Detector/RectangularDetector.cpp +++ b/Device/Detector/RectangularDetector.cpp @@ -234,13 +234,13 @@ void RectangularDetector::initNormalVector(const R3 central_k) // do nothing } - else if (m_detector_arrangement == PERPENDICULAR_TO_SAMPLE) { + else if (m_detector_arrangement == PERPENDICULAR_TO_SAMPLE) m_normal_to_detector = R3(m_distance, 0.0, 0.0); - } - else if (m_detector_arrangement == PERPENDICULAR_TO_DIRECT_BEAM) { + + else if (m_detector_arrangement == PERPENDICULAR_TO_DIRECT_BEAM) m_normal_to_detector = m_distance * central_k_unit; - } + else if (m_detector_arrangement == PERPENDICULAR_TO_REFLECTED_BEAM || m_detector_arrangement == PERPENDICULAR_TO_REFLECTED_BEAM_DPOS) { @@ -248,9 +248,8 @@ void RectangularDetector::initNormalVector(const R3 central_k) m_normal_to_detector.setZ(-m_normal_to_detector.z()); } - else { + else throw std::runtime_error("RectangularDetector::init() -> Unknown detector arrangement"); - } } void RectangularDetector::initUandV(double alpha_i) diff --git a/Device/Histo/Histogram2D.cpp b/Device/Histo/Histogram2D.cpp index ae24edf259e57a22430e774bb5ad8dc2aaabad04..acced428719e43277de9e49dd9fc73c711bbf1c8 100644 --- a/Device/Histo/Histogram2D.cpp +++ b/Device/Histo/Histogram2D.cpp @@ -166,12 +166,10 @@ Histogram1D* Histogram2D::create_projectionX(int ybinlow, int ybinup) auto* result = new Histogram1D(this->xAxis()); for (size_t index = 0; index < getTotalNumberOfBins(); ++index) { - int ybin = static_cast<int>(yAxisIndex(index)); - if (ybin >= ybinlow && ybin <= ybinup) { + if (ybin >= ybinlow && ybin <= ybinup) result->fill(xAxisValue(index), binContent(index)); - } } return result; } @@ -181,12 +179,10 @@ Histogram1D* Histogram2D::create_projectionY(int xbinlow, int xbinup) auto* result = new Histogram1D(this->yAxis()); for (size_t index = 0; index < getTotalNumberOfBins(); ++index) { - int xbin = static_cast<int>(xAxisIndex(index)); - if (xbin >= xbinlow && xbin <= xbinup) { + if (xbin >= xbinlow && xbin <= xbinup) result->fill(yAxisValue(index), binContent(index)); - } } return result; } diff --git a/Device/Histo/IHistogram.cpp b/Device/Histo/IHistogram.cpp index 34c00315d0c7932a50bc666138cd9295f5acf9f6..8fa3928e2c2f1ca3f65f7c84a75ffd01d048ad93 100644 --- a/Device/Histo/IHistogram.cpp +++ b/Device/Histo/IHistogram.cpp @@ -208,17 +208,15 @@ size_t IHistogram::getMinimumBinIndex() const void IHistogram::scale(double value) { - for (size_t index = 0; index < getTotalNumberOfBins(); ++index) { + for (size_t index = 0; index < getTotalNumberOfBins(); ++index) m_data[index].setContent(value * m_data[index].getContent()); - } } double IHistogram::integral() const { double result(0.0); - for (size_t index = 0; index < getTotalNumberOfBins(); ++index) { + for (size_t index = 0; index < getTotalNumberOfBins(); ++index) result += m_data[index].getContent(); - } return result; } @@ -294,9 +292,8 @@ void IHistogram::init_from_data(const OutputData<double>& source) } m_data.copyShapeFrom(source); - for (size_t i = 0; i < source.getAllocatedSize(); ++i) { + for (size_t i = 0; i < source.getAllocatedSize(); ++i) m_data[i].add(source[i]); - } } //! returns data of requested type for globalbin number diff --git a/Device/Histo/IntensityDataIOFactory.cpp b/Device/Histo/IntensityDataIOFactory.cpp index 25d98687e3133b47622dde60c4c63cb20b13e11c..043867341330cf86c8812582d89b102c160af553 100644 --- a/Device/Histo/IntensityDataIOFactory.cpp +++ b/Device/Histo/IntensityDataIOFactory.cpp @@ -166,7 +166,6 @@ OutputData<double>* IntensityDataIOFactory::readOutputData(const std::string& file_name, std::function<OutputData<double>*(std::istream&)> readData) { - if (!BaseUtils::Filesystem::IsFileExists(file_name)) throw std::runtime_error("File does not exist: " + file_name); diff --git a/Device/InputOutput/DataFormatUtils.cpp b/Device/InputOutput/DataFormatUtils.cpp index d1a77f9f723bb6c600549e030469f311bf5de581..c9724bf70fcd60874a7435bf103de7ec08ca72ae 100644 --- a/Device/InputOutput/DataFormatUtils.cpp +++ b/Device/InputOutput/DataFormatUtils.cpp @@ -23,6 +23,7 @@ #include <iterator> namespace { + using createAxisFun = std::function<std::unique_ptr<IAxis>(std::istringstream iss)>; const std::string GzipExtension = ".gz"; @@ -125,11 +126,11 @@ bool DataUtils::Format::isBZipped(const std::string& name) std::string DataUtils::Format::GetFileMainExtension(const std::string& name) { std::string stripped_name(name); - if (isGZipped(name)) { + if (isGZipped(name)) stripped_name = name.substr(0, name.size() - GzipExtension.size()); - } else if (isBZipped(name)) { + else if (isBZipped(name)) stripped_name = name.substr(0, name.size() - BzipExtension.size()); - } + return BaseUtils::Filesystem::extension(stripped_name); } diff --git a/Device/InputOutput/DataFormatUtils.h b/Device/InputOutput/DataFormatUtils.h index e71cceeef5068b4927ad72e1731ad0de97128548..3d7266cd8db3196fa0b9d9b7b977bbb2e9489644 100644 --- a/Device/InputOutput/DataFormatUtils.h +++ b/Device/InputOutput/DataFormatUtils.h @@ -30,6 +30,7 @@ template <class T> class OutputData; //! Utility functions for data input and output. namespace DataUtils::Format { + //! Returns true if name contains *.gz extension bool isCompressed(const std::string& name); @@ -58,6 +59,7 @@ void fillOutputData(OutputData<double>* data, std::istream& input_stream); std::vector<double> parse_doubles(const std::string& str); void readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss); + } // namespace DataUtils::Format #endif // BORNAGAIN_DEVICE_INPUTOUTPUT_DATAFORMATUTILS_H diff --git a/Device/InputOutput/OutputDataReadWriteNicos.h b/Device/InputOutput/OutputDataReadWriteNicos.h index 8de8c39c95be4f9611d51df0a8597d36d91c77d1..0c0c825147894c945a42431bfaa50c85abffb5ba 100644 --- a/Device/InputOutput/OutputDataReadWriteNicos.h +++ b/Device/InputOutput/OutputDataReadWriteNicos.h @@ -22,7 +22,6 @@ namespace IO { OutputData<double>* readNicosData(std::istream& input_stream); - }; #endif // BORNAGAIN_DEVICE_INPUTOUTPUT_OUTPUTDATAREADWRITENICOS_H diff --git a/Device/Resolution/ConvolutionDetectorResolution.cpp b/Device/Resolution/ConvolutionDetectorResolution.cpp index e66a77b0225a5b63fa83599cf02e13cdd0ffc991..e264e428354dd9acc7802214206310c38bd96847 100644 --- a/Device/Resolution/ConvolutionDetectorResolution.cpp +++ b/Device/Resolution/ConvolutionDetectorResolution.cpp @@ -96,9 +96,8 @@ void ConvolutionDetectorResolution::apply1dConvolution(OutputData<double>* p_int double step_size = std::abs(axis[0] - axis[axis.size() - 1]) / (data_size - 1); double mid_value = axis[axis.size() / 2]; // because Convolve expects zero at midpoint std::vector<double> kernel; - for (size_t index = 0; index < data_size; ++index) { + for (size_t index = 0; index < data_size; ++index) kernel.push_back(getIntegratedPDF1d(axis[index] - mid_value, step_size)); - } // Calculate convolution std::vector<double> result; Convolve().fftconvolve(source_vector, kernel, result); diff --git a/Device/Resolution/Convolve.cpp b/Device/Resolution/Convolve.cpp index 680fbb68f55ea56e14bd58e2dd1744dc382db1a4..d2b7d4e2db35d05487e9aa0e53a89ca3fdc5a677 100644 --- a/Device/Resolution/Convolve.cpp +++ b/Device/Resolution/Convolve.cpp @@ -319,9 +319,8 @@ bool Convolve::is_optimal(int n) return false; size_t ntest = n; for (size_t i = 0; i < m_implemented_factors.size(); i++) { - while ((ntest % m_implemented_factors[i]) == 0) { + while ((ntest % m_implemented_factors[i]) == 0) ntest = ntest / m_implemented_factors[i]; - } } return ntest == 1; } diff --git a/Fit/Adapter/GSLLevenbergMarquardtMinimizer.h b/Fit/Adapter/GSLLevenbergMarquardtMinimizer.h index e970a266b1ad1212f7373523ae603577fbb11e9f..9e213a6fb3b82e484eec0fd349ad5e7a281e0517 100644 --- a/Fit/Adapter/GSLLevenbergMarquardtMinimizer.h +++ b/Fit/Adapter/GSLLevenbergMarquardtMinimizer.h @@ -23,6 +23,7 @@ #include "Fit/Adapter/MinimizerAdapter.h" namespace ROOT::Math { + class GSLNLSMinimizer; } diff --git a/Fit/Adapter/GSLMultiMinimizer.h b/Fit/Adapter/GSLMultiMinimizer.h index 2e6edc20a296dbee508128df648a2cf7a8052899..50cfe3a9cb3bb32cc50aa24dfbde5aea51add14a 100644 --- a/Fit/Adapter/GSLMultiMinimizer.h +++ b/Fit/Adapter/GSLMultiMinimizer.h @@ -23,6 +23,7 @@ #include "Fit/Adapter/MinimizerAdapter.h" namespace ROOT::Math { + class GSLMinimizer; } diff --git a/Fit/Adapter/GeneticMinimizer.cpp b/Fit/Adapter/GeneticMinimizer.cpp index 67547ad38756ccfc0731f9966a5dd23bbaf46fc7..e72781c9cc8a340490164d33cf1a33d9276d3bf5 100644 --- a/Fit/Adapter/GeneticMinimizer.cpp +++ b/Fit/Adapter/GeneticMinimizer.cpp @@ -24,6 +24,7 @@ std::map<int, std::string> statusDescription() result[1] = "Maximum number of iterations reached"; return result; } + } // namespace GeneticMinimizer::GeneticMinimizer() diff --git a/Fit/Adapter/GeneticMinimizer.h b/Fit/Adapter/GeneticMinimizer.h index d0ba376ef7d8ebe0e9be71f876dc2d0ffd52ede2..f262de411a3fd5edddbb4cd4caecc061eca0c157 100644 --- a/Fit/Adapter/GeneticMinimizer.h +++ b/Fit/Adapter/GeneticMinimizer.h @@ -23,6 +23,7 @@ #include "Fit/Adapter/MinimizerAdapter.h" namespace ROOT::Math { + class GeneticMinimizer; } diff --git a/Fit/Adapter/MinimizerAdapter.cpp b/Fit/Adapter/MinimizerAdapter.cpp index 3a040ecac678d76f01e328c561164bf74a1a0260..590ff822671bfbd893285b55386fc3c818d9b035 100644 --- a/Fit/Adapter/MinimizerAdapter.cpp +++ b/Fit/Adapter/MinimizerAdapter.cpp @@ -141,11 +141,9 @@ void MinimizerAdapter::propagateResults(mumufit::Parameters& parameters) void MinimizerAdapter::setParameter(unsigned int index, const mumufit::Parameter& par) { bool success; - if (par.limits().isFixed()) { + if (par.limits().isFixed()) success = rootMinimizer()->SetFixedVariable(index, par.name().c_str(), par.value()); - } - else if (par.limits().isLimited()) { success = rootMinimizer()->SetLimitedVariable(index, par.name().c_str(), par.value(), par.step(), par.limits().lowerLimit(), @@ -162,13 +160,12 @@ void MinimizerAdapter::setParameter(unsigned int index, const mumufit::Parameter par.step(), par.limits().upperLimit()); } - else if (par.limits().isLimitless()) { + else if (par.limits().isLimitless()) success = rootMinimizer()->SetVariable(index, par.name().c_str(), par.value(), par.step()); - } - else { + + else throw std::runtime_error("BasicMinimizer::setParameter() -> Error! Unexpected parameter."); - } if (!success) { std::ostringstream ostr; diff --git a/Fit/Adapter/MinimizerAdapter.h b/Fit/Adapter/MinimizerAdapter.h index 7486ec3280c6a74f8537667665b84e3311353c4e..8b1afb2e6b8099f3f9ee35b38fb81c4540683217 100644 --- a/Fit/Adapter/MinimizerAdapter.h +++ b/Fit/Adapter/MinimizerAdapter.h @@ -27,13 +27,16 @@ #include <string> namespace mumufit { + class Parameters; class Parameter; class ObjectiveFunctionAdapter; class MinimizerResult; + } // namespace mumufit namespace ROOT::Math { + class Minimizer; } diff --git a/Fit/Adapter/Minuit2Minimizer.h b/Fit/Adapter/Minuit2Minimizer.h index 583955fc0b9b98264249dea4c0a89f5c1e777583..df0c9ee4fae0c700002e23466e998f2c5edf6b2c 100644 --- a/Fit/Adapter/Minuit2Minimizer.h +++ b/Fit/Adapter/Minuit2Minimizer.h @@ -24,6 +24,7 @@ #include <memory> namespace ROOT::Minuit2 { + class Minuit2Minimizer; } diff --git a/Fit/Adapter/ResidualFunctionAdapter.cpp b/Fit/Adapter/ResidualFunctionAdapter.cpp index aa5b016bc9c62b02913d90a0b5fb5cfa0fc6646f..163298653b0dbf92a85438fb2e38ca4cc830ba93 100644 --- a/Fit/Adapter/ResidualFunctionAdapter.cpp +++ b/Fit/Adapter/ResidualFunctionAdapter.cpp @@ -20,8 +20,10 @@ #include <utility> namespace { + // step size of derivative calculations const double kEps = 1.0E-9; + } // namespace using namespace mumufit; @@ -101,9 +103,8 @@ std::vector<double> ResidualFunctionAdapter::get_residuals(const std::vector<dou double ResidualFunctionAdapter::element_residual(const std::vector<double>& pars, unsigned int index, std::vector<double>& gradients) { - if (index == 0) { + if (index == 0) m_residuals = get_residuals(pars); - } if (!gradients.empty()) { // Non zero size means that minimizer wants to know gradients. diff --git a/Fit/Adapter/ResidualFunctionAdapter.h b/Fit/Adapter/ResidualFunctionAdapter.h index 12a2e1c094a3edb35bc13b7ae23917750c82ab5e..4a9be343a3dda7840dc995185b06fa48af218b46 100644 --- a/Fit/Adapter/ResidualFunctionAdapter.h +++ b/Fit/Adapter/ResidualFunctionAdapter.h @@ -59,7 +59,7 @@ private: std::unique_ptr<RootResidualFunction> m_root_objective; }; -} // namespace mumufit +} // namespace mumufit #endif // BORNAGAIN_FIT_ADAPTER_RESIDUALFUNCTIONADAPTER_H #endif // USER_API diff --git a/Fit/Adapter/ScalarFunctionAdapter.h b/Fit/Adapter/ScalarFunctionAdapter.h index c9cd6981e55eb8c598ef95b03fd21591ee69c18a..bf72d50b1f6ecbb1bd4fdb94b88bcc821c7ac307 100644 --- a/Fit/Adapter/ScalarFunctionAdapter.h +++ b/Fit/Adapter/ScalarFunctionAdapter.h @@ -49,7 +49,7 @@ private: std::unique_ptr<RootScalarFunction> m_root_objective; }; -} // namespace mumufit +} // namespace mumufit #endif // BORNAGAIN_FIT_ADAPTER_SCALARFUNCTIONADAPTER_H #endif // USER_API diff --git a/Fit/Adapter/SimAnMinimizer.h b/Fit/Adapter/SimAnMinimizer.h index ebc0dfed1a715d470829f03b93b476d04a9aafc0..38ad18b0befdecedbc56a187c972a89ffaf89fd9 100644 --- a/Fit/Adapter/SimAnMinimizer.h +++ b/Fit/Adapter/SimAnMinimizer.h @@ -23,6 +23,7 @@ #include "Fit/Adapter/MinimizerAdapter.h" namespace ROOT::Math { + class GSLSimAnMinimizer; } diff --git a/Fit/Kernel/Kernel.cpp b/Fit/Kernel/Kernel.cpp index 9bc354812fcb3aa0267579d63b4b8d67c67c30e3..ea7053b736122826050ee6934525217f6cf828b7 100644 --- a/Fit/Kernel/Kernel.cpp +++ b/Fit/Kernel/Kernel.cpp @@ -20,8 +20,10 @@ using namespace mumufit; namespace { + const std::string default_minimizer = "Minuit2"; const std::string default_algorithm = "Migrad"; + } // namespace Kernel::Kernel() diff --git a/Fit/Kernel/Minimizer.cpp b/Fit/Kernel/Minimizer.cpp index c7ee9fa8819700e0cdaff83cbbb7ea545b7d3edc..637d740dc38f16fc9b8990faeb72aa5253689bee 100644 --- a/Fit/Kernel/Minimizer.cpp +++ b/Fit/Kernel/Minimizer.cpp @@ -48,7 +48,6 @@ MinimizerResult Minimizer::minimize(const PyCallback& callback, const Parameters if (callback.callback_type() == PyCallback::SCALAR) { fcn_scalar_t fcn = [&](const Parameters& pars) { return callback.call_scalar(pars); }; return minimize(fcn, parameters); - } else if (callback.callback_type() == PyCallback::RESIDUAL) { fcn_residual_t fcn = [&](const Parameters& pars) { return callback.call_residuals(pars); }; return minimize(fcn, parameters); diff --git a/Fit/Kernel/MinimizerFactory.cpp b/Fit/Kernel/MinimizerFactory.cpp index 8785830c0eae74b02d490aed55a764bad1991f19..e2ac95f4d5772558e91d6fe0557f71a49cc045bd 100644 --- a/Fit/Kernel/MinimizerFactory.cpp +++ b/Fit/Kernel/MinimizerFactory.cpp @@ -30,25 +30,24 @@ IMinimizer* MinimizerFactory::createMinimizer(const std::string& minimizerName, { IMinimizer* result(nullptr); - if (minimizerName == "Minuit2") { + if (minimizerName == "Minuit2") result = new Minuit2Minimizer(algorithmType); - } - else if (minimizerName == "GSLLMA") { + else if (minimizerName == "GSLLMA") result = new GSLLevenbergMarquardtMinimizer(); - } - else if (minimizerName == "GSLSimAn") { + + else if (minimizerName == "GSLSimAn") result = new SimAnMinimizer(); - } - else if (minimizerName == "GSLMultiMin") { + + else if (minimizerName == "GSLMultiMin") result = new GSLMultiMinimizer(algorithmType); - } - else if (minimizerName == "Genetic") { + + else if (minimizerName == "Genetic") result = new GeneticMinimizer(); - } + if (!result) { std::ostringstream ostr; diff --git a/Fit/Minimizer/IMinimizer.h b/Fit/Minimizer/IMinimizer.h index e10369d25b5c7e7544db364e0fdf07800dff6c45..64c668b47c1172479b86e91c338c3a9f259fcd2b 100644 --- a/Fit/Minimizer/IMinimizer.h +++ b/Fit/Minimizer/IMinimizer.h @@ -21,6 +21,7 @@ #include <string> namespace mumufit { + class Parameters; } diff --git a/Fit/Minimizer/MinimizerOptions.cpp b/Fit/Minimizer/MinimizerOptions.cpp index 5d9bfa5ac7a859df577363c78a31dd3153e56e87..5beb83cbf1e3319f4fc5ebc67b2cf9d5f6da00fc 100644 --- a/Fit/Minimizer/MinimizerOptions.cpp +++ b/Fit/Minimizer/MinimizerOptions.cpp @@ -19,15 +19,15 @@ #include <stdexcept> namespace { + const std::string delimeter = ";"; } std::string MinimizerOptions::toOptionString() const { std::ostringstream result; - for (const auto& option : m_options) { + for (const auto& option : m_options) result << option->name() << "=" << option->value_str() << delimeter; - } return result.str(); } diff --git a/Fit/Minimizer/MinimizerResult.cpp b/Fit/Minimizer/MinimizerResult.cpp index 07fc82693191184c2b1f8be15c7253c69edfb625..4b8c24b8845868ba3c9782e5c7017fc6a3dfd336 100644 --- a/Fit/Minimizer/MinimizerResult.cpp +++ b/Fit/Minimizer/MinimizerResult.cpp @@ -90,7 +90,6 @@ std::string MinimizerResult::toString() const if (m_minimizer_report.empty()) { result << "Don't know anything about external minimizer. " << "Use minimizer API to get result of minimization.\n"; - } else { result << mumufit::utils::sectionString(); result << "Run time (sec) : " << m_duration << "\n"; diff --git a/Fit/Minimizer/Types.h b/Fit/Minimizer/Types.h index 10b2ba1bbf7b9fb52f885837f64faa6f1ca3c4b9..2ae44be5bbb4a88e9bc435bb952276645ed48aff 100644 --- a/Fit/Minimizer/Types.h +++ b/Fit/Minimizer/Types.h @@ -24,6 +24,7 @@ #include <vector> namespace mumufit { + class Parameters; } diff --git a/Fit/Param/Parameter.cpp b/Fit/Param/Parameter.cpp index f34ef0572035d8a445d224042af052bf6404b86c..93423082bf17acc944019b17b6b01168e1a90bb5 100644 --- a/Fit/Param/Parameter.cpp +++ b/Fit/Param/Parameter.cpp @@ -17,6 +17,7 @@ #include <utility> namespace { + const double default_step = 0.01; const double step_factor = 0.01; @@ -24,6 +25,7 @@ double step_for_value(double value) { return value == 0.0 ? default_step : std::abs(value) * step_factor; } + } // namespace using namespace mumufit; diff --git a/Fit/Test/Functional/ClassicalTestFunctions.h b/Fit/Test/Functional/ClassicalTestFunctions.h index c0ee94f90f43ab1efc52f055f7aa118b052a6d30..3c484d4b4d107c5c6368ad23112aa1f51f36b55c 100644 --- a/Fit/Test/Functional/ClassicalTestFunctions.h +++ b/Fit/Test/Functional/ClassicalTestFunctions.h @@ -23,9 +23,11 @@ //! Borrowed from StressFit test framework of http://root.cern.ch. 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); + } // namespace TestFunctions #endif // BORNAGAIN_FIT_TEST_FUNCTIONAL_CLASSICALTESTFUNCTIONS_H diff --git a/Fit/Test/Functional/PlanCases.cpp b/Fit/Test/Functional/PlanCases.cpp index 7fd04ee2d05f3ee46481443f122d48c82ce7d65d..dfc3f0d9be34d2d9510c86982916a315a5e186bd 100644 --- a/Fit/Test/Functional/PlanCases.cpp +++ b/Fit/Test/Functional/PlanCases.cpp @@ -16,6 +16,7 @@ #include "Fit/Test/Functional/ClassicalTestFunctions.h" namespace { + const double loose_tolerance = 0.1; } diff --git a/Fit/TestEngine/MinimizerTestPlan.h b/Fit/TestEngine/MinimizerTestPlan.h index c6718818342d0b2cfdff336dffd6ee0c2b1b8a57..bd3c266a87b88d6c963350df5997d7400a27318f 100644 --- a/Fit/TestEngine/MinimizerTestPlan.h +++ b/Fit/TestEngine/MinimizerTestPlan.h @@ -34,9 +34,11 @@ struct ParameterReference { }; namespace mumufit { + class Parameter; class Parameters; class Minimizer; + } // namespace mumufit //! Defines objective function to fit, expected minimum, initial fit parameters and diff --git a/GUI/Application/ApplicationSettings.cpp b/GUI/Application/ApplicationSettings.cpp index c16b10233138f8415f65c868b674678c84d45e65..8dbbf3a980029a13870b639cc6cd67b2453f51a3 100644 --- a/GUI/Application/ApplicationSettings.cpp +++ b/GUI/Application/ApplicationSettings.cpp @@ -21,6 +21,7 @@ #include <QWidget> namespace { + const QString S_CREATE_NEW_PROJECT_ON_STARTUP = "CreateNewProjectOnStartup"; const QString S_STYLE = "Style"; const QString S_SIZE = "Size"; @@ -29,6 +30,7 @@ const QString S_DEFAULT_FUNCTIONALITIES = "DefaultFunctionalities"; const QString S_SINGLE_INSTRUMENT_MODE = "SingleInstrumentMode"; const QString S_SINGLE_SAMPLE_MODE = "SingleSampleMode"; const QString S_DEFAULT_UNIT_IS_ANGSTROM = "DefaultUnitIsAngstrom"; + } // namespace ApplicationSettings* appSettings; //!< global pointer to _the_ instance diff --git a/GUI/Model/Data/Data1DViewItem.cpp b/GUI/Model/Data/Data1DViewItem.cpp index 38d7c6c31526ee35e690f02bff8e584fe4ecd640..ddf15e957baa2a389ca55f1d171b495932f5349a 100644 --- a/GUI/Model/Data/Data1DViewItem.cpp +++ b/GUI/Model/Data/Data1DViewItem.cpp @@ -23,11 +23,13 @@ #include "GUI/Util/Error.h" namespace { + const QString x_axis_default_name = "X [nbins]"; const QString y_axis_default_name = "Signal [a.u.]"; const double default_min = 0.0; const double default_max = 1.0; + } // namespace Data1DViewItem::Data1DViewItem() : SessionItem(M_TYPE), m_job_item(nullptr) @@ -65,7 +67,6 @@ Data1DViewItem::Data1DViewItem() : SessionItem(M_TYPE), m_job_item(nullptr) int Data1DViewItem::getNbins() const { - return xAxisItem()->binCount(); } diff --git a/GUI/Model/Data/DataItemUtils.cpp b/GUI/Model/Data/DataItemUtils.cpp index 63f9da758efea83e20ffe2a20718d4fb11ed4102..b299f6eef9a987a6bf01ad3a10b726d1ad80f8bc 100644 --- a/GUI/Model/Data/DataItemUtils.cpp +++ b/GUI/Model/Data/DataItemUtils.cpp @@ -19,6 +19,7 @@ #include "GUI/Model/Job/JobItem.h" namespace { + template <class DataItemType> DataItemType* dataItem(SessionItem* parent) { ASSERT(parent && "Assertion failed in GUI::Model::DataItemUtils::dataItem: nullptr passed."); @@ -31,6 +32,7 @@ template <class DataItemType> DataItemType* dataItem(SessionItem* parent) return self; ASSERT(0); } + } // namespace IntensityDataItem* GUI::Model::DataItemUtils::intensityDataItem(SessionItem* parent) diff --git a/GUI/Model/Data/DataProperties.cpp b/GUI/Model/Data/DataProperties.cpp index 7826c075e837d570d449769408065bd52082e885..1e76ee8f7f0f9438974a0bcc0ab933983c367663 100644 --- a/GUI/Model/Data/DataProperties.cpp +++ b/GUI/Model/Data/DataProperties.cpp @@ -22,6 +22,7 @@ #include <utility> 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}, @@ -39,6 +40,7 @@ struct ColorNameComparator { }; ComboProperty defaultColorCombo(); + } // namespace DataProperties::DataProperties(const QString& model_type) : SessionItem(model_type) @@ -107,6 +109,7 @@ void Data1DProperties::setColorProperty(const QString& color_name) } namespace { + ComboProperty defaultColorCombo() { ComboProperty result; @@ -115,4 +118,5 @@ ComboProperty defaultColorCombo() result.setValue(color_queue.front().first); return result; } + } // namespace diff --git a/GUI/Model/Data/DataViewUtils.h b/GUI/Model/Data/DataViewUtils.h index 06848f21b2f9bae4ac594a8f17f82d7c4564347a..33c142800a6b39f26e3f28b0b89c6a8287f1d375 100644 --- a/GUI/Model/Data/DataViewUtils.h +++ b/GUI/Model/Data/DataViewUtils.h @@ -24,10 +24,12 @@ class JobItem; template <class T> class OutputData; namespace GUI::Model::DataViewUtils { + void updateAxesTitle(Data1DViewItem* view_item); std::unique_ptr<OutputData<double>> getTranslatedData(Data1DViewItem* view_item, DataItem* data_item); + } // namespace GUI::Model::DataViewUtils #endif // BORNAGAIN_GUI_MODEL_DATA_DATAVIEWUTILS_H diff --git a/GUI/Model/Data/ImportDataInfo.cpp b/GUI/Model/Data/ImportDataInfo.cpp index 140f41cbb2276146fbed4d7dc9cd0253bdb7f8ff..48a389496559128e561d9897d65c287dfe862f25 100644 --- a/GUI/Model/Data/ImportDataInfo.cpp +++ b/GUI/Model/Data/ImportDataInfo.cpp @@ -22,6 +22,7 @@ #include <memory> namespace { + std::vector<Axes::Coords> specularUnits() { std::vector<Axes::Coords> result; @@ -33,6 +34,7 @@ std::vector<Axes::Coords> specularUnits() // map: data rank --> available units std::map<size_t, std::vector<Axes::Coords>> available_units = {{1u, specularUnits()}, {2u, {Axes::Coords::NBINS}}}; + } // namespace ImportDataInfo::ImportDataInfo(ImportDataInfo&& other) noexcept diff --git a/GUI/Model/Data/IntensityDataItem.cpp b/GUI/Model/Data/IntensityDataItem.cpp index 2756a66e17d1994d6f5f123c7321a4fe08981fbd..17cd42c1bbcf58b25907882b4664cee96de9cc8e 100644 --- a/GUI/Model/Data/IntensityDataItem.cpp +++ b/GUI/Model/Data/IntensityDataItem.cpp @@ -23,6 +23,7 @@ #include "GUI/Util/Error.h" namespace { + ComboProperty gradientCombo() { ComboProperty result; @@ -41,6 +42,7 @@ ComboProperty gradientCombo() result.setValue("Jet"); return result; } + } // namespace const QString x_axis_default_name = "X [nbins]"; diff --git a/GUI/Model/Data/MaskUnitsConverter.cpp b/GUI/Model/Data/MaskUnitsConverter.cpp index 6abd1d82b6cd751b5a0f1f348f8c39a93eff7bb2..b6e1ef966d1390e6a6fadb8ba35ad23e6d669361 100644 --- a/GUI/Model/Data/MaskUnitsConverter.cpp +++ b/GUI/Model/Data/MaskUnitsConverter.cpp @@ -19,6 +19,7 @@ #include "GUI/Model/Data/ProjectionItems.h" #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_downcast; MaskUnitsConverter::MaskUnitsConverter() : m_data(nullptr), m_direction(UNDEFINED) {} diff --git a/GUI/Model/Data/PointwiseAxisItem.h b/GUI/Model/Data/PointwiseAxisItem.h index 84db6449d02e1c7c67fd8851db82f10a57e2725d..b1ce89482491626b3a231d9f63818148cf25d827 100644 --- a/GUI/Model/Data/PointwiseAxisItem.h +++ b/GUI/Model/Data/PointwiseAxisItem.h @@ -23,7 +23,6 @@ class SpecularInstrumentItem; //! Item for non-uniform axis with specified coordinates. class PointwiseAxisItem : public BasicAxisItem, public SaveLoadInterface { - private: static constexpr auto P_NATIVE_AXIS_UNITS{"NativeAxisUnits"}; static constexpr auto P_FILE_NAME{"FileName"}; diff --git a/GUI/Model/Data/RealDataItem.h b/GUI/Model/Data/RealDataItem.h index 5ad28fc9abd004a1fb85ed4e2dfd652b5dd0063c..193ef481bbb76993d73e90c5afe7a9858459858d 100644 --- a/GUI/Model/Data/RealDataItem.h +++ b/GUI/Model/Data/RealDataItem.h @@ -34,7 +34,6 @@ class AbstractDataLoader; //! Owns an AbstractDataLoader. class BA_CORE_API_ RealDataItem : public QObject, public SessionItem { - Q_OBJECT friend class TestView; diff --git a/GUI/Model/Fit/FitParameterContainerItem.h b/GUI/Model/Fit/FitParameterContainerItem.h index 0e9c6de103cc7a5b6979e864ef4e19f9417648f0..642d4fe43ce1c0f9561a9b39b16a66cd5ce931db 100644 --- a/GUI/Model/Fit/FitParameterContainerItem.h +++ b/GUI/Model/Fit/FitParameterContainerItem.h @@ -18,6 +18,7 @@ #include "GUI/Model/Session/SessionItem.h" namespace mumufit { + class Parameters; } class FitParameterItem; diff --git a/GUI/Model/Fit/FitParameterHelper.cpp b/GUI/Model/Fit/FitParameterHelper.cpp index 0a61bdcdff32805ae7c07ae38bbced52982d54be..f53316d53ba3bfc800b36ac002e8f69ceab212bc 100644 --- a/GUI/Model/Fit/FitParameterHelper.cpp +++ b/GUI/Model/Fit/FitParameterHelper.cpp @@ -83,9 +83,8 @@ QStringList FitParameterHelper::getFitParameterNames(FitParameterContainerItem* { ASSERT(container); QStringList result; - for (FitParameterItem* item : container->fitParameterItems()) { + for (FitParameterItem* item : container->fitParameterItems()) result.append(item->displayName()); - } return result; } @@ -107,9 +106,8 @@ ParameterItem* FitParameterHelper::getParameterItem(FitParameterContainerItem* c const QString& link) { SessionItem* cur = container; - while (cur && cur->modelType() != JobItem::M_TYPE) { + while (cur && cur->modelType() != JobItem::M_TYPE) cur = cur->parent(); - } ASSERT(cur && cur->modelType() == JobItem::M_TYPE); auto* jobItem = dynamic_cast<JobItem*>(cur); ASSERT(jobItem); diff --git a/GUI/Model/Fit/FitParameterItem.cpp b/GUI/Model/Fit/FitParameterItem.cpp index 1b64c3ccb40ab6644c7acf3f2db54b5ea8a9fef9..b0d18b5acdbbe69ab8a4fb8d632df0b12f65dc00 100644 --- a/GUI/Model/Fit/FitParameterItem.cpp +++ b/GUI/Model/Fit/FitParameterItem.cpp @@ -71,11 +71,10 @@ void FitParameterItem::initMinMaxValues(const RealLimits& limits) double value = getItemValue(P_START_VALUE).toDouble(); double dr(0); - if (value == 0.0) { + if (value == 0.0) dr = 1.0 * range_factor; - } else { + else dr = std::abs(value) * range_factor; - } double min = value - dr; double max = value + dr; diff --git a/GUI/Model/Fit/FitParameterProxyModel.cpp b/GUI/Model/Fit/FitParameterProxyModel.cpp index 2a150c58eec35263f69c25b17788a8ed00267fd1..ce6ff0b73cc1a2acb115cae435117cfd9d0dd2db 100644 --- a/GUI/Model/Fit/FitParameterProxyModel.cpp +++ b/GUI/Model/Fit/FitParameterProxyModel.cpp @@ -25,6 +25,7 @@ #include <QMimeData> #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_downcast; #include <optional> @@ -56,9 +57,8 @@ FitParameterProxyModel::FitParameterProxyModel(FitParameterContainerItem* fitPar FitParameterProxyModel::~FitParameterProxyModel() { - if (m_root_item) { + if (m_root_item) m_root_item->mapper()->unsubscribe(this); - } } Qt::ItemFlags FitParameterProxyModel::flags(const QModelIndex& index) const @@ -70,9 +70,8 @@ Qt::ItemFlags FitParameterProxyModel::flags(const QModelIndex& index) const if (SessionItem* item = itemForIndex(index)) { if (item->isEditable() && index.column() != COL_NAME) returnVal |= Qt::ItemIsEditable; - if (item->parent()->hasModelType<FitParameterLinkItem>() && index.column() == COL_NAME) { + if (item->parent()->hasModelType<FitParameterLinkItem>() && index.column() == COL_NAME) returnVal |= Qt::ItemIsDragEnabled; - } const bool allow_one_fit_parameter_to_have_more_than_one_link = true; if (allow_one_fit_parameter_to_have_more_than_one_link) { // drop is allowed to fit parameter container, and, to FitParameterItem itself. @@ -84,9 +83,8 @@ Qt::ItemFlags FitParameterProxyModel::flags(const QModelIndex& index) const } else { // drop is allowed only to fit parameter container // (i.e. only one link is allowed in FitParameterItem) - if (item->hasModelType<FitParameterContainerItem>()) { + if (item->hasModelType<FitParameterContainerItem>()) returnVal |= Qt::ItemIsDropEnabled; - } } } return returnVal; @@ -132,9 +130,8 @@ QModelIndex FitParameterProxyModel::index(int row, int column, const QModelIndex QVector<FitParameterLinkItem*> links = polymorphic_downcast<FitParameterItem*>(parent_item)->linkItems(); if (row < links.size()) { - if (FitParameterLinkItem* linkItem = links.at(row)) { + if (FitParameterLinkItem* linkItem = links.at(row)) return createIndex(row, column, linkItem->linkItem()); - } } } return QModelIndex(); @@ -195,9 +192,8 @@ int FitParameterProxyModel::columnCount(const QModelIndex& parent) const if (parent.isValid()) { if (SessionItem* parentItem = itemForIndex(parent)) { - if (parentItem->hasModelType<FitParameterItem>()) { + if (parentItem->hasModelType<FitParameterItem>()) return !polymorphic_downcast<FitParameterItem*>(parentItem)->linkItems().empty(); - } } } return 0; @@ -213,9 +209,8 @@ QVariant FitParameterProxyModel::data(const QModelIndex& index, int role) const if (SessionItem* item = itemForIndex(index)) { if (role == Qt::DisplayRole || role == Qt::EditRole) { - if (item->hasModelType<FitParameterItem>()) { + if (item->hasModelType<FitParameterItem>()) return item->displayName(); - } return item->value(); } if (role == Qt::ForegroundRole && !item->isEditable()) @@ -378,9 +373,8 @@ QModelIndex FitParameterProxyModel::indexOfItem(SessionItem* item) const if (SessionItem* parent_item = item->parent()) { if (parent_item->hasModelType<FitParameterContainerItem>()) { - if (item->hasModelType<FitParameterItem>()) { + if (item->hasModelType<FitParameterItem>()) return createIndex(ParentRow(*item), 0, item); - } } else if (parent_item->hasModelType<FitParameterItem>()) { auto* fitParam = polymorphic_downcast<FitParameterItem*>(parent_item); std::optional<int> col; @@ -412,9 +406,8 @@ SessionItem* FitParameterProxyModel::itemForIndex(const QModelIndex& index) cons if (index.isValid()) { auto* item = static_cast<SessionItem*>(index.internalPointer()); if (item) { - if (!isValidSourceItem(item)) { + if (!isValidSourceItem(item)) return nullptr; - } return item; } } diff --git a/GUI/Model/Fit/ParameterTreeItems.cpp b/GUI/Model/Fit/ParameterTreeItems.cpp index d1107ff06fce27ffe46ca7cc04eb01b04f606c3c..76966e70526c12f57d09dffcc43257f6da73cc56 100644 --- a/GUI/Model/Fit/ParameterTreeItems.cpp +++ b/GUI/Model/Fit/ParameterTreeItems.cpp @@ -27,12 +27,16 @@ using namespace GUI::Session::XML; namespace { + namespace Tags { + const QString BackupValues("BackupValues"); const QString BackupValue("BackupValue"); const QString Link("Link"); const QString Value("Value"); + } // namespace Tags + } // namespace // ---------------------------------------------------------------------------- @@ -120,7 +124,6 @@ void ParameterContainerItem::readNonSessionItems(QXmlStreamReader* reader) while (reader->readNextStartElement()) { if (reader->name().toString() == Tags::BackupValues) { - while (reader->readNextStartElement()) { ASSERT(reader->name().toString() == Tags::BackupValue); QString link; diff --git a/GUI/Model/From/FromDomain.cpp b/GUI/Model/From/FromDomain.cpp index f05d89afff2ec29551693784fc36da590e529df2..980f38a9bd0cd484e1ab41d503c7be0c005366b1 100644 --- a/GUI/Model/From/FromDomain.cpp +++ b/GUI/Model/From/FromDomain.cpp @@ -579,28 +579,24 @@ void GUI::Transform::FromDomain::setRectangularDetector(RectangularDetectorItem* detector_item->setDistance(detector.getDistance()); detector_item->setU0(detector.getU0()); detector_item->setV0(detector.getV0()); - } else if (detector.getDetectorArrangment() == RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM) { detector_item->setDetectorAlignment("Perpendicular to direct beam"); detector_item->setDistance(detector.getDistance()); detector_item->setDirectBeamU0(detector.getU0()); detector_item->setDirectBeamV0(detector.getV0()); - } else if (detector.getDetectorArrangment() == RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM) { detector_item->setDetectorAlignment("Perpendicular to reflected beam"); detector_item->setDistance(detector.getDistance()); detector_item->setU0(detector.getU0()); detector_item->setV0(detector.getV0()); - } else if (detector.getDetectorArrangment() == RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM_DPOS) { detector_item->setDetectorAlignment("Perpendicular to reflected beam (dpos)"); detector_item->setDistance(detector.getDistance()); detector_item->setDirectBeamU0(detector.getDirectBeamU0()); detector_item->setDirectBeamV0(detector.getDirectBeamV0()); - } else { throw Error("GUI::Transform::FromDomain::setItemFromSample(RectangularDetectorItem* " "detectorItem " @@ -614,7 +610,6 @@ void GUI::Transform::FromDomain::setDetectorMasks(DetectorItem* detector_item, const IDetector& detector = simulation.detector(); if ((detector.detectorMask() && detector.detectorMask()->hasMasks()) || detector.hasExplicitRegionOfInterest()) { - detector_item->createMaskContainer(); double scale(1.0); if (detector_item->modelType() == SphericalDetectorItem::M_TYPE) @@ -651,7 +646,6 @@ void GUI::Transform::FromDomain::setMaskContainer(MaskContainerItem* container_i rectangleItem->setYUp(scale * rectangle->getYup()); rectangleItem->setMaskValue(mask_value); container_item->insertMask(0, rectangleItem); - } else if (const auto* polygon = dynamic_cast<const Polygon*>(shape)) { @@ -733,9 +727,8 @@ void GUI::Transform::FromDomain::setBackground(InstrumentItem* instrument_item, auto* constant_bg_item = instrument_item->setBackgroundType<ConstantBackgroundItem>(); double value = p_constant_bg->backgroundValue(); constant_bg_item->setBackgroundValue(value); - } else if (dynamic_cast<const PoissonNoiseBackground*>(p_bg)) { + } else if (dynamic_cast<const PoissonNoiseBackground*>(p_bg)) instrument_item->setBackgroundType<PoissonNoiseBackgroundItem>(); - } } void GUI::Transform::FromDomain::setFootprintFactor(const IFootprintFactor* footprint, @@ -743,11 +736,10 @@ void GUI::Transform::FromDomain::setFootprintFactor(const IFootprintFactor* foot { if (!footprint) return; - if (const auto* const gaussian_fp = dynamic_cast<const FootprintGauss*>(footprint)) { + if (const auto* const gaussian_fp = dynamic_cast<const FootprintGauss*>(footprint)) beam_item->setGaussianFootprint(gaussian_fp->widthRatio()); - } else if (const auto* const square_fp = dynamic_cast<const FootprintSquare*>(footprint)) { + else if (const auto* const square_fp = dynamic_cast<const FootprintSquare*>(footprint)) beam_item->setSquareFootprint(square_fp->widthRatio()); - } } void GUI::Transform::FromDomain::setAxisItem(BasicAxisItem* item, const IAxis& axis, double factor) diff --git a/GUI/Model/From/GUIDomainSampleVisitor.cpp b/GUI/Model/From/GUIDomainSampleVisitor.cpp index cc6e76979c72d4ea1883696f0a1e48dce677516b..e6060320a1475728b38294d11eb2386efe9e9984 100644 --- a/GUI/Model/From/GUIDomainSampleVisitor.cpp +++ b/GUI/Model/From/GUIDomainSampleVisitor.cpp @@ -44,6 +44,7 @@ #include "Sample/SoftParticle/SoftParticles.h" #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_cast; namespace { diff --git a/GUI/Model/From/GUIExamplesFactory.cpp b/GUI/Model/From/GUIExamplesFactory.cpp index e323585ef6fea5d36acdd9f577d0bbd2dbaffcce..c64bfa789c30cd49bf350d6dbffabc305403a32f 100644 --- a/GUI/Model/From/GUIExamplesFactory.cpp +++ b/GUI/Model/From/GUIExamplesFactory.cpp @@ -24,7 +24,6 @@ namespace { const QMap<QString, std::tuple<QString, QString, std::function<MultiLayer*()>>> builders{ - {"CylindersAndPrismsBuilder", {"Cylinder and prisms", "Mixture of cylinders and prisms without interference", ExemplarySamples::createCylindersAndPrisms}}, diff --git a/GUI/Model/Group/DistributionItems.cpp b/GUI/Model/Group/DistributionItems.cpp index 275788f75e33a05b40c351b45f78c00821279828..1a619d95f64e624d48883561960ba099e2ddda77 100644 --- a/GUI/Model/Group/DistributionItems.cpp +++ b/GUI/Model/Group/DistributionItems.cpp @@ -20,6 +20,7 @@ #include <cmath> namespace { + template <class DistrType> std::unique_ptr<IRangedDistribution> createIRangedDistribution(const SymmetricDistributionItem& distr_item, double scale) @@ -72,13 +73,13 @@ void DistributionItem::init_limits_group(const RealLimits& limits, double factor { if (!isTag(P_LIMITS)) return; - if (limits.isLimitless()) { + if (limits.isLimitless()) setGroupProperty(P_LIMITS, LimitlessItem::M_TYPE); - } else if (limits.isPositive()) { + else if (limits.isPositive()) setGroupProperty(P_LIMITS, PositiveItem::M_TYPE); - } else if (limits.isNonnegative()) { + else if (limits.isNonnegative()) setGroupProperty(P_LIMITS, NonnegativeItem::M_TYPE); - } else if (limits.isLowerLimited()) { + else if (limits.isLowerLimited()) { LowerLimitedItem* lim = dynamic_cast<LowerLimitedItem*>(setGroupProperty(P_LIMITS, LowerLimitedItem::M_TYPE)); lim->setLowerLimit(limits.lowerLimit() * factor); diff --git a/GUI/Model/Group/DistributionItems.h b/GUI/Model/Group/DistributionItems.h index 6e2c3a3e10ea63d79bbcca97246691d6d04bba1c..430e942a7567284f9c3d24b42e977c32aae01086 100644 --- a/GUI/Model/Group/DistributionItems.h +++ b/GUI/Model/Group/DistributionItems.h @@ -72,7 +72,6 @@ public: }; class DistributionNoneItem : public SymmetricDistributionItem { - public: static constexpr auto M_TYPE{"DistributionNone"}; diff --git a/GUI/Model/Group/FilterPropertyProxy.h b/GUI/Model/Group/FilterPropertyProxy.h index 89fad39f08d229ec449a5e2ec5b4628e80227d80..faef02cad60700b70d06a84af0ed45dc7b213ddf 100644 --- a/GUI/Model/Group/FilterPropertyProxy.h +++ b/GUI/Model/Group/FilterPropertyProxy.h @@ -11,6 +11,7 @@ //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) // // ************************************************************************************************ + #ifndef BORNAGAIN_GUI_MODEL_GROUP_FILTERPROPERTYPROXY_H #define BORNAGAIN_GUI_MODEL_GROUP_FILTERPROPERTYPROXY_H diff --git a/GUI/Model/Group/ItemFactory.h b/GUI/Model/Group/ItemFactory.h index c272d9a4c8a9d4ff90b3f82cabe93673d3fd2d12..9af2541e6183b1c600613a36f709344b4c23b907 100644 --- a/GUI/Model/Group/ItemFactory.h +++ b/GUI/Model/Group/ItemFactory.h @@ -36,7 +36,6 @@ template <typename ItemType> ItemType* CreateItem(SessionItem* parent) return dynamic_cast<ItemType*>(CreateItem(ItemType::M_TYPE, parent)); } - } // namespace GUI::Model::ItemFactory #endif // BORNAGAIN_GUI_MODEL_GROUP_ITEMFACTORY_H diff --git a/GUI/Model/Group/PropertyItem.h b/GUI/Model/Group/PropertyItem.h index d9c30f5b85bdac976e1d6f53400fbcb6626b7ef8..d0f8a5299ee1b1c37035075d7086f19c39f58984 100644 --- a/GUI/Model/Group/PropertyItem.h +++ b/GUI/Model/Group/PropertyItem.h @@ -18,7 +18,6 @@ #include "GUI/Model/Session/SessionItem.h" class BA_CORE_API_ PropertyItem : public SessionItem { - public: static constexpr auto M_TYPE{"Property"}; diff --git a/GUI/Model/IO/AbstractDataLoaderResultModel.cpp b/GUI/Model/IO/AbstractDataLoaderResultModel.cpp index eb98668b1f50772b909d95d35e31994f7d0e9f1d..2cccb28eb955d8d28694b1352c4a55a65ae07c3d 100644 --- a/GUI/Model/IO/AbstractDataLoaderResultModel.cpp +++ b/GUI/Model/IO/AbstractDataLoaderResultModel.cpp @@ -18,6 +18,7 @@ #include <QVariant> namespace { + struct Palette { static QColor backgroundColorFileContent; static QColor backgroundColorRawContent; diff --git a/GUI/Model/Instrument/BackgroundItems.cpp b/GUI/Model/Instrument/BackgroundItems.cpp index f2abd0df7f7a05a33dbd5fe6d100470115adb880..0c704e00fa022abd57f68599394eb62813d6c2b5 100644 --- a/GUI/Model/Instrument/BackgroundItems.cpp +++ b/GUI/Model/Instrument/BackgroundItems.cpp @@ -32,6 +32,7 @@ std::unique_ptr<IBackground> NoBackgroundItem::createBackground() const /* ------------------------------------------------ */ namespace { + const QString constant_background_value_tooltip = "Constant background value [counts/pixel]"; } diff --git a/GUI/Model/Instrument/BeamDistributionItem.cpp b/GUI/Model/Instrument/BeamDistributionItem.cpp index 0fa49bada409a9b5d0714baeac3d500b636bbb1c..7f1891f4261d57b0ad8ae88cf2dc7a129bdceacd 100644 --- a/GUI/Model/Instrument/BeamDistributionItem.cpp +++ b/GUI/Model/Instrument/BeamDistributionItem.cpp @@ -67,9 +67,8 @@ std::unique_ptr<ParameterDistribution> BeamDistributionItem::getParameterDistrib if (P_distribution) { size_t nbr_samples = distributionItem->numberOfSamples(); double sigma_factor(0); - if (distributionItem->hasSigmaFactor()) { + if (distributionItem->hasSigmaFactor()) sigma_factor = distributionItem->sigmaFactor(); - } RealLimitsItem* limitsItem = distributionItem->limits(); ASSERT(limitsItem); diff --git a/GUI/Model/Instrument/BeamItems.cpp b/GUI/Model/Instrument/BeamItems.cpp index 9538475a9f93ea52d064f069320feed2cfc42803..83e16707f47b1eefc838b2942995d595a8a281b9 100644 --- a/GUI/Model/Instrument/BeamItems.cpp +++ b/GUI/Model/Instrument/BeamItems.cpp @@ -25,6 +25,7 @@ #include <cmath> namespace { + // defines wavelength limits according to given maximum q value RealLimits getLimits(double max_q); @@ -264,6 +265,7 @@ double GISASBeamItem::getInclinationAngle() const } namespace { + RealLimits getLimits(double max_q) { double upper_lim = std::nextafter(4.0 * M_PI / max_q, 0.0); @@ -271,4 +273,5 @@ RealLimits getLimits(double max_q) result.setUpperLimit(upper_lim); return result; } + } // namespace diff --git a/GUI/Model/Instrument/BeamItems.h b/GUI/Model/Instrument/BeamItems.h index c10f1bc00ec1054f0ef29a8c702491b21cdcb31d..c1df416d290d3abc731292981b5fb3cd7aad16bf 100644 --- a/GUI/Model/Instrument/BeamItems.h +++ b/GUI/Model/Instrument/BeamItems.h @@ -64,7 +64,6 @@ protected: }; class SpecularBeamItem : public BeamItem { - public: static constexpr auto M_TYPE{"SpecularBeam"}; diff --git a/GUI/Model/Instrument/BeamWavelengthItem.cpp b/GUI/Model/Instrument/BeamWavelengthItem.cpp index c512378e908cc79a875fa5537aea0bed31135b5e..eaf8291b7b095f266be71330f391110d584ed48f 100644 --- a/GUI/Model/Instrument/BeamWavelengthItem.cpp +++ b/GUI/Model/Instrument/BeamWavelengthItem.cpp @@ -15,6 +15,7 @@ #include "GUI/Model/Instrument/BeamWavelengthItem.h" namespace { + const double default_wl = 0.1; } diff --git a/GUI/Model/Instrument/DetectorItems.cpp b/GUI/Model/Instrument/DetectorItems.cpp index e41ba3a6ddd568339e85d2f6295daee67e58b5e0..770a2ccd632ee43ba0be5a5262e7e177f0c5790b 100644 --- a/GUI/Model/Instrument/DetectorItems.cpp +++ b/GUI/Model/Instrument/DetectorItems.cpp @@ -23,6 +23,7 @@ #include "GUI/Model/Session/SessionModel.h" namespace { + const QString res_func_group_label = "Type"; GroupInfo createResolutionFunctionGroup() diff --git a/GUI/Model/Instrument/ItemWithDistribution.h b/GUI/Model/Instrument/ItemWithDistribution.h index afb9a8da7ef8d1e170f5d3bb71223d4c6cd7dd6f..bf6e083538495c5f6553391188239c3a0e36d6dd 100644 --- a/GUI/Model/Instrument/ItemWithDistribution.h +++ b/GUI/Model/Instrument/ItemWithDistribution.h @@ -25,7 +25,6 @@ class DistributionItem; /// Abstract interface of an item with a distribution property class BA_CORE_API_ ItemWithDistribution { - public: virtual DistributionItem* distribution() const = 0; virtual DistributionItem* setDistributionType(const QString& model_type) = 0; diff --git a/GUI/Model/Instrument/RectangularDetectorItem.cpp b/GUI/Model/Instrument/RectangularDetectorItem.cpp index e7f5752a11d7388d05b7b9830de5b1bb5ea3cc96..807dae6c2433cec926081b61ecc8b85cbad96679 100644 --- a/GUI/Model/Instrument/RectangularDetectorItem.cpp +++ b/GUI/Model/Instrument/RectangularDetectorItem.cpp @@ -20,6 +20,7 @@ #include "GUI/Util/Error.h" namespace { + const double default_detector_width = 20.0; const double default_detector_height = 20.0; const double default_detector_distance = 1000.0; @@ -58,6 +59,7 @@ ComboProperty alignmentCombo() result.setValue("Perpendicular to direct beam"); return result; } + } // namespace RectangularDetectorItem::RectangularDetectorItem() : DetectorItem(M_TYPE), m_is_constructed(false) @@ -299,15 +301,15 @@ std::unique_ptr<IDetector2D> RectangularDetectorItem::createDomainDetector() con auto alignment = getItemValue(P_ALIGNMENT).value<ComboProperty>(); - if (alignment.getValue() == "Generic") { + if (alignment.getValue() == "Generic") result->setPosition(normalVector(), u0, v0, directionVector()); - } else if (alignment.getValue() == "Perpendicular to direct beam") { + else if (alignment.getValue() == "Perpendicular to direct beam") result->setPerpendicularToDirectBeam(distance, dbeam_u0, dbeam_v0); - } else if (alignment.getValue() == "Perpendicular to sample x-axis") { + else if (alignment.getValue() == "Perpendicular to sample x-axis") result->setPerpendicularToSampleX(distance, u0, v0); - } else if (alignment.getValue() == "Perpendicular to reflected beam") { + else if (alignment.getValue() == "Perpendicular to reflected beam") result->setPerpendicularToReflectedBeam(distance, u0, v0); - } else if (alignment.getValue() == "Perpendicular to reflected beam (dpos)") { + else if (alignment.getValue() == "Perpendicular to reflected beam (dpos)") { result->setPerpendicularToReflectedBeam(distance); result->setDirectBeamPosition(dbeam_u0, dbeam_v0); } diff --git a/GUI/Model/Instrument/ResolutionFunctionItems.h b/GUI/Model/Instrument/ResolutionFunctionItems.h index 9434fac99b8559c7ef036949d479bd2214f5ef16..a321cd9fcd99cb77d4cc12f3ad27ed0f568e35bb 100644 --- a/GUI/Model/Instrument/ResolutionFunctionItems.h +++ b/GUI/Model/Instrument/ResolutionFunctionItems.h @@ -21,7 +21,6 @@ class IResolutionFunction2D; class BA_CORE_API_ ResolutionFunctionItem : public SessionItem { - protected: explicit ResolutionFunctionItem(const QString& name); @@ -33,7 +32,6 @@ public: }; class ResolutionFunctionNoneItem : public ResolutionFunctionItem { - public: static constexpr auto M_TYPE{"ResolutionFunctionNone"}; diff --git a/GUI/Model/Instrument/SpecularBeamInclinationItem.cpp b/GUI/Model/Instrument/SpecularBeamInclinationItem.cpp index 22d83f0ee605aae0c0196ac3c39956bbd2a484e8..039d794d4224ae3a267c2efa78971351c1186745 100644 --- a/GUI/Model/Instrument/SpecularBeamInclinationItem.cpp +++ b/GUI/Model/Instrument/SpecularBeamInclinationItem.cpp @@ -18,6 +18,7 @@ #include "GUI/Model/Group/GroupItem.h" namespace { + void setupDistributionMean(SessionItem* distribution); void setAxisPresentationDefaults(SessionItem* axis_item, const QString& type); @@ -95,6 +96,7 @@ void SpecularBeamInclinationItem::setupAxisGroup() } namespace { + void setupDistributionMean(SessionItem* distribution) { ASSERT(distribution); @@ -130,4 +132,5 @@ void setAxisPresentationDefaults(SessionItem* item, const QString& type) axis_item->binsItem()->setEnabled(false); } } + } // namespace diff --git a/GUI/Model/Job/JobItem.cpp b/GUI/Model/Job/JobItem.cpp index 23ca2f32d1abcd5a6decc7dcb960212440fa6b1f..9e6f4594f79873c766f246bd225ffa8ca94eef42 100644 --- a/GUI/Model/Job/JobItem.cpp +++ b/GUI/Model/Job/JobItem.cpp @@ -33,8 +33,10 @@ using namespace GUI::Session::XML; namespace { + const QString SimulationOptionsTag("SimulationOptions"); const QString MaterialsTag("Materials"); + } // namespace diff --git a/GUI/Model/Job/JobItem.h b/GUI/Model/Job/JobItem.h index 8d0230c359dd8a817938f696e176041e62b24c2a..62c857d526a588d361fbf82a59640467674e6e94 100644 --- a/GUI/Model/Job/JobItem.h +++ b/GUI/Model/Job/JobItem.h @@ -38,7 +38,6 @@ class RealDataItem; class SimulationOptionsItem; class BA_CORE_API_ JobItem : public SessionItem { - private: static constexpr auto P_IDENTIFIER{"Identifier"}; static constexpr auto P_SAMPLE_NAME{"Sample"}; diff --git a/GUI/Model/Job/JobModel.h b/GUI/Model/Job/JobModel.h index 656f4ddc84fbc27f2cf9bb13dda949d1f7264364..70b4fb366dfc69e977942dc3e7c5d003ce09a3ef 100644 --- a/GUI/Model/Job/JobModel.h +++ b/GUI/Model/Job/JobModel.h @@ -11,6 +11,7 @@ //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) // // ************************************************************************************************ + #ifndef BORNAGAIN_GUI_MODEL_JOB_JOBMODEL_H #define BORNAGAIN_GUI_MODEL_JOB_JOBMODEL_H diff --git a/GUI/Model/Job/JobQueueData.cpp b/GUI/Model/Job/JobQueueData.cpp index 3a3173ef5d6c89ef2a8b67bf93179207c82969e5..dc44d594eb8b9d481869dcc530088d6463317900 100644 --- a/GUI/Model/Job/JobQueueData.cpp +++ b/GUI/Model/Job/JobQueueData.cpp @@ -223,9 +223,9 @@ void JobQueueData::processFinishedJob(JobWorker* worker, JobItem* jobItem) jobItem->setEndTime(worker->simulationEnd()); // propagating status of runner - if (worker->status() == JobStatus::Failed) { + if (worker->status() == JobStatus::Failed) jobItem->setComments(worker->failureMessage()); - } else { + else { // propagating simulation results auto* simulation = getSimulation(worker->identifier()); jobItem->setResults(simulation); diff --git a/GUI/Model/Job/JobWorker.cpp b/GUI/Model/Job/JobWorker.cpp index 77f6b3323319b7de295252d30ecbaab15db28deb..2f9227992dca6bddf3289f19e4f640c3046c7f96 100644 --- a/GUI/Model/Job/JobWorker.cpp +++ b/GUI/Model/Job/JobWorker.cpp @@ -63,7 +63,6 @@ void JobWorker::start() m_failure_message.append(QString(ex.what())); } - } else { m_job_status = JobStatus::Failed; m_percentage_done = 100; diff --git a/GUI/Model/Job/ParameterTreeUtils.cpp b/GUI/Model/Job/ParameterTreeUtils.cpp index f64a7423aba98cc1717addea2cfa9adab1f1028d..4265ee89ae97e53494335d3d39ae772da07d5b78 100644 --- a/GUI/Model/Job/ParameterTreeUtils.cpp +++ b/GUI/Model/Job/ParameterTreeUtils.cpp @@ -27,6 +27,7 @@ #include <QStack> #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_downcast; namespace { @@ -59,7 +60,6 @@ void handleItem(ParameterContainerItem* container, SessionItem* tree, SessionIte auto* branch = tree->model()->insertItem<ParameterItem>(tree); handleItem(container, branch, child, recreateBackupValues); } - } else if (child->hasModelType<GroupItem>()) { SessionItem* currentItem = dynamic_cast<GroupItem*>(child)->currentItem(); if (currentItem && currentItem->numberOfChildren() > 0) { diff --git a/GUI/Model/Material/MaterialItem.cpp b/GUI/Model/Material/MaterialItem.cpp index a9defd62f76b1838020d34f8560a0692382951b0..ecd88d82bb6f1e1c133404c7a18d88fc86a0fb9e 100644 --- a/GUI/Model/Material/MaterialItem.cpp +++ b/GUI/Model/Material/MaterialItem.cpp @@ -26,7 +26,9 @@ using namespace GUI::Session::XML; namespace { + namespace Tags { + const QString Color("Color"); const QString Id("Id"); const QString Name("Name"); @@ -34,7 +36,9 @@ const QString Delta("Delta"); const QString Beta("Beta"); const QString Sld("Sld"); const QString Magnetization("Magnetization"); + } // namespace Tags + } // namespace #define m_delta std::get<Refractive>(m_data).delta diff --git a/GUI/Model/Project/OutputDataIOService.cpp b/GUI/Model/Project/OutputDataIOService.cpp index 52ffb331c11bce65db969b71277c3626ca4be4db..4d8e84edecb573c264107ae250a380f828a90e72 100644 --- a/GUI/Model/Project/OutputDataIOService.cpp +++ b/GUI/Model/Project/OutputDataIOService.cpp @@ -23,7 +23,9 @@ #include <QSet> namespace { + JobItem* parentJobItem(SaveLoadInterface* item); + } // namespace OutputDataIOService::OutputDataIOService(QObject* parent) @@ -81,7 +83,6 @@ void OutputDataIOService::loadDataFiles(const QString& projectDir, MessageServic jobItem->setStatus(JobStatus::Failed); } } - } catch (const std::exception& ex) { if (auto* jobItem = parentJobItem(item)) { // Handling corrupted file on disk @@ -125,6 +126,7 @@ void OutputDataIOService::cleanOldFiles(const QString& projectDir, const QString } namespace { + JobItem* parentJobItem(SaveLoadInterface* item) { auto* session_item = dynamic_cast<SessionItem*>(item); // sidecast @@ -132,4 +134,5 @@ JobItem* parentJobItem(SaveLoadInterface* item) dynamic_cast<const JobItem*>(GUI::Model::Path::ancestor(session_item, JobItem::M_TYPE)); return const_cast<JobItem*>(jobItem); } + } // namespace diff --git a/GUI/Model/Project/ProjectDocument.cpp b/GUI/Model/Project/ProjectDocument.cpp index 4dc755ab5faa9f23459f106f8821f6473fc440cf..3e07bad7c8b42e19cf7746df629e13df8ba30da0 100644 --- a/GUI/Model/Project/ProjectDocument.cpp +++ b/GUI/Model/Project/ProjectDocument.cpp @@ -221,7 +221,6 @@ ProjectDocument::ReadResult ProjectDocument::loadProjectFile(const QString& proj if (!messageService.warnings().empty()) result = ReadResult::warning; return result; - } catch (const std::exception& ex) { QString message = QString("Exception thrown '%1'").arg(QString(ex.what())); messageService.addError(this, message); diff --git a/GUI/Model/Sample/InterferenceItems.cpp b/GUI/Model/Sample/InterferenceItems.cpp index 7ca2ffbc25949036e91fe305a474cb350c02ef36..34b430243321e68647746f554f7579dc3e14e8e3 100644 --- a/GUI/Model/Sample/InterferenceItems.cpp +++ b/GUI/Model/Sample/InterferenceItems.cpp @@ -111,7 +111,6 @@ Interference2DAbstractLatticeItem::Interference2DAbstractLatticeItem(const QStri bool xi_integration) : InterferenceItem(modelType) { - GroupInfo info; info.add<BasicLattice2DItem>(); info.add<SquareLattice2DItem>(); @@ -123,15 +122,13 @@ Interference2DAbstractLatticeItem::Interference2DAbstractLatticeItem(const QStri ->setToolTip("Enables/disables averaging over the lattice rotation angle."); mapper()->setOnPropertyChange([this](const QString& name) { - if (name == P_XI_INTEGRATION && isTag(P_LATTICE_TYPE)) { + if (name == P_XI_INTEGRATION && isTag(P_LATTICE_TYPE)) update_rotation_availability(); - } }); mapper()->setOnChildPropertyChange([this](SessionItem* item, const QString&) { - if (item->hasModelType<GroupItem>() && item->displayName() == P_LATTICE_TYPE) { + if (item->hasModelType<GroupItem>() && item->displayName() == P_LATTICE_TYPE) update_rotation_availability(); - } }); } diff --git a/GUI/Model/Sample/ItemWithParticles.cpp b/GUI/Model/Sample/ItemWithParticles.cpp index 786216de2e4410e7ee2fe5d064a3b4b9552c2a97..02b5da7dbdce8210f55a04e82ad9bb8cfdfc5ce7 100644 --- a/GUI/Model/Sample/ItemWithParticles.cpp +++ b/GUI/Model/Sample/ItemWithParticles.cpp @@ -26,6 +26,7 @@ #include "Sample/Scattering/Rotations.h" namespace { + bool hasOwnAbundance(const SessionItem* item) { static QStringList special_parent{ParticleCoreShellItem::M_TYPE, @@ -33,6 +34,7 @@ bool hasOwnAbundance(const SessionItem* item) return item ? special_parent.contains(item->modelType()) : false; } + } // namespace DoubleDescriptor ItemWithParticles::abundance() const diff --git a/GUI/Model/Sample/Lattice2DItems.cpp b/GUI/Model/Sample/Lattice2DItems.cpp index 1d1f526caf33655316819da8cd67a97fb6de89c8..87bd888c864854f4ceec60706ead8d8ee5d911b4 100644 --- a/GUI/Model/Sample/Lattice2DItems.cpp +++ b/GUI/Model/Sample/Lattice2DItems.cpp @@ -18,6 +18,7 @@ #include "Sample/Lattice/Lattice2D.h" namespace { + const QString axis_rotation_tooltip = "Rotation of lattice with respect to x-axis of reference frame \n" "(beam direction) in degrees"; diff --git a/GUI/Model/Sample/Lattice2DItems.h b/GUI/Model/Sample/Lattice2DItems.h index 046093775d1b0fe73786c4c4a6721c7697e28582..b71d34d2cb03febffc453a1c3424aa3358e47d23 100644 --- a/GUI/Model/Sample/Lattice2DItems.h +++ b/GUI/Model/Sample/Lattice2DItems.h @@ -16,6 +16,7 @@ #define BORNAGAIN_GUI_MODEL_SAMPLE_LATTICE2DITEMS_H #include "GUI/Model/Session/SessionItem.h" + class Lattice2D; class DoubleDescriptor; diff --git a/GUI/Model/Sample/LayerRoughnessItems.cpp b/GUI/Model/Sample/LayerRoughnessItems.cpp index fbb6aeaba9b4ec431dd8a3e4c87595d50b8c4d35..317daab03bc5b1e619e7d4c5f6079bf9ae8dfb18 100644 --- a/GUI/Model/Sample/LayerRoughnessItems.cpp +++ b/GUI/Model/Sample/LayerRoughnessItems.cpp @@ -16,6 +16,7 @@ #include "GUI/Model/Types/DoubleDescriptor.h" 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."; diff --git a/GUI/Model/Sample/MesoCrystalItem.cpp b/GUI/Model/Sample/MesoCrystalItem.cpp index 8bee38cdbfb929a7a3fc3195c57fb536191e3d3f..4c0f3a8d7042bd165e9a11fa5ed0b259ec2eb45d 100644 --- a/GUI/Model/Sample/MesoCrystalItem.cpp +++ b/GUI/Model/Sample/MesoCrystalItem.cpp @@ -27,6 +27,7 @@ #include "Sample/Scattering/IFormFactor.h" namespace { + const QString abundance_tooltip = "Proportion of this type of mesocrystal normalized to the \n" "total number of particles in the layout"; diff --git a/GUI/Model/Sample/MultiLayerItem.cpp b/GUI/Model/Sample/MultiLayerItem.cpp index 26445675bdbddb73f15436a11f1f1902a6c1fcd5..3962c28e6c8c4319daaec28dc24651f62be97e1e 100644 --- a/GUI/Model/Sample/MultiLayerItem.cpp +++ b/GUI/Model/Sample/MultiLayerItem.cpp @@ -18,6 +18,7 @@ #include "GUI/Model/Types/VectorDescriptor.h" namespace { + const QString external_field_tooltip = "External field (A/m)"; } @@ -113,9 +114,8 @@ void MultiLayerItem::removeLayer(LayerItem* item) void MultiLayerItem::moveLayer(LayerItem* item, LayerItem* beforeThisLayer) { int index = -1; // move to end - if (beforeThisLayer != nullptr) { + if (beforeThisLayer != nullptr) index = layers().indexOf(beforeThisLayer); - } model()->moveItem(item, this, index); } diff --git a/GUI/Model/Sample/ParticleCompositionItem.cpp b/GUI/Model/Sample/ParticleCompositionItem.cpp index f610cd544307bd09280ad825cb8469dcd6559884..f64edccac492fa8c8df92d79a8998c318b72e2d3 100644 --- a/GUI/Model/Sample/ParticleCompositionItem.cpp +++ b/GUI/Model/Sample/ParticleCompositionItem.cpp @@ -54,27 +54,23 @@ std::unique_ptr<ParticleComposition> ParticleCompositionItem::createParticleComp if (childlist[i]->hasModelType<ParticleItem>()) { auto* particle_item = dynamic_cast<ParticleItem*>(childlist[i]); auto P_particle = particle_item->createParticle(); - if (P_particle) { + if (P_particle) P_composition->addParticle(*P_particle); - } } else if (childlist[i]->hasModelType<ParticleCoreShellItem>()) { auto* particle_coreshell_item = dynamic_cast<ParticleCoreShellItem*>(childlist[i]); auto P_particle_coreshell = particle_coreshell_item->createParticleCoreShell(); - if (P_particle_coreshell) { + if (P_particle_coreshell) P_composition->addParticle(*P_particle_coreshell); - } } else if (childlist[i]->hasModelType<ParticleCompositionItem>()) { auto* particlecomposition_item = dynamic_cast<ParticleCompositionItem*>(childlist[i]); auto P_child_composition = particlecomposition_item->createParticleComposition(); - if (P_child_composition) { + if (P_child_composition) P_composition->addParticle(*P_child_composition); - } } else if (childlist[i]->hasModelType<MesoCrystalItem>()) { auto* mesocrystal_item = dynamic_cast<MesoCrystalItem*>(childlist[i]); auto P_child_meso = mesocrystal_item->createMesoCrystal(); - if (P_child_meso) { + if (P_child_meso) P_composition->addParticle(*P_child_meso); - } } } setTransformationInfo(P_composition.get()); diff --git a/GUI/Model/Sample/ParticleCoreShellItem.cpp b/GUI/Model/Sample/ParticleCoreShellItem.cpp index ff0f96bd694097b6dbe7187cc83133667be057be..dbe7fb6951623ded5506b8c6a03a1875b4ed7d84 100644 --- a/GUI/Model/Sample/ParticleCoreShellItem.cpp +++ b/GUI/Model/Sample/ParticleCoreShellItem.cpp @@ -23,6 +23,7 @@ #include "Sample/Particle/ParticleCoreShell.h" namespace { + const QString abundance_tooltip = "Proportion of this type of particles normalized to the \n" "total number of particles in the layout"; diff --git a/GUI/Model/Sample/ParticleLayoutItem.cpp b/GUI/Model/Sample/ParticleLayoutItem.cpp index 4ea90c9ce9071f7db5deb726e58f67ea825e97bd..f957464230aa53662eb3bf7d10e1f2ef24e2b46c 100644 --- a/GUI/Model/Sample/ParticleLayoutItem.cpp +++ b/GUI/Model/Sample/ParticleLayoutItem.cpp @@ -44,6 +44,7 @@ const QString density_tooltip = const QString weight_tooltip = "Weight of this particle layout.\n" "Should be used when multiple layouts define different domains in the sample."; + } // namespace ParticleLayoutItem::ParticleLayoutItem() : SessionItem(M_TYPE) diff --git a/GUI/Model/Sample/SampleModel.cpp b/GUI/Model/Sample/SampleModel.cpp index b2071b98ee5e77e2e55105e549fbd4b42bdefd8d..fb582f1bc54045435142bb2e5fe79486b855fd4a 100644 --- a/GUI/Model/Sample/SampleModel.cpp +++ b/GUI/Model/Sample/SampleModel.cpp @@ -40,7 +40,6 @@ QVariant SampleModel::data(const QModelIndex& index, int role) const return QVariant(); if (SessionItem* item = itemForIndex(index)) { - if (role == Qt::DecorationRole && index.column() == SessionFlags::ITEM_VALUE) { const auto propertyName = item->itemName(); const auto* itemWithMaterial = dynamic_cast<ItemWithMaterial*>(item->parent()); diff --git a/GUI/Model/Sample/SampleValidator.cpp b/GUI/Model/Sample/SampleValidator.cpp index 60ab7893c2b227c9b94bd9543fde02e72c9531e8..d62ddf10c0344d9d695ae87953da06cfc6576aa6 100644 --- a/GUI/Model/Sample/SampleValidator.cpp +++ b/GUI/Model/Sample/SampleValidator.cpp @@ -20,6 +20,7 @@ #include "GUI/Model/Sample/ParticleLayoutItem.h" #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_cast; using boost::polymorphic_downcast; @@ -46,9 +47,9 @@ void SampleValidator::validateItem(const SessionItem* item) QString diagnosis; - if (item->hasModelType<MultiLayerItem>()) { + if (item->hasModelType<MultiLayerItem>()) diagnosis = validateMultiLayerItem(polymorphic_downcast<const MultiLayerItem*>(item)); - } else if (item->hasModelType<ParticleLayoutItem>()) { + else if (item->hasModelType<ParticleLayoutItem>()) { diagnosis = validateParticleLayoutItem(polymorphic_downcast<const ParticleLayoutItem*>(item)); } else if (item->hasModelType<ParticleCoreShellItem>()) { @@ -70,12 +71,11 @@ QString SampleValidator::validateMultiLayerItem(const MultiLayerItem* item) QVector<LayerItem*> layers = item->layers(); - if (layers.isEmpty()) { + if (layers.isEmpty()) result = "MultiLayer should contain at least one layer."; - } else if (layers.size() == 1) { - if (layers.front()->layouts().isEmpty()) { + else if (layers.size() == 1) { + if (layers.front()->layouts().isEmpty()) result = "The single layer in your MultiLayer should contain ParticleLayout."; - } } return result; } diff --git a/GUI/Model/Session/ModelMapper.cpp b/GUI/Model/Session/ModelMapper.cpp index eb69e1a0fcc892443bb4c3b078d5c92b1facb865..28eaca0dca54c1ef5f20d01526aec753f979f1c2 100644 --- a/GUI/Model/Session/ModelMapper.cpp +++ b/GUI/Model/Session/ModelMapper.cpp @@ -219,17 +219,15 @@ void ModelMapper::onDataChanged(const QModelIndex& topLeft, const QModelIndex& b if (SessionItem* item = m_model->itemForIndex(topLeft)) { // only care f const QString tag = m_item->tagFromItem(item); - if (!tag.isEmpty()) { + if (!tag.isEmpty()) callOnPropertyChange(tag); - } } } if (nestling > 1) { if (SessionItem* parent = item->parent()) { const QString tag = parent->tagFromItem(item); - if (!tag.isEmpty()) { + if (!tag.isEmpty()) callOnChildPropertyChange(parent, tag); - } } } if (nestling > 0) @@ -247,9 +245,8 @@ void ModelMapper::onRowsInserted(const QModelIndex& parent, int first, int /*las callOnParentChange(m_model->itemForIndex(parent)); if (nestling == 1) callOnChildrenChange(newChild); - if (nestling > 0) { + if (nestling > 0) callOnAnyChildChange(newChild); - } } void ModelMapper::onBeginRemoveRows(const QModelIndex& parent, int first, int /*last*/) diff --git a/GUI/Model/Session/RealLimitsItems.cpp b/GUI/Model/Session/RealLimitsItems.cpp index 4219708f0fcd2fd818c5eb5dcd3da92b6e785e2d..8d08c91c2b1023a364254a7c6d1fd863ec17f206 100644 --- a/GUI/Model/Session/RealLimitsItems.cpp +++ b/GUI/Model/Session/RealLimitsItems.cpp @@ -15,8 +15,10 @@ #include "GUI/Model/Session/RealLimitsItems.h" namespace { + const QString tooltip_min_value = "Minimum allowed value, value included."; const QString tooltip_max_value = "Maximum allowed value, value excluded."; + } // namespace RealLimitsItem::RealLimitsItem(const QString& name, const std::optional<double>& lower, diff --git a/GUI/Model/Session/SessionModel.cpp b/GUI/Model/Session/SessionModel.cpp index b00c6f03ddd8b3e69c53f84fef933af9c98d93a6..521660e0ee61863a97e5c3c3dca4d6c2f5763c1a 100644 --- a/GUI/Model/Session/SessionModel.cpp +++ b/GUI/Model/Session/SessionModel.cpp @@ -26,6 +26,7 @@ #include <utility> namespace { + const int MaxCompression = 9; //! Returns tooltip for given item. @@ -92,11 +93,11 @@ QVariant SessionModel::data(const QModelIndex& index, int role) const return item->value(); if (index.column() == SessionFlags::ITEM_NAME) return item->itemName(); - } else if (role == Qt::ToolTipRole) { + } else if (role == Qt::ToolTipRole) return toolTipRole(*item, index.column()); - } else if (role == Qt::ForegroundRole) { + else if (role == Qt::ForegroundRole) return item->isEnabled() ? QVariant() : QColor(Qt::gray); - } else if (role == Qt::CheckStateRole && index.column() == SessionFlags::ITEM_VALUE) { + else if (role == Qt::CheckStateRole && index.column() == SessionFlags::ITEM_VALUE) { if (item->value().type() == QVariant::Bool) return item->value().toBool() ? Qt::Checked : Qt::Unchecked; } else diff --git a/GUI/Model/Session/SessionXML.cpp b/GUI/Model/Session/SessionXML.cpp index bca4da3f09bda2cc48a745326ac136952ad81176..c59064703066d7adc6a72d5da342ee19c8796193 100644 --- a/GUI/Model/Session/SessionXML.cpp +++ b/GUI/Model/Session/SessionXML.cpp @@ -115,17 +115,17 @@ void GUI::Session::XML::writeAttribute(QXmlStreamWriter* writer, const QString& ASSERT(writer); ASSERT(variant.isValid()); - if (variant.type() == QVariant::Double) { + if (variant.type() == QVariant::Double) writeAttribute(writer, attributeName, variant.toDouble()); - } else if (variant.type() == QVariant::Int) { + else if (variant.type() == QVariant::Int) writeAttribute(writer, attributeName, variant.toInt()); - } else if (variant.type() == QVariant::UInt) { + else if (variant.type() == QVariant::UInt) writeAttribute(writer, attributeName, variant.toUInt()); - } else if (variant.type() == QVariant::Bool) { + else if (variant.type() == QVariant::Bool) writer->writeAttribute(attributeName, QString::number(variant.toBool())); - } else if (variant.type() == QVariant::String) { + else if (variant.type() == QVariant::String) writer->writeAttribute(attributeName, variant.toString()); - } else if (variant.type() == QVariant::Color) { + else if (variant.type() == QVariant::Color) { const auto col = variant.value<QColor>(); const QString tcol = col.isValid() ? col.name(QColor::HexArgb) : ""; writer->writeAttribute(attributeName, tcol); @@ -133,7 +133,6 @@ void GUI::Session::XML::writeAttribute(QXmlStreamWriter* writer, const QString& auto combo = variant.value<ComboProperty>(); writer->writeAttribute(attributeName, combo.stringOfSelections()); writer->writeAttribute(GUI::Session::XML::ParameterExtAttribute, combo.stringOfValues()); - } else throw Error("GUI::Session::XML::writeVariant: Parameter type not supported " + QString(variant.typeName())); @@ -304,7 +303,6 @@ QString GUI::Session::XML::readProperty(QXmlStreamReader* reader, SessionItem* i reader->attributes().value(GUI::Session::XML::ParameterValueAttribute).toString(); variant = QColor(parameter_value); } else if (parameter_type == "ExternalProperty") { - const bool isMaterialItemColor = item->parent() != nullptr && dynamic_cast<MaterialItem*>(item->parent()); diff --git a/GUI/Model/Session/SimulationOptionsItem.cpp b/GUI/Model/Session/SimulationOptionsItem.cpp index 516f863be28f4c76e7cbdb01e755434d0089ec9a..3a2d6d2876e3e4ea4a63891659da342d12eab670 100644 --- a/GUI/Model/Session/SimulationOptionsItem.cpp +++ b/GUI/Model/Session/SimulationOptionsItem.cpp @@ -19,14 +19,18 @@ #include <thread> namespace { + namespace Tags { + const QString RunImmediately("RunImmediately"); const QString NumberOfThreads("NumberOfThreads"); const QString Analytical("Analytical"); const QString NumberOfMonteCarloPoints("NumberOfMonteCarloPoints"); const QString UseAverageMaterials("UseAverageMaterials"); const QString IncludeSpecularPeak("IncludeSpecularPeak"); + } // namespace Tags + } // namespace using namespace GUI::Session::XML; diff --git a/GUI/Model/To/DomainSimulationBuilder.cpp b/GUI/Model/To/DomainSimulationBuilder.cpp index a358a3812a23cc3d31f8c2b9aaef3cabfe0a49a9..5ee90855d10b51ce6174211dc7b2f7bfa3b7259d 100644 --- a/GUI/Model/To/DomainSimulationBuilder.cpp +++ b/GUI/Model/To/DomainSimulationBuilder.cpp @@ -36,7 +36,6 @@ #include "Resample/Options/SimulationOptions.h" #include "Sample/Multilayer/MultiLayer.h" - namespace { //! If the given item has distributions, then add these distributions to the simulation's diff --git a/GUI/Model/To/DomainSimulationBuilder.h b/GUI/Model/To/DomainSimulationBuilder.h index a3c30c6115dd1aef67d1535860b12d374a8efad4..c6cbc16a201b278738c1643911fc84a70a7d80e4 100644 --- a/GUI/Model/To/DomainSimulationBuilder.h +++ b/GUI/Model/To/DomainSimulationBuilder.h @@ -31,6 +31,7 @@ namespace GUI::Model::DomainSimulationBuilder { std::unique_ptr<ISimulation> createSimulation(const MultiLayerItem* sampleItem, const InstrumentItem* instrumentItem, const SimulationOptionsItem& optionsItem); + } // namespace GUI::Model::DomainSimulationBuilder #endif // BORNAGAIN_GUI_MODEL_TO_DOMAINSIMULATIONBUILDER_H diff --git a/GUI/Model/To/ToDomain.cpp b/GUI/Model/To/ToDomain.cpp index 3d08dc1abaa294426b31044e056d4ba7ef68c62e..b7184922a694d2330dacffdc308f404a549fde3c 100644 --- a/GUI/Model/To/ToDomain.cpp +++ b/GUI/Model/To/ToDomain.cpp @@ -28,7 +28,6 @@ #include "Sample/Particle/Particle.h" #include "Sample/Particle/ParticleCoreShell.h" - std::unique_ptr<MultiLayer> GUI::Transform::ToDomain::createMultiLayer(const MultiLayerItem& item) { auto P_multilayer = std::make_unique<MultiLayer>(); diff --git a/GUI/Model/Types/DoubleDescriptor.h b/GUI/Model/Types/DoubleDescriptor.h index 3fd1f54416d0e530fdac8ac8d9d23f91b6b91081..fee8706ff4c60f747128e35c81a4ffb1a662b35b 100644 --- a/GUI/Model/Types/DoubleDescriptor.h +++ b/GUI/Model/Types/DoubleDescriptor.h @@ -33,7 +33,6 @@ using std::variant; //! eases SessionItem migration. The underlying implementation can be a SessionItem, a simple double //! member, or any other construction to hold a double value. class DoubleDescriptor { - public: DoubleDescriptor(const DoubleDescriptor& other) = default; diff --git a/GUI/Util/ComboProperty.cpp b/GUI/Util/ComboProperty.cpp index ffc07ad9a6ca3c5c4716fdd55b16892f85e78599..a73f3a0ae00ad23e209694b7a83a2dcce671d50c 100644 --- a/GUI/Util/ComboProperty.cpp +++ b/GUI/Util/ComboProperty.cpp @@ -17,8 +17,10 @@ #include "GUI/Util/Error.h" namespace { + const QString value_separator = ";"; const QString selection_separator = ","; + } // namespace ComboProperty::ComboProperty() = default; diff --git a/GUI/View/Common/DocksController.cpp b/GUI/View/Common/DocksController.cpp index c80ad50ee94b8062948c361b7ae9ce9474a94bc6..97ccba913160553fea80ce662bba9d79080264f4 100644 --- a/GUI/View/Common/DocksController.cpp +++ b/GUI/View/Common/DocksController.cpp @@ -25,6 +25,7 @@ #include <QTimer> namespace { + const char dockWidgetActiveState[] = "DockWidgetActiveState"; const char StateKey[] = "State"; const int settingsVersion = 2; @@ -212,9 +213,8 @@ void DocksController::handleWindowVisibilityChanged(bool visible) { m_handleDockVisibilityChanges = false; for (auto* dockWidget : dockWidgets()) { - if (dockWidget->isFloating()) { + if (dockWidget->isFloating()) dockWidget->setVisible(visible && dockWidget->property(dockWidgetActiveState).toBool()); - } } if (visible) m_handleDockVisibilityChanges = true; @@ -272,9 +272,8 @@ QHash<QString, QVariant> DocksController::saveSettings() const { QHash<QString, QVariant> settings; settings.insert(QLatin1String(StateKey), m_mainWindow->saveState(settingsVersion)); - for (auto* dockWidget : dockWidgets()) { + for (auto* dockWidget : dockWidgets()) settings.insert(dockWidget->objectName(), dockWidget->property(dockWidgetActiveState)); - } return settings; } @@ -283,7 +282,6 @@ void DocksController::restoreSettings(const QHash<QString, QVariant>& settings) QByteArray ba = settings.value(QLatin1String(StateKey), QByteArray()).toByteArray(); if (!ba.isEmpty()) m_mainWindow->restoreState(ba, settingsVersion); - for (auto* widget : dockWidgets()) { + for (auto* widget : dockWidgets()) widget->setProperty(dockWidgetActiveState, settings.value(widget->objectName(), false)); - } } diff --git a/GUI/View/Common/InfoPanel.cpp b/GUI/View/Common/InfoPanel.cpp index 0ca60958e2df0a32354e3424cc977a08ab2e58e1..6466b730c0ae089e794b11f5b686a98392fa272c 100644 --- a/GUI/View/Common/InfoPanel.cpp +++ b/GUI/View/Common/InfoPanel.cpp @@ -19,9 +19,11 @@ #include <QStackedWidget> namespace { + const int minimum_widget_height = 25; // height of toolbar const int minimum_height_before_collapse = 50; const int default_height = 200; + } // namespace InfoPanel::InfoPanel(QWidget* parent) @@ -83,7 +85,6 @@ void InfoPanel::setContentVisible(bool editor_status, bool dock_notify) if (m_stackedWidget->currentWidget()) m_stackedWidget->currentWidget()->show(); - } else { m_cached_height = (height() < minimum_height_before_collapse ? default_height : height()); if (m_stackedWidget->currentWidget()) diff --git a/GUI/View/Common/InfoPanelToolBar.cpp b/GUI/View/Common/InfoPanelToolBar.cpp index 285e298dd709d7bc8301d29ae8e70dfd74e553fe..ebf33b42e4af397f98cb60021d6689769be52b62 100644 --- a/GUI/View/Common/InfoPanelToolBar.cpp +++ b/GUI/View/Common/InfoPanelToolBar.cpp @@ -18,10 +18,12 @@ #include <QToolButton> namespace { + const int minimum_size = 25; const QString icon_up = ":/images/dark-angle-up.svg"; const QString icon_down = ":/images/dark-angle-down.svg"; const QString expand_text = "Collapse/expand view"; + } // namespace InfoPanelToolBar::InfoPanelToolBar(QWidget* parent) diff --git a/GUI/View/Common/ScientificSpinBox.cpp b/GUI/View/Common/ScientificSpinBox.cpp index 9dc56aa24b7238e4ffa1cd216408fd80722f32e8..b6893bf9dadf4ad1f44b0f3d623150f4400a26c0 100644 --- a/GUI/View/Common/ScientificSpinBox.cpp +++ b/GUI/View/Common/ScientificSpinBox.cpp @@ -17,12 +17,14 @@ #include <cmath> namespace { + const double upper_switch = 100; const double lower_switch = 0.1; const double min_val = std::numeric_limits<double>::min(); const double max_val = std::numeric_limits<double>::max(); bool useExponentialNotation(double val); + } // namespace ScientificSpinBox::ScientificSpinBox(QWidget* parent) @@ -161,6 +163,7 @@ bool ScientificSpinBox::inRange(double val) const } namespace { + bool useExponentialNotation(double val) { const double abs_val = std::abs(val); @@ -170,4 +173,5 @@ bool useExponentialNotation(double val) return abs_val >= upper_switch || abs_val < lower_switch; } + } // namespace diff --git a/GUI/View/Compare/FitComparisonController.cpp b/GUI/View/Compare/FitComparisonController.cpp index ee8e8ddb410bada356cc970c21375aa619748a31..cf69657786e8f8d55dcf3d7aa54920d75b6399b8 100644 --- a/GUI/View/Compare/FitComparisonController.cpp +++ b/GUI/View/Compare/FitComparisonController.cpp @@ -22,10 +22,12 @@ #include "GUI/View/Compare/PropertyRepeater.h" 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 { diff --git a/GUI/View/Compare/PropertyRepeater.cpp b/GUI/View/Compare/PropertyRepeater.cpp index af211bc9b24533931bd9c5a252f4769a0af38662..d983c0100e423a2bb9cfc7dca343af6130a49c25 100644 --- a/GUI/View/Compare/PropertyRepeater.cpp +++ b/GUI/View/Compare/PropertyRepeater.cpp @@ -68,9 +68,8 @@ void PropertyRepeater::onPropertyChanged(SessionItem* item, const QString& prope m_block_repeater = true; QVariant value = item->getItemValue(propertyName); - for (auto* target : targetItems(item)) { + for (auto* target : targetItems(item)) target->setItemValue(propertyName, value); - } m_block_repeater = false; } @@ -84,9 +83,8 @@ void PropertyRepeater::setOnChildPropertyChange(SessionItem* item, const QString SessionItem* sourceItem = item->parent(); QString tag = sourceItem->tagFromItem(item); QVariant value = item->getItemValue(propertyName); - for (auto* target : targetItems(sourceItem)) { + for (auto* target : targetItems(sourceItem)) target->getItem(tag)->setItemValue(propertyName, value); - } m_block_repeater = false; } diff --git a/GUI/View/Fit/FitActivityPanel.cpp b/GUI/View/Fit/FitActivityPanel.cpp index 18ec625a4a9821d02d80bd54247384df0257141a..93b3217cb7d4edfe1a0456f962d905b4f8c1e71b 100644 --- a/GUI/View/Fit/FitActivityPanel.cpp +++ b/GUI/View/Fit/FitActivityPanel.cpp @@ -69,7 +69,6 @@ QSize FitActivityPanel::minimumSizeHint() const void FitActivityPanel::setItem(JobItem* item) { - if (!isValidJobItem(item)) { if (!item) m_stack->setCurrentWidget(m_blankWidget); diff --git a/GUI/View/Fit/FitObjectiveBuilder.h b/GUI/View/Fit/FitObjectiveBuilder.h index e62d663a768f398b3f321a6a25597e84516188d8..e4bee7069f6218e19b220aaeeab15c734b4f1bbf 100644 --- a/GUI/View/Fit/FitObjectiveBuilder.h +++ b/GUI/View/Fit/FitObjectiveBuilder.h @@ -21,6 +21,7 @@ class JobItem; class FitObjective; class ISimulation; namespace mumufit { + class Parameters; } template <class T> class OutputData; diff --git a/GUI/View/Fit/FitParameterWidget.cpp b/GUI/View/Fit/FitParameterWidget.cpp index c0b3b7d99e918a0433620a54749cb2429c194ec1..084175336a8b5c519849570f29ed581806065288 100644 --- a/GUI/View/Fit/FitParameterWidget.cpp +++ b/GUI/View/Fit/FitParameterWidget.cpp @@ -34,6 +34,7 @@ #include <QVBoxLayout> #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_downcast; FitParameterWidget::FitParameterWidget(QWidget* parent) @@ -177,18 +178,16 @@ void FitParameterWidget::onRemoveFitParAction() // retrieve both, selected FitParameterItem and FitParameterItemLink QVector<FitParameterLinkItem*> linksToRemove = selectedFitParameterLinks(); - for (auto* item : linksToRemove) { + for (auto* item : linksToRemove) container->model()->removeRow(item->index().row(), item->index().parent()); - } QVector<FitParameterItem*> itemsToRemove = selectedFitParameters(); // By uncommenting line below, removing link from fit parameter will lead to fit parameter // removal too (if it doesn't have other links) // QVector<FitParameterItem *> itemsToRemove = selectedFitParameters()+emptyFitParameters(); - for (auto* item : itemsToRemove) { + for (auto* item : itemsToRemove) container->model()->removeRow(item->index().row(), item->index().parent()); - } } //! Add all selected parameters to fitParameter with given index @@ -259,9 +258,8 @@ void FitParameterWidget::initTuningWidgetContextMenu(QMenu& menu) if (allow_one_fit_parameter_to_have_more_than_one_link) { QStringList fitParNames = FitParameterHelper::getFitParameterNames(jobItem()->fitParameterContainerItem()); - if (fitParNames.isEmpty() || !canCreateFitParameter()) { + if (fitParNames.isEmpty() || !canCreateFitParameter()) addToFitParMenu->setEnabled(false); - } for (int i = 0; i < fitParNames.count(); ++i) { auto* action = new QAction(QString("to ").append(fitParNames.at(i)), addToFitParMenu); connect(action, &QAction::triggered, [=] { onAddToFitParAction(i); }); @@ -397,9 +395,8 @@ void FitParameterWidget::spanParameters() break; int childRowCount = m_fitParameterModel->rowCount(parameter); if (childRowCount > 0) { - for (int j = 0; j < childRowCount; j++) { + for (int j = 0; j < childRowCount; j++) m_treeView->setFirstColumnSpanned(j, parameter, true); - } } } } diff --git a/GUI/View/Fit/FitSessionController.cpp b/GUI/View/Fit/FitSessionController.cpp index fa56a852428c879d73ef3894fd4d67d24b0b40ea..56d8de7f49da938c68bb2c4f7a12d76ce068ce5b 100644 --- a/GUI/View/Fit/FitSessionController.cpp +++ b/GUI/View/Fit/FitSessionController.cpp @@ -26,6 +26,7 @@ #include "GUI/View/Fit/GUIFitObserver.h" namespace { + const bool use_fit_objective = true; } @@ -64,9 +65,8 @@ void FitSessionController::setItem(JobItem* item) // Propagates update interval from FitSuiteItem to fit observer. m_jobItem->fitSuiteItem()->mapper()->setOnPropertyChange( [this](const QString& name) { - if (FitSuiteItem::isUpdateIntervalPropertyName(name)) { + if (FitSuiteItem::isUpdateIntervalPropertyName(name)) m_observer->setInterval(m_jobItem->fitSuiteItem()->updateInterval()); - } }, this); } @@ -82,7 +82,6 @@ void FitSessionController::onStartFittingRequest() m_objectiveBuilder->attachObserver(m_observer); m_observer->finishedPlotting(); m_runFitManager->runFitting(m_objectiveBuilder); - } catch (std::exception& e) { m_jobItem->setStatus(JobStatus::Failed); m_fitlog->append(e.what(), FitLogLevel::Error); diff --git a/GUI/View/Fit/JobRealTimeWidget.cpp b/GUI/View/Fit/JobRealTimeWidget.cpp index 719b77813e2c4c3794049d45e52fd9fee1ead847..3d426bff14c49c0f6dd9ddf2843c89a343550055 100644 --- a/GUI/View/Fit/JobRealTimeWidget.cpp +++ b/GUI/View/Fit/JobRealTimeWidget.cpp @@ -20,6 +20,7 @@ #include <QVBoxLayout> namespace { + const bool reuse_widget = true; } diff --git a/GUI/View/Fit/ParameterTuningDelegate.cpp b/GUI/View/Fit/ParameterTuningDelegate.cpp index 16521fca7febf33c90797e02d5e471d3697e3195..d9822ebd13e41ae5c57c8d7c50bfbbf9db155c25 100644 --- a/GUI/View/Fit/ParameterTuningDelegate.cpp +++ b/GUI/View/Fit/ParameterTuningDelegate.cpp @@ -34,8 +34,10 @@ #include <limits> 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() @@ -56,11 +58,10 @@ void ParameterTuningDelegate::TuningData::setItemLimits(const RealLimits& item_l int ParameterTuningDelegate::TuningData::value_to_slider(double value) { double dr(0); - if (value == 0.0) { + if (value == 0.0) dr = 1.0 * m_range_factor / 100.; - } else { + else dr = std::abs(value) * m_range_factor / 100.; - } m_rmin = value - dr; m_rmax = value + dr; @@ -102,7 +103,6 @@ void ParameterTuningDelegate::paint(QPainter* painter, const QStyleOptionViewIte const QModelIndex& index) const { if (index.column() == m_valueColumn) { - if (!index.parent().isValid()) return; @@ -158,17 +158,15 @@ QWidget* ParameterTuningDelegate::createEditor(QWidget* parent, const QStyleOpti m_valueBox->setDecimals(m_currentItem->decimalsOfLink()); m_valueBox->setSingleStep(m_tuning_info.step()); - if (limits.hasLowerLimit()) { + if (limits.hasLowerLimit()) m_valueBox->setMinimum(limits.lowerLimit()); - } else { + else m_valueBox->setMinimum(minimum_doublespin_value); - } - if (limits.hasUpperLimit()) { + if (limits.hasUpperLimit()) m_valueBox->setMaximum(limits.upperLimit()); - } else { + else m_valueBox->setMaximum(maximum_doublespin_value); - } m_valueBox->setValue(value); connect(m_valueBox, &ScientificSpinBox::valueChanged, this, @@ -254,13 +252,10 @@ void ParameterTuningDelegate::setEditorData(QWidget* editor, const QModelIndex& void ParameterTuningDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { - if (index.column() == m_valueColumn) { - + if (index.column() == m_valueColumn) model->setData(index, m_valueBox->value()); - - } else { + else QItemDelegate::setModelData(editor, model, index); - } } void ParameterTuningDelegate::emitSignals(double value) diff --git a/GUI/View/Fit/ParameterTuningWidget.cpp b/GUI/View/Fit/ParameterTuningWidget.cpp index 7c65deaaf8851d96b92bc11dbdb92fc52af98ca0..5e775ca11c421af36fd272e3734ffde209d79c62 100644 --- a/GUI/View/Fit/ParameterTuningWidget.cpp +++ b/GUI/View/Fit/ParameterTuningWidget.cpp @@ -206,9 +206,9 @@ void ParameterTuningWidget::updateDragAndDropSettings() //! editing widget, it will be forced to close. void ParameterTuningWidget::setTuningDelegateEnabled(bool enabled) { - if (enabled) { + if (enabled) m_delegate->setReadOnly(false); - } else { + else { m_delegate->setReadOnly(true); closeActiveEditors(); } diff --git a/GUI/View/Fit/RunFitControlWidget.cpp b/GUI/View/Fit/RunFitControlWidget.cpp index 6602534d6e1d0e5b7ed03a80448bc38c77ee4cff..4b5f769c7e9d0fdf3124b6cf9f50ea06e10e49c3 100644 --- a/GUI/View/Fit/RunFitControlWidget.cpp +++ b/GUI/View/Fit/RunFitControlWidget.cpp @@ -25,10 +25,12 @@ #include <QSlider> 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}; const QString slider_tooltip = "Updates fit progress every Nth iteration"; + } // namespace RunFitControlWidget::RunFitControlWidget(QWidget* parent) diff --git a/GUI/View/Fit/SliderSettingsWidget.cpp b/GUI/View/Fit/SliderSettingsWidget.cpp index ddc32f278ae4e192a9d55a2f3bf953f6367e118c..aed72604f0dbe41d78abb45ac228f9c229f82d1e 100644 --- a/GUI/View/Fit/SliderSettingsWidget.cpp +++ b/GUI/View/Fit/SliderSettingsWidget.cpp @@ -71,11 +71,11 @@ SliderSettingsWidget::SliderSettingsWidget(QWidget* parent) void SliderSettingsWidget::rangeChanged() { - if (m_radio1->isChecked()) { + if (m_radio1->isChecked()) m_currentSliderRange = 10.0; - } else if (m_radio2->isChecked()) { + else if (m_radio2->isChecked()) m_currentSliderRange = 100.0; - } else if (m_radio3->isChecked()) { + else if (m_radio3->isChecked()) { m_currentSliderRange = 1000.0; } emit sliderRangeFactorChanged(m_currentSliderRange); @@ -83,9 +83,8 @@ void SliderSettingsWidget::rangeChanged() void SliderSettingsWidget::onLockZChanged(int state) { - if (state == Qt::Unchecked) { + if (state == Qt::Unchecked) emit lockzChanged(false); - } else if (state == Qt::Checked) { + else if (state == Qt::Checked) emit lockzChanged(true); - } } diff --git a/GUI/View/Import/ImportDataView.cpp b/GUI/View/Import/ImportDataView.cpp index 7d783da5eb38894d8dead996cb2cfef1a0641b33..628b9af847e17bb38362ed1cbf585fba6def2f72 100644 --- a/GUI/View/Import/ImportDataView.cpp +++ b/GUI/View/Import/ImportDataView.cpp @@ -23,6 +23,7 @@ #include <QVBoxLayout> namespace { + const bool reuse_widget = true; } diff --git a/GUI/View/Import/SpecularDataImportWidget.cpp b/GUI/View/Import/SpecularDataImportWidget.cpp index 2135a4707786611bdfb532600cc7fe9563cc0b1a..5c6b79637ecefb1fe1cd8b37e1ad9abab3e94303 100644 --- a/GUI/View/Import/SpecularDataImportWidget.cpp +++ b/GUI/View/Import/SpecularDataImportWidget.cpp @@ -150,12 +150,10 @@ void SpecularDataImportWidget::fillLoaderCombo() { QSignalBlocker b(m_ui->formatSelectionComboBox); m_ui->formatSelectionComboBox->clear(); - for (auto* loader : DataLoaders1D::instance().recentlyUsedLoaders()) { + for (auto* loader : DataLoaders1D::instance().recentlyUsedLoaders()) m_ui->formatSelectionComboBox->addItem(loader->name()); - } - for (auto* loader : DataLoaders1D::instance().loaders()) { + for (auto* loader : DataLoaders1D::instance().loaders()) m_ui->formatSelectionComboBox->addItem(loader->name()); - } // e.g. legacy loader is not present in the combo by default. Add it here so it can be selected if (m_loader != nullptr) @@ -193,7 +191,6 @@ AbstractDataLoader* SpecularDataImportWidget::selectedLoader() void SpecularDataImportWidget::onFormatSelectionChanged() { if (m_loader && m_loader->fileContent().isEmpty()) { - QSignalBlocker b(m_ui->formatSelectionComboBox); m_ui->formatSelectionComboBox->setCurrentText(m_loader->name()); @@ -232,7 +229,6 @@ void SpecularDataImportWidget::updatePreview() // of QAbstractItemView::setModel auto* resultModel = m_loader->createResultModel(); if (resultModel != nullptr) { - const auto originalSections = resultModel->sectionsOfColumnType( AbstractDataLoaderResultModel::ColumnType::fileContent); @@ -314,7 +310,6 @@ void SpecularDataImportWidget::updatePreview() for (auto& w : warnings) new QListWidgetItem(w, m_ui->warningsListWidget); - } else { m_ui->warningsIcon->hide(); m_ui->warningsLabel->hide(); diff --git a/GUI/View/Import/SpecularDataImportWidget.h b/GUI/View/Import/SpecularDataImportWidget.h index 4b518dbaeb4e4b0f458e8bcc5e272afc7d144c4b..a2c2dcc3b47314ba3ef19eab13a23638afa5333e 100644 --- a/GUI/View/Import/SpecularDataImportWidget.h +++ b/GUI/View/Import/SpecularDataImportWidget.h @@ -25,6 +25,7 @@ class AbstractDataLoader; class RealDataItem; namespace Ui { + class SpecularDataImportWidget; } diff --git a/GUI/View/Info/CautionSign.cpp b/GUI/View/Info/CautionSign.cpp index e3603bb36f58d107db2e3cf39ca279598ccd0e93..36dc1ce93629431ab20e1d1170c81df1e57caf55 100644 --- a/GUI/View/Info/CautionSign.cpp +++ b/GUI/View/Info/CautionSign.cpp @@ -21,8 +21,10 @@ #include <QTimer> namespace { + const int xpos_offset = 40; const int ypos_offset = 40; + } // namespace CautionSign::CautionSign(QWidget* parent) @@ -63,7 +65,6 @@ void CautionSign::setCautionMessage(const QString& cautionMessage) m_clear_just_had_happened = false; QTimer::singleShot(50, this, [=]() { setCautionMessage(cautionMessage); }); } else { - m_caution_message = cautionMessage; if (!m_cautionWidget) @@ -111,7 +112,6 @@ QPoint CautionSign::positionForCautionSign() const int y = m_area->height() - ypos_offset; if (auto* scrollArea = dynamic_cast<QAbstractScrollArea*>(m_area)) { - if (QScrollBar* horizontal = scrollArea->horizontalScrollBar()) { if (horizontal->isVisible()) y -= horizontal->height(); diff --git a/GUI/View/Info/DetailedMessageBox.cpp b/GUI/View/Info/DetailedMessageBox.cpp index 721571650135734a0db11e383a1e96f4a0c149b2..d39dd5154693faca19387bef1a34eeb523af5ecd 100644 --- a/GUI/View/Info/DetailedMessageBox.cpp +++ b/GUI/View/Info/DetailedMessageBox.cpp @@ -22,6 +22,7 @@ #include <QVBoxLayout> namespace { + const QSize default_dialog_size(512, 300); } diff --git a/GUI/View/Info/OverlayLabelController.cpp b/GUI/View/Info/OverlayLabelController.cpp index 879cb46c3557d0caa563c69a8feb9a3bdfff07d3..71f2171a378ee3aada5c7fb954735186f0087409 100644 --- a/GUI/View/Info/OverlayLabelController.cpp +++ b/GUI/View/Info/OverlayLabelController.cpp @@ -47,7 +47,6 @@ void OverlayLabelController::setShown(bool shown) updateLabelGeometry(); m_label->show(); } - } else { delete m_label; m_label = nullptr; diff --git a/GUI/View/Info/ProjectLoadProblemDialog.cpp b/GUI/View/Info/ProjectLoadProblemDialog.cpp index 392d1d0c8e32b0094a6d3c5f79c29797942be251..3b65e1fb82a1ea390b7be71bbb5a9c536b914d9c 100644 --- a/GUI/View/Info/ProjectLoadProblemDialog.cpp +++ b/GUI/View/Info/ProjectLoadProblemDialog.cpp @@ -23,6 +23,7 @@ #include <utility> namespace { + const int top_panel_height = 80; } diff --git a/GUI/View/Info/PythonSyntaxHighlighter.cpp b/GUI/View/Info/PythonSyntaxHighlighter.cpp index ea0a62b8dda30898f97545fc8eb06aa4722dab98..02031e16dca7745b5f6536dd73a1c35da906cf37 100644 --- a/GUI/View/Info/PythonSyntaxHighlighter.cpp +++ b/GUI/View/Info/PythonSyntaxHighlighter.cpp @@ -136,9 +136,8 @@ void PythonSyntaxHighlighter::initializeRules() rules.append( HighlightingRule(QString("%1").arg(currOperator), 0, basicStyles.value("operator"))); } - for (const QString& currBrace : braces) { + for (const QString& currBrace : braces) rules.append(HighlightingRule(QString("%1").arg(currBrace), 0, basicStyles.value("brace"))); - } // 'self' rules.append(HighlightingRule("\\bself\\b", 0, basicStyles.value("self"))); diff --git a/GUI/View/Instrument/Detail/detailsbutton.cpp b/GUI/View/Instrument/Detail/detailsbutton.cpp index c224e98dfe49b60f221bd9de94eb348fd9f79564..a09a13f4f87f8e1094906acb063a27a41e909740 100644 --- a/GUI/View/Instrument/Detail/detailsbutton.cpp +++ b/GUI/View/Instrument/Detail/detailsbutton.cpp @@ -33,8 +33,10 @@ #include <QStyleOption> namespace { + const bool FlatProjectsMode(false); const QColor DetailsButtonBackgroundColorHover("#eff0f1"); + } // namespace namespace GUI::FromQt { diff --git a/GUI/View/Instrument/Detail/detailswidget.cpp b/GUI/View/Instrument/Detail/detailswidget.cpp index aa42aac670adc70439eb6095bd5da7d35c65b586..9d6d486786a4876fe1ea42458fe3ecd82dc8699a 100644 --- a/GUI/View/Instrument/Detail/detailswidget.cpp +++ b/GUI/View/Instrument/Detail/detailswidget.cpp @@ -35,6 +35,7 @@ #include <QScrollArea> #include <QStyle> #include <qglobal.h> + /*! \class GUI::Util::DetailsWidget @@ -56,6 +57,7 @@ */ namespace { + const bool FlatProjectsMode(false); } diff --git a/GUI/View/Instrument/DetectorAlignmentEditor.cpp b/GUI/View/Instrument/DetectorAlignmentEditor.cpp index 64a571d5055d037be3f72125922da4abdc9295d8..59005b989a8009d58ff79fefdf62f9f1c3692c07 100644 --- a/GUI/View/Instrument/DetectorAlignmentEditor.cpp +++ b/GUI/View/Instrument/DetectorAlignmentEditor.cpp @@ -261,7 +261,6 @@ void PerpendicularDetectorAlignmentForm::onDistanceValueChanged(double distance) /// detector alignment form for the perpendicular case where the reflected beam is used class ReflectedBeamDetectorAlignmentForm : public PerpendicularDetectorAlignmentForm { - public: ReflectedBeamDetectorAlignmentForm(const QString& title, const QString& tooltip, QWidget* parent = nullptr, @@ -318,7 +317,6 @@ void ReflectedBeamDetectorAlignmentForm::setV0(double v0) /// detector alignment form for the perpendicular case where the direct beam is used class DirectBeamDetectorAlignmentForm : public PerpendicularDetectorAlignmentForm { - public: DirectBeamDetectorAlignmentForm(const QString& title, const QString& tooltip, QWidget* parent = nullptr, diff --git a/GUI/View/Instrument/DetectorAlignmentEditor.h b/GUI/View/Instrument/DetectorAlignmentEditor.h index 33d65937e69a6aa7666bcc7286e29f32dbb63b83..a4ebe3a1b8ef2a18dd31889bb1e61d0bb369c47a 100644 --- a/GUI/View/Instrument/DetectorAlignmentEditor.h +++ b/GUI/View/Instrument/DetectorAlignmentEditor.h @@ -29,7 +29,6 @@ class RectangularDetectorItem; /// values class DetectorAlignmentEditor : public QWidget { - public: DetectorAlignmentEditor(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); void setItem(RectangularDetectorItem* item); diff --git a/GUI/View/Instrument/DetectorEditor.cpp b/GUI/View/Instrument/DetectorEditor.cpp index e4d642b51ab898a88dc2507b1e483615cf5bc281..dd9fb442b24344c16f00b2aeea797d77e475266d 100644 --- a/GUI/View/Instrument/DetectorEditor.cpp +++ b/GUI/View/Instrument/DetectorEditor.cpp @@ -23,7 +23,6 @@ #include <QFormLayout> #include <QStackedLayout> - //================================================================================================== // DetectorEditor //================================================================================================== diff --git a/GUI/View/Instrument/DistributionForms.cpp b/GUI/View/Instrument/DistributionForms.cpp index 367a372e6038dab8e2bb386eb32490f2bce0a20b..f2dc09622bb2d79f9591e1de50a3ef8e3b5ce554 100644 --- a/GUI/View/Instrument/DistributionForms.cpp +++ b/GUI/View/Instrument/DistributionForms.cpp @@ -23,9 +23,11 @@ #include <QSpinBox> #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_downcast; #include <boost/numeric/interval.hpp> + using boost::numeric::interval; namespace { @@ -38,6 +40,7 @@ static const interval<double> full(std::numeric_limits<double>::lowest(), // constant for often used interval [0,inf[ static const interval<double> nonnegative(0, std::numeric_limits<double>::max()); + } // namespace Range /// perform a strandard configuration for the QSpinBox diff --git a/GUI/View/Instrument/DistributionPlot.cpp b/GUI/View/Instrument/DistributionPlot.cpp index 0e0472647110500da8f1bd6923c1af67b96acafa..cb315451be1ca56f54279f408ca59d51843e53c4 100644 --- a/GUI/View/Instrument/DistributionPlot.cpp +++ b/GUI/View/Instrument/DistributionPlot.cpp @@ -23,6 +23,7 @@ #include <qcustomplot.h> namespace { + const QPair<double, double> default_xrange(-0.1, 0.1); const QPair<double, double> default_yrange(0.0, 1.1); @@ -93,7 +94,6 @@ void DistributionPlot::plotItem() try { plot_distributions(); - } catch (const std::exception& ex) { init_plot(); @@ -315,6 +315,7 @@ void DistributionPlot::setXAxisName(const QString& xAxisName) } namespace { + //! Returns (xmin, xmax) of x-axis to display single value. QPair<double, double> xRangeForValue(double value) { diff --git a/GUI/View/Instrument/EditDistributionDialog.cpp b/GUI/View/Instrument/EditDistributionDialog.cpp index e421326c960566b7ecf2d1c08da4091d8112fc9b..c2013bfbec523565f17cc1b1c1153b6f82559c29 100644 --- a/GUI/View/Instrument/EditDistributionDialog.cpp +++ b/GUI/View/Instrument/EditDistributionDialog.cpp @@ -21,7 +21,6 @@ #include <QSplitter> #include <QVBoxLayout> - EditDistributionDialog::EditDistributionDialog(ItemWithDistribution* item, const QString& title, const std::optional<MeanConfig>& mean_config, GUI::ID::Distributions distributions, diff --git a/GUI/View/Instrument/EnvironmentEditor.cpp b/GUI/View/Instrument/EnvironmentEditor.cpp index d265c5d508957578f75e9866bd2cab65837a4ce8..4fa1d3a55013f2924c7679a074d60e51c2e92d01 100644 --- a/GUI/View/Instrument/EnvironmentEditor.cpp +++ b/GUI/View/Instrument/EnvironmentEditor.cpp @@ -27,7 +27,6 @@ //================================================================================================== class ConstantBackgroundForm : public QWidget { - public: ConstantBackgroundForm(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); void setupBackground(ConstantBackgroundItem* item); diff --git a/GUI/View/Instrument/FootprintCorrectionEditor.cpp b/GUI/View/Instrument/FootprintCorrectionEditor.cpp index 652597ffc685d14dd73c1a855cf3e4ae178c5082..1ab51cf989641cedeba0f4289ecf0ad07d984241 100644 --- a/GUI/View/Instrument/FootprintCorrectionEditor.cpp +++ b/GUI/View/Instrument/FootprintCorrectionEditor.cpp @@ -27,7 +27,6 @@ //================================================================================================== class SquareFootprintForm : public QWidget { - public: SquareFootprintForm(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); void setFootprint(FootprintSquareItem* item); @@ -85,7 +84,6 @@ void SquareFootprintForm::onValueChanged(double value) //================================================================================================== class GaussFootprintForm : public QWidget { - public: GaussFootprintForm(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); void setFootprint(FootprintGaussianItem* item); diff --git a/GUI/View/Instrument/GISASBeamEditor.cpp b/GUI/View/Instrument/GISASBeamEditor.cpp index 0fad4120c4ce70cb4fdb29e7880fa6e3ee551bff..96b70d327996167c9d3429440f978dd00912be08 100644 --- a/GUI/View/Instrument/GISASBeamEditor.cpp +++ b/GUI/View/Instrument/GISASBeamEditor.cpp @@ -23,7 +23,6 @@ #include <QGridLayout> #include <QLineEdit> - GISASBeamEditor::GISASBeamEditor(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f), m_item(nullptr) { diff --git a/GUI/View/Instrument/InclinationAnglesEditor.h b/GUI/View/Instrument/InclinationAnglesEditor.h index a73439ecda61b780b877d28371833f31d76bb200..4cd20838799cf15f6b20f1b1a429facd6d2f5caa 100644 --- a/GUI/View/Instrument/InclinationAnglesEditor.h +++ b/GUI/View/Instrument/InclinationAnglesEditor.h @@ -25,7 +25,6 @@ class SphericalAxisForm; //! Editor for the case where there is no single inclination angle class InclinationAnglesEditor : public QWidget { - public: explicit InclinationAnglesEditor(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); diff --git a/GUI/View/Instrument/InstrumentLibraryEditor.h b/GUI/View/Instrument/InstrumentLibraryEditor.h index 8bfa939c61793e17926ab0d3cabd467dac6e6e63..692cf380ece32457afd905b5c263dc12d81e72ac 100644 --- a/GUI/View/Instrument/InstrumentLibraryEditor.h +++ b/GUI/View/Instrument/InstrumentLibraryEditor.h @@ -21,6 +21,7 @@ class InstrumentItem; namespace Ui { + class InstrumentLibraryEditor; } diff --git a/GUI/View/Instrument/OffSpecularBeamEditor.cpp b/GUI/View/Instrument/OffSpecularBeamEditor.cpp index 6240318a5d1e82efe4a5f96abb7a4a0d6f18486c..0be4835ea3f646ae6d6531eee6788cd5be387a67 100644 --- a/GUI/View/Instrument/OffSpecularBeamEditor.cpp +++ b/GUI/View/Instrument/OffSpecularBeamEditor.cpp @@ -24,7 +24,6 @@ #include <QGridLayout> #include <QLineEdit> - OffSpecularBeamEditor::OffSpecularBeamEditor(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f), m_item(nullptr) { diff --git a/GUI/View/Instrument/PolarizationAnalysisEditor.cpp b/GUI/View/Instrument/PolarizationAnalysisEditor.cpp index f84240bfe6a288caa795578eda34c27ac6c3b5ca..4638f26d8d8399241723671f2d6c44e4f43aecbf 100644 --- a/GUI/View/Instrument/PolarizationAnalysisEditor.cpp +++ b/GUI/View/Instrument/PolarizationAnalysisEditor.cpp @@ -24,13 +24,11 @@ #include <QGridLayout> #include <QGroupBox> - //================================================================================================== // AnalyzerPropertiesEditor //================================================================================================== class AnalyzerPropertiesEditor : public QWidget { - public: AnalyzerPropertiesEditor(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); void setItem(InstrumentItem* item); @@ -102,16 +100,14 @@ void AnalyzerPropertiesEditor::clearItem() void AnalyzerPropertiesEditor::onEfficiencyValueChanged(double efficiency) { - if (m_item) { + if (m_item) m_item->setAnalyzerEfficiency(efficiency); - } } void AnalyzerPropertiesEditor::onTransmissionValueChanged(double transmission) { - if (m_item) { + if (m_item) m_item->setAnalyzerTotalTransmission(transmission); - } } //================================================================================================== diff --git a/GUI/View/Instrument/RectangularDetectorEditor.cpp b/GUI/View/Instrument/RectangularDetectorEditor.cpp index 90c914612d18f4361a070c5d6822d4ba0493b672..ff439c71878d914487551063c9d0c1821ef1d6f8 100644 --- a/GUI/View/Instrument/RectangularDetectorEditor.cpp +++ b/GUI/View/Instrument/RectangularDetectorEditor.cpp @@ -33,7 +33,6 @@ //================================================================================================== class RectangularAxisEditor : public QWidget { - public: enum Orientation { X_Axis, Y_Axis }; RectangularAxisEditor(const Orientation& orientation, QWidget* parent = nullptr, diff --git a/GUI/View/Instrument/ResolutionFunctionEditor.h b/GUI/View/Instrument/ResolutionFunctionEditor.h index 7dfd8f096458a9a4358a21003fa7bebca3a9387c..dbd5e238384e9031ff0a4b92de4706cf95eff4ea 100644 --- a/GUI/View/Instrument/ResolutionFunctionEditor.h +++ b/GUI/View/Instrument/ResolutionFunctionEditor.h @@ -28,7 +28,6 @@ class GaussResolutionFunctionForm; /// corresponding values class ResolutionFunctionEditor : public QWidget { - public: enum Unit { Degree, Millimeter }; ResolutionFunctionEditor(Unit unit, QWidget* parent = nullptr, diff --git a/GUI/View/Instrument/SphericalAxisEditor.cpp b/GUI/View/Instrument/SphericalAxisEditor.cpp index b19d8d9ad769b786c7dc462cfb4bd881343a03a4..f4fcad6ee76112705582e07088ca194d261a5fd7 100644 --- a/GUI/View/Instrument/SphericalAxisEditor.cpp +++ b/GUI/View/Instrument/SphericalAxisEditor.cpp @@ -20,7 +20,6 @@ #include <QGroupBox> #include <QSpinBox> - //================================================================================================== // SphericalAxisForm //================================================================================================== diff --git a/GUI/View/Instrument/SphericalAxisEditor.h b/GUI/View/Instrument/SphericalAxisEditor.h index 3cffb4c32ca8750fb6b3dcb69a2704505ef6c992..e668a2acc431f43b32e60cc116eb0b749168271f 100644 --- a/GUI/View/Instrument/SphericalAxisEditor.h +++ b/GUI/View/Instrument/SphericalAxisEditor.h @@ -27,7 +27,6 @@ class QSpinBox; /// The input widgets will be inserted in the form given in the constructor class SphericalAxisForm : public QObject { - public: SphericalAxisForm(QFormLayout* form, QWidget* parent); void setItem(BasicAxisItem* item); @@ -50,7 +49,6 @@ private: /// An editor for a spherical axis: the form for the axis placed into a group box with title class SphericalAxisEditor : public QWidget { - public: SphericalAxisEditor(const QString& title, QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); diff --git a/GUI/View/Instrument/SphericalDetectorEditor.cpp b/GUI/View/Instrument/SphericalDetectorEditor.cpp index 944002c945edfd338aef28770f7ff61dd15ce1ec..29b0d261c815aebd3301f448476a93c474a90e3c 100644 --- a/GUI/View/Instrument/SphericalDetectorEditor.cpp +++ b/GUI/View/Instrument/SphericalDetectorEditor.cpp @@ -19,7 +19,6 @@ #include <QGridLayout> - //================================================================================================== // SphericalDetectorEditor //================================================================================================== diff --git a/GUI/View/Intensity/ColorMap.cpp b/GUI/View/Intensity/ColorMap.cpp index 33978bc29b755f01f666eb1cb8f603c886cecd63..e0cd4acb2d0ca95d6bbbf8a028c10bbaeec4be02 100644 --- a/GUI/View/Intensity/ColorMap.cpp +++ b/GUI/View/Intensity/ColorMap.cpp @@ -21,9 +21,11 @@ #include "GUI/View/Tool/UpdateTimer.h" namespace { + const int replot_update_interval = 10; const int colorbar_width_logz = 50; const int colorbar_width = 80; + } // namespace ColorMap::ColorMap(QWidget* parent) @@ -154,7 +156,6 @@ void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& pro } else if (AmplitudeAxisItem::isLogScalePropertyName(propertyName)) { setLogz(intensityItem()->isLogz()); replot(); - } else if (BasicAxisItem::isVisibilityPropertyName(propertyName)) { setColorScaleVisible(intensityItem()->zAxisItem()->visibilityValue()); replot(); @@ -272,7 +273,6 @@ void ColorMap::setAxesRangeConnected(bool isConnected) connect(m_customPlot->yAxis, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, &ColorMap::onYaxisRangeChanged, Qt::UniqueConnection); - } else { disconnect(m_customPlot->xAxis, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, diff --git a/GUI/View/Intensity/ColorMapUtils.cpp b/GUI/View/Intensity/ColorMapUtils.cpp index 6f0ba2cf1e466d410cf1c3850160fb0570fb54fd..136cf94011173d6d85e455aa79349165a9738410 100644 --- a/GUI/View/Intensity/ColorMapUtils.cpp +++ b/GUI/View/Intensity/ColorMapUtils.cpp @@ -20,6 +20,7 @@ using gradient_map_t = QMap<QString, QCPColorGradient::GradientPreset>; namespace { + gradient_map_t createGradientMap() { gradient_map_t result; @@ -65,9 +66,8 @@ QCPColorGradient GUI::View::ColorMapUtils::getGradient(const QString& gradientNa static gradient_map_t gradient_map = createGradientMap(); auto it = gradient_map.find(gradientName); - if (it == gradient_map.end()) { + if (it == gradient_map.end()) throw Error("ColorMapHelper::getGradient() -> Error. No such gradient" + gradientName); - } return QCPColorGradient(it.value()); } diff --git a/GUI/View/Intensity/FontScalingEvent.cpp b/GUI/View/Intensity/FontScalingEvent.cpp index a432c5bfff2557974e8341c0564d0cf7a3a56585..bcc924855d82a45efa059d19d4435430a2f2f309 100644 --- a/GUI/View/Intensity/FontScalingEvent.cpp +++ b/GUI/View/Intensity/FontScalingEvent.cpp @@ -19,8 +19,10 @@ #include <qcustomplot.h> namespace { + const QString tick_font = "tick-font-key"; const int widget_size_to_switch_font = 500; + } // namespace FontScalingEvent::FontScalingEvent(ScientificPlot* plot, QWidget* parent) @@ -34,15 +36,13 @@ bool FontScalingEvent::eventFilter(QObject* obj, QEvent* event) auto* resizeEvent = dynamic_cast<QResizeEvent*>(event); ASSERT(resizeEvent); - if (!m_fonts.contains(tick_font)) { + if (!m_fonts.contains(tick_font)) backupFonts(); - - } else { - if (resizeEvent->size().width() < widget_size_to_switch_font) { + else { + if (resizeEvent->size().width() < widget_size_to_switch_font) scaleFonts(0.8); - } else { + else restoreFonts(); - } } } diff --git a/GUI/View/Intensity/Plot1D.cpp b/GUI/View/Intensity/Plot1D.cpp index 26cf0e4ba86f7ab8290721a112890af1f2de71ba..f398c39798b671b3eaac6cf35b9f8904c4255219 100644 --- a/GUI/View/Intensity/Plot1D.cpp +++ b/GUI/View/Intensity/Plot1D.cpp @@ -24,9 +24,11 @@ #include "GUI/View/Tool/UpdateTimer.h" namespace { + const int replot_update_interval = 10; int bin(double x, const QCPGraph* graph); + } // namespace Plot1D::Plot1D(QWidget* parent) @@ -169,7 +171,6 @@ void Plot1D::setAxesRangeConnected(bool isConnected) connect(m_custom_plot->yAxis, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, &Plot1D::onYaxisRangeChanged, Qt::UniqueConnection); - } else { disconnect(m_custom_plot->xAxis, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, @@ -300,6 +301,7 @@ void Plot1D::replot() } namespace { + int bin(double x, const QCPGraph* graph) { const int key_start = graph->findBegin(x); @@ -309,4 +311,5 @@ int bin(double x, const QCPGraph* graph) return (x - graph->dataSortKey(key_start)) <= (graph->dataSortKey(key_end) - x) ? key_start : key_end; } + } // namespace diff --git a/GUI/View/Intensity/SavePlotAssistant.h b/GUI/View/Intensity/SavePlotAssistant.h index 64f8cb0375387e3b5849ae7777f8c3110cdd8344..d08278248d685c29db29b67c7b8c373d4bb7aa4b 100644 --- a/GUI/View/Intensity/SavePlotAssistant.h +++ b/GUI/View/Intensity/SavePlotAssistant.h @@ -21,6 +21,7 @@ class QCustomPlot; template <class T> class OutputData; namespace GUI::Plot { + void savePlot(const QString& dirname, QCustomPlot* plot, OutputData<double>* output_data); }; diff --git a/GUI/View/Intensity/StatusLabel.cpp b/GUI/View/Intensity/StatusLabel.cpp index 0081ce72afa708c989a09c181a587d15a9b1db45..b876d623dd75ce44f3b5d8889a770966ac48e9c3 100644 --- a/GUI/View/Intensity/StatusLabel.cpp +++ b/GUI/View/Intensity/StatusLabel.cpp @@ -19,6 +19,7 @@ #include <QPainter> namespace { + int default_text_size() { return GUI::Util::Style::SystemPointSize(); @@ -27,6 +28,7 @@ int default_label_height() { return GUI::Util::Style::SizeOfLetterM().height() * 1.75; } + } // namespace StatusLabel::StatusLabel(QWidget* parent) diff --git a/GUI/View/Job/JobListView.cpp b/GUI/View/Job/JobListView.cpp index 3ac4d5037f59baa9f8056ee03711322c7cbe9155..eeba68f290ffc0250dd1bff61eb3cd1b2ae3931a 100644 --- a/GUI/View/Job/JobListView.cpp +++ b/GUI/View/Job/JobListView.cpp @@ -25,6 +25,7 @@ #include <QVBoxLayout> namespace { + //! compare function for sorting indexes according to row descending bool row_descending(const QModelIndex& idx1, const QModelIndex& idx2) { @@ -36,6 +37,7 @@ bool row_ascending(const QModelIndex& idx1, const QModelIndex& idx2) { return idx1.row() < idx2.row(); } + } // namespace //================================================================================================== diff --git a/GUI/View/Job/JobListViewDelegate.cpp b/GUI/View/Job/JobListViewDelegate.cpp index fab20c5dac7d302ee8c3489af50625030cbc8727..2758863c55c487f2b468bfc140d4ef44a18577fd 100644 --- a/GUI/View/Job/JobListViewDelegate.cpp +++ b/GUI/View/Job/JobListViewDelegate.cpp @@ -93,9 +93,9 @@ bool JobListViewDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, return false; // so that selection can change } - if (event->type() == QEvent::MouseButtonPress) { + if (event->type() == QEvent::MouseButtonPress) m_buttonState = QStyle::State_Sunken; - } else if (event->type() == QEvent::MouseButtonRelease) { + else if (event->type() == QEvent::MouseButtonRelease) { m_buttonState = QStyle::State_Raised; emit cancelButtonClicked(index); } diff --git a/GUI/View/Job/JobPropertiesTableModel.cpp b/GUI/View/Job/JobPropertiesTableModel.cpp index fb50fdc79635f768aed831fbaded0e9b7071a49f..e3e3b92d312a00f1c3dcd7d83bb599b85c592ab3 100644 --- a/GUI/View/Job/JobPropertiesTableModel.cpp +++ b/GUI/View/Job/JobPropertiesTableModel.cpp @@ -17,19 +17,23 @@ #include <QLocale> namespace { + namespace Column { + enum Columns { Name, Value }; } const QString ColumnNames[] = {"Name", "Value"}; const int NumColumns = (int)std::size(ColumnNames); namespace Row { + enum Rows { Name, Sample, Instrument, Status, Begin, End, Duration }; } const QString RowNames[] = {"Name", "Sample", "Instrument", "Status", "Begin", "End", "Duration"}; const int NumRows = (int)std::size(RowNames); const QString ModelDateShortFormat = "yyyy.MM.dd hh:mm:ss"; + } // namespace //================================================================================================== diff --git a/GUI/View/Job/JobPropertiesWidget.cpp b/GUI/View/Job/JobPropertiesWidget.cpp index e7c2ee24fe687d341c48fc566be84b6325b59c33..42bbd476db2fef19a928059ed501b78d549cda43 100644 --- a/GUI/View/Job/JobPropertiesWidget.cpp +++ b/GUI/View/Job/JobPropertiesWidget.cpp @@ -24,6 +24,7 @@ #include <QVBoxLayout> namespace { + enum ETabId { JOB_PROPERTIES, JOB_COMMENTS }; } diff --git a/GUI/View/Job/JobViewActivities.cpp b/GUI/View/Job/JobViewActivities.cpp index 3bf8d80d526950361329087843073fff9ff47f2b..1c2166d59d6db2ebe0ffbc1c9df4be3a8eb428e0 100644 --- a/GUI/View/Job/JobViewActivities.cpp +++ b/GUI/View/Job/JobViewActivities.cpp @@ -17,6 +17,7 @@ #include "GUI/View/Tool/mainwindow_constants.h" namespace { + QMap<JobViewActivity, QVector<JobViewFlags::Dock>> createActivityMap() { QMap<JobViewActivity, QVector<JobViewFlags::Dock>> result; diff --git a/GUI/View/Loaders/QREDataLoader.cpp b/GUI/View/Loaders/QREDataLoader.cpp index 3f9b1904739e9d6b2680c76bbdeca808ea6c84ec..23c55539ef70bda0dca983db7d69a07f44fb0f32 100644 --- a/GUI/View/Loaders/QREDataLoader.cpp +++ b/GUI/View/Loaders/QREDataLoader.cpp @@ -53,9 +53,9 @@ QVector<QPair<int, int>> expandLineNumberPattern(const QString& pattern, bool* o const auto conv0 = parts[0].toInt(&ok2); if (ok2) { const auto conv1 = parts.size() > 1 ? parts[1].toInt(&ok2) : conv0; - if (ok2) { + if (ok2) result.push_back({conv0, conv1}); - } else { + else { if (ok != nullptr) { *ok = false; } @@ -268,7 +268,6 @@ void QREDataLoader::processContents() } if (creationOfOutputDataIsNecessary) { - try { createOutputDataFromParsingResult(m_item); } catch (...) { @@ -421,7 +420,6 @@ void QREDataLoader::parseFileContent() const m_importResult.rawValues.resize(m_importResult.lines.size()); for (int lineNr = 0; lineNr < m_importResult.lines.size(); lineNr++) { - const bool skip = m_importResult.lines[lineNr].first; if (skip) continue; diff --git a/GUI/View/Loaders/QREDataLoaderProperties.cpp b/GUI/View/Loaders/QREDataLoaderProperties.cpp index d680860b6f7ba312c739f3791bd0e1727e0fef86..58de0ef78b5648d0caed8df9b0be2ec1280df414 100644 --- a/GUI/View/Loaders/QREDataLoaderProperties.cpp +++ b/GUI/View/Loaders/QREDataLoaderProperties.cpp @@ -36,7 +36,6 @@ QREDataLoaderProperties::QREDataLoaderProperties() : m_allowFactors(false) [=]() { emit propertiesChanged(); }); for (int dataType = 0; dataType < 3; dataType++) { - // In the following: disable the checkbox before signaling propertyChanged to suppress ghost // value changes in case the propertiesChanged signals triggers long calculations (the // spinbox would see a timeout in its "pressed"-loop and generate a second value change) diff --git a/GUI/View/Loaders/QREDataLoaderProperties.h b/GUI/View/Loaders/QREDataLoaderProperties.h index d13c489ed511a5841c8090d9e505738a97e217b5..0200175f3a1684a1cc8bc25193f573be8dbd2445 100644 --- a/GUI/View/Loaders/QREDataLoaderProperties.h +++ b/GUI/View/Loaders/QREDataLoaderProperties.h @@ -24,6 +24,7 @@ class QCheckBox; class QLabel; namespace Ui { + class QREDataLoaderProperties; } diff --git a/GUI/View/Main/AutosaveController.cpp b/GUI/View/Main/AutosaveController.cpp index 71056e4ed8e117913e01c605535c144b15268866..6b15d8d300f812e30f68cbf7930f1900af34dbd4 100644 --- a/GUI/View/Main/AutosaveController.cpp +++ b/GUI/View/Main/AutosaveController.cpp @@ -19,6 +19,7 @@ #include <QDir> namespace { + const int update_every = 20000; // in msec } diff --git a/GUI/View/Main/MainWindow.cpp b/GUI/View/Main/MainWindow.cpp index bf02c7dfc9c8d5614b724b955ae3f918a1832223..d720a1b53d2b2c658c071331d965ce271e310b27 100644 --- a/GUI/View/Main/MainWindow.cpp +++ b/GUI/View/Main/MainWindow.cpp @@ -61,7 +61,6 @@ MainWindow::MainWindow() , m_jobView(nullptr) , m_sessionModelView(nullptr) { - s_instance = this; auto* centralWidget = new QWidget(this); diff --git a/GUI/View/Main/NewProjectDialog.cpp b/GUI/View/Main/NewProjectDialog.cpp index 327fd94ba0d5cc7d472fa9628fbec0676599d426..07a5d9109ac8e10d587088cf41e33108fe348ce5 100644 --- a/GUI/View/Main/NewProjectDialog.cpp +++ b/GUI/View/Main/NewProjectDialog.cpp @@ -180,9 +180,9 @@ void NewProjectDialog::updateWarningStatus() + "' does not exist. </font>"); } else if (!m_valid_projectName) { m_createButton->setEnabled(false); - if (getProjectName().isEmpty()) { + if (getProjectName().isEmpty()) m_warningLabel->setText("<font color='darkRed'> Please specify project name. </font>"); - } else { + else { m_warningLabel->setText("<font color='darkRed'> The directory '" + getProjectName() + "' already exists. </font>"); } diff --git a/GUI/View/Main/ProjectManager.cpp b/GUI/View/Main/ProjectManager.cpp index 6e97e054357677ee18ed439f61411c43368e8222..516fc719a141a05a12491eae7b94aaff70c5efc3 100644 --- a/GUI/View/Main/ProjectManager.cpp +++ b/GUI/View/Main/ProjectManager.cpp @@ -319,9 +319,9 @@ void ProjectManager::openProject(QString fileName) MessageService messageService; const auto readResult = loadProject(fileName, messageService); - if (readResult == ProjectDocument::ReadResult::ok) { + if (readResult == ProjectDocument::ReadResult::ok) addToRecentProjects(); - } else if (readResult == ProjectDocument::ReadResult::error) { + else if (readResult == ProjectDocument::ReadResult::error) { riseProjectLoadFailedDialog(messageService); deleteCurrentProject(); createNewProject(); diff --git a/GUI/View/Main/PyImportAssistant.cpp b/GUI/View/Main/PyImportAssistant.cpp index 1f3eecba5445d7ef18522694e700c5ed8e002c15..6141f607d711fed0bef6eff8810ebed386f6a5e4 100644 --- a/GUI/View/Main/PyImportAssistant.cpp +++ b/GUI/View/Main/PyImportAssistant.cpp @@ -146,7 +146,6 @@ QString PyImportAssistant::getPySampleFunctionName(const QString& snippet) try { auto funcs = Py::Import::listOfFunctions(snippet.toStdString(), bornagainDir()); funcList = GUI::Util::String::fromStdStrings(funcs); - } catch (const std::exception& ex) { QApplication::restoreOverrideCursor(); QString message("Exception thrown while acquiring functions from Python code.\n\n"); @@ -169,11 +168,9 @@ QString PyImportAssistant::selectPySampleFunction(const QStringList& funcNames) if (funcNames.empty()) { QString message("Python code doesn't contain any functions.\n\n"); GUI::View::Helpers::warning(m_parentForDialogs, "Python failure", message); - - } else if (funcNames.size() == 1) { + } else if (funcNames.size() == 1) return funcNames.front(); - - } else { + else { ComboSelectorDialog dialog; dialog.addItems(funcNames, getCandidate(funcNames)); dialog.setTextTop("Python code contains a few functions. Do you know by chance, " @@ -199,7 +196,6 @@ std::unique_ptr<MultiLayer> PyImportAssistant::createMultiLayer(const QString& s try { result = Py::Import::createFromPython(snippet.toStdString(), funcName.toStdString(), bornagainDir()); - } catch (const std::exception& ex) { QApplication::restoreOverrideCursor(); QString message("Exception thrown while executing Python code to create multilayer.\n\n"); @@ -226,7 +222,6 @@ void PyImportAssistant::populateModels(const MultiLayer& multilayer, const QStri QString message("Seems that import was successful.\n\n" "Check SampleView for new sample and material editor for new materials."); GUI::View::Helpers::information(m_parentForDialogs, "PyImport", message); - } catch (const std::exception& ex) { QString message("Exception thrown while trying to build GUI models.\n" "GUI models might be in inconsistent state.\n\n"); diff --git a/GUI/View/Mask/ColorMapSceneAdaptor.h b/GUI/View/Mask/ColorMapSceneAdaptor.h index e46c9693ca3687cd04415dbefdcf766f671e577a..139ead585f9e2823202f1a44ae5902cf35d03f0b 100644 --- a/GUI/View/Mask/ColorMapSceneAdaptor.h +++ b/GUI/View/Mask/ColorMapSceneAdaptor.h @@ -16,6 +16,7 @@ #define BORNAGAIN_GUI_VIEW_MASK_COLORMAPSCENEADAPTOR_H #include "GUI/View/Mask/ISceneAdaptor.h" + class ColorMap; //! Performs conversion of MaskItems coordinates between ColorMap and GraphicsScene. diff --git a/GUI/View/Mask/EllipseView.cpp b/GUI/View/Mask/EllipseView.cpp index 190038dcabecd7eb518a0ed30ee7b67e3b78a163..78669bc6d3f11b2920e6d0462c3307a7900c0a4a 100644 --- a/GUI/View/Mask/EllipseView.cpp +++ b/GUI/View/Mask/EllipseView.cpp @@ -73,20 +73,17 @@ void EllipseView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) m_item->setYRadius((fromSceneY(centerInScene.y() - height / 2.) - fromSceneY(centerInScene.y() + height / 2.)) / 2.); - } else if (m_activeHandleElement->getHandleType() == SizeHandleElement::RESIZE_HEIGHT) { m_item->setYCenter(fromSceneY(centerInScene.y())); m_item->setYRadius((fromSceneY(centerInScene.y() - height / 2.) - fromSceneY(centerInScene.y() + height / 2.)) / 2.); - } else if (m_activeHandleElement->getHandleType() == SizeHandleElement::RESIZE_WIDTH) { m_item->setXCenter(fromSceneX(centerInScene.x())); m_item->setXRadius((fromSceneX(centerInScene.x() + width / 2.) - fromSceneX(centerInScene.x() - width / 2.)) / 2.); } - } else { IShape2DView::mouseMoveEvent(event); } diff --git a/GUI/View/Mask/IShape2DView.cpp b/GUI/View/Mask/IShape2DView.cpp index c51c8ee823055c47520cf6cc518cf6db3c3c5b0a..6cf70815232e652ca2de8e26e0a73ffc1e460ff9 100644 --- a/GUI/View/Mask/IShape2DView.cpp +++ b/GUI/View/Mask/IShape2DView.cpp @@ -22,12 +22,14 @@ #include <QPainter> namespace { + bool itemMaskValue(const SessionItem* item) { if (const auto* maskItem = dynamic_cast<const MaskItem*>(item)) return maskItem->maskValue(); return false; } + } // namespace IShape2DView::IShape2DView(SessionItem* item) @@ -153,9 +155,9 @@ void IShape2DView::onItemPropertyChange(const QString& propertyName) m_block_on_property_change = true; bool schedule_update = false; - if (MaskItem::isMaskValuePropertyName(propertyName)) { + if (MaskItem::isMaskValuePropertyName(propertyName)) schedule_update = true; - } else if (MaskItem::isIsVisiblePropertyName(propertyName)) { + else if (MaskItem::isIsVisiblePropertyName(propertyName)) { bool visible = false; if (auto* maskItem = dynamic_cast<MaskItem*>(parameterizedItem())) visible = maskItem->isVisibleValue(); diff --git a/GUI/View/Mask/LineViews.cpp b/GUI/View/Mask/LineViews.cpp index 89f8e47c1d8c24fe492e6a8766a791b2a7f6c84b..7abef9872e4c117ada2cfcf27f9bde8d70fb2f44 100644 --- a/GUI/View/Mask/LineViews.cpp +++ b/GUI/View/Mask/LineViews.cpp @@ -20,8 +20,10 @@ #include <QStyleOptionGraphicsItem> namespace { + const double mask_width = 8.0; const double mask_visible_width = 3.0; + } // namespace VerticalLineView::VerticalLineView(VerticalLineItem* item) : IShape2DView(item), m_item(item) diff --git a/GUI/View/Mask/MaskEditorActions.cpp b/GUI/View/Mask/MaskEditorActions.cpp index 486616215dca72ffdac8e6c279888daa7647d696..1d5d1e57e0dceca184967fe797254da60cd6341b 100644 --- a/GUI/View/Mask/MaskEditorActions.cpp +++ b/GUI/View/Mask/MaskEditorActions.cpp @@ -121,9 +121,8 @@ void MaskEditorActions::onToggleMaskValueAction() ASSERT(m_maskModel); ASSERT(m_selectionModel); for (auto itemIndex : m_selectionModel->selectedIndexes()) { - if (auto* item = dynamic_cast<MaskItem*>(m_maskModel->itemForIndex(itemIndex))) { + if (auto* item = dynamic_cast<MaskItem*>(m_maskModel->itemForIndex(itemIndex))) item->setMaskValue(!item->maskValue()); - } } } diff --git a/GUI/View/Mask/MaskEditorToolBar.cpp b/GUI/View/Mask/MaskEditorToolBar.cpp index 2cc66c1f9e1be997059fd00dac7324ee085d4801..38447ea3c80655a5f98a6cd3298c1f84f5bb40a2 100644 --- a/GUI/View/Mask/MaskEditorToolBar.cpp +++ b/GUI/View/Mask/MaskEditorToolBar.cpp @@ -59,9 +59,9 @@ MaskEditorToolBar::MaskEditorToolBar(MaskEditorActions* editorActions, QWidget* //! space bar. As soon as space bar is released, activity is returned to previous state. void MaskEditorToolBar::onChangeActivityRequest(MaskEditorFlags::Activity value) { - if (value == MaskEditorFlags::PREVIOUS_MODE) { + if (value == MaskEditorFlags::PREVIOUS_MODE) setCurrentActivity(m_previousActivity); - } else { + else { m_previousActivity = currentActivity(); setCurrentActivity(value); } diff --git a/GUI/View/Mask/MaskGraphicsProxy.cpp b/GUI/View/Mask/MaskGraphicsProxy.cpp index a2b7919a92927632ada25c8af77a9b329916efd5..480e42b132da6226d73620ffcb6c84678d48298c 100644 --- a/GUI/View/Mask/MaskGraphicsProxy.cpp +++ b/GUI/View/Mask/MaskGraphicsProxy.cpp @@ -55,11 +55,10 @@ void MaskGraphicsProxy::setSceneAdaptor(ISceneAdaptor* sceneAdaptor) void MaskGraphicsProxy::setInZoomMode(bool value) { m_send_signals_to_colormap = value; - if (value) { + if (value) setAcceptedMouseButtons(Qt::LeftButton); - } else { + else setAcceptedMouseButtons(Qt::NoButton); - } } ColorMap* MaskGraphicsProxy::colorMap() diff --git a/GUI/View/Mask/MaskGraphicsScene.cpp b/GUI/View/Mask/MaskGraphicsScene.cpp index 18140aa464d2ebac8e9d3edec34e5ee491277b87..3278749fef38b1619a8c1f9d0a41371fdbd00199 100644 --- a/GUI/View/Mask/MaskGraphicsScene.cpp +++ b/GUI/View/Mask/MaskGraphicsScene.cpp @@ -30,11 +30,14 @@ #include <QPainter> #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_downcast; namespace { + const QRectF default_scene_rect(0, 0, 800, 600); const qreal min_distance_to_create_rect = 10; + } // namespace MaskGraphicsScene::MaskGraphicsScene(QObject* parent) @@ -64,7 +67,6 @@ void MaskGraphicsScene::setMaskContext(SessionModel* model, const QModelIndex& m m_intensityItem = intensityItem; if (model != m_maskModel || m_maskContainerIndex != maskContainerIndex) { - if (m_maskModel) { disconnect(m_maskModel, &SessionModel::modelAboutToBeReset, this, &MaskGraphicsScene::resetScene); @@ -256,11 +258,10 @@ void MaskGraphicsScene::onSceneSelectionChanged() void MaskGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* event) { if (event->buttons() & Qt::RightButton) { - if (isDrawingInProgress()) { + if (isDrawingInProgress()) cancelCurrentDrawing(); - } else { + else makeViewAtMousePosSelected(event); - } return; } if (isValidForPolygonDrawing(event)) { @@ -305,9 +306,8 @@ void MaskGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) clearSelection(); if (m_currentItem) { // drawing ended up with item drawn, let's make it selected - if (IShape2DView* view = m_ItemToView[m_currentItem]) { + if (IShape2DView* view = m_ItemToView[m_currentItem]) view->setSelected(true); - } } else { // drawing ended without item to be draw (too short mouse move) // making item beneath of mouse release position to be selected @@ -575,11 +575,10 @@ void MaskGraphicsScene::setInPanAndZoomMode(bool value) void MaskGraphicsScene::updateCursors() { for (auto it = m_ItemToView.begin(); it != m_ItemToView.end(); ++it) { - if (it.key()->modelType() == VerticalLineItem::M_TYPE) { + if (it.key()->modelType() == VerticalLineItem::M_TYPE) it.value()->setCursor(m_context.isInZoomMode() ? Qt::ArrowCursor : Qt::SizeHorCursor); - } else if (it.key()->modelType() == HorizontalLineItem::M_TYPE) { + else if (it.key()->modelType() == HorizontalLineItem::M_TYPE) it.value()->setCursor(m_context.isInZoomMode() ? Qt::ArrowCursor : Qt::SizeVerCursor); - } } } diff --git a/GUI/View/Mask/MaskGraphicsView.cpp b/GUI/View/Mask/MaskGraphicsView.cpp index 635393f4cb7f240422ac307dd55a25efc33ada4b..4e66f84a32f043227a1532f7180b3b4255962861 100644 --- a/GUI/View/Mask/MaskGraphicsView.cpp +++ b/GUI/View/Mask/MaskGraphicsView.cpp @@ -21,9 +21,11 @@ #include <QWheelEvent> 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) @@ -84,9 +86,8 @@ void MaskGraphicsView::keyPressEvent(QKeyEvent* event) case Qt::Key_Left: break; case Qt::Key_Space: - if (!event->isAutoRepeat()) { + if (!event->isAutoRepeat()) emit changeActivityRequest(MaskEditorFlags::PAN_ZOOM_MODE); - } break; case Qt::Key_Escape: cancelCurrentDrawing(); diff --git a/GUI/View/Mask/MaskViewFactory.cpp b/GUI/View/Mask/MaskViewFactory.cpp index 7caa57c8ac8c59f8a4f2b52f61fc85052e592860..dec7adb56ab5d0ff3532b1e49e625665a056fd0d 100644 --- a/GUI/View/Mask/MaskViewFactory.cpp +++ b/GUI/View/Mask/MaskViewFactory.cpp @@ -26,51 +26,51 @@ #include "GUI/View/Mask/RegionOfInterestView.h" #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_downcast; IShape2DView* MaskViewFactory::createMaskView(SessionItem* item, ISceneAdaptor* adaptor) { IShape2DView* result(nullptr); - if (item->hasModelType<MaskContainerItem>()) { + if (item->hasModelType<MaskContainerItem>()) result = new MaskContainerView(polymorphic_downcast<MaskContainerItem*>(item)); - } - else if (item->hasModelType<ProjectionContainerItem>()) { + else if (item->hasModelType<ProjectionContainerItem>()) result = new MaskContainerView(polymorphic_downcast<ProjectionContainerItem*>(item)); - } - else if (item->hasModelType<RectangleItem>()) { + + else if (item->hasModelType<RectangleItem>()) result = new RectangleView(polymorphic_downcast<RectangleItem*>(item)); - } - else if (item->hasModelType<PolygonItem>()) { + + else if (item->hasModelType<PolygonItem>()) result = new PolygonView(polymorphic_downcast<PolygonItem*>(item)); - } - else if (item->hasModelType<PolygonPointItem>()) { + + else if (item->hasModelType<PolygonPointItem>()) result = new PolygonPointView(polymorphic_downcast<PolygonPointItem*>(item)); - } - else if (item->hasModelType<VerticalLineItem>()) { + + else if (item->hasModelType<VerticalLineItem>()) result = new VerticalLineView(polymorphic_downcast<VerticalLineItem*>(item)); - } - else if (item->hasModelType<HorizontalLineItem>()) { + + else if (item->hasModelType<HorizontalLineItem>()) result = new HorizontalLineView(polymorphic_downcast<HorizontalLineItem*>(item)); - } - else if (item->hasModelType<EllipseItem>()) { + + else if (item->hasModelType<EllipseItem>()) result = new EllipseView(polymorphic_downcast<EllipseItem*>(item)); - } - else if (item->hasModelType<MaskAllItem>()) { + + else if (item->hasModelType<MaskAllItem>()) result = new MaskAllView(polymorphic_downcast<MaskAllItem*>(item)); - } - else if (item->hasModelType<RegionOfInterestItem>()) { + + else if (item->hasModelType<RegionOfInterestItem>()) result = new RegionOfInterestView(polymorphic_downcast<RegionOfInterestItem*>(item)); - } + else { throw Error("MaskViewFactory::createSampleView() -> Error! " diff --git a/GUI/View/Mask/PolygonPointView.cpp b/GUI/View/Mask/PolygonPointView.cpp index 91fd118469a14bd7609f9f5f2772083d218d42ba..8b5049ed4e24c718d971ba30dd37c37ae8fe4ad6 100644 --- a/GUI/View/Mask/PolygonPointView.cpp +++ b/GUI/View/Mask/PolygonPointView.cpp @@ -59,9 +59,8 @@ void PolygonPointView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, { painter->setRenderHints(QPainter::Antialiasing); QBrush brush = MaskEditorHelper::getSelectionMarkerBrush(); - if (acceptHoverEvents() && m_on_hover) { + if (acceptHoverEvents() && m_on_hover) brush.setColor(Qt::red); - } painter->setBrush(brush); painter->setPen(MaskEditorHelper::getSelectionMarkerPen()); painter->drawEllipse(boundingRect()); diff --git a/GUI/View/Mask/PolygonView.cpp b/GUI/View/Mask/PolygonView.cpp index 4d7e5a25630e7e7eada8f2b2981775d3fa032034..7d189017b26dfa3c15b7ecd05b42f01f933e39f6 100644 --- a/GUI/View/Mask/PolygonView.cpp +++ b/GUI/View/Mask/PolygonView.cpp @@ -19,6 +19,7 @@ #include <QPainter> namespace { + const double bbox_margins = 5; // additional margins around points to form bounding box } @@ -152,7 +153,6 @@ void PolygonView::update_polygon() m_block_on_point_update = true; if (!m_item->points().isEmpty()) { - m_polygon.clear(); for (auto* point : m_item->points()) diff --git a/GUI/View/Mask/RectangleBaseView.cpp b/GUI/View/Mask/RectangleBaseView.cpp index f0619235cf6e690f54dc0d388c2656cc0bb8617a..8916130980c05f696a47ee94614027d52b2d29c4 100644 --- a/GUI/View/Mask/RectangleBaseView.cpp +++ b/GUI/View/Mask/RectangleBaseView.cpp @@ -16,6 +16,7 @@ #include "Base/Util/Assert.h" namespace { + const double bbox_margins = 5; // additional margins around rectangle to form bounding box } @@ -50,9 +51,8 @@ QVariant RectangleBaseView::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) { if (change == QGraphicsItem::ItemSelectedChange) { - for (auto it = m_resize_handles.begin(); it != m_resize_handles.end(); ++it) { + for (auto it = m_resize_handles.begin(); it != m_resize_handles.end(); ++it) it.value()->setVisible(!this->isSelected()); - } } return value; } diff --git a/GUI/View/Mask/RectangleView.cpp b/GUI/View/Mask/RectangleView.cpp index 404ed0607ddcc613d3065261177b9750cdaee39a..2e996b75fb9ed0894f2d0c7fc4d6d0cfd42a553a 100644 --- a/GUI/View/Mask/RectangleView.cpp +++ b/GUI/View/Mask/RectangleView.cpp @@ -60,7 +60,6 @@ void RectangleView::onPropertyChange() void RectangleView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (m_activeHandleElement) { - qreal xmin = std::min(event->scenePos().x(), m_resize_opposite_origin.x()); qreal xmax = std::max(event->scenePos().x(), m_resize_opposite_origin.x()); qreal ymin = std::min(event->scenePos().y(), m_resize_opposite_origin.y()); @@ -71,18 +70,14 @@ void RectangleView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) m_item->setYLow(fromSceneY(ymax)); m_item->setXUp(fromSceneX(xmax)); m_item->setYUp(fromSceneY(ymin)); - } else if (m_activeHandleElement->getHandleType() == SizeHandleElement::RESIZE_HEIGHT) { m_item->setYLow(fromSceneY(ymax)); m_item->setYUp(fromSceneY(ymin)); - } else if (m_activeHandleElement->getHandleType() == SizeHandleElement::RESIZE_WIDTH) { - m_item->setXLow(fromSceneX(xmin)); m_item->setXUp(fromSceneX(xmax)); } update_view(); - } else { IShape2DView::mouseMoveEvent(event); } diff --git a/GUI/View/Mask/SizeHandleElement.cpp b/GUI/View/Mask/SizeHandleElement.cpp index 85a677696a23cf11b277124b757afe7533d6844d..cb98b00c3017fdc097b222a80be0ca4a61b9b88f 100644 --- a/GUI/View/Mask/SizeHandleElement.cpp +++ b/GUI/View/Mask/SizeHandleElement.cpp @@ -17,6 +17,7 @@ #include <QPainter> namespace { + QMap<SizeHandleElement::EHandleLocation, Qt::CursorShape> create_cursors_map() { QMap<SizeHandleElement::EHandleLocation, Qt::CursorShape> result; @@ -96,11 +97,10 @@ void SizeHandleElement::paint(QPainter* painter, const QStyleOptionGraphicsItem* painter->setBrush(MaskEditorHelper::getSelectionMarkerBrush()); painter->setPen(MaskEditorHelper::getSelectionMarkerPen()); - if (getHandleType() == RESIZE) { + if (getHandleType() == RESIZE) painter->drawRect(boundingRect()); - } else { + else painter->drawEllipse(boundingRect()); - } } void SizeHandleElement::mousePressEvent(QGraphicsSceneMouseEvent* event) @@ -118,37 +118,35 @@ void SizeHandleElement::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) //! set position from location type using coordinates of external rectangle void SizeHandleElement::updateHandleElementPosition(const QRectF& rect) { - if (m_handleLocation == TOPLEFT) { + if (m_handleLocation == TOPLEFT) setPos(rect.topLeft()); - } - else if (m_handleLocation == TOPMIDDLE) { + else if (m_handleLocation == TOPMIDDLE) setPos(QPointF(rect.x() + rect.width() / 2., rect.y())); - } - else if (m_handleLocation == TOPRIGHT) { + + else if (m_handleLocation == TOPRIGHT) setPos(rect.topRight()); - } - else if (m_handleLocation == MIDDLERIGHT) { + + else if (m_handleLocation == MIDDLERIGHT) setPos(QPointF(rect.x() + rect.width(), rect.y() + rect.height() / 2.)); - } - else if (m_handleLocation == BOTTOMRIGHT) { + + else if (m_handleLocation == BOTTOMRIGHT) setPos(rect.bottomRight()); - } - else if (m_handleLocation == BOTTOMMIDLE) { + + else if (m_handleLocation == BOTTOMMIDLE) setPos(QPointF(rect.x() + rect.width() / 2., rect.y() + rect.height())); - } - else if (m_handleLocation == BOTTOMLEFT) { + + else if (m_handleLocation == BOTTOMLEFT) setPos(rect.bottomLeft()); - } - else if (m_handleLocation == MIDDLELEFT) { + + else if (m_handleLocation == MIDDLELEFT) setPos(QPointF(rect.x(), rect.y() + rect.height() / 2.)); - } } SizeHandleElement::EHandleLocation SizeHandleElement::getHandleLocation() const diff --git a/GUI/View/MaterialEditor/MaterialEditorDialog.h b/GUI/View/MaterialEditor/MaterialEditorDialog.h index bf37d20260d359f32624ff68bcb17c5bc2b93834..e71d496a3d4772d9c729d95581c95545371b9401 100644 --- a/GUI/View/MaterialEditor/MaterialEditorDialog.h +++ b/GUI/View/MaterialEditor/MaterialEditorDialog.h @@ -24,6 +24,7 @@ class MaterialEditorModel; class ProjectDocument; namespace Ui { + class MaterialEditorDialog; } diff --git a/GUI/View/MaterialEditor/MaterialEditorModel.h b/GUI/View/MaterialEditor/MaterialEditorModel.h index 92486aac46beba13d95556deca2688126962c23c..35eca50ac126c79d4fd27c5a85b2dc64354d9fe7 100644 --- a/GUI/View/MaterialEditor/MaterialEditorModel.h +++ b/GUI/View/MaterialEditor/MaterialEditorModel.h @@ -25,7 +25,6 @@ class MaterialModel; //! This model is also used for changing values of a material, therefore the list can be //! updated accordingly. class MaterialEditorModel : public QAbstractTableModel { - public: MaterialEditorModel(MaterialModel* p); diff --git a/GUI/View/Projection/ProjectionsEditorCanvas.cpp b/GUI/View/Projection/ProjectionsEditorCanvas.cpp index 6743a507d655abc3ea342865f303cc7346b4df25..1fa6f7520912f681558c3de87fd7e70cd6bc291c 100644 --- a/GUI/View/Projection/ProjectionsEditorCanvas.cpp +++ b/GUI/View/Projection/ProjectionsEditorCanvas.cpp @@ -25,6 +25,7 @@ #include <QVBoxLayout> #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_downcast; ProjectionsEditorCanvas::ProjectionsEditorCanvas(QWidget* parent) diff --git a/GUI/View/Projection/ProjectionsPlot.cpp b/GUI/View/Projection/ProjectionsPlot.cpp index f746dba570de9feda40c435d767bf8bae9b227eb..c219dcd15de625c76d0ad378faa59d327ee7932e 100644 --- a/GUI/View/Projection/ProjectionsPlot.cpp +++ b/GUI/View/Projection/ProjectionsPlot.cpp @@ -25,6 +25,7 @@ #include <boost/polymorphic_cast.hpp> #include <utility> + using boost::polymorphic_downcast; ProjectionsPlot::ProjectionsPlot(QString projectionType, QWidget* parent) diff --git a/GUI/View/Projection/ProjectionsToolBar.cpp b/GUI/View/Projection/ProjectionsToolBar.cpp index 675dcce532b701953f962996a63de037135ea192..0ec9ac06ffc26fd49190269566929e9cf1ec9efe 100644 --- a/GUI/View/Projection/ProjectionsToolBar.cpp +++ b/GUI/View/Projection/ProjectionsToolBar.cpp @@ -20,6 +20,7 @@ #include <QToolButton> namespace { + const QString pan_zoom_tooltip = "Pan/zoom mode (space)\n" "Drag axes with the mouse, use mouse wheel to zoom in/out"; @@ -62,9 +63,9 @@ ProjectionsToolBar::ProjectionsToolBar(ProjectionsEditorActions* editorActions, void ProjectionsToolBar::onChangeActivityRequest(MaskEditorFlags::Activity value) { - if (value == MaskEditorFlags::PREVIOUS_MODE) { + if (value == MaskEditorFlags::PREVIOUS_MODE) setCurrentActivity(m_previousActivity); - } else { + else { m_previousActivity = currentActivity(); setCurrentActivity(value); } diff --git a/GUI/View/Projection/ProjectionsWidget.cpp b/GUI/View/Projection/ProjectionsWidget.cpp index 91c87e1940042f4dc586b5071fde58a5e352ddb9..a82ccb9032fe4a2e3c5d71d794e48ec6f133fbde 100644 --- a/GUI/View/Projection/ProjectionsWidget.cpp +++ b/GUI/View/Projection/ProjectionsWidget.cpp @@ -19,8 +19,10 @@ #include <QVBoxLayout> namespace { + const int horizontal_projection_tab = 0; const int vertical_projection_tab = 1; + } // namespace ProjectionsWidget::ProjectionsWidget(QWidget* parent) diff --git a/GUI/View/Projection/SaveProjectionsAssistant.cpp b/GUI/View/Projection/SaveProjectionsAssistant.cpp index 7383611498a8604df86c360fc3fdeb47a3de3387..f33e8ff6289acbe638daf4aef9ce0e21a3d15509 100644 --- a/GUI/View/Projection/SaveProjectionsAssistant.cpp +++ b/GUI/View/Projection/SaveProjectionsAssistant.cpp @@ -26,6 +26,7 @@ #include <QTextStream> #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_downcast; namespace { diff --git a/GUI/View/PropertyEditor/CustomEditors.cpp b/GUI/View/PropertyEditor/CustomEditors.cpp index 208be506db41c15aa8fa29d9b3451c45276ca616..95c312168670109eab490813761c882cba098047 100644 --- a/GUI/View/PropertyEditor/CustomEditors.cpp +++ b/GUI/View/PropertyEditor/CustomEditors.cpp @@ -23,6 +23,7 @@ #include <cmath> namespace { + //! Single step for QDoubleSpinBox. double singleStep(int decimals) diff --git a/GUI/View/PropertyEditor/CustomEventFilters.cpp b/GUI/View/PropertyEditor/CustomEventFilters.cpp index 9c98c98cb87497ceba17e2bd52a4985abef121e5..0461821908f3a0f8f2321b336c4960c3df7d24c1 100644 --- a/GUI/View/PropertyEditor/CustomEventFilters.cpp +++ b/GUI/View/PropertyEditor/CustomEventFilters.cpp @@ -46,7 +46,6 @@ void WheelEventEater::install(QObject* obj) bool WheelEventEater::eventFilter(QObject* obj, QEvent* event) { if (auto* spinBox = qobject_cast<QAbstractSpinBox*>(obj)) { - if (event->type() == QEvent::Wheel) { if (spinBox->focusPolicy() == Qt::WheelFocus) { event->accept(); @@ -55,11 +54,10 @@ bool WheelEventEater::eventFilter(QObject* obj, QEvent* event) event->ignore(); return true; } - if (event->type() == QEvent::FocusIn) { + if (event->type() == QEvent::FocusIn) spinBox->setFocusPolicy(Qt::WheelFocus); - } else if (event->type() == QEvent::FocusOut) { + else if (event->type() == QEvent::FocusOut) spinBox->setFocusPolicy(Qt::StrongFocus); - } } else if (qobject_cast<QComboBox*>(obj)) { if (event->type() == QEvent::Wheel) { event->ignore(); diff --git a/GUI/View/PropertyEditor/GroupInfoBox.cpp b/GUI/View/PropertyEditor/GroupInfoBox.cpp index 45b72cc999a9a31806e614725ef76ab87d05cbe0..ee422cced17bf827d08092cc0814655d0b8933b6 100644 --- a/GUI/View/PropertyEditor/GroupInfoBox.cpp +++ b/GUI/View/PropertyEditor/GroupInfoBox.cpp @@ -25,10 +25,12 @@ #include <iostream> 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) diff --git a/GUI/View/Realspace/IPositionBuilder.cpp b/GUI/View/Realspace/IPositionBuilder.cpp index bef6089b662a02d471408c3a7c91d8829873dcc7..33611b5b53971b72dcf127f76904df426fec7fda 100644 --- a/GUI/View/Realspace/IPositionBuilder.cpp +++ b/GUI/View/Realspace/IPositionBuilder.cpp @@ -19,6 +19,7 @@ #include <random> namespace { + std::vector<std::vector<double>> Generate2DLatticePoints(double l1, double l2, double alpha, double xi, unsigned n1, unsigned n2); } @@ -229,9 +230,8 @@ RadialParacrystalPositionBuilder::generatePositionsImpl(double layer_size, doubl int n = distance <= 0.0 ? 1 : static_cast<int>(layer_size * std::sqrt(2.0) / distance); lattice_positions.resize(2 * n + 1); - for (auto& it : lattice_positions) { + for (auto& it : lattice_positions) it.resize(2); - } lattice_positions[0][0] = 0.0; // x coordinate of reference particle - at the origin lattice_positions[0][1] = 0.0; // y coordinate of reference particle - at the origin @@ -258,6 +258,7 @@ double RadialParacrystalPositionBuilder::positionVariance() const } namespace { + std::vector<std::vector<double>> Generate2DLatticePoints(double l1, double l2, double alpha, double xi, unsigned n1, unsigned n2) { @@ -286,4 +287,5 @@ std::vector<std::vector<double>> Generate2DLatticePoints(double l1, double l2, d } return lattice_positions; } + } // namespace diff --git a/GUI/View/Realspace/Particle3DContainer.h b/GUI/View/Realspace/Particle3DContainer.h index 3ccba92a0429066bfd0ef9b7aab0a2c31432039c..b29d80596d847b69df3d5285e4cabe97d972865d 100644 --- a/GUI/View/Realspace/Particle3DContainer.h +++ b/GUI/View/Realspace/Particle3DContainer.h @@ -20,7 +20,9 @@ #include <vector> namespace GUI::RealSpace::Particles { + class Particle; + } // namespace GUI::RealSpace::Particles class Particle3DContainer { diff --git a/GUI/View/Realspace/RealSpace2DParacrystalUtils.cpp b/GUI/View/Realspace/RealSpace2DParacrystalUtils.cpp index b7c4e6892026b9ac5a09e62ef189af727500d2fc..8a68b660ad1b20bbabfcb7618e6e648236340d57 100644 --- a/GUI/View/Realspace/RealSpace2DParacrystalUtils.cpp +++ b/GUI/View/Realspace/RealSpace2DParacrystalUtils.cpp @@ -30,9 +30,8 @@ void ResizeLatticePositions(std::vector<std::vector<double>>& lattice_positions, n1 = std::max(n1, n2); lattice_positions.resize((2 * n1 + 1) * (2 * n1 + 1)); - for (auto& it : lattice_positions) { + for (auto& it : lattice_positions) it.resize(2); - } lattice_positions[0][0] = 0.0; // x coordinate of reference particle - at the origin lattice_positions[0][1] = 0.0; // y coordinate of reference particle - at the origin @@ -132,7 +131,6 @@ void ComputePositionsAlongLatticeVectorAxes(std::vector<std::vector<double>>& la std::pair<double, double> xy; for (int iter = 1; iter <= 2 * n; ++iter) { - int iterl1, iterl2; if (std::sin(l_alpha) == 0) { diff --git a/GUI/View/Realspace/RealSpace2DParacrystalUtils.h b/GUI/View/Realspace/RealSpace2DParacrystalUtils.h index 7e37f847005cc7e27addabfe21fd7e2590ca4275..fc875cfc35794e7b25885f9397a239d988c773b2 100644 --- a/GUI/View/Realspace/RealSpace2DParacrystalUtils.h +++ b/GUI/View/Realspace/RealSpace2DParacrystalUtils.h @@ -23,7 +23,6 @@ namespace GUI::RealSpace::Paracrystal2D { std::vector<std::vector<double>> latticePositions(const Interference2DParaCrystal*, double layer_size); - } #endif // BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACE2DPARACRYSTALUTILS_H diff --git a/GUI/View/Realspace/RealSpaceBuilder.cpp b/GUI/View/Realspace/RealSpaceBuilder.cpp index 709e06e45e94895e973bed6713047a7e75adc53d..dd73b1b3b88a207883bcc581ccc004583dcd9ac1 100644 --- a/GUI/View/Realspace/RealSpaceBuilder.cpp +++ b/GUI/View/Realspace/RealSpaceBuilder.cpp @@ -101,7 +101,6 @@ void RealSpaceBuilder::populateMultiLayer(GUI::RealSpace::Model* model, double total_height(0.0); int index(0); for (LayerItem* layer : mlayerItem.layers()) { - bool isTopLayer = index == 0; populateLayer(model, *layer, sceneGeometry, QVector3D(0, 0, static_cast<float>(-total_height)), isTopLayer); diff --git a/GUI/View/Realspace/RealSpaceBuilder.h b/GUI/View/Realspace/RealSpaceBuilder.h index b11e0aa95c69b49990a4be1ce4dd71f56bb340a0..53538f6d531f828b7ada7532f8345872abce10f5 100644 --- a/GUI/View/Realspace/RealSpaceBuilder.h +++ b/GUI/View/Realspace/RealSpaceBuilder.h @@ -29,6 +29,7 @@ struct SceneGeometry; class Particle3DContainer; namespace GUI::RealSpace { + class Model; } diff --git a/GUI/View/Realspace/RealSpaceBuilderUtils.cpp b/GUI/View/Realspace/RealSpaceBuilderUtils.cpp index 8eaae01d56acc19ff3a65ec36d9e0a9f23d55811..9a549926c7fc6f6a7f33cbb2280ec02456f0b4e4 100644 --- a/GUI/View/Realspace/RealSpaceBuilderUtils.cpp +++ b/GUI/View/Realspace/RealSpaceBuilderUtils.cpp @@ -34,6 +34,7 @@ #include "Sample/Scattering/IFormFactorDecorator.h" namespace { + const double layerBorderWidth = 10.0; const IFormFactor* getUnderlyingFormFactor(const IFormFactor* ff) @@ -100,7 +101,6 @@ void GUI::RealSpace::BuilderUtils::populateParticlesAtLatticePositions( if (std::abs(pos_x) <= layer_size - layerBorderWidth && std::abs(pos_y) <= layer_size - layerBorderWidth && std::abs(pos_z) <= layer_thickness) { - builder3D->populateParticleFromParticle3DContainer( model, particle3DContainer, QVector3D(static_cast<float>(position[0]), static_cast<float>(position[1]), @@ -218,7 +218,6 @@ GUI::RealSpace::BuilderUtils::particle3DContainerVector(const ParticleLayoutItem double cumulative_abundance = 0; for (auto* particleItem : layoutItem.particles()) { - Particle3DContainer particle3DContainer; if (particleItem->hasModelType<ParticleItem>()) { diff --git a/GUI/View/Realspace/RealSpaceBuilderUtils.h b/GUI/View/Realspace/RealSpaceBuilderUtils.h index af0601ee5ed8807523c92760d7544a199dc3e9ba..564a946a4b0c1b81d7afc978698163de441fcbf0 100644 --- a/GUI/View/Realspace/RealSpaceBuilderUtils.h +++ b/GUI/View/Realspace/RealSpaceBuilderUtils.h @@ -34,11 +34,14 @@ class Particle3DContainer; class Interference2DParaCrystal; class MaterialModel; namespace GUI::RealSpace { + struct Vector3D; class Model; namespace Particles { + class Particle; } + } // namespace GUI::RealSpace namespace GUI::RealSpace { diff --git a/GUI/View/Realspace/RealSpaceCanvas.cpp b/GUI/View/Realspace/RealSpaceCanvas.cpp index 5fdb5519893936a8fd9839f01e1dbc9f219d97ff..62a4755ade444068a078bd5b41cd06cb88935fa7 100644 --- a/GUI/View/Realspace/RealSpaceCanvas.cpp +++ b/GUI/View/Realspace/RealSpaceCanvas.cpp @@ -187,7 +187,6 @@ void RealSpaceCanvas::setConnected(SampleModel* model, bool makeConnected) connect( model, &SampleModel::modelAboutToBeReset, this, [&]() { m_currentItem = nullptr; }, Qt::UniqueConnection); - } else model->disconnect(this); } diff --git a/GUI/View/Realspace/RealSpaceCanvas.h b/GUI/View/Realspace/RealSpaceCanvas.h index 9b732deaf599126986fe7aa986ed61cec96d0c26..a1d1f764f84afaa79d825a2753380770672ce467 100644 --- a/GUI/View/Realspace/RealSpaceCanvas.h +++ b/GUI/View/Realspace/RealSpaceCanvas.h @@ -23,8 +23,10 @@ class CautionSign; class SessionItem; class MaterialModel; namespace GUI::RealSpace { + class Canvas; class Model; + } // namespace GUI::RealSpace //! Size and thickness information of layers diff --git a/GUI/View/Realspace/RealSpaceMesoCrystalUtils.cpp b/GUI/View/Realspace/RealSpaceMesoCrystalUtils.cpp index 629f8c1a6f1649961e6ec079252bf268b27df6b7..fb6eeae81a51e08b83a6b924de57fea18d520a2c 100644 --- a/GUI/View/Realspace/RealSpaceMesoCrystalUtils.cpp +++ b/GUI/View/Realspace/RealSpaceMesoCrystalUtils.cpp @@ -25,6 +25,7 @@ #include "Sample/Particle/ParticleCoreShell.h" namespace { + const int n = 10; // TODO: Adjust this parameter based on the size of the mesocrystal bool isPositionInsideMesoCrystal(const IFormFactor* outerShape, R3 positionInside) @@ -336,6 +337,7 @@ bool isPositionInsideMesoCrystal(const IFormFactor* outerShape, R3 positionInsid } return check; } + } // namespace diff --git a/GUI/View/Realspace/TransformTo3D.cpp b/GUI/View/Realspace/TransformTo3D.cpp index 364fc83a3c2bc1884db8154fa607a404bcb925c5..6c740dee016b904a53fa2354222b914cfef60c22 100644 --- a/GUI/View/Realspace/TransformTo3D.cpp +++ b/GUI/View/Realspace/TransformTo3D.cpp @@ -21,9 +21,11 @@ #include "Sample/HardParticle/HardParticles.h" #include <boost/polymorphic_cast.hpp> + using boost::polymorphic_downcast; namespace { + bool isTopLayer(const LayerItem& layerItem) { auto layers = polymorphic_downcast<MultiLayerItem*>(layerItem.parent())->layers(); @@ -34,6 +36,7 @@ bool isBottomLayer(const LayerItem& layerItem) auto layers = polymorphic_downcast<MultiLayerItem*>(layerItem.parent())->layers(); return layers.indexOf(const_cast<LayerItem*>(&layerItem)) == layers.size() - 1; } + } // namespace diff --git a/GUI/View/SampleDesigner/LatticeTypeSelectionForm.cpp b/GUI/View/SampleDesigner/LatticeTypeSelectionForm.cpp index 3ae9358204e54abaef83071b652637f8d0791bc1..418e1c3cfae826b80d297661feeb6ee4ca98f6f9 100644 --- a/GUI/View/SampleDesigner/LatticeTypeSelectionForm.cpp +++ b/GUI/View/SampleDesigner/LatticeTypeSelectionForm.cpp @@ -34,11 +34,11 @@ void LatticeTypeSelectionForm::createContent() if (auto* p = dynamic_cast<BasicLattice2DItem*>(currentLatticeType)) { vertical = true; valueDescriptors = {p->latticeLength1(), p->latticeLength2(), p->latticeAngle()}; - } else if (auto* p = dynamic_cast<SquareLattice2DItem*>(currentLatticeType)) { + } else if (auto* p = dynamic_cast<SquareLattice2DItem*>(currentLatticeType)) valueDescriptors = {p->latticeLength()}; - } else if (auto* p = dynamic_cast<HexagonalLattice2DItem*>(currentLatticeType)) { + else if (auto* p = dynamic_cast<HexagonalLattice2DItem*>(currentLatticeType)) valueDescriptors = {p->latticeLength()}; - } + const auto onValueChange = [=](double newValue, DoubleDescriptor d) { diff --git a/GUI/View/SampleDesigner/LayerEditorUtils.cpp b/GUI/View/SampleDesigner/LayerEditorUtils.cpp index 34fa452e6cee89b827efabe021cc1e8e096bc38e..d69403b7d25ec398d882a85b25c7be375a51faf5 100644 --- a/GUI/View/SampleDesigner/LayerEditorUtils.cpp +++ b/GUI/View/SampleDesigner/LayerEditorUtils.cpp @@ -34,8 +34,8 @@ #include <QMenu> #include <QPushButton> - namespace { + void updateLabelUnit(QLabel* label, const QString& unit) { QString text = label->text(); diff --git a/GUI/View/SampleDesigner/MultiLayerForm.cpp b/GUI/View/SampleDesigner/MultiLayerForm.cpp index 9085b1e87148e0a0d205cdb770ec5da07f2920cd..e074bce7b5279e827b5a520e37b1f285629bd7c8 100644 --- a/GUI/View/SampleDesigner/MultiLayerForm.cpp +++ b/GUI/View/SampleDesigner/MultiLayerForm.cpp @@ -113,7 +113,6 @@ void MultiLayerForm::onLayerMoved(LayerItem* layerItem) LayerForm* wl = nullptr; AddLayerWidget* al = nullptr; for (int index = 0; index < m_layout->count(); index++) { - if (auto* w = dynamic_cast<AddLayerWidget*>(m_layout->itemAt(index)->widget())) if (w->m_layer == layerItem) { al = w; @@ -147,15 +146,13 @@ void MultiLayerForm::onAboutToRemoveLayer(LayerItem* layerItem) LayerForm* layerForm = nullptr; AddLayerWidget* addLayerWidget = nullptr; for (auto* c : findChildren<QWidget*>()) { - if (auto* w = dynamic_cast<AddLayerWidget*>(c)) if (w->m_layer == layerItem) addLayerWidget = w; if (auto* w = dynamic_cast<LayerForm*>(c)) { - if (w->layerItem() == layerItem) { + if (w->layerItem() == layerItem) layerForm = w; - } } } diff --git a/GUI/View/SampleDesigner/ScriptPanel.cpp b/GUI/View/SampleDesigner/ScriptPanel.cpp index 6bb6a78db5608b8f891e5f9a3825370e4769f85f..b48d55a3c2cb5596c9910b13dac5274fbab43be7 100644 --- a/GUI/View/SampleDesigner/ScriptPanel.cpp +++ b/GUI/View/SampleDesigner/ScriptPanel.cpp @@ -29,6 +29,7 @@ #include <QVBoxLayout> namespace { + const int accumulateUpdatesDuringMsec = 20.; } @@ -96,7 +97,6 @@ void ScriptPanel::setEditorConnected(bool isConnected) Qt::UniqueConnection); m_updateTimer->scheduleUpdate(); - } else { m_sampleModel->disconnect(this); m_sampleModel->disconnect(m_updateTimer); diff --git a/GUI/View/SampleDesigner/WidgetMoverButton.cpp b/GUI/View/SampleDesigner/WidgetMoverButton.cpp index e16d27cc315c2da35ce2d47cbb57e7acd47dbfe6..f1767006fad0da433e176db9001e8532dd6743b0 100644 --- a/GUI/View/SampleDesigner/WidgetMoverButton.cpp +++ b/GUI/View/SampleDesigner/WidgetMoverButton.cpp @@ -82,7 +82,6 @@ void WidgetMoverButton::mouseMoveEvent(QMouseEvent* event) } if (m_started) { - // -- move the dragged widget to the new position QPoint newPos = m_widgetToMove->parentWidget()->mapFromGlobal(event->globalPos()) - m_hotSpot; @@ -112,9 +111,9 @@ void WidgetMoverButton::mouseMoveEvent(QMouseEvent* event) if (r != layoutItem->geometry()) { QWidget* w = layoutItem->widget(); - if (w == nullptr) { + if (w == nullptr) layoutItem->setGeometry(r); - } else if (!m_animations.contains(w)) { + else if (!m_animations.contains(w)) { auto* animation = new QPropertyAnimation(w, "geometry"); animation->setDuration(100); animation->setEasingCurve(QEasingCurve::OutQuad); diff --git a/GUI/View/Script/PythonScriptWidget.cpp b/GUI/View/Script/PythonScriptWidget.cpp index a2679968b82d026fe88e02ec5b1d26844bc9dac5..aad5ac58deb2d56574c02d63bcd789e0d0a67f65 100644 --- a/GUI/View/Script/PythonScriptWidget.cpp +++ b/GUI/View/Script/PythonScriptWidget.cpp @@ -96,7 +96,6 @@ void PythonScriptWidget::generatePythonScript(const MultiLayerItem* sampleItem, QString code = QString::fromStdString(Py::Export::simulationPlotCode(*simulation)); m_textEdit->clear(); m_textEdit->setText(code); - } catch (const std::exception& ex) { QString message = QString( diff --git a/GUI/View/SpecularData/SpecularPlot.cpp b/GUI/View/SpecularData/SpecularPlot.cpp index 0d947b637f4e2c60fef80bb14d0ba012b9b50f41..27c69403c8a35e59763b2fd023a68b0b14f3b832 100644 --- a/GUI/View/SpecularData/SpecularPlot.cpp +++ b/GUI/View/SpecularData/SpecularPlot.cpp @@ -21,9 +21,11 @@ #include "GUI/View/Tool/UpdateTimer.h" namespace { + const int replot_update_interval = 10; int bin(double x, const QCPGraph* graph); + } // namespace SpecularPlot::SpecularPlot(QWidget* parent) @@ -157,7 +159,6 @@ void SpecularPlot::setAxesRangeConnected(bool isConnected) connect(m_custom_plot->yAxis, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, &SpecularPlot::onYaxisRangeChanged, Qt::UniqueConnection); - } else { disconnect(m_custom_plot->xAxis, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, @@ -285,6 +286,7 @@ void SpecularPlot::replot() } namespace { + int bin(double x, const QCPGraph* graph) { const int key_start = graph->findBegin(x); @@ -294,4 +296,5 @@ int bin(double x, const QCPGraph* graph) return (x - graph->dataSortKey(key_start)) <= (graph->dataSortKey(key_end) - x) ? key_start : key_end; } + } // namespace diff --git a/GUI/View/Tool/DesignerHelper.cpp b/GUI/View/Tool/DesignerHelper.cpp index f43170d333654e0ea094956f90018d3f349375a9..94116f7c5500c28642ed0733e66ec568c75cd6ad 100644 --- a/GUI/View/Tool/DesignerHelper.cpp +++ b/GUI/View/Tool/DesignerHelper.cpp @@ -19,6 +19,7 @@ #include <iostream> namespace { + double m_current_zoom_level = 1.0; } diff --git a/GUI/View/Tool/ItemDelegateForHTML.cpp b/GUI/View/Tool/ItemDelegateForHTML.cpp index 40f14e8d72ea5f8a2807e91d21a41e5ffc83907e..48de8571ee914489bb303951c3db052093d7bd9a 100644 --- a/GUI/View/Tool/ItemDelegateForHTML.cpp +++ b/GUI/View/Tool/ItemDelegateForHTML.cpp @@ -12,7 +12,6 @@ // // ************************************************************************************************ - #include "GUI/View/Tool/ItemDelegateForHTML.h" #include <QAbstractItemView> #include <QAbstractTextDocumentLayout> @@ -21,10 +20,12 @@ #include <QTextDocument> namespace { + bool hasHtml(const QString& t) { return t.contains("<") && t.contains(">"); } + } // namespace diff --git a/GUI/View/Toplevel/ProjectSettingsView.h b/GUI/View/Toplevel/ProjectSettingsView.h index 42bc2b03033f76177d3c840f1dadcc484ad694f5..848adc2c9f2c90ffe97f64ac9a3bfc3210e331e3 100644 --- a/GUI/View/Toplevel/ProjectSettingsView.h +++ b/GUI/View/Toplevel/ProjectSettingsView.h @@ -19,6 +19,7 @@ #include <QWidget> namespace Ui { + class ProjectSettingsView; } diff --git a/GUI/View/Toplevel/SessionModelView.cpp b/GUI/View/Toplevel/SessionModelView.cpp index bba330a1fcc2dc7e406fd76a5b34094dd40717c2..49d8d0b6205d24bb794054ae9b6ae4e857a76ad0 100644 --- a/GUI/View/Toplevel/SessionModelView.cpp +++ b/GUI/View/Toplevel/SessionModelView.cpp @@ -31,6 +31,7 @@ #include <QVBoxLayout> namespace { + //! The SessionModelDelegate class presents the content of SessionModel items in //! standard QTreeView. Extents base QItemDelegate with possibility to show/edit //! our custom QVariant's. diff --git a/GUI/View/Toplevel/SimulationView.h b/GUI/View/Toplevel/SimulationView.h index ff820e4f9de6ce01fc0acd0ff85c04067d29ca4a..cf36fc98630ba1cc6ed44cb28a24474f32d653fe 100644 --- a/GUI/View/Toplevel/SimulationView.h +++ b/GUI/View/Toplevel/SimulationView.h @@ -26,6 +26,7 @@ class SimulationOptionsItem; class ProjectDocument; namespace Ui { + class SimulationView; } diff --git a/GUI/View/Toplevel/WelcomeView.h b/GUI/View/Toplevel/WelcomeView.h index ce49ad398f261fad01b1f090e538f61c905298cf..d777a79f727c953aff319ca94650f91965f33289 100644 --- a/GUI/View/Toplevel/WelcomeView.h +++ b/GUI/View/Toplevel/WelcomeView.h @@ -20,6 +20,7 @@ class ProjectManager; namespace Ui { + class WelcomeView; } diff --git a/GUI/ba3d/mesh/box.cpp b/GUI/ba3d/mesh/box.cpp index 6fe3cdba8fbe7acba4c10c9322a9a7892cb75d39..0557d3ac61cf3a3697711069f7537e6fca2118a1 100644 --- a/GUI/ba3d/mesh/box.cpp +++ b/GUI/ba3d/mesh/box.cpp @@ -44,4 +44,5 @@ Geometry::Mesh Geometry::meshBox() return makeMesh(vs); } + } // namespace GUI::RealSpace diff --git a/GUI/ba3d/model/geometry.cpp b/GUI/ba3d/model/geometry.cpp index f53fe68d5d451188c5244d760e498915b8a41a04..2b62411889d56d23034d5b2eb82832b8fa4398ec 100644 --- a/GUI/ba3d/model/geometry.cpp +++ b/GUI/ba3d/model/geometry.cpp @@ -17,6 +17,7 @@ #include "GUI/ba3d/model/model.h" namespace GUI::RealSpace { + //------------------------------------------------------------------------------ Geometry::Vert_Normal::Vert_Normal(const Vector3D& v_, const Vector3D& n_) : v(v_), n(n_) {} @@ -174,4 +175,5 @@ GeometryStore& geometryStore() } //------------------------------------------------------------------------------ + } // namespace GUI::RealSpace diff --git a/GUI/ba3d/model/geometry_inc.cpp b/GUI/ba3d/model/geometry_inc.cpp index 9e372b57dca6695e0d4b69444575a7b255d21355..1d806400186f7bdb2975bde92d8a9475e77459d5 100644 --- a/GUI/ba3d/model/geometry_inc.cpp +++ b/GUI/ba3d/model/geometry_inc.cpp @@ -44,4 +44,5 @@ std::size_t GeometricID::KeyHash::operator()(const GeometricID::Key& key) const return h1 ^ (h2 ^ (h3 ^ h4)); } } + } // namespace GUI::RealSpace diff --git a/GUI/ba3d/model/layer.cpp b/GUI/ba3d/model/layer.cpp index 294649e352524c8d9bd5dab7c1806a39d642956b..4584a16b2d9d42f6f94de5743fb8c224b1e40b53 100644 --- a/GUI/ba3d/model/layer.cpp +++ b/GUI/ba3d/model/layer.cpp @@ -20,4 +20,5 @@ Layer::Layer(VectorRange d) : Object(GeometricID::Key(GeometricID::BaseShape::Bo { transform(d.size(), Vector3D::_0, d.mid()); } + } // namespace GUI::RealSpace diff --git a/GUI/ba3d/model/object.cpp b/GUI/ba3d/model/object.cpp index d8a3d7d266fef9fa7f7f44b5576a236c6cfc8910..679e7ae045af51c2d379e6d7c3a3b368038f1af8 100644 --- a/GUI/ba3d/model/object.cpp +++ b/GUI/ba3d/model/object.cpp @@ -18,9 +18,11 @@ #include <cmath> namespace { + QQuaternion EulerToQuaternion(const GUI::RealSpace::Vector3D& euler); GUI::RealSpace::Vector3D QuaternionToEuler(const QQuaternion& q); + } // namespace namespace GUI::RealSpace { @@ -106,6 +108,7 @@ void Object::draw(Canvas& canvas) } // namespace GUI::RealSpace namespace { + QQuaternion EulerToQuaternion(const GUI::RealSpace::Vector3D& euler) { float cpsi2 = std::cos(euler.x / 2.0f); @@ -144,4 +147,5 @@ GUI::RealSpace::Vector3D QuaternionToEuler(const QQuaternion& q) return GUI::RealSpace::Vector3D(x, y, z); } + } // namespace diff --git a/GUI/ba3d/model/particles.cpp b/GUI/ba3d/model/particles.cpp index 27c2b0209efc84338b9017ebf65e88c691952461..264bd6e5eaffff96cce3e67bf3ffc53ea4b25a04 100644 --- a/GUI/ba3d/model/particles.cpp +++ b/GUI/ba3d/model/particles.cpp @@ -346,4 +346,5 @@ TruncatedSpheroid::TruncatedSpheroid(float R, float H, float fp, float deltaH) offset = Vector3D(0, 0, 0); set(); } + } // namespace GUI::RealSpace::Particles diff --git a/GUI/ba3d/view/buffer.cpp b/GUI/ba3d/view/buffer.cpp index 0019e8dbc4a53b6054144894929e441c1a1a5b5c..396ec13bf1265afd999fe3ff444eb9672fba5df9 100644 --- a/GUI/ba3d/view/buffer.cpp +++ b/GUI/ba3d/view/buffer.cpp @@ -16,8 +16,10 @@ #include "GUI/ba3d/model/geometry.h" 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 GUI::RealSpace { diff --git a/GUI/ba3d/view/camera.h b/GUI/ba3d/view/camera.h index 8bffd8053717428c9c757dd68efe248c990f64f5..cd080208cbdc4934182e0e1d64979e37a579cfbd 100644 --- a/GUI/ba3d/view/camera.h +++ b/GUI/ba3d/view/camera.h @@ -34,7 +34,6 @@ public: Camera(); struct Position { - Position(); Position(const Vector3D& eye, const Vector3D& ctr, const Vector3D& up, const QQuaternion& = {}); diff --git a/GUI/ba3d/view/canvas.cpp b/GUI/ba3d/view/canvas.cpp index d11ee35386ad182edb61475a63a87d48f68cb529..16eac8985b382721bb7b3ee85e2279ec589d5d95 100644 --- a/GUI/ba3d/view/canvas.cpp +++ b/GUI/ba3d/view/canvas.cpp @@ -25,6 +25,7 @@ #include <cstdlib> namespace { + float ZoomInScale() { if (QSysInfo::productType() == "osx") @@ -44,6 +45,7 @@ const float rot_speed_v = 0.4f; // camera rotation speed in vertical direction // Default camera position in accordance with RealSpaceBuilder.h const float cameraDefaultPosY = -200.0f; // default camera position on Y axis const float cameraDefaultPosZ = 120.0f; // default camera position on Z axis + } // namespace namespace GUI::RealSpace { @@ -389,7 +391,6 @@ void Canvas::topView() void Canvas::horizontalCameraTurn(float angle) { if (isInitialized()) { - float theta = angle * static_cast<float>(M_PI / 180.0); // in radians // Horizontal camera turn for 3D axes @@ -435,7 +436,6 @@ void Canvas::horizontalCameraTurn(float angle) void Canvas::verticalCameraTurn(float angle) { if (isInitialized()) { - float theta = angle * static_cast<float>(M_PI / 180.0); // in radians // Vertical camera turn for 3D axes diff --git a/GUI/ba3d/widget.cpp b/GUI/ba3d/widget.cpp index 652f5f1c4ccac4c47c3ad5cee5cb0de3613c6b16..2865fd498fcfb3617d9a4dbf1c0f8fda55e43627 100644 --- a/GUI/ba3d/widget.cpp +++ b/GUI/ba3d/widget.cpp @@ -20,6 +20,7 @@ #include <QBoxLayout> namespace GUI::RealSpace { + //------------------------------------------------------------------------------ Widget3D::Widget3D() : canvas(nullptr) @@ -68,4 +69,5 @@ Model* Widget3D::model() } //------------------------------------------------------------------------------ + } // namespace GUI::RealSpace diff --git a/Param/Distrib/Distributions.cpp b/Param/Distrib/Distributions.cpp index 451f11dded86e3ded9877dad936158edbead414b..6d50abd84519335916ae309853047d3589e6db83 100644 --- a/Param/Distrib/Distributions.cpp +++ b/Param/Distrib/Distributions.cpp @@ -433,9 +433,8 @@ double DistributionTrapezoid::probabilityDensity(double x) const return (x - min) * height / m_left; if (x < min + m_left + m_middle) return height; - if (x < min + m_left + m_middle + m_right) { + if (x < min + m_left + m_middle + m_right) return height - (x - min - m_left - m_middle) * height / m_right; - } return 0.0; } @@ -480,6 +479,7 @@ void DistributionTrapezoid::adjustLimitsToNonZeroSamples(double& min, double& ma } namespace { + bool DoubleEqual(double a, double b) { double eps = 10.0 @@ -487,4 +487,5 @@ bool DoubleEqual(double a, double b) std::numeric_limits<double>::min()); return std::abs(a - b) < eps; } + } // namespace diff --git a/Param/Node/INode.cpp b/Param/Node/INode.cpp index 0421eb493cae58f9c9b8e096cf3e76e9a9f97d74..063cf352893b44192ac247ffb66ec01850651b98 100644 --- a/Param/Node/INode.cpp +++ b/Param/Node/INode.cpp @@ -28,7 +28,6 @@ NodeMeta nodeMetaUnion(const std::vector<ParaMeta>& base, const NodeMeta& other) INode::INode(const NodeMeta& meta, std::vector<double> PValues) : m_P(std::move(PValues)) { - for (size_t i = 0; i < meta.paraMeta.size(); ++i) { const ParaMeta& pm = meta.paraMeta[i]; diff --git a/Resample/Slice/SliceStack.h b/Resample/Slice/SliceStack.h index 020ddb0db848ecadd050ce64d58193a7de430def..5d801cf87246799bba3a149c5bb3ba337c7275c8 100644 --- a/Resample/Slice/SliceStack.h +++ b/Resample/Slice/SliceStack.h @@ -22,6 +22,7 @@ #include "Resample/Slice/Slice.h" // TODO move back to cpp file #include <heinz/Vectors3D.h> + // - either get rid of m_roughness_model // - or of inheritance from std::vector diff --git a/Resample/Specular/ComputeFluxMagnetic.h b/Resample/Specular/ComputeFluxMagnetic.h index 44390ffb11dd61eb52719ff6bae3dae87e07a5b3..0eda0fc837f21fbf139f43c30211e85ca9701c54 100644 --- a/Resample/Specular/ComputeFluxMagnetic.h +++ b/Resample/Specular/ComputeFluxMagnetic.h @@ -48,6 +48,7 @@ Fluxes fluxes(const SliceStack& slices, const R3& k, bool forward); //! Introduced in order to speed up pure reflectivity computations Eigen::Matrix2cd topLayerR(const SliceStack& slices, const std::vector<complex_t>& kzs, bool forward); + } // namespace Compute::SpecularMagnetic #endif // BORNAGAIN_RESAMPLE_SPECULAR_COMPUTEFLUXMAGNETIC_H diff --git a/Resample/Specular/TransitionMagneticNevot.h b/Resample/Specular/TransitionMagneticNevot.h index 0e851d3b9be9503abd780b532c7f185300b1c2db..ed769bf8f8b56f7dfc8366f13e2c56bc7b466eca 100644 --- a/Resample/Specular/TransitionMagneticNevot.h +++ b/Resample/Specular/TransitionMagneticNevot.h @@ -36,7 +36,6 @@ namespace Compute::MagneticNevotCroceTransition { std::pair<Eigen::Matrix2cd, Eigen::Matrix2cd> backwardsSubmatrices(const MatrixFlux& coeff_i, const MatrixFlux& coeff_i1, double sigma); - } #endif // BORNAGAIN_RESAMPLE_SPECULAR_TRANSITIONMAGNETICNEVOT_H diff --git a/Resample/Specular/TransitionMagneticTanh.h b/Resample/Specular/TransitionMagneticTanh.h index cd186ea3b18edecd81bf281d9a53c681b56d5ecf..b43b1742efe45040e5156f304791c9f0eaf1c15a 100644 --- a/Resample/Specular/TransitionMagneticTanh.h +++ b/Resample/Specular/TransitionMagneticTanh.h @@ -36,7 +36,6 @@ namespace Compute::TransitionMagneticTanh { std::pair<Eigen::Matrix2cd, Eigen::Matrix2cd> backwardsSubmatrices(const MatrixFlux& coeff_i, const MatrixFlux& coeff_i1, double sigma); - } #endif // BORNAGAIN_RESAMPLE_SPECULAR_TRANSITIONMAGNETICTANH_H diff --git a/Resample/Swig/MultiLayerFuncs.cpp b/Resample/Swig/MultiLayerFuncs.cpp index 63688cd034620962ac7987824cc163dc30be7f3d..15cf5bfa00d5f97019d1d7a0a84a719d4b7fcdd8 100644 --- a/Resample/Swig/MultiLayerFuncs.cpp +++ b/Resample/Swig/MultiLayerFuncs.cpp @@ -23,9 +23,8 @@ std::vector<double> swigAPI::generateZValues(int n_points, double z_min, double if (n_points < 1) return result; double step = n_points > 1 ? (z_max - z_min) / (n_points - 1) : 0.0; - for (int i = 0; i < n_points; ++i) { + for (int i = 0; i < n_points; ++i) result.push_back(z_min + i * step); - } return result; } diff --git a/Sample/Aggregate/Interference1DLattice.cpp b/Sample/Aggregate/Interference1DLattice.cpp index ec2a07bcbb10b34433b553119fbb45d8d1e44f00..b9649005f116347190353f046a8590f329f32f20 100644 --- a/Sample/Aggregate/Interference1DLattice.cpp +++ b/Sample/Aggregate/Interference1DLattice.cpp @@ -20,10 +20,12 @@ #include <algorithm> namespace { + // maximum value for qx*Lambdax const int nmax = 20; // minimum number of neighboring reciprocal lattice points to use const int min_points = 4; + } // namespace //! Constructor of interference function of one-dimensional lattice. diff --git a/Sample/Aggregate/Interference2DLattice.cpp b/Sample/Aggregate/Interference2DLattice.cpp index d91a0ecbb1d46cfc72e03f08429c2f23e83f0730..3c2b9155d769714766cdcc9fda63c70c9fd5b3f9 100644 --- a/Sample/Aggregate/Interference2DLattice.cpp +++ b/Sample/Aggregate/Interference2DLattice.cpp @@ -17,10 +17,12 @@ #include <algorithm> namespace { + // maximum value for qx*Lambdax and qy*lambday const int nmax = 20; // minimum number of neighboring reciprocal lattice points to use const int min_points = 4; + } // namespace Interference2DLattice::Interference2DLattice(const Lattice2D& lattice) diff --git a/Sample/Aggregate/InterferenceRadialParaCrystal.cpp b/Sample/Aggregate/InterferenceRadialParaCrystal.cpp index 9951e19ea7e6457c81f0e1a72b4020f5fa463d7c..1f3259d5146c7fab4260c35e0a528acb06c8f202 100644 --- a/Sample/Aggregate/InterferenceRadialParaCrystal.cpp +++ b/Sample/Aggregate/InterferenceRadialParaCrystal.cpp @@ -104,15 +104,13 @@ double InterferenceRadialParaCrystal::iff_without_dw(const R3 q) const auto nd = static_cast<double>(n); complex_t fp = FTPDF(qpar); if (n < 1) { - if (std::abs(1.0 - fp) < 10. * std::numeric_limits<double>::epsilon()) { + if (std::abs(1.0 - fp) < 10. * std::numeric_limits<double>::epsilon()) result = m_pdf->qSecondDerivative() / m_peak_distance / m_peak_distance; - } else { + else result = ((1.0 + fp) / (1.0 - fp)).real(); - } } else { - if (std::norm(1.0 - fp) < 10. * std::numeric_limits<double>::epsilon()) { + if (std::norm(1.0 - fp) < 10. * std::numeric_limits<double>::epsilon()) result = nd; - } // for (1-fp)*nd small, take the series expansion to second order in nd*(1-fp) else if (std::abs(1.0 - fp) * nd < 2e-4) { complex_t intermediate = diff --git a/Sample/Correlations/IPeakShape.cpp b/Sample/Correlations/IPeakShape.cpp index b0327cced2f617a7c9c9cb1a7f268d03771d480d..87726d7d942a5006f44590e5ca55a4f24a52a3d5 100644 --- a/Sample/Correlations/IPeakShape.cpp +++ b/Sample/Correlations/IPeakShape.cpp @@ -25,13 +25,11 @@ const double maxkappa2 = std::log(std::numeric_limits<double>::max()); double FisherDistribution(double x, double kappa) { - if (kappa <= 0.0) { + if (kappa <= 0.0) return 1.0 / (4.0 * M_PI); - } double prefactor = kappa / (4.0 * M_PI); - if (kappa > maxkappa) { + if (kappa > maxkappa) return 2.0 * prefactor * std::exp(kappa * (x - 1.0)); - } return prefactor * std::exp(kappa * x) / std::sinh(kappa); } diff --git a/Sample/HardParticle/IFormFactorPolyhedron.h b/Sample/HardParticle/IFormFactorPolyhedron.h index 50c234531a71232010253cf57a937dc3fde7f6df..faf98d7dff52a348ecfef2841232d05c46672448 100644 --- a/Sample/HardParticle/IFormFactorPolyhedron.h +++ b/Sample/HardParticle/IFormFactorPolyhedron.h @@ -21,6 +21,7 @@ #include <memory> namespace ff { + class Polyhedron; } diff --git a/Sample/Material/MaterialBySLDImpl.cpp b/Sample/Material/MaterialBySLDImpl.cpp index 0fab576ba602063be7b5327a061f53b13c5b06c4..e0503d267025b6ee6687d0d70512b4a692aa1e4b 100644 --- a/Sample/Material/MaterialBySLDImpl.cpp +++ b/Sample/Material/MaterialBySLDImpl.cpp @@ -17,12 +17,14 @@ #include "Base/Vector/WavevectorInfo.h" namespace { + const double square_angstroms = Units::angstrom * Units::angstrom; inline double getWlPrefactor(double wavelength) { return wavelength * wavelength / M_PI; } + } // namespace MaterialBySLDImpl::MaterialBySLDImpl(const std::string& name, double sld_real, double sld_imag, diff --git a/Sample/Material/MaterialUtils.cpp b/Sample/Material/MaterialUtils.cpp index 03ef9749e81f0ae05f77c39a9177dd490b49f57b..4612fc4be1afa808eee4f02b6a96e1dedcb35c03 100644 --- a/Sample/Material/MaterialUtils.cpp +++ b/Sample/Material/MaterialUtils.cpp @@ -26,10 +26,12 @@ constexpr double magnetic_prefactor = (m_n * g_factor_n * mu_N / h_bar / h_bar) const Eigen::Matrix2cd Unit_Matrix(Eigen::Matrix2cd::Identity()); 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()); const Eigen::Matrix2cd Pauli_Z((Eigen::Matrix2cd() << 1, 0, 0, -1).finished()); + } // namespace template <typename T> diff --git a/Sample/Multilayer/PyImport.h b/Sample/Multilayer/PyImport.h index cdad48d35335a45b3cecc1b113e0f40f1c01b1ad..ed407d632783562e78b5da70cb2e1fb203e9a272 100644 --- a/Sample/Multilayer/PyImport.h +++ b/Sample/Multilayer/PyImport.h @@ -45,6 +45,7 @@ std::unique_ptr<MultiLayer> createFromPython(const std::string& script, //! @param script: Python script //! @param path: A path to import BornAgain library. If empty, relies on PYTHONPATH std::vector<std::string> listOfFunctions(const std::string& script, const std::string& path = ""); + } // namespace Py::Import #endif // BORNAGAIN_PYTHON diff --git a/Sample/Particle/Particle.cpp b/Sample/Particle/Particle.cpp index 023c0430933535f350ec21d4de5790b511b96661..889c5abb47ecc1fdb3430ae4cc0fa2df4a5ee576 100644 --- a/Sample/Particle/Particle.cpp +++ b/Sample/Particle/Particle.cpp @@ -78,9 +78,8 @@ void Particle::setMaterial(Material material) void Particle::setFormFactor(const IFormFactor& form_factor) { - if (&form_factor != m_form_factor.get()) { + if (&form_factor != m_form_factor.get()) m_form_factor.reset(form_factor.clone()); - } } std::vector<const INode*> Particle::getChildren() const diff --git a/Sample/StandardSamples/BoxCompositionBuilder.h b/Sample/StandardSamples/BoxCompositionBuilder.h index a19b5228b18cf19695fec0334c230763fe8bdd63..44d5ff1cb536624c25d607dcdb9e7d7a37a6dbe4 100644 --- a/Sample/StandardSamples/BoxCompositionBuilder.h +++ b/Sample/StandardSamples/BoxCompositionBuilder.h @@ -27,35 +27,45 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createBoxCompositionRotateX(); + } // namespace ExemplarySamples //! Two boxes in particle composition rotated in Y by 90 degrees. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createBoxCompositionRotateY(); + } // namespace ExemplarySamples //! Two boxes in particle composition rotated in Z by 90 degrees. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createBoxCompositionRotateZ(); + } // namespace ExemplarySamples //! Two boxes in particle composition rotated in Z and Y by 90 degrees. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createBoxCompositionRotateZandY(); + } // namespace ExemplarySamples //! Two different boxes are first rotated and then composed, composition is then rotated. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createBoxStackComposition(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_BOXCOMPOSITIONBUILDER_H diff --git a/Sample/StandardSamples/BoxesSquareLatticeBuilder.h b/Sample/StandardSamples/BoxesSquareLatticeBuilder.h index 898f07d8c199d9bc0b9bc058f6a47ed144d80714..2c6039cae5c1b2996abea55839ae366299ce9bbb 100644 --- a/Sample/StandardSamples/BoxesSquareLatticeBuilder.h +++ b/Sample/StandardSamples/BoxesSquareLatticeBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createBoxesSquareLattice2D(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_BOXESSQUARELATTICEBUILDER_H diff --git a/Sample/StandardSamples/CoreShellParticleBuilder.h b/Sample/StandardSamples/CoreShellParticleBuilder.h index 489b216c459f673e7b0a030c9e3f478ffa6c3663..f08cc7884cba39c29ef5bb69f98124d8c1d0e796 100644 --- a/Sample/StandardSamples/CoreShellParticleBuilder.h +++ b/Sample/StandardSamples/CoreShellParticleBuilder.h @@ -27,14 +27,18 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createCoreShellParticle(); + } // namespace ExemplarySamples //! Rotation and translation of core shell box particle in 3 layers system. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createCoreShellBoxRotateZandY(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_CORESHELLPARTICLEBUILDER_H diff --git a/Sample/StandardSamples/CustomMorphologyBuilder.cpp b/Sample/StandardSamples/CustomMorphologyBuilder.cpp index a402dedd0821196d233dd0ee009b6079c86b6141..8a10b81dec2fa4986f853d0aa537fb4f76d600c0 100644 --- a/Sample/StandardSamples/CustomMorphologyBuilder.cpp +++ b/Sample/StandardSamples/CustomMorphologyBuilder.cpp @@ -25,7 +25,6 @@ using Units::deg; MultiLayer* ExemplarySamples::createCustomMorphology() { - Material mat_vacuum = refMat::Vacuum; Material mat_particle = refMat::Particle; diff --git a/Sample/StandardSamples/CustomMorphologyBuilder.h b/Sample/StandardSamples/CustomMorphologyBuilder.h index 610c845b58ab12271f1d8ae4723a5ea730e23af8..a046d8357382f507006946b284fbd5385fe8b437 100644 --- a/Sample/StandardSamples/CustomMorphologyBuilder.h +++ b/Sample/StandardSamples/CustomMorphologyBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createCustomMorphology(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_CUSTOMMORPHOLOGYBUILDER_H diff --git a/Sample/StandardSamples/CylindersAndPrismsBuilder.h b/Sample/StandardSamples/CylindersAndPrismsBuilder.h index 6ffc73025391c64d1f0efc9720fa5ff78b1aee94..1e00118aa9ebe34946b0e42344b7c84d169c077b 100644 --- a/Sample/StandardSamples/CylindersAndPrismsBuilder.h +++ b/Sample/StandardSamples/CylindersAndPrismsBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createCylindersAndPrisms(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_CYLINDERSANDPRISMSBUILDER_H diff --git a/Sample/StandardSamples/CylindersBuilder.h b/Sample/StandardSamples/CylindersBuilder.h index 38c166263a3234c66d628e7ffb4a6310a4eaf0d7..481e89a41c22b16c5e81ceade9456f3812039309 100644 --- a/Sample/StandardSamples/CylindersBuilder.h +++ b/Sample/StandardSamples/CylindersBuilder.h @@ -27,28 +27,36 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createCylindersInDWBA(); + } // namespace ExemplarySamples //! Builds sample: cylinder form factor in BA (IsGISAXS example #3, part II). //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createCylindersInBA(double height = 5, double radius = 5); + } // namespace ExemplarySamples //! Builds sample with large cylinders for MC integration tests. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createLargeCylindersInDWBA(double height = 1000, double radius = 500); + } // namespace ExemplarySamples //! Builds sample: cylinder form factor in DWBA (IsGISAXS example #3, part I). //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createRotatedCylinders(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_CYLINDERSBUILDER_H diff --git a/Sample/StandardSamples/FeNiBilayerBuilder.h b/Sample/StandardSamples/FeNiBilayerBuilder.h index 934d5a42912b384d55874882b9cbf1b208959b8f..9b9aa83dec962e6fc12bd74aabde0039d0b673fd 100644 --- a/Sample/StandardSamples/FeNiBilayerBuilder.h +++ b/Sample/StandardSamples/FeNiBilayerBuilder.h @@ -25,27 +25,39 @@ class MultiLayer; namespace ExemplarySamples { + MultiLayer* createFeNiBilayer(); + } // namespace ExemplarySamples namespace ExemplarySamples { + MultiLayer* createFeNiBilayerTanh(); + } // namespace ExemplarySamples namespace ExemplarySamples { + MultiLayer* createFeNiBilayerNC(); + } // namespace ExemplarySamples namespace ExemplarySamples { + MultiLayer* createFeNiBilayerSpinFlip(); + } // namespace ExemplarySamples namespace ExemplarySamples { + MultiLayer* createFeNiBilayerSpinFlipTanh(); + } // namespace ExemplarySamples namespace ExemplarySamples { + MultiLayer* createFeNiBilayerSpinFlipNC(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_FENIBILAYERBUILDER_H diff --git a/Sample/StandardSamples/HomogeneousMultilayerBuilder.h b/Sample/StandardSamples/HomogeneousMultilayerBuilder.h index 8f75a0c77388c1443d83fd07151da3782ed6b9ce..36b938befcfaab939348011dd4bef2dbc5978712 100644 --- a/Sample/StandardSamples/HomogeneousMultilayerBuilder.h +++ b/Sample/StandardSamples/HomogeneousMultilayerBuilder.h @@ -29,7 +29,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createHomogeneousMultilayer(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_HOMOGENEOUSMULTILAYERBUILDER_H diff --git a/Sample/StandardSamples/LatticeBuilder.h b/Sample/StandardSamples/LatticeBuilder.h index d9684d42bc949603a37ceba6f779ae3400cbcae4..7e985a925108af8740b94a0494908094dda4481e 100644 --- a/Sample/StandardSamples/LatticeBuilder.h +++ b/Sample/StandardSamples/LatticeBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createLattice1D(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_LATTICEBUILDER_H diff --git a/Sample/StandardSamples/LayersWithAbsorptionBuilder.h b/Sample/StandardSamples/LayersWithAbsorptionBuilder.h index 3f565c9a61ee1f75a18345bb2be8241e14f25dec..bb78ccd9a1fa151002d8aac234fe39981f706f4c 100644 --- a/Sample/StandardSamples/LayersWithAbsorptionBuilder.h +++ b/Sample/StandardSamples/LayersWithAbsorptionBuilder.h @@ -31,7 +31,9 @@ class IFormFactor; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createLayersWithAbsorptionWithFF(const IFormFactor*); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_LAYERSWITHABSORPTIONBUILDER_H diff --git a/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h b/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h index e97c173e0b8e36dfef8683ae6a21977036d0a141..300a079b6d8286cbd99bf380f664a324d2b4857f 100644 --- a/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h +++ b/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h @@ -29,7 +29,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createLayersWithAbsorptionBySLD(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_LAYERSWITHABSORPTIONBYSLDBUILDER_H diff --git a/Sample/StandardSamples/MagneticLayersBuilder.h b/Sample/StandardSamples/MagneticLayersBuilder.h index 6dee042e9e55cbbf8a3b5c9c7c4eee46f8e2132c..df4aeead57408c87a383818be0e03ac69e3bea20 100644 --- a/Sample/StandardSamples/MagneticLayersBuilder.h +++ b/Sample/StandardSamples/MagneticLayersBuilder.h @@ -28,35 +28,45 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createMagneticSubstrateZeroField(); + } // namespace ExemplarySamples //! Builds sample: ambient and one magnetized layer on a non-magnetized substrate. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSimpleMagneticLayer(); + } // namespace ExemplarySamples //! Builds sample: magnetic spheres in a magnetized layer on a non-magnetized substrate. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createMagneticLayer(); + } // namespace ExemplarySamples //! Builds sample: magnetic layer on a magnetic substrate with the fields rotated by 90° //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSimpleMagneticRotationWithRoughness(const std::string& roughnessKey); + } // namespace ExemplarySamples //! Builds sample: rotated magnetic spheres in substrate layer with a unit magnetic field. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createMagneticRotation(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_MAGNETICLAYERSBUILDER_H diff --git a/Sample/StandardSamples/MagneticParticlesBuilder.h b/Sample/StandardSamples/MagneticParticlesBuilder.h index 0e2e1d2ad6b0cf83d40564f5dd2cd4cfefc7b964..469984db84bc6d49af06b88d51bec10465834941 100644 --- a/Sample/StandardSamples/MagneticParticlesBuilder.h +++ b/Sample/StandardSamples/MagneticParticlesBuilder.h @@ -27,21 +27,27 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createMagneticParticleZeroField(); + } // namespace ExemplarySamples //! Builds sample: cylinders with magnetic material and non-zero magnetic field. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createMagneticCylinders(); + } // namespace ExemplarySamples //! Builds sample: spheres with magnetization inside substrate. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createMagneticSpheres(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_MAGNETICPARTICLESBUILDER_H diff --git a/Sample/StandardSamples/MesoCrystalBuilder.h b/Sample/StandardSamples/MesoCrystalBuilder.h index 880fdb891167465fb99bca8a4fec5213c7268e00..78fd3180e30b3a44981cc20bdb78716df830b222 100644 --- a/Sample/StandardSamples/MesoCrystalBuilder.h +++ b/Sample/StandardSamples/MesoCrystalBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createMesoCrystal(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_MESOCRYSTALBUILDER_H diff --git a/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.h b/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.h index 06416fd02f5530b7cb2a2d6f85a2a56344eba7bf..24f225cd3ad8b624f33e56659eb5f8a0e63f6249 100644 --- a/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.h +++ b/Sample/StandardSamples/MultiLayerWithNCRoughnessBuilder.h @@ -28,7 +28,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createMultiLayerWithNCRoughness(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_MULTILAYERWITHNCROUGHNESSBUILDER_H diff --git a/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.h b/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.h index d981c870ba5f22feeba977d5c8dea226d39b40ba..c464f30f6f3b98ca07bfe404136b9a8aa8d8e774 100644 --- a/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.h +++ b/Sample/StandardSamples/MultiLayerWithRoughnessBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createMultiLayerWithRoughness(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_MULTILAYERWITHROUGHNESSBUILDER_H diff --git a/Sample/StandardSamples/MultipleLayoutBuilder.h b/Sample/StandardSamples/MultipleLayoutBuilder.h index 78f3fce7d96e334b7e8e819ae54adeddc84c7ba3..cab1f32e4af58ccf69089972d6aa1053821e89c6 100644 --- a/Sample/StandardSamples/MultipleLayoutBuilder.h +++ b/Sample/StandardSamples/MultipleLayoutBuilder.h @@ -28,7 +28,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createMultipleLayout(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_MULTIPLELAYOUTBUILDER_H diff --git a/Sample/StandardSamples/ParaCrystalBuilder.h b/Sample/StandardSamples/ParaCrystalBuilder.h index 26322355dbdf20f300e7969c392972693ecf12e5..b90474376d150f024815b3b7b08610f2545b76bb 100644 --- a/Sample/StandardSamples/ParaCrystalBuilder.h +++ b/Sample/StandardSamples/ParaCrystalBuilder.h @@ -31,7 +31,9 @@ class FTDistribution2DComponents; //! Builds sample: cylinders with 1DDL structure factor (IsGISAXS example #4). namespace ExemplarySamples { + MultiLayer* createRadialParaCrystal(); + } // namespace ExemplarySamples //! Builds sample: basic two dimensional paracrystal with various probability @@ -39,21 +41,27 @@ MultiLayer* createRadialParaCrystal(); //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createBasic2DParaCrystalWithFTDis(const IFTDistribution2D* pdf2); + } // namespace ExemplarySamples //! Builds sample: cylinders with 2DDL structure factor (IsGISAXS example #4). //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createHexParaCrystal(); + } // namespace ExemplarySamples //! @ingroup standard_samples //! Builds sample: 2D paracrystal lattice (IsGISAXS example #8). namespace ExemplarySamples { + MultiLayer* createRectParaCrystal(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_PARACRYSTALBUILDER_H diff --git a/Sample/StandardSamples/ParticleCompositionBuilder.h b/Sample/StandardSamples/ParticleCompositionBuilder.h index 92acaa2856b097c41d05c7cc7c2d01dbcd65fd96..06c4eaaeddcff280ba284efb3160a3806b64f5ec 100644 --- a/Sample/StandardSamples/ParticleCompositionBuilder.h +++ b/Sample/StandardSamples/ParticleCompositionBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createParticleComposition(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_PARTICLECOMPOSITIONBUILDER_H diff --git a/Sample/StandardSamples/ParticleDistributionsBuilder.h b/Sample/StandardSamples/ParticleDistributionsBuilder.h index 5117bf1af7a769c532b1945811d9e07bda73e000..67e2f99875aa5c32f90507766881e7eda4664ab2 100644 --- a/Sample/StandardSamples/ParticleDistributionsBuilder.h +++ b/Sample/StandardSamples/ParticleDistributionsBuilder.h @@ -27,42 +27,54 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createCylindersWithSizeDistribution(); + } // namespace ExemplarySamples //! Builds mixture of cylinder particles with different size distribution (IsGISAXS example #2) //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createTwoTypesCylindersDistribution(); + } // namespace ExemplarySamples //! Rotated Pyramids with the distribution applied to the rotation angle. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createRotatedPyramidsDistribution(); + } // namespace ExemplarySamples //! Spherical particles with the distribution applied to the radius and RealLimits defined. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSpheresWithLimitsDistribution(); + } // namespace ExemplarySamples //! Cones with the distribution applied to the angle and RealLimits defined. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createConesWithLimitsDistribution(); + } // namespace ExemplarySamples //! Distribution of boxes with main parameter and two linked parameters. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createLinkedBoxDistribution(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_PARTICLEDISTRIBUTIONSBUILDER_H diff --git a/Sample/StandardSamples/ParticleInVacuumBuilder.h b/Sample/StandardSamples/ParticleInVacuumBuilder.h index 722b0c23467ab7d07c3dd0a41d3cf56cd077a858..4b85957022d5666adcb8ef70040a7fd81d1b1dd8 100644 --- a/Sample/StandardSamples/ParticleInVacuumBuilder.h +++ b/Sample/StandardSamples/ParticleInVacuumBuilder.h @@ -29,7 +29,9 @@ class IFormFactor; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createParticleInVacuumWithFF(const IFormFactor*); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_PARTICLEINVACUUMBUILDER_H diff --git a/Sample/StandardSamples/PercusYevickBuilder.h b/Sample/StandardSamples/PercusYevickBuilder.h index fcf6718773065ed5dac5eb0d57da15ee494961fb..25377baf8dd1de3aa2157a3f7d204bbd8932ea8b 100644 --- a/Sample/StandardSamples/PercusYevickBuilder.h +++ b/Sample/StandardSamples/PercusYevickBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! Builds sample: cylinders with hard disk Percus-Yevick interference. namespace ExemplarySamples { + MultiLayer* createHardDisk(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_PERCUSYEVICKBUILDER_H diff --git a/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.h b/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.h index d63b4e69182dde85e826d847b1e9978349b77daf..d558e075b352f18cf12bc612ecef7f21a8b1166d 100644 --- a/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.h +++ b/Sample/StandardSamples/PlainMultiLayerBySLDBuilder.h @@ -28,7 +28,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createPlainMultiLayerBySLD(int n_layers = 10, double thick_ti = 3.0); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_PLAINMULTILAYERBYSLDBUILDER_H diff --git a/Sample/StandardSamples/ResonatorBuilder.h b/Sample/StandardSamples/ResonatorBuilder.h index c38528ed98976075bb6166e292bcfdf191803c43..f389d1030117475d42fc8cdf8f4568c945bc7071 100644 --- a/Sample/StandardSamples/ResonatorBuilder.h +++ b/Sample/StandardSamples/ResonatorBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createResonator(double ti_thickness = 13.0); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_RESONATORBUILDER_H diff --git a/Sample/StandardSamples/RipplesBuilder.h b/Sample/StandardSamples/RipplesBuilder.h index 8bed0a9230ad18d19b2a078fb0ce8ed830279ea2..94486fe553c544b022c63696210ea5cc5385f72b 100644 --- a/Sample/StandardSamples/RipplesBuilder.h +++ b/Sample/StandardSamples/RipplesBuilder.h @@ -27,18 +27,24 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createCosineRipple(); + } // namespace ExemplarySamples //! Builds sample: triangular ripple within the 1D-paracrystal model (from PRB 85, 235415, 2012). //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createTriangularRipple(double d = 0); + } // namespace ExemplarySamples namespace ExemplarySamples { + MultiLayer* createAsymRipple(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_RIPPLESBUILDER_H diff --git a/Sample/StandardSamples/RotatedPyramidsBuilder.h b/Sample/StandardSamples/RotatedPyramidsBuilder.h index f9c3caa8512f98734cd46a4aedd8caec47547027..70cc017d851571f42fce4920696015aaab8a471b 100644 --- a/Sample/StandardSamples/RotatedPyramidsBuilder.h +++ b/Sample/StandardSamples/RotatedPyramidsBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createRotatedPyramids(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_ROTATEDPYRAMIDSBUILDER_H diff --git a/Sample/StandardSamples/SizeDistributionModelsBuilder.h b/Sample/StandardSamples/SizeDistributionModelsBuilder.h index d4a83aa96aa0f2445ddd575993341b484b249431..55b82f73bf51c859fca6bac3172999550a56ba75 100644 --- a/Sample/StandardSamples/SizeDistributionModelsBuilder.h +++ b/Sample/StandardSamples/SizeDistributionModelsBuilder.h @@ -28,7 +28,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSizeDistributionDAModel(); + } // namespace ExemplarySamples //! Creates the sample demonstrating size distribution model in local monodisperse approximation. @@ -36,7 +38,9 @@ MultiLayer* createSizeDistributionDAModel(); //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSizeDistributionLMAModel(); + } // namespace ExemplarySamples //! Creates the sample demonstrating size distribution model in size space coupling approximation. @@ -44,14 +48,18 @@ MultiLayer* createSizeDistributionLMAModel(); //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSizeDistributionSSCAModel(); + } // namespace ExemplarySamples //! Builds sample: size spacing correlation approximation (IsGISAXS example #15). //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createCylindersInSSCA(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_SIZEDISTRIBUTIONMODELSBUILDER_H diff --git a/Sample/StandardSamples/SlicedCompositionBuilder.h b/Sample/StandardSamples/SlicedCompositionBuilder.h index 463e5e661415f40a95c19ff2f0c6091b2e253896..71074e7cd4c3594b1c6c79710ff083cc318d5d25 100644 --- a/Sample/StandardSamples/SlicedCompositionBuilder.h +++ b/Sample/StandardSamples/SlicedCompositionBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSlicedComposition(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_SLICEDCOMPOSITIONBUILDER_H diff --git a/Sample/StandardSamples/SlicedCylindersBuilder.cpp b/Sample/StandardSamples/SlicedCylindersBuilder.cpp index dfae7d9da179537a0571651c19cc92febec8569f..71e24dcb610fb4a1f1aedb7441381fe40cf5d144 100644 --- a/Sample/StandardSamples/SlicedCylindersBuilder.cpp +++ b/Sample/StandardSamples/SlicedCylindersBuilder.cpp @@ -23,6 +23,7 @@ #include "Sample/Particle/Particle.h" namespace { + const double height(5); const double radius(5); const double wavelength(0.154); // nm @@ -40,6 +41,7 @@ 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* ExemplarySamples::createSlicedCylinders() diff --git a/Sample/StandardSamples/SlicedCylindersBuilder.h b/Sample/StandardSamples/SlicedCylindersBuilder.h index 68ad96a22130c109864d9d69530532f233021c82..ff388b7b3d93b4756028ac664d5dfca3d95e591b 100644 --- a/Sample/StandardSamples/SlicedCylindersBuilder.h +++ b/Sample/StandardSamples/SlicedCylindersBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSlicedCylinders(); + } // namespace ExemplarySamples //! Provides exactly the same sample as SlicedCylindersBuilder, but with @@ -35,7 +37,9 @@ MultiLayer* createSlicedCylinders(); //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSLDSlicedCylinders(); + } // namespace ExemplarySamples //! Provides exactly the same sample as SLDSlicedCylindersBuilder, but with @@ -44,7 +48,9 @@ MultiLayer* createSLDSlicedCylinders(); //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createAveragedSlicedCylinders(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_SLICEDCYLINDERSBUILDER_H diff --git a/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.h b/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.h index 34e5f080a5e09fa371caf27a278c24feaf811b27..8e8cc2fa4081f7ea2141e4a80967d13b7f3e8c9d 100644 --- a/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.h +++ b/Sample/StandardSamples/ThickAbsorptiveSampleBuilder.h @@ -24,7 +24,9 @@ class MultiLayer; namespace ExemplarySamples { + MultiLayer* createThickAbsorptiveSample(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_THICKABSORPTIVESAMPLEBUILDER_H diff --git a/Sample/StandardSamples/TransformationsBuilder.h b/Sample/StandardSamples/TransformationsBuilder.h index d2b4b93f456d9872f3f8673e3bbf27b484e15123..cac21f5eda2bed19dd5d55043ff4ff89d4bb7dd3 100644 --- a/Sample/StandardSamples/TransformationsBuilder.h +++ b/Sample/StandardSamples/TransformationsBuilder.h @@ -27,7 +27,9 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createTransformBox(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_TRANSFORMATIONSBUILDER_H diff --git a/Sample/StandardSamples/TwoDimLatticeBuilder.h b/Sample/StandardSamples/TwoDimLatticeBuilder.h index 552906c7673a5bc2e0b98b2ddf0e19584db9f721..28af754ce743ae18e7106d1e813956e13f8924d5 100644 --- a/Sample/StandardSamples/TwoDimLatticeBuilder.h +++ b/Sample/StandardSamples/TwoDimLatticeBuilder.h @@ -27,42 +27,54 @@ class MultiLayer; //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createBasic2DLattice(); + } // namespace ExemplarySamples //! Builds sample: 2D lattice with different disorder (IsGISAXS example #6). //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSquareLattice2D(); + } // namespace ExemplarySamples //! Builds sample: 2D lattice with different disorder (IsGISAXS example #6). //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createCenteredSquareLattice2D(); + } // namespace ExemplarySamples //! Builds sample: 2D lattice with different disorder (IsGISAXS example #6). //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createRotatedSquareLattice2D(); + } // namespace ExemplarySamples //! Builds sample: 2D finite lattice with thermal disorder. //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createFiniteSquareLattice2D(); + } // namespace ExemplarySamples //! Builds sample: 2D finite lattice of 2D finite lattices (superlattice). //! @ingroup standard_samples namespace ExemplarySamples { + MultiLayer* createSuperLattice(); + } // namespace ExemplarySamples #endif // BORNAGAIN_SAMPLE_STANDARDSAMPLES_TWODIMLATTICEBUILDER_H diff --git a/Tests/Functional/Core/CoreSpecial/CoreIOPathTest.cpp b/Tests/Functional/Core/CoreSpecial/CoreIOPathTest.cpp index d15433063148fa2a5a2c80d8cdec0f85fd349ac3..0756bf3f1fe62293a9347ee9e65d9335da070c01 100644 --- a/Tests/Functional/Core/CoreSpecial/CoreIOPathTest.cpp +++ b/Tests/Functional/Core/CoreSpecial/CoreIOPathTest.cpp @@ -22,6 +22,7 @@ #include <memory> namespace { + std::unique_ptr<OutputData<double>> createTestData() { std::unique_ptr<OutputData<double>> result(new OutputData<double>); diff --git a/Tests/SingleUse/ff-tetrahedron.cpp b/Tests/SingleUse/ff-tetrahedron.cpp index 410a8887732d7ca80dab78636e5456464503f3a7..bb627f25b83a53d92a657fc8dd42c253bd8454bc 100644 --- a/Tests/SingleUse/ff-tetrahedron.cpp +++ b/Tests/SingleUse/ff-tetrahedron.cpp @@ -1,5 +1,6 @@ #include "Base/Math/Constants.h" #include "Sample/HardParticle/HardParticles.h" + <ff / PolyhedralComponents.h> #include "Tests/GTestWrapper/google_test.h" #include <iostream> diff --git a/Tests/Unit/Core/RectangularDetectorTest.cpp b/Tests/Unit/Core/RectangularDetectorTest.cpp index 12567f80663bcffd8ff9fadfca68bc666cfabf50..af175b6ca93557f121bdeb4b81b893ffe50470ca 100644 --- a/Tests/Unit/Core/RectangularDetectorTest.cpp +++ b/Tests/Unit/Core/RectangularDetectorTest.cpp @@ -17,9 +17,8 @@ protected: bool is_equal = BaseUtils::algo::almostEqual(lhs.x(), rhs.x()) && BaseUtils::algo::almostEqual(lhs.y(), rhs.y()) && BaseUtils::algo::almostEqual(lhs.z(), rhs.z()); - if (!is_equal) { + if (!is_equal) std::cout << "lhs:" << lhs << " rhs:" << rhs << " diff:" << (lhs - rhs) << std::endl; - } return is_equal; } }; diff --git a/Tests/Unit/Device/ConstKBinAxisTest.cpp b/Tests/Unit/Device/ConstKBinAxisTest.cpp index 8631b95364adeacedd4f725d2808d8cdf59a8574..9d956641647b2232c767cb4baa21d506485d9bf8 100644 --- a/Tests/Unit/Device/ConstKBinAxisTest.cpp +++ b/Tests/Unit/Device/ConstKBinAxisTest.cpp @@ -21,9 +21,8 @@ protected: (std::asin(start_sin + step * i) + std::asin(start_sin + step * (i + 1))) / 2.0); } - for (size_t i = 0; i < m_nbins + 1; ++i) { + for (size_t i = 0; i < m_nbins + 1; ++i) m_boundaries.push_back(std::asin(start_sin + step * i)); - } } size_t m_nbins; @@ -45,9 +44,8 @@ TEST_F(ConstKBinAxisTest, TypicalAxis) EXPECT_DOUBLE_EQ(m_start, m_axis.binBoundaries().front()); EXPECT_DOUBLE_EQ(m_end, m_axis.binBoundaries().back()); - for (size_t i = 0; i < m_axis.size(); ++i) { + for (size_t i = 0; i < m_axis.size(); ++i) EXPECT_DOUBLE_EQ(m_centers[i], m_axis[i]); - } for (size_t i = 0; i < m_axis.size(); ++i) { EXPECT_DOUBLE_EQ(m_boundaries[i], m_axis.bin(i).m_lower); diff --git a/Tests/Unit/Device/DetectorMaskTest.cpp b/Tests/Unit/Device/DetectorMaskTest.cpp index 50b3b65af87c859c5d99158faa03da71e73ec896..17e664076c81d3b8104773fcca86a2d1814df0b3 100644 --- a/Tests/Unit/Device/DetectorMaskTest.cpp +++ b/Tests/Unit/Device/DetectorMaskTest.cpp @@ -50,11 +50,10 @@ TEST_F(DetectorMaskTest, AddMask) for (size_t index = 0; index < detectorMask.getMaskData()->getAllocatedSize(); ++index) { double x = detectorMask.getMaskData()->getAxisValue(index, 0); double y = detectorMask.getMaskData()->getAxisValue(index, 1); - if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) { + if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) EXPECT_TRUE(detectorMask.isMasked(index)); - } else { + else EXPECT_FALSE(detectorMask.isMasked(index)); - } } EXPECT_EQ(detectorMask.numberOfMaskedChannels(), 32); @@ -63,9 +62,8 @@ TEST_F(DetectorMaskTest, AddMask) detectorMask.addMask(polygon, false); detectorMask.initMaskData(detector.axes()); - for (size_t index = 0; index < detectorMask.getMaskData()->getAllocatedSize(); ++index) { + for (size_t index = 0; index < detectorMask.getMaskData()->getAllocatedSize(); ++index) EXPECT_FALSE(detectorMask.isMasked(index)); - } EXPECT_EQ(detectorMask.numberOfMaskedChannels(), 0); // adding third mask @@ -77,11 +75,10 @@ TEST_F(DetectorMaskTest, AddMask) for (size_t index = 0; index < detectorMask.getMaskData()->getAllocatedSize(); ++index) { double x = detectorMask.getMaskData()->getAxisValue(index, 0); double y = detectorMask.getMaskData()->getAxisValue(index, 1); - if (x >= 5.0 && x <= 8.0 && y >= 2.0 && y <= 4.0) { + if (x >= 5.0 && x <= 8.0 && y >= 2.0 && y <= 4.0) EXPECT_TRUE(detectorMask.isMasked(index)); - } else { + else EXPECT_FALSE(detectorMask.isMasked(index)); - } } } @@ -108,11 +105,10 @@ TEST_F(DetectorMaskTest, AssignmentOperator) for (size_t index = 0; index < mask.getMaskData()->getAllocatedSize(); ++index) { double x = mask.getMaskData()->getAxisValue(index, 0); double y = mask.getMaskData()->getAxisValue(index, 1); - if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) { + if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) EXPECT_TRUE(mask.isMasked(index)); - } else { + else EXPECT_FALSE(mask.isMasked(index)); - } } EXPECT_EQ(mask.numberOfMaskedChannels(), 32); } @@ -140,10 +136,9 @@ TEST_F(DetectorMaskTest, CopyConstructor) for (size_t index = 0; index < mask.getMaskData()->getAllocatedSize(); ++index) { double x = mask.getMaskData()->getAxisValue(index, 0); double y = mask.getMaskData()->getAxisValue(index, 1); - if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) { + if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) EXPECT_TRUE(mask.isMasked(index)); - } else { + else EXPECT_FALSE(mask.isMasked(index)); - } } } diff --git a/Tests/Unit/Device/Histogram1DTest.cpp b/Tests/Unit/Device/Histogram1DTest.cpp index df6d346a7f5b83f19ac2beed32fcf48d08ca89e1..2eb67000a1ae397558a906d93ec07a9c33b16da9 100644 --- a/Tests/Unit/Device/Histogram1DTest.cpp +++ b/Tests/Unit/Device/Histogram1DTest.cpp @@ -48,9 +48,8 @@ TEST_F(Histogram1DTest, FixedBinDefaultContent) } // default bin entries - for (size_t index = 0; index < bin_centers.size(); ++index) { + for (size_t index = 0; index < bin_centers.size(); ++index) EXPECT_EQ(hist.binNumberOfEntries(index), 0); - } } TEST_F(Histogram1DTest, FixedBinFill) @@ -114,9 +113,8 @@ TEST_F(Histogram1DTest, crop) std::vector<double> xvalues = {-0.75, 0.0, 0.75, 1.5}; Histogram1D hist(4, xedges); - for (size_t i = 0; i < xvalues.size(); ++i) { + for (size_t i = 0; i < xvalues.size(); ++i) hist.fill(xvalues[i], i * 10.0); - } std::unique_ptr<Histogram1D> crop(hist.crop(-0.49, 0.99)); @@ -131,9 +129,8 @@ 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) { + for (size_t i = 0; i < data.getAllocatedSize(); ++i) data[i] = double(i); - } std::unique_ptr<IHistogram> hist(IHistogram::createHistogram(data)); EXPECT_EQ(size_t(1), hist->rank()); @@ -162,24 +159,20 @@ TEST_F(Histogram1DTest, CreateOutputData) EXPECT_EQ(data->getAllocatedSize(), hist.getNbinsX()); EXPECT_EQ(data->axis(0).lowerBound(), hist.getXmin()); EXPECT_EQ(data->axis(0).upperBound(), hist.getXmax()); - for (size_t i = 0; i < data->getAllocatedSize(); ++i) { + for (size_t i = 0; i < data->getAllocatedSize(); ++i) EXPECT_EQ(4.0, (*data)[i]); - } data.reset(hist.createOutputData(IHistogram::DataType::AVERAGE)); - for (size_t i = 0; i < data->getAllocatedSize(); ++i) { + for (size_t i = 0; i < data->getAllocatedSize(); ++i) EXPECT_EQ(2.0, (*data)[i]); - } data.reset(hist.createOutputData(IHistogram::DataType::STANDARD_ERROR)); - for (size_t i = 0; i < data->getAllocatedSize(); ++i) { + for (size_t i = 0; i < data->getAllocatedSize(); ++i) EXPECT_EQ(1.0, (*data)[i]); - } data.reset(hist.createOutputData(IHistogram::DataType::NENTRIES)); - for (size_t i = 0; i < data->getAllocatedSize(); ++i) { + for (size_t i = 0; i < data->getAllocatedSize(); ++i) EXPECT_EQ(2.0, (*data)[i]); - } } TEST_F(Histogram1DTest, GetMaximumGetMinimum) @@ -200,39 +193,33 @@ TEST_F(Histogram1DTest, Scale) { Histogram1D hist(10, -5.0, 5.0); - for (size_t i = 0; i < hist.getTotalNumberOfBins(); ++i) { + for (size_t i = 0; i < hist.getTotalNumberOfBins(); ++i) hist.fill(-4.5 + i, 1.0); - } hist.scale(10.0); - for (size_t i = 0; i < hist.getTotalNumberOfBins(); ++i) { + for (size_t i = 0; i < hist.getTotalNumberOfBins(); ++i) EXPECT_EQ(10.0, hist.binContent(i)); - } } TEST_F(Histogram1DTest, Integral) { Histogram1D hist(10, -5.0, 5.0); - for (size_t i = 0; i < hist.getTotalNumberOfBins(); ++i) { + for (size_t i = 0; i < hist.getTotalNumberOfBins(); ++i) hist.fill(-4.5 + i, 1.0); - } EXPECT_EQ(10.0, hist.integral()); } TEST_F(Histogram1DTest, Addition) { Histogram1D hist1(10, -5.0, 5.0); - for (size_t i = 0; i < hist1.getTotalNumberOfBins(); ++i) { + for (size_t i = 0; i < hist1.getTotalNumberOfBins(); ++i) hist1.fill(-4.5 + i, 1.0); - } Histogram1D hist2(10, -5.0, 5.0); - for (size_t i = 0; i < hist2.getTotalNumberOfBins(); ++i) { + for (size_t i = 0; i < hist2.getTotalNumberOfBins(); ++i) hist2.fill(-4.5 + i, 2.0); - } hist1 += hist2; - for (size_t i = 0; i < hist1.getTotalNumberOfBins(); ++i) { + for (size_t i = 0; i < hist1.getTotalNumberOfBins(); ++i) EXPECT_EQ(3.0, hist1.binContent(i)); - } } diff --git a/Tests/Unit/Device/Histogram2DTest.cpp b/Tests/Unit/Device/Histogram2DTest.cpp index 7562407ecf05ddc3535c12c8e0873578dd9b7d13..6135cc9ac4dae14077e41b006f2616fe4f849f93 100644 --- a/Tests/Unit/Device/Histogram2DTest.cpp +++ b/Tests/Unit/Device/Histogram2DTest.cpp @@ -106,9 +106,8 @@ TEST_F(Histogram2DTest, VariableHistFill) std::vector<double> yvalues = {0.5, 1.5, 3.0, 0.5, 1.5, 3.0, 0.5, 1.5, 3.0, 0.5, 1.5, 3.0}; // put in every histogram bin one double value proportional to globalbin (globalbin*10.0) - for (size_t i = 0; i < xvalues.size(); ++i) { + for (size_t i = 0; i < xvalues.size(); ++i) hist.fill(xvalues[i], yvalues[i], i * 10.0); - } // check bin content using globalbin for (size_t globalbin = 0; globalbin < hist.getTotalNumberOfBins(); ++globalbin) { @@ -148,9 +147,8 @@ TEST_F(Histogram2DTest, projectionX) std::vector<double> content = {1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0}; // put in every histogram bin the value from 'content' vector - for (size_t i = 0; i < xvalues.size(); ++i) { + for (size_t i = 0; i < xvalues.size(); ++i) hist.fill(xvalues[i], yvalues[i], content[i]); - } // a) create projection along X axis std::unique_ptr<Histogram1D> h1(hist.projectionX()); @@ -226,9 +224,8 @@ TEST_F(Histogram2DTest, projectionY) std::vector<double> content = {1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0}; // put in every histogram bin the value from 'content' vector - for (size_t i = 0; i < xvalues.size(); ++i) { + for (size_t i = 0; i < xvalues.size(); ++i) hist.fill(xvalues[i], yvalues[i], content[i]); - } // a) create projection along Y axis std::unique_ptr<Histogram1D> h1(hist.projectionY()); @@ -313,9 +310,8 @@ TEST_F(Histogram2DTest, crop) std::vector<double> content = {1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0}; // put in every histogram bin the value from 'content' vector - for (size_t i = 0; i < xvalues.size(); ++i) { + for (size_t i = 0; i < xvalues.size(); ++i) hist.fill(xvalues[i], yvalues[i], content[i]); - } std::unique_ptr<Histogram2D> crop(hist.crop(-0.49, 0.0, 1.99, 1.9)); EXPECT_EQ(-0.5, crop->getXmin()); @@ -338,9 +334,8 @@ 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); - for (size_t i = 0; i < data.getAllocatedSize(); ++i) { + for (size_t i = 0; i < data.getAllocatedSize(); ++i) data[i] = double(i); - } std::unique_ptr<IHistogram> h2(IHistogram::createHistogram(data)); EXPECT_EQ(size_t(2), h2->rank()); @@ -376,24 +371,20 @@ TEST_F(Histogram2DTest, CreateOutputData) EXPECT_EQ(data->axis(0).upperBound(), h2.getXmax()); EXPECT_EQ(data->axis(1).lowerBound(), h2.getYmin()); EXPECT_EQ(data->axis(1).upperBound(), h2.getYmax()); - for (size_t i = 0; i < data->getAllocatedSize(); ++i) { + for (size_t i = 0; i < data->getAllocatedSize(); ++i) EXPECT_EQ(double(i), (*data)[i]); - } data.reset(h2.createOutputData(IHistogram::DataType::AVERAGE)); - for (size_t i = 0; i < data->getAllocatedSize(); ++i) { + for (size_t i = 0; i < data->getAllocatedSize(); ++i) EXPECT_EQ(double(i), (*data)[i]); - } data.reset(h2.createOutputData(IHistogram::DataType::STANDARD_ERROR)); - for (size_t i = 0; i < data->getAllocatedSize(); ++i) { + for (size_t i = 0; i < data->getAllocatedSize(); ++i) EXPECT_EQ(0.0, (*data)[i]); - } data.reset(h2.createOutputData(IHistogram::DataType::NENTRIES)); - for (size_t i = 0; i < data->getAllocatedSize(); ++i) { + for (size_t i = 0; i < data->getAllocatedSize(); ++i) EXPECT_EQ(1.0, (*data)[i]); - } } TEST_F(Histogram2DTest, GetMaximumGetMinimum) @@ -401,9 +392,8 @@ 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) { - for (size_t iy = 0; iy < h2.getNbinsY(); ++iy) { + for (size_t iy = 0; iy < h2.getNbinsY(); ++iy) h2.fill(-5.0 + ix + 0.5, -5.0 + iy + 0.5, 10.0 + ix + h2.getNbinsX() * iy); - } } EXPECT_EQ(10.0, h2.getMinimum()); diff --git a/Tests/Unit/Device/LLDataTest.cpp b/Tests/Unit/Device/LLDataTest.cpp index cab22c188502dcda883745d34595066f61b72b33..c43a18f36b73184f50ee5c75410d6ddb02c11173 100644 --- a/Tests/Unit/Device/LLDataTest.cpp +++ b/Tests/Unit/Device/LLDataTest.cpp @@ -128,7 +128,6 @@ TEST_F(LLDataTest, DataCopyingConstructor) TEST_F(LLDataTest, DataAssignment) { - auto* other_fl_data_1d = new LLData<float>(*fl_data_1d); fl_data_1d->setAll(1.1f); (*other_fl_data_1d) = (*fl_data_1d); @@ -154,7 +153,6 @@ TEST_F(LLDataTest, DataAssignment) TEST_F(LLDataTest, Addition) { - auto* other_fl_data_1d = new LLData<float>(*fl_data_1d); fl_data_1d->setAll(1.1f); other_fl_data_1d->setAll(2.9f); @@ -193,7 +191,6 @@ TEST_F(LLDataTest, Addition) TEST_F(LLDataTest, Substraction) { - auto* other_fl_data_1d = new LLData<float>(*fl_data_1d); fl_data_1d->setAll(1.15f); other_fl_data_1d->setAll(5.15f); @@ -231,7 +228,6 @@ TEST_F(LLDataTest, Substraction) TEST_F(LLDataTest, Multiplication) { - auto* other_fl_data_1d = new LLData<float>(*fl_data_1d); fl_data_1d->setAll(1.15f); other_fl_data_1d->setAll(2.0f); @@ -269,7 +265,6 @@ TEST_F(LLDataTest, Multiplication) TEST_F(LLDataTest, Division) { - auto* other_fl_data_1d = new LLData<float>(*fl_data_1d); fl_data_1d->setAll(1.15f); other_fl_data_1d->setAll(2.3f); diff --git a/Tests/Unit/Device/RectangularConverterTest.cpp b/Tests/Unit/Device/RectangularConverterTest.cpp index 7797010d31b4cede2be18ca52615e3dc05c6f928..5fae564ffdeac072319daf1d32abcb4471a8bdf9 100644 --- a/Tests/Unit/Device/RectangularConverterTest.cpp +++ b/Tests/Unit/Device/RectangularConverterTest.cpp @@ -9,11 +9,13 @@ #include <cmath> namespace { + const double det_width = 200.0; const double det_height = 140.0; const double det_distance = 1000.0; const size_t det_nx = 100u; const size_t det_ny = 70u; + } // namespace class ImageCoordsTest : public ::testing::Test { diff --git a/Tests/Unit/Device/SphericalDetectorTest.cpp b/Tests/Unit/Device/SphericalDetectorTest.cpp index 69411a82b7839aa805c63cadc4f2df550d8bbdf4..0c1cc6361bcce5f18529f9894283d090e019fb13 100644 --- a/Tests/Unit/Device/SphericalDetectorTest.cpp +++ b/Tests/Unit/Device/SphericalDetectorTest.cpp @@ -146,11 +146,10 @@ TEST_F(SphericalDetectorTest, MaskOfDetector) for (size_t index = 0; index < mask->getAllocatedSize(); ++index) { double x = mask->getAxisValue(index, 0); double y = mask->getAxisValue(index, 1); - if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) { + if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) EXPECT_TRUE(detector.detectorMask()->isMasked(index)); - } else { + else EXPECT_FALSE(detector.detectorMask()->isMasked(index)); - } } SphericalDetector detector2(detector); @@ -158,22 +157,20 @@ TEST_F(SphericalDetectorTest, MaskOfDetector) for (size_t index = 0; index < mask->getAllocatedSize(); ++index) { double x = mask->getAxisValue(index, 0); double y = mask->getAxisValue(index, 1); - if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) { + if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) EXPECT_TRUE(detector2.detectorMask()->isMasked(index)); - } else { + else EXPECT_FALSE(detector2.detectorMask()->isMasked(index)); - } } mask = detector.detectorMask()->getMaskData(); for (size_t index = 0; index < mask->getAllocatedSize(); ++index) { double x = mask->getAxisValue(index, 0); double y = mask->getAxisValue(index, 1); - if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) { + if (x >= -4.0 && x <= 4.0 && y >= -2.0 && y <= 2.0) EXPECT_TRUE(detector.detectorMask()->isMasked(index)); - } else { + else EXPECT_FALSE(detector.detectorMask()->isMasked(index)); - } } } diff --git a/Tests/Unit/Device/VariableBinAxisTest.cpp b/Tests/Unit/Device/VariableBinAxisTest.cpp index 09ab8ecf5bd6f84df1486719ed72e90f7779947a..57e24353238dcc5155a2eceb002f2bb2381037a3 100644 --- a/Tests/Unit/Device/VariableBinAxisTest.cpp +++ b/Tests/Unit/Device/VariableBinAxisTest.cpp @@ -40,9 +40,8 @@ TEST_F(VariableBinAxisTest, IndexedAccessor) double end(10.0); size_t nbins(100); double step = (end - start) / (nbins); - for (size_t i = 0; i < nbins + 1; ++i) { + for (size_t i = 0; i < nbins + 1; ++i) values.push_back(start + step * (int)i); - } VariableBinAxis a1("name", nbins, values); diff --git a/Tests/Unit/GUI/TestDataItemViews.cpp b/Tests/Unit/GUI/TestDataItemViews.cpp index eefcbceba7edcf320fd530c80bff819b93b74ff2..0cccc04b3a20f4e43a8148fece4bb28f19e695c9 100644 --- a/Tests/Unit/GUI/TestDataItemViews.cpp +++ b/Tests/Unit/GUI/TestDataItemViews.cpp @@ -121,7 +121,6 @@ TEST_F(TestDataItemViews, testSavingLinkedData) UTest::GUI::create_dir(projectDir); const QString projectFileName(projectDir + "/document.pro"); { - ProjectDocument document; SessionModel* real_data_model = document.realDataModel(); diff --git a/Tests/Unit/GUI/TestProjectUtils.cpp b/Tests/Unit/GUI/TestProjectUtils.cpp index 0e7d1181e04073477b45599c6a4d9edb5023fda1..37192cf8a26c8beef18d13b892e11e43067adfe2 100644 --- a/Tests/Unit/GUI/TestProjectUtils.cpp +++ b/Tests/Unit/GUI/TestProjectUtils.cpp @@ -9,6 +9,7 @@ #include <iostream> namespace { + QStringList nonXMLDataInDir(const QString& dirname) { QDir dir(dirname); diff --git a/Tests/Unit/GUI/TestPropertyRepeater.cpp b/Tests/Unit/GUI/TestPropertyRepeater.cpp index 19a09dd27587c46dcd4714e258ebcada6ca4954b..ad217d8fba8731a439048e2504dd94ff13bc7b87 100644 --- a/Tests/Unit/GUI/TestPropertyRepeater.cpp +++ b/Tests/Unit/GUI/TestPropertyRepeater.cpp @@ -15,6 +15,7 @@ BasicAxisItem* createAxis(SessionModel& model) { return model.insertItem<BasicAxisItem>(); } + } // namespace class TestPropertyRepeater : public ::testing::Test { diff --git a/Tests/Unit/GUI/TestSessionItemControllerHelper.h b/Tests/Unit/GUI/TestSessionItemControllerHelper.h index 247b99c18f4da24ac427dc12af2a8998aef75c58..b1749c7e73f0d7ea6eca2d7893f895e7d7fbdfb1 100644 --- a/Tests/Unit/GUI/TestSessionItemControllerHelper.h +++ b/Tests/Unit/GUI/TestSessionItemControllerHelper.h @@ -2,6 +2,7 @@ #define BORNAGAIN_TESTS_UNIT_GUI_TESTSESSIONITEMCONTROLLERHELPER_H #include <QObject> + class SessionItem; class SessionItemController; diff --git a/Tests/Unit/GUI/TestSessionXML.cpp b/Tests/Unit/GUI/TestSessionXML.cpp index 39a76f641aef61470d1e174ed21bf31da3abbc28..2a9351e2a212194e09395cb0a4749fa1515a27d7 100644 --- a/Tests/Unit/GUI/TestSessionXML.cpp +++ b/Tests/Unit/GUI/TestSessionXML.cpp @@ -10,6 +10,7 @@ #include <memory> namespace { + QString itemToXML(SessionItem* item) { QString result; @@ -23,6 +24,7 @@ void itemFromXML(QString buffer, SessionItem* item) QXmlStreamReader reader(buffer); GUI::Session::XML::readItems(&reader, item); } + } // namespace class TestSessionXML : public ::testing::Test { diff --git a/Tests/Unit/GUI/Utils.cpp b/Tests/Unit/GUI/Utils.cpp index e36c833d07ec28db5d1b6d25925b29d055730ee7..10e9c640c4bb5e82e4dab062711de8d9b0d4eab8 100644 --- a/Tests/Unit/GUI/Utils.cpp +++ b/Tests/Unit/GUI/Utils.cpp @@ -23,8 +23,10 @@ #include <QDir> namespace { + const int nxsize = 5; const int nysize = 10; + } // namespace void UTest::GUI::create_dir(const QString& dir_name) diff --git a/Tests/Unit/Numeric/BisectFF.cpp b/Tests/Unit/Numeric/BisectFF.cpp index 536ea5f2bf03cd4a84e7108cb248349b28c31c11..6593756832c3c70a8e903bceef7d78c4cb0bb043 100644 --- a/Tests/Unit/Numeric/BisectFF.cpp +++ b/Tests/Unit/Numeric/BisectFF.cpp @@ -2,6 +2,7 @@ #include "Base/Math/Constants.h" #include "Sample/HardParticle/HardParticles.h" + <ff / PolyhedralComponents.h> // for diagnostic #include "Tests/GTestWrapper/google_test.h" #include <cassert> diff --git a/Tests/Unit/Param/INodeTest.cpp b/Tests/Unit/Param/INodeTest.cpp index b89234b94c99f4f78cc16462f7350628594c9a23..e4efc171b948d6237cb4a96ea226e0e9c4694c64 100644 --- a/Tests/Unit/Param/INodeTest.cpp +++ b/Tests/Unit/Param/INodeTest.cpp @@ -6,8 +6,10 @@ #include <stdexcept> namespace { + const std::string test_class_name = "TestClass"; const std::string another_test_class_name = "AnotherTestClass"; + } // namespace class INodeTest : public ::testing::Test { diff --git a/Tests/Unit/Resample/LayerFillLimitsTest.cpp b/Tests/Unit/Resample/LayerFillLimitsTest.cpp index ef0ef33b4e178d687b5c976eb4c4825372fb029e..bb1bc05f013c93b7d52ec2dbbdb7dd0a1fb81fbe 100644 --- a/Tests/Unit/Resample/LayerFillLimitsTest.cpp +++ b/Tests/Unit/Resample/LayerFillLimitsTest.cpp @@ -4,7 +4,6 @@ #define INCLUDED_BY_TEST #include "Resample/Processed/ParticleRegions.cpp" - class LayerFillLimitsTest : public ::testing::Test { protected: LayerFillLimitsTest(); diff --git a/Tests/Unit/Sample/MultiLayerTest.cpp b/Tests/Unit/Sample/MultiLayerTest.cpp index 50128f20fe3304cc3daa88e7a049b57c3af010b6..0ef4a1e4d4cc389c180d7ac1384c129080eb31aa 100644 --- a/Tests/Unit/Sample/MultiLayerTest.cpp +++ b/Tests/Unit/Sample/MultiLayerTest.cpp @@ -228,10 +228,8 @@ TEST_F(MultiLayerTest, MultiLayerCompositeTest) } EXPECT_EQ(size_t(5), layer_buffer.size()); EXPECT_EQ(size_t(4), interface_buffer.size()); - for (size_t i = 0; i < layer_buffer.size(); ++i) { + for (size_t i = 0; i < layer_buffer.size(); ++i) EXPECT_EQ(double(i * 10), layer_buffer[i]->thickness()); - } - for (size_t i = 0; i < interface_buffer.size(); ++i) { + for (size_t i = 0; i < interface_buffer.size(); ++i) EXPECT_EQ(double((i + 1) * 10), interface_buffer[i]->bottomLayer()->thickness()); - } } diff --git a/ff/PolyhedralComponents.cpp b/ff/PolyhedralComponents.cpp index aa90f5aff642eeb4779986f19be1b858e9ad0bbb..59937d13097bd02973904623af09a05953dc7341 100644 --- a/ff/PolyhedralComponents.cpp +++ b/ff/PolyhedralComponents.cpp @@ -89,9 +89,9 @@ complex_t ff::PolyhedralEdge::contrib(int M, C3 qpa, complex_t qrperp) const } complex_t ret = 0; // the l=0 term, minus (qperp.R)^M, which cancels under the sum over E*contrib() - if (v1 == 0.) { + if (v1 == 0.) ret = ReciprocalFactorialArray[M] * pow(v2, M); - } else if (v2 == 0.) { + else if (v2 == 0.) { ; // leave ret=0 } else { // binomial expansion @@ -170,9 +170,8 @@ ff::PolyhedralFace::PolyhedralFace(const std::vector<R3>& V, bool _sym_S2) : sym for (size_t j = 0; j < NE; ++j) { size_t jj = (j + 1) % NE; R3 ee = edges[j].E().cross(edges[jj].E()); - if (ee.mag2() == 0) { + if (ee.mag2() == 0) throw std::runtime_error("Invalid polyhedral face: two adjacent edges are parallel"); - } m_normal += ee.unit(); } m_normal /= NE;