diff --git a/GUI/Models/ComboProperty.cpp b/GUI/Models/ComboProperty.cpp index 3fd0ef87046f8a96d380107fb3a59529b6be995e..c2ad7bc52ffb9edbcc20a2b5954aa230a4190955 100644 --- a/GUI/Models/ComboProperty.cpp +++ b/GUI/Models/ComboProperty.cpp @@ -14,7 +14,7 @@ #include "GUI/Models/ComboProperty.h" #include "Base/Utils/Assert.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" namespace { const QString value_separator = ";"; @@ -43,9 +43,9 @@ QString ComboProperty::getValue() const void ComboProperty::setValue(const QString& name) { if (!m_values.contains(name)) - throw GUIHelpers::Error("ComboProperty::setValue() -> Error. Combo doesn't contain " - "value " - + name); + throw Error("ComboProperty::setValue() -> Error. Combo doesn't contain " + "value " + + name); setCurrentIndex(m_values.indexOf(name)); } @@ -83,8 +83,8 @@ int ComboProperty::currentIndex() const void ComboProperty::setCurrentIndex(int index) { if (index < 0 || index >= m_values.size()) - throw GUIHelpers::Error("ComboProperty::setCurrentIndex(int index) -> Error. " - "Invalid index"); + throw Error("ComboProperty::setCurrentIndex(int index) -> Error. " + "Invalid index"); m_selected_indices.clear(); m_selected_indices.push_back(index); } diff --git a/GUI/Models/Data1DViewItem.cpp b/GUI/Models/Data1DViewItem.cpp index d507a5853cc65cee60bf9c0fdb780f2f13b025fd..e54ef9e43f3eda3faa40f3070c6e50b09847eb04 100644 --- a/GUI/Models/Data1DViewItem.cpp +++ b/GUI/Models/Data1DViewItem.cpp @@ -19,8 +19,8 @@ #include "GUI/Models/DataProperties.h" #include "GUI/Models/DataPropertyContainer.h" #include "GUI/Models/DataViewUtils.h" +#include "GUI/Models/Error.h" #include "GUI/Models/JobItem.h" -#include "GUI/utils/GUIHelpers.h" namespace { const QString x_axis_default_name = "X [nbins]"; @@ -142,7 +142,7 @@ void Data1DViewItem::setAxesRangeToData() void Data1DViewItem::resetToDefault() { // TODO: implement when applying DataITem1DView in ImportView - throw GUIHelpers::Error("Error in DataItem1DView::resetToDefault: not implemented"); + throw Error("Error in DataItem1DView::resetToDefault: not implemented"); } QPair<QVector<double>, QVector<double>> Data1DViewItem::graphData(Data1DProperties* property_item) @@ -174,7 +174,7 @@ JobItem* Data1DViewItem::jobItem() return m_job_item; } } while ((item = item->parent())); - throw GUIHelpers::Error( + throw Error( "Error in DataItem1DView::jobItem: passed item is not owned by any job item"); } diff --git a/GUI/Models/DataItem.cpp b/GUI/Models/DataItem.cpp index 2d08650fbc5ffb20a3a6d0e87ea6170fc8004663..fcda670d795a98c4d2d7fd59c8e4d881b1f690b1 100644 --- a/GUI/Models/DataItem.cpp +++ b/GUI/Models/DataItem.cpp @@ -15,7 +15,7 @@ #include "GUI/Models/DataItem.h" #include "Device/Histo/IntensityDataIOFactory.h" #include "GUI/Models/ComboProperty.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" #include "GUI/utils/ImportDataInfo.h" const QString DataItem::P_FILE_NAME = "FileName"; @@ -30,8 +30,8 @@ void DataItem::setOutputData(OutputData<double>* data) void DataItem::setRawDataVector(std::vector<double> data) { if (m_data->getAllocatedSize() != data.size()) - throw GUIHelpers::Error("DataItem::setRawDataVector() -> Error. " - "Different data size."); + throw Error("DataItem::setRawDataVector() -> Error. " + "Different data size."); std::unique_lock<std::mutex> lock(m_update_data_mutex); m_data->setRawDataVector(std::move(data)); emitDataChanged(); diff --git a/GUI/Models/DataItemUtils.cpp b/GUI/Models/DataItemUtils.cpp index 841e8d90cb39602ae7b3ff716161226a018a3525..38ad5b63137f5cc2fc0fd6ae47fc47af950ef3ab 100644 --- a/GUI/Models/DataItemUtils.cpp +++ b/GUI/Models/DataItemUtils.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "GUI/Models/DataItemUtils.h" +#include "GUI/Models/Error.h" #include "GUI/Models/IntensityDataItem.h" #include "GUI/Models/JobItem.h" #include "GUI/Models/RealDataItem.h" #include "GUI/Models/SpecularDataItem.h" -#include "GUI/utils/GUIHelpers.h" namespace { template <class DataItemType> DataItemType* dataItem(SessionItem* parent) @@ -31,7 +31,7 @@ template <class DataItemType> DataItemType* dataItem(SessionItem* parent) else if (auto self = dynamic_cast<DataItemType*>(parent)) return self; - throw GUIHelpers::Error("Error in DataItemUtils::dataItem: unexpected item passed."); + throw Error("Error in DataItemUtils::dataItem: unexpected item passed."); } } // namespace diff --git a/GUI/Models/DataProperties.cpp b/GUI/Models/DataProperties.cpp index 94f068c2c668572892c0d899e0734c4c82e28838..8fb2c35296bdeb8ca73515690a8ce02ce7025ecc 100644 --- a/GUI/Models/DataProperties.cpp +++ b/GUI/Models/DataProperties.cpp @@ -15,9 +15,10 @@ #include "GUI/Models/DataProperties.h" #include "GUI/Models/ComboProperty.h" #include "GUI/Models/DataItem.h" +#include "GUI/Models/Error.h" #include "GUI/Models/ModelPath.h" #include "GUI/Models/SessionModel.h" -#include "GUI/utils/GUIHelpers.h" +#include <QColor> namespace { // set of simple colors for representation of 1D graphs @@ -61,7 +62,7 @@ DataItem* DataProperties::dataItem() std::stringstream os; os << "Error in DataProperties::dataItem: index produced by path"; os << path.toStdString() << " is invalid" << std::endl; - throw GUIHelpers::Error(QString::fromStdString(os.str())); + throw Error(QString::fromStdString(os.str())); } auto item = hosting_model->itemForIndex(item_index); return dynamic_cast<DataItem*>(item); @@ -80,7 +81,7 @@ QColor Data1DProperties::color() auto iter = std::find_if(color_queue.begin(), color_queue.end(), ColorNameComparator(color_name)); if (iter == color_queue.end()) - throw GUIHelpers::Error("Error in Data1DPresentationProperties::color: unknown color name"); + throw Error("Error in Data1DPresentationProperties::color: unknown color name"); return QColor(iter->second); } diff --git a/GUI/Models/DataPropertyContainer.cpp b/GUI/Models/DataPropertyContainer.cpp index 68689b01499538fbd2e9b4ff7fce6e40a22ae1ae..a3daab4d02d795be3ddcf7274265847135e2436c 100644 --- a/GUI/Models/DataPropertyContainer.cpp +++ b/GUI/Models/DataPropertyContainer.cpp @@ -15,7 +15,7 @@ #include "GUI/Models/DataPropertyContainer.h" #include "GUI/Models/DataItem.h" #include "GUI/Models/DataProperties.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" const QString DataPropertyContainer::T_CHILDREN = "data links"; @@ -55,7 +55,7 @@ DataItem* DataPropertyContainer::basicDataItem() void DataPropertyContainer::addItem(DataItem* data_item) { if (this->model() != data_item->model()) - throw GUIHelpers::Error( + throw Error( "Error in DataPropertyContainer::addItem: hosting models are different"); auto property_items = propertyItems(); diff --git a/GUI/Models/DomainObjectBuilder.cpp b/GUI/Models/DomainObjectBuilder.cpp index 8b4f85314fd1e3c95e5420cb1d8506fd44a34f66..2e1e96a2b73f220df4cf95cc48f5cd1dde016e54 100644 --- a/GUI/Models/DomainObjectBuilder.cpp +++ b/GUI/Models/DomainObjectBuilder.cpp @@ -19,13 +19,13 @@ #include "Device/Instrument/CoordSystem2D.h" #include "GUI/Models/AxesItems.h" #include "GUI/Models/ComboProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/InstrumentItems.h" #include "GUI/Models/InterferenceFunctionItems.h" #include "GUI/Models/LayerItem.h" #include "GUI/Models/ParticleLayoutItem.h" #include "GUI/Models/SpecularBeamInclinationItem.h" #include "GUI/Models/TransformToDomain.h" -#include "GUI/utils/GUIHelpers.h" std::unique_ptr<MultiLayer> DomainObjectBuilder::buildMultiLayer(const SessionItem& multilayer_item) { @@ -73,8 +73,8 @@ std::unique_ptr<ParticleLayout> DomainObjectBuilder::buildParticleLayout(const S continue; } - throw GUIHelpers::Error("DomainObjectBuilder::buildParticleLayout()" - " -> Error! Not implemented"); + throw Error("DomainObjectBuilder::buildParticleLayout()" + " -> Error! Not implemented"); } QVector<SessionItem*> interferences = item.getItems(ParticleLayoutItem::T_INTERFERENCE); for (int i = 0; i < interferences.size(); i++) { diff --git a/GUI/Models/DomainSimulationBuilder.cpp b/GUI/Models/DomainSimulationBuilder.cpp index a3a0ce6fc2c7c1a2162ad3717ad958d98e17e112..a44306a33c0a63ed8e841954fe9185a0dfb3b99b 100644 --- a/GUI/Models/DomainSimulationBuilder.cpp +++ b/GUI/Models/DomainSimulationBuilder.cpp @@ -22,13 +22,13 @@ #include "GUI/Models/BackgroundItems.h" #include "GUI/Models/DetectorItems.h" #include "GUI/Models/DomainObjectBuilder.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FootprintItems.h" #include "GUI/Models/InstrumentItems.h" #include "GUI/Models/MultiLayerItem.h" #include "GUI/Models/SimulationOptionsItem.h" #include "GUI/Models/SpecularBeamInclinationItem.h" #include "GUI/Models/TransformToDomain.h" -#include "GUI/utils/GUIHelpers.h" namespace { @@ -139,7 +139,7 @@ DomainSimulationBuilder::createSimulation(const MultiLayerItem* sampleItem, if (sampleItem == nullptr || instrumentItem == nullptr) { QString message("DomainSimulationBuilder::getSimulation() -> Error. Either MultiLayerItem " " or InstrumentItem is not defined."); - throw GUIHelpers::Error(message); + throw Error(message); } auto P_multilayer = DomainObjectBuilder::buildMultiLayer(*sampleItem); @@ -154,6 +154,6 @@ DomainSimulationBuilder::createSimulation(const MultiLayerItem* sampleItem, else if (auto penetrator = dynamic_cast<const DepthProbeInstrumentItem*>(instrumentItem)) return createDepthProbeSimulation(std::move(P_multilayer), penetrator, optionsItem); - throw GUIHelpers::Error( + throw Error( "DomainSimulationBuilder::createSimulation() -> Error. Not yet implemented"); } diff --git a/GUI/Models/Error.cpp b/GUI/Models/Error.cpp new file mode 100644 index 0000000000000000000000000000000000000000..27359a2d60d7ba9cd192075d11810ca2dfe21c6a --- /dev/null +++ b/GUI/Models/Error.cpp @@ -0,0 +1,24 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file GUI/Models/Error.cpp +//! @brief Implements Error class +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2018 +//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) +// +// ************************************************************************************************ + +#include "GUI/Models/Error.h" + +Error::Error(const QString& message) noexcept + : m_messageAsLatin1(message.toLatin1()) +{} + +const char* Error::what() const noexcept +{ + return m_messageAsLatin1.data(); +} diff --git a/GUI/Models/Error.h b/GUI/Models/Error.h new file mode 100644 index 0000000000000000000000000000000000000000..b13f097e1b2ef01257d366343f5fb8788f58eb2b --- /dev/null +++ b/GUI/Models/Error.h @@ -0,0 +1,30 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file GUI/Models/Error.h +//! @brief Defines error class +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2018 +//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) +// +// ************************************************************************************************ + +#ifndef BORNAGAIN_GUI_MODELS_ERROR_H +#define BORNAGAIN_GUI_MODELS_ERROR_H + +#include <QString> +#include <QByteArray> + +class Error : public std::exception { +public: + explicit Error(const QString& message) noexcept; + const char* what() const noexcept override; + +private: + QByteArray m_messageAsLatin1; +}; + +#endif // BORNAGAIN_GUI_MODELS_ERROR_H diff --git a/GUI/Models/FitParameterItems.cpp b/GUI/Models/FitParameterItems.cpp index cfbdc863b6e0f6bd2a98d7db359fdd1c8746ac04..e9553ef7bf4bd327c574deb9515aa7978740d409 100644 --- a/GUI/Models/FitParameterItems.cpp +++ b/GUI/Models/FitParameterItems.cpp @@ -15,10 +15,10 @@ #include "GUI/Models/FitParameterItems.h" #include "Fit/Param/Parameters.h" #include "GUI/Models/ComboProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/JobItem.h" #include "GUI/Models/ModelPath.h" #include "GUI/Models/ParameterTreeItems.h" -#include "GUI/utils/GUIHelpers.h" #include <cmath> namespace { @@ -138,7 +138,7 @@ AttLimits FitParameterItem::attLimits() const } else { - throw GUIHelpers::Error("FitParameterItem::attLimits() -> Error. Unknown limit type"); + throw Error("FitParameterItem::attLimits() -> Error. Unknown limit type"); } } @@ -305,7 +305,7 @@ mumufit::Parameters FitParameterContainerItem::createParameters() const "or (min, max) range in fitting parameter par" << index; std::string message = ss.str(); - throw GUIHelpers::Error(QString::fromStdString(ss.str())); + throw Error(QString::fromStdString(ss.str())); } double startValue = fitPar->getItemValue(FitParameterItem::P_START_VALUE).toDouble(); AttLimits limits = fitPar->attLimits(); diff --git a/GUI/Models/FitParameterProxyModel.cpp b/GUI/Models/FitParameterProxyModel.cpp index ed8af4e5079a42e611e0051a5f82da68a2e96598..7ab7a38e7d744252278bd953c2a5011e19136787 100644 --- a/GUI/Models/FitParameterProxyModel.cpp +++ b/GUI/Models/FitParameterProxyModel.cpp @@ -13,12 +13,13 @@ // ************************************************************************************************ #include "GUI/Models/FitParameterProxyModel.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FitParameterHelper.h" #include "GUI/Models/FitParameterItems.h" #include "GUI/Models/JobModel.h" #include "GUI/Models/ModelPath.h" #include "GUI/Models/SessionItemUtils.h" -#include "GUI/utils/GUIHelpers.h" +#include <QColor> #include <QMimeData> using SessionItemUtils::ParentRow; @@ -38,7 +39,7 @@ FitParameterProxyModel::FitParameterProxyModel(FitParameterContainerItem* fitPar m_root_item->mapper()->setOnItemDestroy( [this](SessionItem* parentItem) { if (parentItem != m_root_item) { - throw GUIHelpers::Error( + throw Error( "FitParameterProxyModel::FitParameterProxyModel() -> Error. " "Wrong item reported."); } diff --git a/GUI/Models/GUIDomainSampleVisitor.cpp b/GUI/Models/GUIDomainSampleVisitor.cpp index a8f07ff19bafe326271d78a0d548d353b07bcc0d..badf6f60f9b44fa610a0439bb47267db66b60eea 100644 --- a/GUI/Models/GUIDomainSampleVisitor.cpp +++ b/GUI/Models/GUIDomainSampleVisitor.cpp @@ -15,6 +15,7 @@ #include "GUI/Models/GUIDomainSampleVisitor.h" #include "Base/Const/Units.h" #include "GUI/Models/ComboProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FormFactorItems.h" #include "GUI/Models/InterferenceFunctionItems.h" #include "GUI/Models/LayerItem.h" @@ -30,7 +31,6 @@ #include "GUI/Models/TransformationItem.h" #include "GUI/Models/VectorItem.h" #include "GUI/Views/MaterialEditor/MaterialItemUtils.h" -#include "GUI/utils/GUIHelpers.h" #include "Param/Node/NodeUtils.h" #include "Sample/Aggregate/ParticleLayout.h" #include "Sample/HardParticle/HardParticles.h" @@ -54,8 +54,8 @@ SessionItem* AddFormFactorItem(SessionItem* parent, const QString& model_type) else if (parent_type == "MesoCrystal") property_name = MesoCrystalItem::P_OUTER_SHAPE; if (property_name.isEmpty()) - throw GUIHelpers::Error("AddFormFactorItem: parent is neither ParticleItem or " - "MesoCrystalItem"); + throw Error("AddFormFactorItem: parent is neither ParticleItem or " + "MesoCrystalItem"); return parent->setGroupProperty(property_name, model_type); } } // namespace @@ -157,8 +157,8 @@ void GUIDomainSampleVisitor::visit(const Crystal* sample) SessionItem* mesocrystal_item = m_levelToParentItem[depth() - 1]; ASSERT(mesocrystal_item); if (mesocrystal_item->modelType() != "MesoCrystal") { - throw GUIHelpers::Error("GUIObjectBuilder::visit(const Crystal*) " - "-> Error. Parent is not a MesoCrystal"); + throw Error("GUIObjectBuilder::visit(const Crystal*) " + "-> Error. Parent is not a MesoCrystal"); } auto lattice = sample->transformedLattice(); auto vector_a = lattice.getBasisVectorA(); @@ -581,8 +581,8 @@ ExternalProperty GUIDomainSampleVisitor::createMaterialFromDomain(const Material materialItem = m_materialModel->addSLDMaterial(materialName, material_data.real(), material_data.imag()); } else { - throw GUIHelpers::Error("GUIObjectBuilder::createMaterialFromDomain() -> Error. " - "Unsupported material"); + throw Error("GUIObjectBuilder::createMaterialFromDomain() -> Error. " + "Unsupported material"); } materialItem->setMagnetization(material->magnetization()); @@ -606,8 +606,8 @@ SessionItem* GUIDomainSampleVisitor::InsertIParticle(const IParticle* particle, } else if (particle == coreshell->shellParticle()) { tag = ParticleCoreShellItem::T_SHELL; } else { - throw GUIHelpers::Error("GUIObjectBuilder::InsertIParticle:" - "Particle not found in parent ParticleCoreShell"); + throw Error("GUIObjectBuilder::InsertIParticle:" + "Particle not found in parent ParticleCoreShell"); } } } diff --git a/GUI/Models/GUIObjectBuilder.cpp b/GUI/Models/GUIObjectBuilder.cpp index 25996116492ad35ccba221c6664f4ead460702ec..98575191a4ced79ce6dfcf3113f257b0410fa9a9 100644 --- a/GUI/Models/GUIObjectBuilder.cpp +++ b/GUI/Models/GUIObjectBuilder.cpp @@ -17,13 +17,13 @@ #include "Core/Simulation/includeSimulations.h" #include "GUI/Models/AxesItems.h" #include "GUI/Models/DocumentModel.h" +#include "GUI/Models/Error.h" #include "GUI/Models/GUIDomainSampleVisitor.h" #include "GUI/Models/InstrumentItems.h" #include "GUI/Models/InstrumentModel.h" #include "GUI/Models/SampleModel.h" #include "GUI/Models/SimulationOptionsItem.h" #include "GUI/Models/TransformFromDomain.h" -#include "GUI/utils/GUIHelpers.h" #include "Sample/Multilayer/MultiLayer.h" namespace { @@ -77,8 +77,8 @@ SessionItem* GUIObjectBuilder::populateInstrumentModel(InstrumentModel* p_instru return createSpecularInstrumentItem(p_instrument_model, *spec_simulation, name); } - throw GUIHelpers::Error("GUIObjectBuilder::populateInstrumentModel() -> Error. ISimulation is " - "not yet supported"); + throw Error("GUIObjectBuilder::populateInstrumentModel() -> Error. ISimulation is " + "not yet supported"); } SessionItem* GUIObjectBuilder::populateDocumentModel(DocumentModel* p_document_model, diff --git a/GUI/Models/GroupInfo.cpp b/GUI/Models/GroupInfo.cpp index 8142091f0a82bc58d534d2485197565ca39701fc..882d2203b04a2a26cdd50851b2ff260b6e729e61 100644 --- a/GUI/Models/GroupInfo.cpp +++ b/GUI/Models/GroupInfo.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "GUI/Models/GroupInfo.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" GroupInfo::GroupInfo(const QString& groupType, bool is_sorted) : m_groupType(groupType), is_sorted(is_sorted) @@ -23,12 +23,12 @@ GroupInfo::GroupInfo(const QString& groupType, bool is_sorted) void GroupInfo::add(const QString& itemType, const QString& itemLabel) { if (groupType().isEmpty()) - throw GUIHelpers::Error("GroupInfo::add() -> Error. Empty group name"); + throw Error("GroupInfo::add() -> Error. Empty group name"); if (containsType(itemType)) - throw GUIHelpers::Error("GroupInfo::add() -> Error. " - "Model type '" - + itemType + "' already exists."); + throw Error("GroupInfo::add() -> Error. " + "Model type '" + + itemType + "' already exists."); m_info.push_back({itemType, itemLabel}); @@ -47,7 +47,7 @@ QString GroupInfo::defaultType() const void GroupInfo::setDefaultType(const QString& modelType) { if (!containsType(modelType)) - throw GUIHelpers::Error("GroupInfo::add() -> Error. No such type '" + modelType + "'"); + throw Error("GroupInfo::add() -> Error. No such type '" + modelType + "'"); m_defaultItemType = modelType; } diff --git a/GUI/Models/GroupInfoCatalog.cpp b/GUI/Models/GroupInfoCatalog.cpp index e91ee032db4be4bbe58888ebd73373ed0f2db975..87fae3c95e3cf580f2face4c961b625cbeff4218 100644 --- a/GUI/Models/GroupInfoCatalog.cpp +++ b/GUI/Models/GroupInfoCatalog.cpp @@ -15,10 +15,10 @@ #include "GUI/Models/GroupInfoCatalog.h" #include "GUI/Models/AxesItems.h" #include "GUI/Models/DistributionItems.h" +#include "GUI/Models/Error.h" #include "GUI/Models/MaterialDataItems.h" #include "GUI/Models/PointwiseAxisItem.h" #include "GUI/Models/RealLimitsItems.h" -#include "GUI/utils/GUIHelpers.h" GroupInfoCatalog::GroupInfoCatalog() { @@ -209,8 +209,8 @@ GroupInfo GroupInfoCatalog::groupInfo(const QString& groupType) const if (info.groupType() == groupType) return info; - throw GUIHelpers::Error("GroupInfoCatalog::groupInfo() -> Error. No such group '" + groupType - + "'"); + throw Error("GroupInfoCatalog::groupInfo() -> Error. No such group '" + groupType + + "'"); } bool GroupInfoCatalog::containsGroup(const QString& groupType) const @@ -225,8 +225,8 @@ bool GroupInfoCatalog::containsGroup(const QString& groupType) const void GroupInfoCatalog::addInfo(const GroupInfo& info) { if (containsGroup(info.groupType())) - throw GUIHelpers::Error("GroupInfoCatalog::addInfo -> Error. Already exists '" - + info.groupType() + "'"); + throw Error("GroupInfoCatalog::addInfo -> Error. Already exists '" + + info.groupType() + "'"); m_groups.push_back(info); } diff --git a/GUI/Models/GroupItem.cpp b/GUI/Models/GroupItem.cpp index 4d828fc77eec9e69b8bb36086e035381ea82e877..e70959f193a666676e2447a35dc7b5456693b3f7 100644 --- a/GUI/Models/GroupItem.cpp +++ b/GUI/Models/GroupItem.cpp @@ -14,7 +14,7 @@ #include "GUI/Models/GroupItem.h" #include "GUI/Models/ComboProperty.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" const QString GroupItem::T_ITEMS = "Item tag"; @@ -31,7 +31,7 @@ GroupItem::~GroupItem() = default; void GroupItem::setGroupInfo(const GroupInfo& groupInfo) { if (m_controller) - throw GUIHelpers::Error("GroupItem::setGroup() -> Error. Attempt to set group twice."); + throw Error("GroupItem::setGroup() -> Error. Attempt to set group twice."); m_controller = std::make_unique<GroupItemController>(this, groupInfo); updateComboValue(); @@ -62,7 +62,7 @@ SessionItem* GroupItem::getItemOfType(const QString& type) void GroupItem::onValueChange() { if (!value().canConvert<ComboProperty>()) - throw GUIHelpers::Error("GroupItem::onValueChange() -> Error. Wrong property type"); + throw Error("GroupItem::onValueChange() -> Error. Wrong property type"); ComboProperty property = value().value<ComboProperty>(); if (property.currentIndex() != m_controller->currentIndex()) { diff --git a/GUI/Models/InstrumentItems.cpp b/GUI/Models/InstrumentItems.cpp index cd2f50eb6c64d23b7095202a3db8e46c7f0c71ad..9799308f92b545d068a44a2d61085671ed9cd66a 100644 --- a/GUI/Models/InstrumentItems.cpp +++ b/GUI/Models/InstrumentItems.cpp @@ -25,6 +25,7 @@ #include "GUI/Models/BeamWavelengthItem.h" #include "GUI/Models/DataItem.h" #include "GUI/Models/DetectorItems.h" +#include "GUI/Models/Error.h" #include "GUI/Models/GroupItem.h" #include "GUI/Models/ItemFileNameUtils.h" #include "GUI/Models/JobItemUtils.h" @@ -160,8 +161,8 @@ std::vector<int> SpecularInstrumentItem::shape() const void SpecularInstrumentItem::updateToRealData(const RealDataItem* item) { if (shape().size() != item->shape().size()) - throw GUIHelpers::Error("Error in SpecularInstrumentItem::updateToRealData: The type " - "of instrument is incompatible with passed data shape."); + throw Error("Error in SpecularInstrumentItem::updateToRealData: The type " + "of instrument is incompatible with passed data shape."); const auto& data = item->nativeOutputData()->axis(0); beamItem()->updateToData(data, item->nativeDataUnits()); @@ -284,8 +285,8 @@ void GISASInstrumentItem::updateToRealData(const RealDataItem* item) const auto data_shape = item->shape(); if (shape().size() != data_shape.size()) - throw GUIHelpers::Error("Error in GISASInstrumentItem::updateToRealData: The type of " - "instrument is incompatible with passed data shape."); + throw Error("Error in GISASInstrumentItem::updateToRealData: The type of " + "instrument is incompatible with passed data shape."); detectorItem()->setXSize(data_shape[0]); detectorItem()->setYSize(data_shape[1]); } @@ -334,8 +335,8 @@ void OffSpecularInstrumentItem::updateToRealData(const RealDataItem* dataItem) const auto data_shape = dataItem->shape(); if (shape().size() != data_shape.size()) - throw GUIHelpers::Error("Error in OffSpecularInstrumentItem::updateToRealData: The type of " - "instrument is incompatible with passed data shape."); + throw Error("Error in OffSpecularInstrumentItem::updateToRealData: The type of " + "instrument is incompatible with passed data shape."); item<BasicAxisItem>(P_ALPHA_AXIS)->setBinCount(data_shape[0]); detectorItem()->setYSize(data_shape[1]); diff --git a/GUI/Models/IntensityDataItem.cpp b/GUI/Models/IntensityDataItem.cpp index c930e375691e2450c08385ec2657877fd8d841a0..272f0e3572ce53e0ece4a84fe14aad4aa69fe522 100644 --- a/GUI/Models/IntensityDataItem.cpp +++ b/GUI/Models/IntensityDataItem.cpp @@ -14,13 +14,13 @@ #include "GUI/Models/IntensityDataItem.h" #include "GUI/Models/AxesItems.h" +#include "GUI/Models/Error.h" #include "GUI/Models/JobItemUtils.h" #include "GUI/Models/MaskItems.h" #include "GUI/Models/ProjectionItems.h" #include "GUI/Models/SessionModel.h" #include "GUI/Views/ImportDataWidgets/ImportDataUtils.h" #include "GUI/Views/MaskWidgets/MaskUnitsConverter.h" -#include "GUI/utils/GUIHelpers.h" namespace { ComboProperty gradientCombo() @@ -88,7 +88,7 @@ void IntensityDataItem::setOutputData(OutputData<double>* data) { ASSERT(data && "Assertion failed in IntensityDataItem::setOutputData: nullptr data passed"); if (data->rank() != 2) - throw GUIHelpers::Error( + throw Error( "Error in IntensityDataItem::setOutputData: cannot handle non-2D data"); DataItem::setOutputData(data); diff --git a/GUI/Models/ItemCatalog.cpp b/GUI/Models/ItemCatalog.cpp index 34342b48720dc273e984571235e2de323c3c7dcd..ffbe07b272d499e10b7b72fa4a77514e85b11dfa 100644 --- a/GUI/Models/ItemCatalog.cpp +++ b/GUI/Models/ItemCatalog.cpp @@ -19,6 +19,7 @@ #include "GUI/Models/Data1DViewItem.h" #include "GUI/Models/DataProperties.h" #include "GUI/Models/DataPropertyContainer.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FTDecayFunctionItems.h" #include "GUI/Models/FTDistributionItems.h" #include "GUI/Models/FitParameterItems.h" @@ -59,7 +60,6 @@ #include "GUI/Models/SphericalDetectorItem.h" #include "GUI/Models/TransformationItem.h" #include "GUI/Models/VectorItem.h" -#include "GUI/utils/GUIHelpers.h" ItemCatalog::ItemCatalog() { @@ -244,8 +244,8 @@ ItemCatalog::ItemCatalog() std::unique_ptr<SessionItem> ItemCatalog::createItemPtr(const QString& modelType) const { if (!m_data.contains(modelType)) - throw GUIHelpers::Error("ItemFactory::createItem() -> Error: Model name does not exist: " - + modelType); + throw Error("ItemFactory::createItem() -> Error: Model name does not exist: " + + modelType); return m_data.createItemPtr(modelType); } diff --git a/GUI/Models/JobModelFunctions.cpp b/GUI/Models/JobModelFunctions.cpp index 39e4afb4a38b70b59ba97037d166a4b5d02f4613..1d8a918b5a4711574356184e26bf60e74e5ae2a7 100644 --- a/GUI/Models/JobModelFunctions.cpp +++ b/GUI/Models/JobModelFunctions.cpp @@ -20,6 +20,7 @@ #include "GUI/Models/DataPropertyContainer.h" #include "GUI/Models/DetectorItems.h" #include "GUI/Models/DomainObjectBuilder.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FitParameterItems.h" #include "GUI/Models/FitSuiteItem.h" #include "GUI/Models/GroupItem.h" @@ -151,8 +152,8 @@ void JobModelFunctions::setupJobItemOutput(JobItem* jobItem) else if (isIntensityInstrument) jobItem->model()->insertItem<IntensityDataItem>(jobItem, -1, JobItem::T_OUTPUT); else - throw GUIHelpers::Error("JobModelFunctions::setupJobItemOutput() -> Error. " - "Unsupported instrument type"); + throw Error("JobModelFunctions::setupJobItemOutput() -> Error. " + "Unsupported instrument type"); } //! Setups JobItem for fit. @@ -160,8 +161,8 @@ void JobModelFunctions::setupJobItemOutput(JobItem* jobItem) void JobModelFunctions::setupJobItemForFit(JobItem* jobItem, const RealDataItem* realDataItem) { if (!jobItem->instrumentItem()) - throw GUIHelpers::Error("JobModelFunctions::processInstrumentLink() -> Error. " - "No instrument."); + throw Error("JobModelFunctions::processInstrumentLink() -> Error. " + "No instrument."); copyRealDataItem(jobItem, realDataItem); processInstrumentLink(jobItem); @@ -223,7 +224,7 @@ void processInstrumentLink(JobItem* jobItem) { RealDataItem* realData = jobItem->realDataItem(); if (!realData) - throw GUIHelpers::Error("JobModelFunctions::processInstrumentLink() -> Error. No data."); + throw Error("JobModelFunctions::processInstrumentLink() -> Error. No data."); realData->setInstrumentId(jobItem->instrumentItem()->id()); realData->updateToInstrument(jobItem->instrumentItem()); @@ -261,8 +262,8 @@ void createFitContainers(JobItem* jobItem) SessionItem* fitSuiteItem = jobItem->getItem(JobItem::T_FIT_SUITE); if (fitSuiteItem != nullptr) { - throw GUIHelpers::Error("JobModel::createFitContainers() -> Error. Attempt to create " - "a second FitSuiteItem."); + throw Error("JobModel::createFitContainers() -> Error. Attempt to create " + "a second FitSuiteItem."); } fitSuiteItem = model->insertItem<FitSuiteItem>(jobItem, -1, JobItem::T_FIT_SUITE); @@ -270,8 +271,8 @@ void createFitContainers(JobItem* jobItem) SessionItem* parsContainerItem = fitSuiteItem->getItem(FitSuiteItem::T_FIT_PARAMETERS_CONTAINER); if (parsContainerItem != nullptr) { - throw GUIHelpers::Error("JobModel::createFitContainers() -> Error. Attempt to create " - "a second FitParameterContainer."); + throw Error("JobModel::createFitContainers() -> Error. Attempt to create " + "a second FitParameterContainer."); } model->insertItem<FitParameterContainerItem>(fitSuiteItem, -1, @@ -280,8 +281,8 @@ void createFitContainers(JobItem* jobItem) // Minimizer settings SessionItem* minimizerContainerItem = fitSuiteItem->getItem(FitSuiteItem::T_MINIMIZER); if (minimizerContainerItem != nullptr) { - throw GUIHelpers::Error("JobModel::createFitContainers() -> Error. Attempt to create " - "a second MinimizerContainer."); + throw Error("JobModel::createFitContainers() -> Error. Attempt to create " + "a second MinimizerContainer."); } model->insertItem<MinimizerContainerItem>(fitSuiteItem, -1, FitSuiteItem::T_MINIMIZER); diff --git a/GUI/Models/JobQueueData.cpp b/GUI/Models/JobQueueData.cpp index 5ddb8f3bd1788fc815675d7822159a958516e4e9..5f269176ab69b452b2e8c9caf754df6a661812e6 100644 --- a/GUI/Models/JobQueueData.cpp +++ b/GUI/Models/JobQueueData.cpp @@ -15,6 +15,7 @@ #include "GUI/Models/JobQueueData.h" #include "Core/Simulation/GISASSimulation.h" #include "GUI/Models/DomainSimulationBuilder.h" +#include "GUI/Models/Error.h" #include "GUI/Models/InstrumentItems.h" #include "GUI/Models/JobItem.h" #include "GUI/Models/JobModel.h" @@ -41,7 +42,7 @@ void JobQueueData::runJob(JobItem* jobItem) return; if (getSimulation(identifier)) - throw GUIHelpers::Error( + throw Error( "JobQueueData::runJob() -> Error. ISimulation is already existing."); try { @@ -193,7 +194,7 @@ void JobQueueData::assignForDeletion(QThread* thread) } } - throw GUIHelpers::Error("JobQueueData::assignForDeletion() -> Error! Can't find thread."); + throw Error("JobQueueData::assignForDeletion() -> Error! Can't find thread."); } //! Removes JobRunner from the map of known runners, assigns it for deletion. @@ -210,7 +211,7 @@ void JobQueueData::assignForDeletion(JobWorker* worker) } } - throw GUIHelpers::Error("JobQueueData::assignForDeletion() -> Error! Can't find the runner."); + throw Error("JobQueueData::assignForDeletion() -> Error! Can't find the runner."); } void JobQueueData::clearSimulation(const QString& identifier) diff --git a/GUI/Models/MaskItems.cpp b/GUI/Models/MaskItems.cpp index cce94698b92cdb2b44e34a5e2c3eca48d2802fa3..e971d6969b33d41cb970349c72b3a12517f39755 100644 --- a/GUI/Models/MaskItems.cpp +++ b/GUI/Models/MaskItems.cpp @@ -18,7 +18,7 @@ #include "Device/Mask/Line.h" #include "Device/Mask/Polygon.h" #include "Device/Mask/Rectangle.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" MaskContainerItem::MaskContainerItem() : SessionItem("MaskContainer") { @@ -48,7 +48,7 @@ MaskItem::MaskItem(const QString& name) : SessionItem(name) std::unique_ptr<IShape2D> MaskItem::createShape(double scale) const { Q_UNUSED(scale); - throw GUIHelpers::Error("MaskItem::createShape() -> Not implemented."); + throw Error("MaskItem::createShape() -> Not implemented."); } /* ------------------------------------------------------------------------- */ diff --git a/GUI/Models/MaterialItem.cpp b/GUI/Models/MaterialItem.cpp index aa95bfd01ebbf6b6fa79f27910305809687ccaa9..7ec6fcce27ed661aca3798c62b06a7297a1a4362 100644 --- a/GUI/Models/MaterialItem.cpp +++ b/GUI/Models/MaterialItem.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/Models/MaterialDataItems.h" +#include "GUI/Models/Error.h" #include "GUI/Models/SessionItemUtils.h" #include "GUI/Models/VectorItem.h" #include "GUI/Views/MaterialEditor/MaterialItemUtils.h" @@ -141,6 +142,6 @@ std::unique_ptr<Material> MaterialItem::createMaterial() const return std::make_unique<Material>(MaterialBySLD(name, sld_real, sld_imag, magnetization)); } - throw GUIHelpers::Error("MaterialItem::createMaterial() -> Error. " - "Not implemented material type"); + throw Error("MaterialItem::createMaterial() -> Error. " + "Not implemented material type"); } diff --git a/GUI/Models/MesoCrystalItem.cpp b/GUI/Models/MesoCrystalItem.cpp index 9a4be55f3399d6b607c9bbf9e8f6ce8794f0af3e..ca0358609638b8b84620b634d0edf969957a150d 100644 --- a/GUI/Models/MesoCrystalItem.cpp +++ b/GUI/Models/MesoCrystalItem.cpp @@ -14,6 +14,7 @@ #include "GUI/Models/MesoCrystalItem.h" #include "GUI/Models/ComboProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FormFactorItems.h" #include "GUI/Models/ModelPath.h" #include "GUI/Models/ParticleCompositionItem.h" @@ -22,7 +23,6 @@ #include "GUI/Models/SessionItemUtils.h" #include "GUI/Models/TransformToDomain.h" #include "GUI/Models/VectorItem.h" -#include "GUI/utils/GUIHelpers.h" #include "Sample/Particle/Crystal.h" #include "Sample/Particle/MesoCrystal.h" #include "Sample/Particle/Particle.h" @@ -100,18 +100,18 @@ std::unique_ptr<MesoCrystal> MesoCrystalItem::createMesoCrystal() const { const Lattice3D& lattice = getLattice(); if (!(lattice.unitCellVolume() > 0.0)) - throw GUIHelpers::Error("MesoCrystalItem::createMesoCrystal(): " - "Lattice volume not strictly positive"); + throw Error("MesoCrystalItem::createMesoCrystal(): " + "Lattice volume not strictly positive"); std::unique_ptr<IParticle> basis = getBasis(); if (!basis) - throw GUIHelpers::Error("MesoCrystalItem::createMesoCrystal(): " - "No basis particle defined"); + throw Error("MesoCrystalItem::createMesoCrystal(): " + "No basis particle defined"); Crystal crystal(*basis, lattice); std::unique_ptr<IFormFactor> ff = getOuterShape(); if (!ff) - throw GUIHelpers::Error("MesoCrystalItem::createMesoCrystal(): " - "No outer shape defined"); + throw Error("MesoCrystalItem::createMesoCrystal(): " + "No outer shape defined"); auto result = std::make_unique<MesoCrystal>(crystal, *ff); TransformToDomain::setTransformationInfo(result.get(), *this); diff --git a/GUI/Models/ParameterTreeUtils.cpp b/GUI/Models/ParameterTreeUtils.cpp index e8d9c286ba8e49404922970a70b119395e5c1dce..44813af68f442b4e7b40474dcfb466978f67a0c5 100644 --- a/GUI/Models/ParameterTreeUtils.cpp +++ b/GUI/Models/ParameterTreeUtils.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/Models/ParameterTreeUtils.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FitParameterHelper.h" #include "GUI/Models/GroupItem.h" #include "GUI/Models/JobItem.h" @@ -20,7 +21,6 @@ #include "GUI/Models/MultiLayerItem.h" #include "GUI/Models/ParameterTreeItems.h" #include "GUI/Models/SampleModel.h" -#include "GUI/utils/GUIHelpers.h" #include <QStack> namespace { @@ -75,8 +75,8 @@ void handleItem(SessionItem* tree, const SessionItem* source) void populateParameterContainer(SessionItem* container, const SessionItem* source) { if (container->modelType() != "Parameter Container") - throw GUIHelpers::Error("ParameterTreeUtils::populateParameterContainer() -> Error. " - "Not a ParameterContainerType."); + throw Error("ParameterTreeUtils::populateParameterContainer() -> Error. " + "Not a ParameterContainerType."); auto sourceLabel = container->model()->insertItem<ParameterLabelItem>(container); handleItem(sourceLabel, source); diff --git a/GUI/Models/ParticleCoreShellItem.cpp b/GUI/Models/ParticleCoreShellItem.cpp index 399b7c8278292a1fc2c43fe471f892961465b0d1..71b3c58043f2fe95ee647c73e68a848888191a8a 100644 --- a/GUI/Models/ParticleCoreShellItem.cpp +++ b/GUI/Models/ParticleCoreShellItem.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "GUI/Models/ParticleCoreShellItem.h" +#include "GUI/Models/Error.h" #include "GUI/Models/ModelPath.h" #include "GUI/Models/ParticleItem.h" #include "GUI/Models/SessionItemUtils.h" #include "GUI/Models/TransformToDomain.h" #include "GUI/Models/VectorItem.h" -#include "GUI/utils/GUIHelpers.h" #include "Sample/Particle/Particle.h" #include "Sample/Particle/ParticleCoreShell.h" @@ -78,8 +78,8 @@ std::unique_ptr<ParticleCoreShell> ParticleCoreShellItem::createParticleCoreShel if (shell_item) P_shell = shell_item->createParticle(); if (!P_core || !P_shell) - throw GUIHelpers::Error("ParticleCoreShellItem::createParticleCoreShell -> Error. Either " - "core or shell particle is undefined."); + throw Error("ParticleCoreShellItem::createParticleCoreShell -> Error. Either " + "core or shell particle is undefined."); auto P_coreshell = std::make_unique<ParticleCoreShell>(*P_shell, *P_core); P_coreshell->setAbundance(abundance); TransformToDomain::setTransformationInfo(P_coreshell.get(), *this); diff --git a/GUI/Models/RealDataItem.cpp b/GUI/Models/RealDataItem.cpp index a253e727b86287fb488fefe5484ae70b2c96bb7d..9e0f17ed26bc53a920a9b3af0abca9172bb7173d 100644 --- a/GUI/Models/RealDataItem.cpp +++ b/GUI/Models/RealDataItem.cpp @@ -16,6 +16,7 @@ #include "Device/Data/DataUtils.h" #include "GUI/DataLoaders/AbstractDataLoader1D.h" #include "GUI/DataLoaders/DataLoaders1D.h" +#include "GUI/Models/Error.h" #include "GUI/Models/InstrumentItems.h" #include "GUI/Models/InstrumentModel.h" #include "GUI/Models/IntensityDataItem.h" @@ -28,7 +29,6 @@ #include "GUI/Models/SessionModel.h" #include "GUI/Models/SpecularDataItem.h" #include "GUI/utils/DeserializationException.h" -#include "GUI/utils/GUIHelpers.h" #include "GUI/utils/ImportDataInfo.h" #include <QtCore/QXmlStreamReader> #include <QtCore/QXmlStreamWriter> @@ -183,8 +183,8 @@ void RealDataItem::initDataItem(size_t rank, const QString& tag) if (data_item != nullptr) { if ((rank == 1 && !data_item->is<SpecularDataItem>()) || (rank == 2 && !data_item->is<IntensityDataItem>())) - throw GUIHelpers::Error("Error in RealDataItem::initDataItem: trying to set data " - "incompatible with underlying data item"); + throw Error("Error in RealDataItem::initDataItem: trying to set data " + "incompatible with underlying data item"); } else { if (rank == 1) model()->insertItem<SpecularDataItem>(this, 0, tag); diff --git a/GUI/Models/RectangularDetectorItem.cpp b/GUI/Models/RectangularDetectorItem.cpp index 5230b55a6a20a8946b43ab3f1ddd09fd261691e8..897be27b9a7eb29ea6606fe121b48c245a09324b 100644 --- a/GUI/Models/RectangularDetectorItem.cpp +++ b/GUI/Models/RectangularDetectorItem.cpp @@ -16,9 +16,9 @@ #include "Device/Detector/RectangularDetector.h" #include "GUI/Models/AxesItems.h" #include "GUI/Models/ComboProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/ResolutionFunctionItems.h" #include "GUI/Models/VectorItem.h" -#include "GUI/utils/GUIHelpers.h" namespace { const double default_detector_width = 20.0; @@ -130,7 +130,7 @@ void RectangularDetectorItem::setDetectorAlignment(const QString& alignment) getItemValue(RectangularDetectorItem::P_ALIGNMENT).value<ComboProperty>(); if (!combo_property.getValues().contains(alignment)) - throw GUIHelpers::Error( + throw Error( "RectangularDetectorItem::setDetectorAlignment -> Unexpected alignment"); combo_property.setValue(alignment); diff --git a/GUI/Models/SessionItemTags.cpp b/GUI/Models/SessionItemTags.cpp index 024644fac115035b3e2bd0177eb1408c7cd527bd..4d44b8c44ee2d96fce8087911f76344b7665e963 100644 --- a/GUI/Models/SessionItemTags.cpp +++ b/GUI/Models/SessionItemTags.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "GUI/Models/SessionItemTags.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" //! Register tag with given parameters. Returns true in case of success. Returns //! false if parameters are invalid or such tag was already registered. @@ -62,7 +62,7 @@ int SessionItemTags::tagStartIndex(const QString& tagName) const return index; index += tag.childCount; } - throw GUIHelpers::Error("SessionItemTags::tagStartIndex() -> Error. Can';t find start index"); + throw Error("SessionItemTags::tagStartIndex() -> Error. Can';t find start index"); } //! Returns index in SessionItem's m_children corresponding to given row in tagName. @@ -70,7 +70,7 @@ int SessionItemTags::tagStartIndex(const QString& tagName) const int SessionItemTags::indexFromTagRow(const QString& tagName, int row) const { if (row < 0 || row >= tagInfo(tagName).childCount) - throw GUIHelpers::Error("SessionItemTags::tagIndexFromRow() -> Error. Wrong row"); + throw Error("SessionItemTags::tagIndexFromRow() -> Error. Wrong row"); return tagStartIndex(tagName) + row; } @@ -114,7 +114,7 @@ int SessionItemTags::childMax(const QString& tagName) void SessionItemTags::addChild(const QString& tagName) { if (maximumReached(tagName)) - throw GUIHelpers::Error("SessionItemTags::addChild() -> Error. Can't exceed maximum" + throw Error("SessionItemTags::addChild() -> Error. Can't exceed maximum" "allowed number of children."); tagInfo(tagName).childCount++; } @@ -123,8 +123,8 @@ void SessionItemTags::removeChild(const QString& tagName) { auto& tag = tagInfo(tagName); if (tag.childCount == 0) - throw GUIHelpers::Error("SessionItemTags::removeChild() -> Error. Attempt to remove " - "unexisting child."); + throw Error("SessionItemTags::removeChild() -> Error. Attempt to remove " + "unexisting child."); tag.childCount--; } @@ -146,7 +146,7 @@ const SessionItemTags::TagInfo& SessionItemTags::tagInfo(const QString& tagName) for (const auto& tag : m_tags) if (tag.name == tagName) return tag; - throw GUIHelpers::Error("SessionItemTags::tagInfo() -> Error. No such tag '" + tagName + "'."); + throw Error("SessionItemTags::tagInfo() -> Error. No such tag '" + tagName + "'."); } bool SessionItemTags::maximumReached(const QString& tagName) const diff --git a/GUI/Models/SessionModel.cpp b/GUI/Models/SessionModel.cpp index c1fc4494bc9ff0c0184774cdcebdd491b7602aa8..b3c2c936276604ece380fc3eeebc6e1483788d42 100644 --- a/GUI/Models/SessionModel.cpp +++ b/GUI/Models/SessionModel.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/Models/SessionModel.h" +#include "GUI/Models/Error.h" #include "GUI/Models/ItemFactory.h" #include "GUI/Models/SessionItemTags.h" #include "GUI/Models/SessionItemUtils.h" @@ -275,10 +276,10 @@ SessionItem* SessionModel::insertNewItem(QString model_type, SessionItem* parent SessionItem* new_item = ItemFactory::CreateItem(model_type); if (!new_item) - throw GUIHelpers::Error("SessionModel::insertNewItem() -> Wrong model type " + model_type); + throw Error("SessionModel::insertNewItem() -> Wrong model type " + model_type); if (!parent_item->insertItem(row, new_item, tag)) - throw GUIHelpers::Error("SessionModel::insertNewItem -> Error. Can't insert item"); + throw Error("SessionModel::insertNewItem -> Error. Can't insert item"); return new_item; } @@ -318,13 +319,13 @@ void SessionModel::load(const QString& filename) beginResetModel(); QFile file(filename); if (!file.open(QIODevice::ReadOnly)) - throw GUIHelpers::Error(file.errorString()); + throw Error(file.errorString()); clear(); m_root_item = ItemFactory::CreateEmptyItem(); QXmlStreamReader reader(&file); SessionXML::readItems(&reader, m_root_item); if (reader.hasError()) - throw GUIHelpers::Error(reader.errorString()); + throw Error(reader.errorString()); endResetModel(); } @@ -332,7 +333,7 @@ void SessionModel::save(const QString& filename) { QFile file(filename); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - throw GUIHelpers::Error(file.errorString()); + throw Error(file.errorString()); QXmlStreamWriter writer(&file); writer.setAutoFormatting(true); @@ -358,7 +359,7 @@ void SessionModel::readFrom(QXmlStreamReader* reader, MessageService* messageSer ASSERT(reader); if (reader->name() != m_model_tag) - throw GUIHelpers::Error("SessionModel::readFrom() -> Format error in p1"); + throw Error("SessionModel::readFrom() -> Format error in p1"); beginResetModel(); clear(); @@ -367,7 +368,7 @@ void SessionModel::readFrom(QXmlStreamReader* reader, MessageService* messageSer SessionXML::readItems(reader, m_root_item, QString(), messageService); if (reader->hasError()) - throw GUIHelpers::Error(reader->errorString()); + throw Error(reader->errorString()); endResetModel(); } @@ -437,7 +438,7 @@ SessionItem* SessionModel::copy(const SessionItem* item_to_copy, SessionItem* ne SessionModel* SessionModel::createCopy(SessionItem* parent) { Q_UNUSED(parent); - throw GUIHelpers::Error("SessionModel::createCopy() -> Error. Not implemented."); + throw Error("SessionModel::createCopy() -> Error. Not implemented."); } void SessionModel::initFrom(SessionModel* model, SessionItem*) diff --git a/GUI/Models/SessionXML.cpp b/GUI/Models/SessionXML.cpp index 255a6ef8686b3c939338c824198136e531cb204d..d9492393687535be7c6846870614a71bca1de316 100644 --- a/GUI/Models/SessionXML.cpp +++ b/GUI/Models/SessionXML.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/Models/ComboProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/ExternalProperty.h" #include "GUI/Models/GroupItem.h" #include "GUI/Models/GroupItemController.h" @@ -20,7 +21,6 @@ #include "GUI/Models/SessionItemTags.h" #include "GUI/Models/SessionModel.h" #include "GUI/utils/DeserializationException.h" -#include "GUI/utils/GUIHelpers.h" #include "GUI/utils/MessageService.h" #include <QtCore/QXmlStreamWriter> @@ -111,8 +111,8 @@ void SessionXML::writeVariant(QXmlStreamWriter* writer, QVariant variant, int ro writer->writeAttribute(SessionXML::ParameterExtAttribute, combo.stringOfValues()); } else { - throw GUIHelpers::Error("SessionXML::writeVariant: Parameter type not supported " - + type_name); + throw Error("SessionXML::writeVariant: Parameter type not supported " + + type_name); } writer->writeEndElement(); // end ParameterTag @@ -251,7 +251,7 @@ QString SessionXML::readProperty(QXmlStreamReader* reader, SessionItem* item, } else { QString message = QString("SessionModel::readProperty: parameter type not supported '" + parameter_type + "'"); - throw GUIHelpers::Error(message); + throw Error(message); } if (variant.isValid()) { @@ -267,7 +267,7 @@ void report_error(MessageService* messageService, SessionItem* item, const QStri if (messageService) { messageService->send_warning(item->model(), message); } else { - throw GUIHelpers::Error(QString("Warning: ") + message); + throw Error(QString("Warning: ") + message); } } diff --git a/GUI/Models/SpecularDataItem.cpp b/GUI/Models/SpecularDataItem.cpp index 0ae0a9b101265a626990a46be5b1a4ae79e82c08..2054473cedab38022fdbf6f96eb476e4eb4b1828 100644 --- a/GUI/Models/SpecularDataItem.cpp +++ b/GUI/Models/SpecularDataItem.cpp @@ -14,9 +14,9 @@ #include "GUI/Models/SpecularDataItem.h" #include "GUI/Models/AxesItems.h" +#include "GUI/Models/Error.h" #include "GUI/Models/JobItemUtils.h" #include "GUI/Views/ImportDataWidgets/ImportDataUtils.h" -#include "GUI/utils/GUIHelpers.h" const QString SpecularDataItem::P_TITLE = "Title"; const QString SpecularDataItem::P_XAXIS = "x-axis"; @@ -46,7 +46,7 @@ void SpecularDataItem::setOutputData(OutputData<double>* data) { if (data != nullptr) { if (data->rank() != 1) - throw GUIHelpers::Error( + throw Error( "Error in SpecularDataItem::setOutputData: cannot handle non-1D data"); DataItem::setOutputData(data); updateAxesZoomLevel(); diff --git a/GUI/Models/TransformFromDomain.cpp b/GUI/Models/TransformFromDomain.cpp index 12f30eca153a79450ef6b35c7adf87d4963a12c7..14ecf8eb04a353bdf2cd6415e8ad22b78f797e32 100644 --- a/GUI/Models/TransformFromDomain.cpp +++ b/GUI/Models/TransformFromDomain.cpp @@ -35,6 +35,7 @@ #include "GUI/Models/BackgroundItems.h" #include "GUI/Models/BeamAngleItems.h" #include "GUI/Models/BeamWavelengthItem.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FTDecayFunctionItems.h" #include "GUI/Models/FTDistributionItems.h" #include "GUI/Models/FootprintItems.h" @@ -50,7 +51,6 @@ #include "GUI/Models/SpecularBeamInclinationItem.h" #include "GUI/Models/SphericalDetectorItem.h" #include "GUI/Models/VectorItem.h" -#include "GUI/utils/GUIHelpers.h" #include "Param/Distrib/Distributions.h" #include "Param/Distrib/RangedDistributions.h" #include "Sample/Aggregate/InterferenceFunctions.h" @@ -306,7 +306,7 @@ void TransformFromDomain::setDetectorGeometry(Instrument2DItem* instrument_item, auto item = dynamic_cast<RectangularDetectorItem*>(instrument_item->detectorItem()); setRectangularDetector(item, *det); } else { - throw GUIHelpers::Error( + throw Error( "TransformFromDomain::setDetectorGeometry() -> Unknown detector type."); } } @@ -332,12 +332,12 @@ void TransformFromDomain::setDetectorResolution(DetectorItem* detector_item, item->setItemValue(ResolutionFunction2DGaussianItem::P_SIGMA_Y, scale * resfunc->getSigmaY()); } else { - throw GUIHelpers::Error("TransformFromDomain::setDetectorResolution() -> Error. " - "Unknown detector resolution function"); + throw Error("TransformFromDomain::setDetectorResolution() -> Error. " + "Unknown detector resolution function"); } } else { - throw GUIHelpers::Error("TransformFromDomain::setDetectorResolution() -> Error. " - "Not a ConvolutionDetectorResolution function"); + throw Error("TransformFromDomain::setDetectorResolution() -> Error. " + "Not a ConvolutionDetectorResolution function"); } } @@ -428,7 +428,7 @@ void TransformFromDomain::setRectangularDetector(RectangularDetectorItem* detect detector.getDirectBeamV0()); } else { - throw GUIHelpers::Error( + throw Error( "TransformFromDomain::setItemFromSample(RectangularDetectorItem* detectorItem " "Error. Unknown detector arrangement"); } @@ -519,8 +519,8 @@ void TransformFromDomain::setMaskContainer(MaskContainerItem* container_item, } else { - throw GUIHelpers::Error("TransformFromDomain::setDetectorMasks() -> Error. " - "Unknown shape"); + throw Error("TransformFromDomain::setDetectorMasks() -> Error. " + "Unknown shape"); } } @@ -543,7 +543,7 @@ void TransformFromDomain::setItemFromSample(BeamDistributionItem* beam_distribut ASSERT(beam_distribution_item); if (parameter_distribution.getMinValue() < parameter_distribution.getMaxValue()) { - throw GUIHelpers::Error( + throw Error( "TransformFromDomain::setItemFromSample(BeamDistributionItem* beamDistributionItem," "const ParameterDistribution& parameterDistribution) -> Error. ParameterDistribution " "with defined min,max are not yet implemented in GUI"); @@ -582,7 +582,7 @@ void TransformFromDomain::setFootprintFactor(const IFootprintFactor* footprint, void TransformFromDomain::setAxisItem(BasicAxisItem* item, const IAxis& axis, double factor) { if (!dynamic_cast<const FixedBinAxis*>(&axis)) - throw GUIHelpers::Error("TransformFromDomain::setAxisItem() -> Error. Unexpected axis"); + throw Error("TransformFromDomain::setAxisItem() -> Error. Unexpected axis"); item->setBinCount(static_cast<int>(axis.size())); item->setLowerBound(factor * axis.lowerBound()); @@ -617,7 +617,7 @@ void SetPDF1D(SessionItem* item, const IFTDistribution1D* ipdf, QString group_na pdfItem->setItemValue(FTDistribution1DVoigtItem::P_OMEGA, pdf->omega()); pdfItem->setItemValue(FTDistribution1DVoigtItem::P_ETA, pdf->eta()); } else { - throw GUIHelpers::Error("TransformFromDomain::setPDF1D: -> Error"); + throw Error("TransformFromDomain::setPDF1D: -> Error"); } } @@ -658,7 +658,7 @@ void setPDF2D(SessionItem* item, const IFTDistribution2D* pdf, QString group_nam Units::rad2deg(pdf_voigt->gamma())); pdfItem->setItemValue(FTDistribution2DVoigtItem::P_ETA, pdf_voigt->eta()); } else { - throw GUIHelpers::Error("TransformFromDomain::setPDF2D: -> Error"); + throw Error("TransformFromDomain::setPDF2D: -> Error"); } } @@ -681,7 +681,7 @@ void SetDecayFunction1D(SessionItem* item, const IFTDecayFunction1D* ipdf, QStri pdfItem->setItemValue(FTDecayFunction1DItem::P_DECAY_LENGTH, pdf->decayLength()); pdfItem->setItemValue(FTDecayFunction1DVoigtItem::P_ETA, pdf->eEta()); } else { - throw GUIHelpers::Error("TransformFromDomain::SetDecayFunction1D: -> Error"); + throw Error("TransformFromDomain::SetDecayFunction1D: -> Error"); } } @@ -707,7 +707,7 @@ void SetDecayFunction2D(SessionItem* item, const IFTDecayFunction2D* pdf, QStrin pdfItem->setItemValue(FTDecayFunction2DItem::P_GAMMA, Units::rad2deg(pdf_voigt->gamma())); pdfItem->setItemValue(FTDecayFunction2DVoigtItem::P_ETA, pdf_voigt->eta()); } else { - throw GUIHelpers::Error("TransformFromDomain::SetDecayFunction2D: -> Error"); + throw Error("TransformFromDomain::SetDecayFunction2D: -> Error"); } } @@ -792,7 +792,7 @@ void setDistribution(BeamDistributionItem* part_distr_item, ParameterDistributio distr_trapez_item->setRightWidth(factor * distr->getRightWidth()); distItem = distr_trapez_item; } else { - throw GUIHelpers::Error("TransformFromDomain::setDistribution: -> unknown distribution"); + throw Error("TransformFromDomain::setDistribution: -> unknown distribution"); } distItem->setNumberOfSamples(par_distr.getNbrSamples()); diff --git a/GUI/Models/TransformToDomain.cpp b/GUI/Models/TransformToDomain.cpp index 383e887294c804a82f5dd1d36be41e7ed8ee987c..1ed1e86e414ebe6428456dba771e782b9ca51ba5 100644 --- a/GUI/Models/TransformToDomain.cpp +++ b/GUI/Models/TransformToDomain.cpp @@ -21,6 +21,7 @@ #include "GUI/Models/BeamItems.h" #include "GUI/Models/BeamWavelengthItem.h" #include "GUI/Models/ComboProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FTDecayFunctionItems.h" #include "GUI/Models/FTDistributionItems.h" #include "GUI/Models/JobItem.h" @@ -44,7 +45,6 @@ #include "GUI/Models/TransformationItem.h" #include "GUI/Models/VectorItem.h" #include "GUI/Views/MaterialEditor/MaterialItemUtils.h" -#include "GUI/utils/GUIHelpers.h" #include "Param/Distrib/RangedDistributions.h" #include "Sample/Aggregate/InterferenceFunctions.h" #include "Sample/Particle/MesoCrystal.h" @@ -100,7 +100,7 @@ TransformToDomain::createLayerRoughness(const SessionItem& roughnessItem) roughnessItem.getItemValue(LayerBasicRoughnessItem::P_HURST).toDouble(), roughnessItem.getItemValue(LayerBasicRoughnessItem::P_LATERAL_CORR_LENGTH).toDouble()); } else { - throw GUIHelpers::Error("TransformToDomain::createLayerRoughness() -> Error."); + throw Error("TransformToDomain::createLayerRoughness() -> Error."); } } diff --git a/GUI/Views/CommonWidgets/DocksController.cpp b/GUI/Views/CommonWidgets/DocksController.cpp index ed517b1e25aba3076f21d1b91a1f79355be00fa2..4694491eef4f7b40574563a7106de33ebb97a8d7 100644 --- a/GUI/Views/CommonWidgets/DocksController.cpp +++ b/GUI/Views/CommonWidgets/DocksController.cpp @@ -14,7 +14,7 @@ #include "GUI/Views/CommonWidgets/DocksController.h" #include "Base/Utils/Assert.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" #include <QAbstractItemView> #include <QAction> #include <QDockWidget> @@ -80,8 +80,8 @@ QDockWidget* DocksController::addDockForWidget(QWidget* widget) void DocksController::addWidget(int id, QWidget* widget, Qt::DockWidgetArea area) { if (m_docks.find(id) != m_docks.end()) - throw GUIHelpers::Error("DocksController::addWidget() -> Error. " - "Attempt to add widget id twice"); + throw Error("DocksController::addWidget() -> Error. " + "Attempt to add widget id twice"); auto dock = addDockForWidget(widget); m_docks[id] = DockWidgetInfo(dock, widget, area); @@ -132,7 +132,7 @@ QDockWidget* DocksController::findDock(QWidget* widget) if (it.second.widget() == widget) return it.second.dock(); - throw GUIHelpers::Error("DocksController::findDock() -> Can't find dock for widget"); + throw Error("DocksController::findDock() -> Can't find dock for widget"); } const QList<QDockWidget*> DocksController::dockWidgets() const diff --git a/GUI/Views/CommonWidgets/ItemStackWidget.cpp b/GUI/Views/CommonWidgets/ItemStackWidget.cpp index 1da804ba6eed071a8fc92cf573fc7fba351e298e..41b99a637c2d32c2844fd64c251196dda7aac793 100644 --- a/GUI/Views/CommonWidgets/ItemStackWidget.cpp +++ b/GUI/Views/CommonWidgets/ItemStackWidget.cpp @@ -13,8 +13,8 @@ // ************************************************************************************************ #include "GUI/Views/CommonWidgets/ItemStackWidget.h" +#include "GUI/Models/Error.h" #include "GUI/Models/SessionModel.h" -#include "GUI/utils/GUIHelpers.h" #include <QStackedWidget> #include <QVBoxLayout> @@ -105,8 +105,8 @@ void ItemStackWidget::validateItem(SessionItem* item) if (m_model) { if (m_model != item->model()) // in principle it should be possible, but should be tested - throw GUIHelpers::Error("ItemStackWidget::validateItem() -> Error. " - "Attempt to use items from different models."); + throw Error("ItemStackWidget::validateItem() -> Error. " + "Attempt to use items from different models."); } else { setModel(item->model()); } diff --git a/GUI/Views/CommonWidgets/ModelTreeView.cpp b/GUI/Views/CommonWidgets/ModelTreeView.cpp index 2f8e1b26a478f94021737f8b3c9eac891a12ec83..bb3a5b7db0da837c7e53a83b5cd37828747f6e72 100644 --- a/GUI/Views/CommonWidgets/ModelTreeView.cpp +++ b/GUI/Views/CommonWidgets/ModelTreeView.cpp @@ -13,9 +13,9 @@ // ************************************************************************************************ #include "GUI/Views/CommonWidgets/ModelTreeView.h" +#include "GUI/Models/Error.h" #include "GUI/Models/SessionDecorationModel.h" #include "GUI/Models/SessionModel.h" -#include "GUI/utils/GUIHelpers.h" #include "GUI/utils/StyleUtils.h" #include <QTreeView> #include <QVBoxLayout> @@ -27,7 +27,7 @@ ModelTreeView::ModelTreeView(QWidget* parent, SessionModel* model) , m_is_expanded(false) { if (!model) - throw GUIHelpers::Error("ModelTreeView::ModelTreeView() -> Error. Nullptr as model."); + throw Error("ModelTreeView::ModelTreeView() -> Error. Nullptr as model."); setObjectName(model->getModelTag()); diff --git a/GUI/Views/FitWidgets/FitObjectiveBuilder.cpp b/GUI/Views/FitWidgets/FitObjectiveBuilder.cpp index a79b16d2f98e5d38e9bd617868e4978f9f9ea756..5de8f590cfd0df6e8c9c36e2352cfed0a57df4cd 100644 --- a/GUI/Views/FitWidgets/FitObjectiveBuilder.cpp +++ b/GUI/Views/FitWidgets/FitObjectiveBuilder.cpp @@ -20,6 +20,7 @@ #include "Fit/Minimizer/IMinimizer.h" #include "GUI/Models/DataItem.h" #include "GUI/Models/DomainSimulationBuilder.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FitParameterItems.h" #include "GUI/Models/FitSuiteItem.h" #include "GUI/Models/JobItem.h" @@ -115,7 +116,7 @@ std::unique_ptr<OutputData<double>> FitObjectiveBuilder::createOutputData() cons { auto realDataItem = m_jobItem->realDataItem(); if (!realDataItem) - throw GUIHelpers::Error("FitObjectiveBuilder::createOutputData() -> No Real Data defined."); + throw Error("FitObjectiveBuilder::createOutputData() -> No Real Data defined."); const DataItem* intensity_item = realDataItem->dataItem(); ASSERT(intensity_item); diff --git a/GUI/Views/FitWidgets/FitSessionController.cpp b/GUI/Views/FitWidgets/FitSessionController.cpp index 336fdb2f696c9d573e1da1ffb712cbd050537cde..3cac1792bccf03ad42e7c2aec170a9ca968929ed 100644 --- a/GUI/Views/FitWidgets/FitSessionController.cpp +++ b/GUI/Views/FitWidgets/FitSessionController.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/Views/FitWidgets/FitSessionController.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FitParameterItems.h" #include "GUI/Models/FitSuiteItem.h" #include "GUI/Models/IntensityDataItem.h" @@ -51,7 +52,7 @@ FitSessionController::~FitSessionController() = default; void FitSessionController::setItem(JobItem* item) { if (m_jobItem && m_jobItem != item) - throw GUIHelpers::Error("FitSuiteManager::setItem() -> Item was already set."); + throw Error("FitSuiteManager::setItem() -> Item was already set."); m_jobItem = item; ASSERT(m_jobItem); diff --git a/GUI/Views/FitWidgets/FitSessionManager.cpp b/GUI/Views/FitWidgets/FitSessionManager.cpp index ef31def86beccde79ca7fbb3745d4b311d569b81..90dd6f837c74d20e22b4af25cd2a49e7b37cda98 100644 --- a/GUI/Views/FitWidgets/FitSessionManager.cpp +++ b/GUI/Views/FitWidgets/FitSessionManager.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "GUI/Views/FitWidgets/FitSessionManager.h" +#include "GUI/Models/Error.h" #include "GUI/Models/JobItem.h" #include "GUI/Views/FitWidgets/FitLog.h" #include "GUI/Views/FitWidgets/FitSessionController.h" #include "GUI/Views/JobWidgets/JobMessagePanel.h" -#include "GUI/utils/GUIHelpers.h" FitSessionManager::FitSessionManager(QObject* parent) : QObject(parent), m_activeController(nullptr), m_jobMessagePanel(nullptr) @@ -73,8 +73,8 @@ void FitSessionManager::removeController(SessionItem* jobItem) { auto it = m_item_to_controller.find(jobItem); if (it == m_item_to_controller.end()) - throw GUIHelpers::Error("FitActivityManager::removeFitSession() -> Error. " - "Can't find fit session"); + throw Error("FitActivityManager::removeFitSession() -> Error. " + "Can't find fit session"); if (m_activeController == it.value()) m_activeController = nullptr; diff --git a/GUI/Views/ImportDataWidgets/RealDataPresenter.cpp b/GUI/Views/ImportDataWidgets/RealDataPresenter.cpp index fb09d05d84a15c242b6af78372addd0cc60c166e..05cfa1e362041533b14bfb2a1b82b69c3ef9c5c4 100644 --- a/GUI/Views/ImportDataWidgets/RealDataPresenter.cpp +++ b/GUI/Views/ImportDataWidgets/RealDataPresenter.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "GUI/Views/ImportDataWidgets/RealDataPresenter.h" +#include "GUI/Models/Error.h" #include "GUI/Models/RealDataItem.h" #include "GUI/Views/ImportDataWidgets/RealDataMaskWidget.h" #include "GUI/Views/IntensityDataWidgets/IntensityDataProjectionsWidget.h" #include "GUI/Views/IntensityDataWidgets/IntensityDataWidget.h" #include "GUI/Views/SpecularDataWidgets/SpecularDataImportWidget.h" #include "GUI/Views/SpecularDataWidgets/SpecularDataWidget.h" -#include "GUI/utils/GUIHelpers.h" #include <QAction> RealDataPresenter::RealDataPresenter(QWidget* parent) : ItemComboWidget(parent) @@ -51,7 +51,7 @@ QStringList RealDataPresenter::activePresentationList(SessionItem* item) result << "Reflectometry (Configuration)"; result << "Reflectometry (Graph only)"; } else - throw GUIHelpers::Error( + throw Error( "Error in RealDataPresenter::activePresentationList: unsupported data type"); return result; } diff --git a/GUI/Views/ImportDataWidgets/RealDataSelectorWidget.cpp b/GUI/Views/ImportDataWidgets/RealDataSelectorWidget.cpp index 86e78488c33173530634592db7774ec2c04b66e0..ad15106ae86e72e0cc0da2bb549053eab27c4f0e 100644 --- a/GUI/Views/ImportDataWidgets/RealDataSelectorWidget.cpp +++ b/GUI/Views/ImportDataWidgets/RealDataSelectorWidget.cpp @@ -16,6 +16,7 @@ #include "Device/Data/DataUtils.h" #include "GUI/DataLoaders/DataLoaders1D.h" #include "GUI/DataLoaders/QREDataLoader.h" +#include "GUI/Models/Error.h" #include "GUI/Models/RealDataItem.h" #include "GUI/Models/RealDataModel.h" #include "GUI/Views/ImportDataWidgets/ImportDataUtils.h" @@ -290,7 +291,7 @@ void RealDataSelectorWidget::importData2D() try { if (data->rank() != 2) - throw GUIHelpers::Error( + throw Error( "The content could not be interpreted correctly as 2-dimensional."); realDataItem->setOutputData(data.release()); diff --git a/GUI/Views/InstrumentWidgets/DetectorPresenter.cpp b/GUI/Views/InstrumentWidgets/DetectorPresenter.cpp index fb97feb892b6da4036bd8e2ba206ea2c4f1fc17f..3e000943e5aacc95538e7d42ce2bcd301954b012 100644 --- a/GUI/Views/InstrumentWidgets/DetectorPresenter.cpp +++ b/GUI/Views/InstrumentWidgets/DetectorPresenter.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "GUI/Views/InstrumentWidgets/DetectorPresenter.h" +#include "GUI/Models/Error.h" #include "GUI/Models/SessionItem.h" #include "GUI/Views/InstrumentWidgets/RectangularDetectorEditor.h" #include "GUI/Views/InstrumentWidgets/SphericalDetectorEditor.h" -#include "GUI/utils/GUIHelpers.h" namespace { const QString SphericalDetectorPresentation = "Spherical"; @@ -40,9 +40,9 @@ QString DetectorPresenter::itemPresentation() const else if (currentItem()->modelType() == "RectangularDetector") return RectangularDetectorPresentation; else - throw GUIHelpers::Error("DetectorPresenter::itemPresentation() -> Error. Wrong item " - "type '" - + currentItem()->modelType() + "'"); + throw Error("DetectorPresenter::itemPresentation() -> Error. Wrong item " + "type '" + + currentItem()->modelType() + "'"); } QStringList DetectorPresenter::activePresentationList(SessionItem* item) diff --git a/GUI/Views/InstrumentWidgets/InstrumentPresenter.cpp b/GUI/Views/InstrumentWidgets/InstrumentPresenter.cpp index 1a163b1d75b4f1b81560ec4db5f317c383cd8485..97e841a6aaf8ecdf8e359b510cde2cc03b4215f4 100644 --- a/GUI/Views/InstrumentWidgets/InstrumentPresenter.cpp +++ b/GUI/Views/InstrumentWidgets/InstrumentPresenter.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "GUI/Views/InstrumentWidgets/InstrumentPresenter.h" +#include "GUI/Models/Error.h" #include "GUI/Models/InstrumentItems.h" #include "GUI/Models/SessionItem.h" #include "GUI/Views/InstrumentWidgets/DepthProbeInstrumentEditor.h" #include "GUI/Views/InstrumentWidgets/GISASInstrumentEditor.h" #include "GUI/Views/InstrumentWidgets/OffSpecularInstrumentEditor.h" #include "GUI/Views/InstrumentWidgets/SpecularInstrumentEditor.h" -#include "GUI/utils/GUIHelpers.h" namespace { const QString GISASPresentation = "GISAS"; @@ -54,9 +54,9 @@ QString InstrumentPresenter::itemPresentation() const if (currentItem()->is<DepthProbeInstrumentItem>()) return DepthProbePresentation; - throw GUIHelpers::Error("InstrumentPresenter::itemPresentation() -> Error. Wrong item " - "type '" - + currentItem()->modelType() + "'"); + throw Error("InstrumentPresenter::itemPresentation() -> Error. Wrong item " + "type '" + + currentItem()->modelType() + "'"); } QStringList InstrumentPresenter::activePresentationList(SessionItem* item) diff --git a/GUI/Views/IntensityDataWidgets/ColorMapUtils.cpp b/GUI/Views/IntensityDataWidgets/ColorMapUtils.cpp index d64ba8358895d3538910fdbfce6742f8dcb2ac9d..9f87668cb7029c0c1e37e71d6173a2871f10d671 100644 --- a/GUI/Views/IntensityDataWidgets/ColorMapUtils.cpp +++ b/GUI/Views/IntensityDataWidgets/ColorMapUtils.cpp @@ -13,9 +13,9 @@ // ************************************************************************************************ #include "GUI/Views/IntensityDataWidgets/ColorMapUtils.h" +#include "GUI/Models/Error.h" #include "GUI/Models/IntensityDataItem.h" #include "GUI/Views/IntensityDataWidgets/ColorMap.h" -#include "GUI/utils/GUIHelpers.h" #include "GUI/utils/StyleUtils.h" using gradient_map_t = QMap<QString, QCPColorGradient::GradientPreset>; @@ -67,8 +67,8 @@ QCPColorGradient ColorMapUtils::getGradient(const QString& gradientName) auto it = gradient_map.find(gradientName); if (it == gradient_map.end()) { - throw GUIHelpers::Error("ColorMapHelper::getGradient() -> Error. No such gradient" - + gradientName); + throw Error("ColorMapHelper::getGradient() -> Error. No such gradient" + + gradientName); } return QCPColorGradient(it.value()); } diff --git a/GUI/Views/IntensityDataWidgets/IntensityDataFFTPresenter.cpp b/GUI/Views/IntensityDataWidgets/IntensityDataFFTPresenter.cpp index 089be23c0c558877535afc366e8295a3cd717053..fcfd3b0648c6b4998f702e56b60188f9981c848d 100644 --- a/GUI/Views/IntensityDataWidgets/IntensityDataFFTPresenter.cpp +++ b/GUI/Views/IntensityDataWidgets/IntensityDataFFTPresenter.cpp @@ -14,9 +14,9 @@ #include "GUI/Views/IntensityDataWidgets/IntensityDataFFTPresenter.h" #include "Device/Data/DataUtils.h" +#include "GUI/Models/Error.h" #include "GUI/Models/IntensityDataItem.h" #include "GUI/Models/SessionModel.h" -#include "GUI/utils/GUIHelpers.h" #include <QAction> #include <QApplication> #include <QWidget> @@ -44,7 +44,7 @@ void IntensityDataFFTPresenter::reset() IntensityDataItem* IntensityDataFFTPresenter::fftItem(IntensityDataItem* origItem) { if (!origItem) - throw GUIHelpers::Error("IntensityDataFFTPresenter::fftItem() -> Error. Empty item."); + throw Error("IntensityDataFFTPresenter::fftItem() -> Error. Empty item."); QApplication::setOverrideCursor(Qt::WaitCursor); diff --git a/GUI/Views/IntensityDataWidgets/SaveProjectionsAssistant.cpp b/GUI/Views/IntensityDataWidgets/SaveProjectionsAssistant.cpp index fb7da6575926a8842c7555ef79d26c1fb281c702..25623a4ce0c565fd16d64a8b100689fcb5379a53 100644 --- a/GUI/Views/IntensityDataWidgets/SaveProjectionsAssistant.cpp +++ b/GUI/Views/IntensityDataWidgets/SaveProjectionsAssistant.cpp @@ -16,11 +16,11 @@ #include "Base/Py/PyFmt.h" #include "Device/Histo/Histogram1D.h" #include "Device/Histo/Histogram2D.h" +#include "GUI/Models/Error.h" #include "GUI/Models/IntensityDataItem.h" #include "GUI/Models/MaskItems.h" #include "GUI/Models/ProjectionItems.h" #include "GUI/mainwindow/ProjectUtils.h" -#include "GUI/utils/GUIHelpers.h" #include <QFileDialog> #include <QTextStream> @@ -59,8 +59,8 @@ void SaveProjectionsAssistant::saveProjections(QWidget* parent, IntensityDataIte QFile file(fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - throw GUIHelpers::Error("TestProjectUtils::createTestFile() -> Error. " - "Can't create file"); + throw Error("TestProjectUtils::createTestFile() -> Error. " + "Can't create file"); m_hist2d = std::make_unique<Histogram2D>(*intensityItem->getOutputData()); diff --git a/GUI/Views/JobWidgets/JobViewActivities.cpp b/GUI/Views/JobWidgets/JobViewActivities.cpp index 80408194389eaa0221d26222a8016a074a664e5b..9949108e7289b1c3916f75ed4653dd63ceece71c 100644 --- a/GUI/Views/JobWidgets/JobViewActivities.cpp +++ b/GUI/Views/JobWidgets/JobViewActivities.cpp @@ -13,8 +13,8 @@ // ************************************************************************************************ #include "GUI/Views/JobWidgets/JobViewActivities.h" +#include "GUI/Models/Error.h" #include "GUI/mainwindow/mainwindow_constants.h" -#include "GUI/utils/GUIHelpers.h" namespace { JobViewActivities::activity_map_t createActivityMap() @@ -50,7 +50,7 @@ QVector<JobViewFlags::Dock> JobViewActivities::activeDocks(JobViewFlags::Activit { activity_map_t::iterator it = m_activityToDocks.find(activity); if (it == m_activityToDocks.end()) { - GUIHelpers::Error("JobViewActivities::activeDocks -> Error. Unknown activity"); + Error("JobViewActivities::activeDocks -> Error. Unknown activity"); } return m_activityToDocks[activity]; } diff --git a/GUI/Views/JobWidgets/ParameterTuningWidget.cpp b/GUI/Views/JobWidgets/ParameterTuningWidget.cpp index b490e01a5b5f5a6b1a67b3e3ea630e5bcac3f46b..20649c97aa3a2aec915fbabcc6ce8fde8d97e783 100644 --- a/GUI/Views/JobWidgets/ParameterTuningWidget.cpp +++ b/GUI/Views/JobWidgets/ParameterTuningWidget.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/Views/JobWidgets/ParameterTuningWidget.h" +#include "GUI/Models/Error.h" #include "GUI/Models/IntensityDataItem.h" #include "GUI/Models/JobItem.h" #include "GUI/Models/JobModel.h" @@ -22,7 +23,6 @@ #include "GUI/Views/JobWidgets/JobRealTimeToolBar.h" #include "GUI/Views/JobWidgets/ParameterTuningDelegate.h" #include "GUI/Views/JobWidgets/SliderSettingsWidget.h" -#include "GUI/utils/GUIHelpers.h" #include <QTreeView> #include <QVBoxLayout> @@ -116,8 +116,8 @@ void ParameterTuningWidget::updateParameterModel() return; if (!jobItem()->multiLayerItem() || !jobItem()->instrumentItem()) - throw GUIHelpers::Error("ModelTuningWidget::updateParameterModel() -> Error." - "JobItem doesn't have sample or instrument model."); + throw Error("ModelTuningWidget::updateParameterModel() -> Error." + "JobItem doesn't have sample or instrument model."); delete m_parameterTuningModel; m_parameterTuningModel = new ParameterTuningModel(this); diff --git a/GUI/Views/MaskWidgets/MaskGraphicsScene.cpp b/GUI/Views/MaskWidgets/MaskGraphicsScene.cpp index 84a915cfbe238b4edb7fab99a7773bd403aa4e80..e504dac4ed18dedb94acc0376b184acae8dc19af 100644 --- a/GUI/Views/MaskWidgets/MaskGraphicsScene.cpp +++ b/GUI/Views/MaskWidgets/MaskGraphicsScene.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/Views/MaskWidgets/MaskGraphicsScene.h" +#include "GUI/Models/Error.h" #include "GUI/Models/IntensityDataItem.h" #include "GUI/Models/MaskItems.h" #include "GUI/Models/SessionModel.h" @@ -20,7 +21,6 @@ #include "GUI/Views/MaskWidgets/MaskGraphicsProxy.h" #include "GUI/Views/MaskWidgets/MaskViewFactory.h" #include "GUI/Views/MaskWidgets/PolygonView.h" -#include "GUI/utils/GUIHelpers.h" #include <QGraphicsItem> #include <QGraphicsSceneMoveEvent> #include <QItemSelection> @@ -77,7 +77,7 @@ void MaskGraphicsScene::setMaskContext(SessionModel* model, const QModelIndex& m QString containerType = m_maskModel->itemForIndex(maskContainerIndex)->modelType(); if (containerType != "MaskContainer" && containerType != "ProjectionContainer") - throw GUIHelpers::Error( + throw Error( "MaskGraphicsScene::setMaskContext() -> Error. Not a container"); m_maskContainerIndex = maskContainerIndex; diff --git a/GUI/Views/MaskWidgets/MaskUnitsConverter.cpp b/GUI/Views/MaskWidgets/MaskUnitsConverter.cpp index 9eeea6fb171537d0a5a0007e9817c89ae2a40a3e..b7e1e979e436fc73fcadaed2d8e44a631337b112 100644 --- a/GUI/Views/MaskWidgets/MaskUnitsConverter.cpp +++ b/GUI/Views/MaskWidgets/MaskUnitsConverter.cpp @@ -14,10 +14,10 @@ #include "GUI/Views/MaskWidgets/MaskUnitsConverter.h" #include "Device/Data/DataUtils.h" +#include "GUI/Models/Error.h" #include "GUI/Models/IntensityDataItem.h" #include "GUI/Models/MaskItems.h" #include "GUI/Models/ProjectionItems.h" -#include "GUI/utils/GUIHelpers.h" MaskUnitsConverter::MaskUnitsConverter() : m_data(nullptr), m_direction(UNDEFINED) {} @@ -121,5 +121,5 @@ double MaskUnitsConverter::convert(double value, int axis_index) } else if (m_direction == FROM_NBINS) { return DataUtils::coordinateFromBinf(value, m_data->axis(axis_index)); } - throw GUIHelpers::Error("MaskUnitsConverter::convertX() -> Error. Unknown conversion"); + throw Error("MaskUnitsConverter::convertX() -> Error. Unknown conversion"); } diff --git a/GUI/Views/MaskWidgets/MaskViewFactory.cpp b/GUI/Views/MaskWidgets/MaskViewFactory.cpp index efddf5c42ced58ba7cd1cfef5b924c26a89e117b..7eead06c3abd2227a0104509104fd6a37fc16987 100644 --- a/GUI/Views/MaskWidgets/MaskViewFactory.cpp +++ b/GUI/Views/MaskWidgets/MaskViewFactory.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/Views/MaskWidgets/MaskViewFactory.h" +#include "GUI/Models/Error.h" #include "GUI/Models/SessionItem.h" #include "GUI/Views/MaskWidgets/EllipseView.h" #include "GUI/Views/MaskWidgets/IntensityDataView.h" @@ -22,7 +23,6 @@ #include "GUI/Views/MaskWidgets/PolygonPointView.h" #include "GUI/Views/MaskWidgets/PolygonView.h" #include "GUI/Views/MaskWidgets/RegionOfInterestView.h" -#include "GUI/utils/GUIHelpers.h" IShape2DView* MaskViewFactory::createMaskView(SessionItem* item, ISceneAdaptor* adaptor) { @@ -70,9 +70,9 @@ IShape2DView* MaskViewFactory::createMaskView(SessionItem* item, ISceneAdaptor* } else { - throw GUIHelpers::Error("MaskViewFactory::createSampleView() -> Error! " - "Can't create a view for " - + model_type); + throw Error("MaskViewFactory::createSampleView() -> Error! " + "Can't create a view for " + + model_type); } result->setParameterizedItem(item); diff --git a/GUI/Views/MaterialEditor/MaterialItemUtils.cpp b/GUI/Views/MaterialEditor/MaterialItemUtils.cpp index 2a5f6eca2cb36bf7414ce4fef754bbe0e7bdb0b9..872aa95cd4df306b7b561ed9da974fcccef6884a 100644 --- a/GUI/Views/MaterialEditor/MaterialItemUtils.cpp +++ b/GUI/Views/MaterialEditor/MaterialItemUtils.cpp @@ -14,6 +14,7 @@ #include "GUI/Views/MaterialEditor/MaterialItemUtils.h" #include "GUI/Models/ComboProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/LayerItem.h" #include "GUI/Models/MaterialDataItems.h" #include "GUI/Models/MaterialItemContainer.h" @@ -27,7 +28,6 @@ #include "GUI/Views/SampleDesigner/DesignerHelper.h" #include "GUI/mainwindow/AppSvc.h" #include "GUI/mainwindow/mainwindow.h" -#include "GUI/utils/GUIHelpers.h" #include "Sample/Material/Material.h" #include <QColorDialog> @@ -81,24 +81,24 @@ MaterialItemUtils::createDomainMaterial(const ExternalProperty& material_propert { const MaterialItem* material_item = container.findMaterialById(material_property.identifier()); if (!material_item) - throw GUIHelpers::Error("MaterialUtils::createDomainMaterial() -> Error. Can't find " - "material with name '" - + material_property.text() + "'."); + throw Error("MaterialUtils::createDomainMaterial() -> Error. Can't find " + "material with name '" + + material_property.text() + "'."); return material_item->createMaterial(); } MaterialItem* MaterialItemUtils::findMaterial(const ExternalProperty& material_property) { if (!AppSvc::materialModel()) - throw GUIHelpers::Error("MaterialItemUtils::findMaterial() -> Error. " - "Attempt to access non-existing material model"); + throw Error("MaterialItemUtils::findMaterial() -> Error. " + "Attempt to access non-existing material model"); auto material = AppSvc::materialModel()->materialFromIdentifier(material_property.identifier()); if (!material) - throw GUIHelpers::Error("MaterialUtils::findMaterial() -> Error. Can't find " - "material with name '" - + material_property.text() + "'."); + throw Error("MaterialUtils::findMaterial() -> Error. Can't find " + "material with name '" + + material_property.text() + "'."); return material; } @@ -201,7 +201,7 @@ QVector<SessionItem*> MaterialItemUtils::materialPropertyItems(SessionItem* item else if (model_type == "ParticleCoreShell") materials.append(static_cast<ParticleCoreShellItem*>(item)->materialPropertyItems()); else - throw GUIHelpers::Error( + throw Error( "Error in MaterialItemUtils::materialProperties: cannot handle passed model type '" + model_type + "'"); } diff --git a/GUI/Views/PropertyEditor/CustomEditors.cpp b/GUI/Views/PropertyEditor/CustomEditors.cpp index 2e69b0e8e7af61abe27a20e24b293f4db6b4907e..90b6b8812a879448140a6f0f0467aae027ffd484 100644 --- a/GUI/Views/PropertyEditor/CustomEditors.cpp +++ b/GUI/Views/PropertyEditor/CustomEditors.cpp @@ -14,11 +14,11 @@ #include "GUI/Views/PropertyEditor/CustomEditors.h" #include "GUI/Models/ComboProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/GroupItemController.h" #include "GUI/Views/JobWidgets/ScientificSpinBox.h" #include "GUI/Views/MaterialEditor/MaterialItemUtils.h" #include "GUI/utils/CustomEventFilters.h" -#include "GUI/utils/GUIHelpers.h" #include <QApplication> #include <QBoxLayout> #include <QCheckBox> @@ -114,7 +114,7 @@ void ExternalPropertyEditor::buttonClicked() } else if (m_extDialogType == "ExtColorEditor") { newProperty = MaterialItemUtils::selectColorProperty(property); } else { - throw GUIHelpers::Error("ExternalPropertyEditor::buttonClicked() -> Unexpected dialog"); + throw Error("ExternalPropertyEditor::buttonClicked() -> Unexpected dialog"); } removeEventFilter(m_focusFilter); diff --git a/GUI/Views/SampleDesigner/ConnectableView.cpp b/GUI/Views/SampleDesigner/ConnectableView.cpp index 0b1fe135edf4aefe3a77ff8ebc79822b86fec5b9..fae2fe98c5d46fe828c69860db457a1716e257c8 100644 --- a/GUI/Views/SampleDesigner/ConnectableView.cpp +++ b/GUI/Views/SampleDesigner/ConnectableView.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "GUI/Views/SampleDesigner/ConnectableView.h" +#include "GUI/Models/Error.h" #include "GUI/Models/SessionItem.h" #include "GUI/Views/SampleDesigner/DesignerHelper.h" #include "GUI/Views/SampleDesigner/NodeEditorConnection.h" -#include "GUI/utils/GUIHelpers.h" #include "GUI/utils/StyleUtils.h" #include <QObject> #include <QPainter> @@ -75,7 +75,7 @@ NodeEditorPort* ConnectableView::addPort(const QString& name, } else if (direction == NodeEditorPort::OUTPUT) { m_output_ports.append(port); } else { - throw GUIHelpers::Error("ConnectableView::addPort() -> Unknown port type"); + throw Error("ConnectableView::addPort() -> Unknown port type"); } setPortCoordinates(); return port; @@ -92,10 +92,10 @@ void ConnectableView::connectInputPort(ConnectableView* other, int port_number) ASSERT(other); if (port_number >= m_input_ports.size()) - throw GUIHelpers::Error("ConnectableView::connectInputPort() -> Wrong input port number"); + throw Error("ConnectableView::connectInputPort() -> Wrong input port number"); if (other->getOutputPorts().size() != 1) - throw GUIHelpers::Error("ConnectableView::connectInputPort() -> Wrong output port number"); + throw Error("ConnectableView::connectInputPort() -> Wrong output port number"); if (port_number < 0) return; diff --git a/GUI/Views/SampleDesigner/DesignerView.cpp b/GUI/Views/SampleDesigner/DesignerView.cpp index 60ec1b3f47bc9d79f37e4eb5b3cb65f5d718a3b0..8509de23bd8cbadfedf2ac886515a4d8c05e81c9 100644 --- a/GUI/Views/SampleDesigner/DesignerView.cpp +++ b/GUI/Views/SampleDesigner/DesignerView.cpp @@ -14,9 +14,9 @@ #include "GUI/Views/SampleDesigner/DesignerView.h" #include "Base/Utils/Assert.h" +#include "GUI/Models/Error.h" #include "GUI/Views/SampleDesigner/DesignerMimeData.h" #include "GUI/Views/SampleDesigner/DesignerScene.h" -#include "GUI/utils/GUIHelpers.h" #include <QDragEnterEvent> #include <QGraphicsScene> #include <QGraphicsView> @@ -41,7 +41,7 @@ int DesignerView::getSelectionMode() const } else if (dragMode() == QGraphicsView::ScrollHandDrag) { return HAND_DRAG; } else { - throw GUIHelpers::Error("DesignerView::getSelectionMode() -> Error."); + throw Error("DesignerView::getSelectionMode() -> Error."); } } diff --git a/GUI/Views/SampleDesigner/ILayerView.cpp b/GUI/Views/SampleDesigner/ILayerView.cpp index 6b9c1aa792f6802adcbbb996a390d81ab890f6b3..b1ca4d7ec32a25c7447b22eddb4ce8636a3b8056 100644 --- a/GUI/Views/SampleDesigner/ILayerView.cpp +++ b/GUI/Views/SampleDesigner/ILayerView.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "GUI/Models/ExternalProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/LayerItem.h" #include "GUI/Models/SampleModel.h" #include "GUI/Views/SampleDesigner/DesignerHelper.h" #include "GUI/Views/SampleDesigner/DesignerScene.h" #include "GUI/Views/SampleDesigner/MultiLayerView.h" -#include "GUI/utils/GUIHelpers.h" #include <QGraphicsSceneMouseEvent> QLineF MultiLayerCandidate::getInterfaceToScene() @@ -202,7 +202,7 @@ void ILayerView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) } // throw only happens when not all cases were considered previously - throw GUIHelpers::Error("LayerView::mouseReleaseEvent() -> Loggic error."); + throw Error("LayerView::mouseReleaseEvent() -> Loggic error."); } void ILayerView::update_appearance() diff --git a/GUI/Views/SampleDesigner/ParticleLayoutView.cpp b/GUI/Views/SampleDesigner/ParticleLayoutView.cpp index 8194b6f4a3d56b7417941f81e0327744301d9797..9bae6b1d6d1b56fdd2849ee86de11f7827417add 100644 --- a/GUI/Views/SampleDesigner/ParticleLayoutView.cpp +++ b/GUI/Views/SampleDesigner/ParticleLayoutView.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "GUI/Views/SampleDesigner/ParticleLayoutView.h" +#include "GUI/Models/Error.h" #include "GUI/Models/SessionItem.h" #include "GUI/Views/SampleDesigner/DesignerHelper.h" #include "GUI/Views/SampleDesigner/ParticleView.h" -#include "GUI/utils/GUIHelpers.h" ParticleLayoutView::ParticleLayoutView(QGraphicsItem* parent) : ConnectableView(parent) { @@ -45,6 +45,6 @@ void ParticleLayoutView::addView(IView* childView, int /* row */) || childView->type() == ViewTypes::INTERFERENCE_FUNCTION_RADIAL_PARA) { connectInputPort(dynamic_cast<ConnectableView*>(childView), 1); } else { - throw GUIHelpers::Error("ParticleLayoutView::addView() -> Error. Unknown view"); + throw Error("ParticleLayoutView::addView() -> Error. Unknown view"); } } diff --git a/GUI/Views/SampleDesigner/ParticleView.cpp b/GUI/Views/SampleDesigner/ParticleView.cpp index c3ca05142254d27e050e84bb72dd369ac3ba30ad..7696d27bcafc7e20a2f32e4a5e3bf3968b5e1a38 100644 --- a/GUI/Views/SampleDesigner/ParticleView.cpp +++ b/GUI/Views/SampleDesigner/ParticleView.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "GUI/Views/SampleDesigner/ParticleView.h" +#include "GUI/Models/Error.h" #include "GUI/Models/FormFactorItems.h" #include "GUI/Models/GroupItem.h" #include "GUI/Models/ParticleItem.h" #include "GUI/Views/SampleDesigner/DesignerHelper.h" -#include "GUI/utils/GUIHelpers.h" #include "GUI/utils/StyleUtils.h" #include <QObject> #include <QPainter> @@ -81,7 +81,7 @@ void ParticleView::addView(IView* childView, int /*row*/) if (childView->type() == ViewTypes::TRANSFORMATION) { connectInputPort(dynamic_cast<ConnectableView*>(childView), 0); } else { - throw GUIHelpers::Error("ParticleView::addView() -> Error. Unknown view"); + throw Error("ParticleView::addView() -> Error. Unknown view"); } } diff --git a/GUI/mainwindow/AppSvc.cpp b/GUI/mainwindow/AppSvc.cpp index 85966cf2b9866bc287b01b18cd59fc8271875120..ddd12bf070c4856e6c74011fee2271ee824ecfb5 100644 --- a/GUI/mainwindow/AppSvc.cpp +++ b/GUI/mainwindow/AppSvc.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "GUI/mainwindow/AppSvc.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" ProjectManager* AppSvc::projectManager() { @@ -50,8 +50,8 @@ AppSvc::AppSvc() : m_projectManager(nullptr), m_materialModel(nullptr) {} ProjectManager* AppSvc::this_projectManager() { if (!m_projectManager) - throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to access " - "non existing ProjectManager."); + throw Error("AppSvc::projectManager() -> Error. Attempt to access " + "non existing ProjectManager."); return m_projectManager; } @@ -64,8 +64,8 @@ MaterialModel* AppSvc::this_materialModel() void AppSvc::this_subscribe(ProjectManager* projectManager) { if (m_projectManager != nullptr) - throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to subscribe " - "ProjectManager twice."); + throw Error("AppSvc::projectManager() -> Error. Attempt to subscribe " + "ProjectManager twice."); m_projectManager = projectManager; } @@ -73,8 +73,8 @@ void AppSvc::this_subscribe(ProjectManager* projectManager) void AppSvc::this_unsubscribe(ProjectManager* projectManager) { if (m_projectManager != projectManager) - throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to unsubscribe " - "ProjectManager before it was subscribed."); + throw Error("AppSvc::projectManager() -> Error. Attempt to unsubscribe " + "ProjectManager before it was subscribed."); m_projectManager = nullptr; } @@ -82,8 +82,8 @@ void AppSvc::this_unsubscribe(ProjectManager* projectManager) void AppSvc::this_subscribe(MaterialModel* materialModel) { if (m_materialModel) - throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to subscribe " - "MaterialModel twice."); + throw Error("AppSvc::projectManager() -> Error. Attempt to subscribe " + "MaterialModel twice."); m_materialModel = materialModel; } @@ -91,8 +91,8 @@ void AppSvc::this_subscribe(MaterialModel* materialModel) void AppSvc::this_unsubscribe(MaterialModel* materialModel) { if (m_materialModel != materialModel) - throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to unsubscribe " - "MaterialModel before it was subscribed."); + throw Error("AppSvc::projectManager() -> Error. Attempt to unsubscribe " + "MaterialModel before it was subscribed."); m_materialModel = nullptr; } diff --git a/GUI/mainwindow/OutputDataIOHistory.cpp b/GUI/mainwindow/OutputDataIOHistory.cpp index 432920a540f8f6e692e7ca6e8d3db92cf5f98bdd..bd9044f4e53e43d1513f1cd91aefa545aa2cc165 100644 --- a/GUI/mainwindow/OutputDataIOHistory.cpp +++ b/GUI/mainwindow/OutputDataIOHistory.cpp @@ -14,8 +14,8 @@ #include "GUI/mainwindow/OutputDataIOHistory.h" #include "Base/Utils/Assert.h" +#include "GUI/Models/Error.h" #include "GUI/mainwindow/SaveLoadInterface.h" -#include "GUI/utils/GUIHelpers.h" //! Static method to create info for just saved item. @@ -48,8 +48,8 @@ bool OutputDataSaveInfo::wasSavedBefore(const QDateTime& dtime) const void OutputDataDirHistory::markAsSaved(const SaveLoadInterface* item) { if (contains(item)) - throw GUIHelpers::Error("OutputDataDirHistory::markAsSaved() -> Error. " - "Already existing item."); + throw Error("OutputDataDirHistory::markAsSaved() -> Error. " + "Already existing item."); // Don't create any history info for empty items if (item->containsNonXMLData()) m_history.push_back(OutputDataSaveInfo::createSaved(item)); @@ -89,7 +89,7 @@ OutputDataSaveInfo OutputDataDirHistory::itemInfo(const SaveLoadInterface* item) return info; } - throw GUIHelpers::Error("OutputDataDirHistory::itemInfo() -> Error. No info exists."); + throw Error("OutputDataDirHistory::itemInfo() -> Error. No info exists."); } //----------------------------------------------------------------------------- @@ -103,9 +103,8 @@ bool OutputDataIOHistory::wasModifiedSinceLastSave(const QString& dirname, const SaveLoadInterface* item) { if (!hasHistory(dirname)) - throw GUIHelpers::Error("OutputDataIOHistory::wasModifiedSinceLastSave() -> Error. " - "No info for directory '" - + dirname + "'."); + throw Error("OutputDataIOHistory::wasModifiedSinceLastSave() -> Error. " + "No info for directory '" + dirname + "'."); return m_dir_history[dirname].wasModifiedSinceLastSave(item); } @@ -121,9 +120,8 @@ void OutputDataIOHistory::setHistory(const QString& dirname, const OutputDataDir QStringList OutputDataIOHistory::savedFileNames(const QString& dirname) const { if (!hasHistory(dirname)) - throw GUIHelpers::Error("OutputDataIOHistory::savedFileNames() -> Error. " - "No info for directory '" - + dirname + "'."); + throw Error("OutputDataIOHistory::savedFileNames() -> Error. " + "No info for directory '" + dirname + "'."); return m_dir_history[dirname].savedFileNames(); } diff --git a/GUI/mainwindow/ProjectUtils.cpp b/GUI/mainwindow/ProjectUtils.cpp index 11fa76dd037470ac31519398a919ceaedddf1e9f..b857b17647ed965ac4562f6fc1c0079ae2756aa5 100644 --- a/GUI/mainwindow/ProjectUtils.cpp +++ b/GUI/mainwindow/ProjectUtils.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "GUI/mainwindow/ProjectUtils.h" +#include "GUI/Models/Error.h" #include "GUI/Models/ItemFileNameUtils.h" #include "GUI/mainwindow/AppSvc.h" #include "GUI/mainwindow/projectdocument.h" #include "GUI/mainwindow/projectmanager.h" -#include "GUI/utils/GUIHelpers.h" #include <QDateTime> #include <QDebug> #include <QDir> @@ -77,9 +77,9 @@ QStringList ProjectUtils::nonXMLDataInDir(const QString& dirname) QDir dir(dirname); if (!dir.exists()) - throw GUIHelpers::Error("ProjectUtils::nonXMLDataInDir() -> Error. Non existing " - "directory '" - + dirname + "'."); + throw Error("ProjectUtils::nonXMLDataInDir() -> Error. Non existing " + "directory '" + + dirname + "'."); return dir.entryList(ItemFileNameUtils::nonXMLFileNameFilters()); } @@ -89,9 +89,9 @@ bool ProjectUtils::removeRecursively(const QString& dirname) QDir dir(dirname); if (!dir.exists()) - throw GUIHelpers::Error("ProjectUtils::removeRecursively() -> Error. Non existing " - "directory '" - + dirname + "'."); + throw Error("ProjectUtils::removeRecursively() -> Error. Non existing " + "directory '" + + dirname + "'."); return dir.removeRecursively(); } @@ -102,9 +102,9 @@ bool ProjectUtils::removeFile(const QString& dirname, const QString& filename) QFile fin(name); if (!fin.exists()) - throw GUIHelpers::Error("ProjectUtils::removeFile() -> Error. Non existing " - "file '" - + name + "'."); + throw Error("ProjectUtils::removeFile() -> Error. Non existing " + "file '" + + name + "'."); return fin.remove(); } @@ -136,8 +136,8 @@ QString ProjectUtils::readTextFile(const QString& fileName) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - throw GUIHelpers::Error("ProjectUtils::readTextFile -> Error. Can't open the file '" - + fileName + "' for reading."); + throw Error("ProjectUtils::readTextFile -> Error. Can't open the file '" + + fileName + "' for reading."); QTextStream in(&file); return in.readAll(); } diff --git a/GUI/mainwindow/SaveService.cpp b/GUI/mainwindow/SaveService.cpp index 2f260d487dbb57ae3c2d0a67bd173af11594e928..0b8030327ddb1ec8e305de00824fc1d493e0d631 100644 --- a/GUI/mainwindow/SaveService.cpp +++ b/GUI/mainwindow/SaveService.cpp @@ -14,12 +14,12 @@ #include "GUI/mainwindow/SaveService.h" #include "Base/Utils/Assert.h" +#include "GUI/Models/Error.h" #include "GUI/Views/CommonWidgets/UpdateTimer.h" #include "GUI/mainwindow/AutosaveController.h" #include "GUI/mainwindow/ProjectUtils.h" #include "GUI/mainwindow/SaveThread.h" #include "GUI/mainwindow/projectdocument.h" -#include "GUI/utils/GUIHelpers.h" #include <QApplication> #include <QCoreApplication> #include <QTime> @@ -107,7 +107,7 @@ void SaveService::stopService() break; } if (isSaving()) - throw GUIHelpers::Error("SaveService::stopService() -> Error. Can't stop service. "); + throw Error("SaveService::stopService() -> Error. Can't stop service. "); } if (m_autosave) diff --git a/GUI/mainwindow/projectdocument.cpp b/GUI/mainwindow/projectdocument.cpp index 06f3bf79c192fdc388bcddcd4391e7ee11e25db8..41767d443e75490c33d09a7fcc2e610e17597c6b 100644 --- a/GUI/mainwindow/projectdocument.cpp +++ b/GUI/mainwindow/projectdocument.cpp @@ -14,6 +14,7 @@ #include "GUI/mainwindow/projectdocument.h" #include "GUI/Models/ApplicationModels.h" +#include "GUI/Models/Error.h" #include "GUI/Models/JobModel.h" #include "GUI/mainwindow/OutputDataIOService.h" #include "GUI/mainwindow/ProjectUtils.h" @@ -104,9 +105,9 @@ void ProjectDocument::saveProjectFile(const QString& project_file_name, bool aut QFile file(project_file_name); if (!file.open(QFile::ReadWrite | QIODevice::Truncate | QFile::Text)) - throw GUIHelpers::Error("ProjectDocument::save_project_file() -> Error. Can't open " - "file '" - + project_file_name + "' for writing."); + throw Error("ProjectDocument::save_project_file() -> Error. Can't open " + "file '" + + project_file_name + "' for writing."); writeTo(&file); file.close(); diff --git a/GUI/mainwindow/projectmanager.cpp b/GUI/mainwindow/projectmanager.cpp index 51a5eed8f4572c3ca69be09d9183f041799a64b1..adb406f4b531960c9303781ec4d77b5711b427b7 100644 --- a/GUI/mainwindow/projectmanager.cpp +++ b/GUI/mainwindow/projectmanager.cpp @@ -15,6 +15,7 @@ #include "GUI/mainwindow/projectmanager.h" #include "Base/Utils/Assert.h" #include "GUI/Models/ApplicationModels.h" +#include "GUI/Models/Error.h" #include "GUI/Views/InfoWidgets/ProjectLoadWarningDialog.h" #include "GUI/mainwindow/AppSvc.h" #include "GUI/mainwindow/ProjectUtils.h" @@ -349,7 +350,7 @@ void ProjectManager::openProject(QString fileName) void ProjectManager::createNewProject() { if (m_project_document) - throw GUIHelpers::Error("ProjectManager::createNewProject() -> Project already exists"); + throw Error("ProjectManager::createNewProject() -> Project already exists"); m_messageService->clear(); diff --git a/GUI/mainwindow/tooltipdatabase.cpp b/GUI/mainwindow/tooltipdatabase.cpp index 10251d8c0a4f2f5c416d0a0f31f9e4835271eb11..9f594cf8aeebfd52ebce0dbcbe46ba4dc9c0ca99 100644 --- a/GUI/mainwindow/tooltipdatabase.cpp +++ b/GUI/mainwindow/tooltipdatabase.cpp @@ -14,7 +14,7 @@ #include "GUI/mainwindow/tooltipdatabase.h" #include "Base/Utils/Assert.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" #include <QFile> #include <QXmlStreamReader> @@ -59,7 +59,7 @@ void ToolTipDataBase::initDataBase() { QFile file(":/mainwindow/tooltips.xml"); if (!file.open(QIODevice::ReadOnly)) - throw GUIHelpers::Error(file.errorString()); + throw Error(file.errorString()); QXmlStreamReader reader(&file); @@ -103,7 +103,7 @@ void ToolTipDataBase::initDataBase() } if (reader.hasError()) - throw GUIHelpers::Error(reader.errorString()); + throw Error(reader.errorString()); } QString ToolTipDataBase::getTag(const QString& contextName, const QString& categoryName, diff --git a/GUI/utils/GUIHelpers.cpp b/GUI/utils/GUIHelpers.cpp index 7ead01b61fe066bc0efaeb7ce529503fc9af433c..b2448b0f31aa438edcb2464d3bf1147a22660c4e 100644 --- a/GUI/utils/GUIHelpers.cpp +++ b/GUI/utils/GUIHelpers.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/utils/GUIHelpers.h" +#include "GUI/Models/Error.h" #include "BAVersion.h" #include <QApplication> #include <QDateTime> @@ -41,13 +42,6 @@ const QMap<QString, QString> invalidCharacterMap = initializeCharacterMap(); namespace GUIHelpers { -Error::~Error() noexcept = default; - -const char* Error::what() const noexcept -{ - return m_messageAsLatin1.data(); -} - void information(QWidget* parent, const QString& title, const QString& text, const QString& detailedText) { @@ -235,8 +229,8 @@ QString readTextFile(const QString& fileName) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - throw GUIHelpers::Error("PyImportAssistant::readFile() -> Error. Can't read file '" - + fileName + "'"); + throw Error("PyImportAssistant::readFile() -> Error. Can't read file '" + + fileName + "'"); QTextStream in(&file); return in.readAll(); } diff --git a/GUI/utils/GUIHelpers.h b/GUI/utils/GUIHelpers.h index 27f322b315d7f263acd7ad191b8de9049e851bcf..9b1f7829caa04954704302772b1290ec2ff7f066 100644 --- a/GUI/utils/GUIHelpers.h +++ b/GUI/utils/GUIHelpers.h @@ -24,21 +24,6 @@ class JobItem; class RealDataItem; namespace GUIHelpers { -class Error : public std::exception { -public: - explicit Error(const QString& message) noexcept : m_messageAsLatin1(message.toLatin1()) {} - virtual ~Error() noexcept; - - Error(const Error&) = default; - Error& operator=(const Error&) = default; - Error(Error&&) = default; - Error& operator=(Error&&) = default; - - const char* what() const noexcept override; - -private: - QByteArray m_messageAsLatin1; -}; void information(QWidget* parent, const QString& title, const QString& text, const QString& detailedText = ""); diff --git a/GUI/utils/ImportDataInfo.cpp b/GUI/utils/ImportDataInfo.cpp index e16e5ae5358f69fdfd3916a98221f50f59b3664e..5a4f6dc449ceb290129ccec751cc7eaaa316d979 100644 --- a/GUI/utils/ImportDataInfo.cpp +++ b/GUI/utils/ImportDataInfo.cpp @@ -14,9 +14,9 @@ #include "Device/Coord/AxisNames.h" #include "Device/Data/OutputData.h" +#include "GUI/Models/Error.h" #include "GUI/Models/JobItemUtils.h" #include "GUI/Views/ImportDataWidgets/ImportDataUtils.h" -#include "GUI/utils/GUIHelpers.h" namespace { std::vector<Axes::Coords> specularUnits() @@ -101,7 +101,7 @@ QString ImportDataInfo::axisLabel(size_t axis_index) const return "Signal [a.u.]"; return QString::fromStdString(AxisNames::specAxis.at(m_coords)); } - throw GUIHelpers::Error("Error in ImportDataInfo::axisLabel: unsupported data type"); + throw Error("Error in ImportDataInfo::axisLabel: unsupported data type"); } void ImportDataInfo::checkValidity() @@ -110,10 +110,10 @@ void ImportDataInfo::checkValidity() return; auto iter = available_units.find(m_data->rank()); if (iter == available_units.end()) - throw GUIHelpers::Error("Error in ImportDataInfo constructor: unsupported data type"); + throw Error("Error in ImportDataInfo constructor: unsupported data type"); for (auto& value : iter->second) if (m_coords == value) return; - throw GUIHelpers::Error("Error in ImportDataInfo constructor: inacceptable units passed."); + throw Error("Error in ImportDataInfo constructor: inacceptable units passed."); } diff --git a/Tests/UnitTests/GUI/TestAxesItems.cpp b/Tests/UnitTests/GUI/TestAxesItems.cpp index f35124a909da75eda6886854414f3daad1415eea..bf4e156f651ef81461d4e49dc7da773b56356749 100644 --- a/Tests/UnitTests/GUI/TestAxesItems.cpp +++ b/Tests/UnitTests/GUI/TestAxesItems.cpp @@ -2,9 +2,9 @@ #include "Base/Axis/VariableBinAxis.h" #include "Base/Const/Units.h" #include "GUI/Models/AxesItems.h" +#include "GUI/Models/Error.h" #include "GUI/Models/PropertyItem.h" #include "GUI/Models/TransformFromDomain.h" -#include "GUI/utils/GUIHelpers.h" #include "Tests/GTestWrapper/google_test.h" class TestAxesItems : public ::testing::Test { @@ -61,5 +61,5 @@ TEST_F(TestAxesItems, transformFromDomain) // transform from unexpected axis std::vector<double> bins = {1.0, 2.0, 3.0}; VariableBinAxis varaxis("axis", bins.size() - 1, bins); - EXPECT_THROW(TransformFromDomain::setAxisItem(&item, varaxis), GUIHelpers::Error); + EXPECT_THROW(TransformFromDomain::setAxisItem(&item, varaxis), Error); } diff --git a/Tests/UnitTests/GUI/TestDataItemViews.cpp b/Tests/UnitTests/GUI/TestDataItemViews.cpp index 4dd42d6a0b1084e4bb74eebb68e82e089907c0af..31cadc08da7c8c3b5eeb5bf4a9a1e4456675d220 100644 --- a/Tests/UnitTests/GUI/TestDataItemViews.cpp +++ b/Tests/UnitTests/GUI/TestDataItemViews.cpp @@ -3,10 +3,10 @@ #include "GUI/Models/DataItem.h" #include "GUI/Models/DataProperties.h" #include "GUI/Models/DataPropertyContainer.h" +#include "GUI/Models/Error.h" #include "GUI/Models/RealDataModel.h" #include "GUI/Models/SpecularDataItem.h" #include "GUI/mainwindow/projectdocument.h" -#include "GUI/utils/GUIHelpers.h" #include "GUI/utils/MessageService.h" #include "Tests/GTestWrapper/google_test.h" #include "Tests/UnitTests/GUI/Utils.h" @@ -103,7 +103,7 @@ TEST_F(TestDataItemViews, testBrokenLink) DataItem* item2 = insertNewDataItem(model, 1.0); view_item->addItem(item2); - EXPECT_THROW(view_item->propertyItem(0)->dataItem(), GUIHelpers::Error); + EXPECT_THROW(view_item->propertyItem(0)->dataItem(), Error); } TEST_F(TestDataItemViews, testWrongHostingModel) @@ -115,7 +115,7 @@ TEST_F(TestDataItemViews, testWrongHostingModel) SessionModel model2("TempModel2"); DataItem* item2 = insertNewDataItem(model2, 1.0); - EXPECT_THROW(view_item->addItem(item2), GUIHelpers::Error); + EXPECT_THROW(view_item->addItem(item2), Error); auto stored_items = view_item->propertyItems(); EXPECT_EQ(stored_items.size(), 1); diff --git a/Tests/UnitTests/GUI/TestGroupItem.cpp b/Tests/UnitTests/GUI/TestGroupItem.cpp index c12bcebcf7687bec000497e9ff5f631e4e1e4123..33a00ffe492a475d00f5e10816a831d082461ada 100644 --- a/Tests/UnitTests/GUI/TestGroupItem.cpp +++ b/Tests/UnitTests/GUI/TestGroupItem.cpp @@ -1,8 +1,8 @@ #include "GUI/Models/ComboProperty.h" +#include "GUI/Models/Error.h" #include "GUI/Models/GroupItem.h" #include "GUI/Models/SessionItemUtils.h" #include "GUI/Models/SessionModel.h" -#include "GUI/utils/GUIHelpers.h" #include "Tests/GTestWrapper/google_test.h" #include "Tests/UnitTests/GUI/Utils.h" @@ -42,10 +42,10 @@ TEST_F(TestGroupItem, test_groupInfo) << "c_label2"); // attempt to set non-existing default type - EXPECT_THROW(info.setDefaultType("XXX"), GUIHelpers::Error); + EXPECT_THROW(info.setDefaultType("XXX"), Error); // attempt to add same info twice - EXPECT_THROW(info.add("CCC2", "c_label2"), GUIHelpers::Error); + EXPECT_THROW(info.add("CCC2", "c_label2"), Error); } TEST_F(TestGroupItem, test_CreateGroup) @@ -64,7 +64,7 @@ TEST_F(TestGroupItem, test_CreateGroup) groupItem->setGroupInfo(groupInfo); // setting group info twice - EXPECT_THROW(groupItem->setGroupInfo(groupInfo), GUIHelpers::Error); + EXPECT_THROW(groupItem->setGroupInfo(groupInfo), Error); // checking current item EXPECT_EQ(groupItem->children().size(), 1); diff --git a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp index a495b169dbacdb0cfea79e247b74de0c8fa2c64d..ed23685ce3cf1ecd8bfc159d95aa5ed12f473fe8 100644 --- a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp +++ b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp @@ -5,6 +5,7 @@ #include "GUI/Models/JobItem.h" #include "GUI/Models/JobItemUtils.h" #include "GUI/Models/JobModel.h" +#include "GUI/Models/Error.h" #include "GUI/Models/JobModelFunctions.h" #include "GUI/Models/RealDataItem.h" #include "GUI/Models/RealDataModel.h" @@ -79,7 +80,7 @@ TEST_F(TestOutputDataIOService, test_nonXMLData) // Replacing the data inside RealDataItem with the data of different dimensions auto data = GuiUnittestUtils::createData(3.0, GuiUnittestUtils::DIM::D1); EXPECT_THROW(dynamic_cast<RealDataItem*>(realData)->setOutputData(data.get()), - GUIHelpers::Error); + Error); EXPECT_EQ(models.realDataModel()->nonXMLItems().size(), 1); } @@ -131,7 +132,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataDirHistory) EXPECT_FALSE(history.wasModifiedSinceLastSave(item1)); // Attempt to save same item second time - EXPECT_THROW(history.markAsSaved(item1), GUIHelpers::Error); + EXPECT_THROW(history.markAsSaved(item1), Error); // Modifying item QTest::qSleep(10); @@ -178,7 +179,7 @@ TEST_F(TestOutputDataIOService, test_OutputDataIOHistory) == true); // since item2 doesn't exist // asking info for some non-existing directory - EXPECT_THROW(history.wasModifiedSinceLastSave("dir3", item1), GUIHelpers::Error); + EXPECT_THROW(history.wasModifiedSinceLastSave("dir3", item1), Error); } //! Testing saving abilities of OutputDataIOService class. diff --git a/Tests/UnitTests/GUI/TestProjectUtils.cpp b/Tests/UnitTests/GUI/TestProjectUtils.cpp index 51cdf3f5b261b98e6f925ce747dbb9e80cd7d9fa..85eddc40ce945d30d06f416b60075c5219b51966 100644 --- a/Tests/UnitTests/GUI/TestProjectUtils.cpp +++ b/Tests/UnitTests/GUI/TestProjectUtils.cpp @@ -1,5 +1,5 @@ +#include "GUI/Models/Error.h" #include "GUI/mainwindow/ProjectUtils.h" -#include "GUI/utils/GUIHelpers.h" #include "Tests/GTestWrapper/google_test.h" #include "Utils.h" #include <QDir> @@ -16,8 +16,8 @@ protected: QFile file(filename); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - throw GUIHelpers::Error("TestProjectUtils::createTestFile() -> Error. " - "Can't create file"); + throw Error("TestProjectUtils::createTestFile() -> Error. " + "Can't create file"); QTextStream out(&file); out << "Test file " << 42 << "\n"; diff --git a/Tests/UnitTests/GUI/TestSaveService.cpp b/Tests/UnitTests/GUI/TestSaveService.cpp index 0849e06da71db00fd4e23930589595c85c1be501..2853462fa42195114cce17e280467cfcf41d397a 100644 --- a/Tests/UnitTests/GUI/TestSaveService.cpp +++ b/Tests/UnitTests/GUI/TestSaveService.cpp @@ -1,4 +1,5 @@ #include "GUI/Models/ApplicationModels.h" +#include "GUI/Models/Error.h" #include "GUI/Models/InstrumentItems.h" #include "GUI/Models/InstrumentModel.h" #include "GUI/Models/IntensityDataItem.h" @@ -151,7 +152,7 @@ TEST_F(TestSaveService, test_failingSaveService) QSignalSpy spySaveService(&service, SIGNAL(projectSaved())); service.setDocument(document.get()); - EXPECT_THROW(service.save(projectFileName), GUIHelpers::Error); + EXPECT_THROW(service.save(projectFileName), Error); EXPECT_EQ(spySaveService.count(), 0); EXPECT_FALSE(ProjectUtils::exists(projectFileName)); diff --git a/Tests/UnitTests/GUI/TestSavingSpecularData.cpp b/Tests/UnitTests/GUI/TestSavingSpecularData.cpp index cbce4a700ba7c7f49c256e8112318b40e9bb0862..201a05db000a56d0375afb08a77fb8044cb4b1ed 100644 --- a/Tests/UnitTests/GUI/TestSavingSpecularData.cpp +++ b/Tests/UnitTests/GUI/TestSavingSpecularData.cpp @@ -2,6 +2,7 @@ #include "Device/Histo/IntensityDataIOFactory.h" #include "GUI/Models/ApplicationModels.h" #include "GUI/Models/DataItem.h" +#include "GUI/Models/Error.h" #include "GUI/Models/GroupItem.h" #include "GUI/Models/InstrumentItems.h" #include "GUI/Models/InstrumentModel.h" @@ -14,7 +15,6 @@ #include "GUI/Models/SpecularBeamInclinationItem.h" #include "GUI/mainwindow/OutputDataIOService.h" #include "GUI/mainwindow/ProjectUtils.h" -#include "GUI/utils/GUIHelpers.h" #include "Tests/GTestWrapper/google_test.h" #include "Tests/UnitTests/GUI/Utils.h" #include <QTest> @@ -176,7 +176,7 @@ TEST_F(TestSavingSpecularData, test_DirHistory) EXPECT_FALSE(history.wasModifiedSinceLastSave(item1)); // Attempt to save same item second time - EXPECT_THROW(history.markAsSaved(item1), GUIHelpers::Error); + EXPECT_THROW(history.markAsSaved(item1), Error); // Modifying item QTest::qSleep(10); diff --git a/Tests/UnitTests/GUI/TestSessionItemTags.cpp b/Tests/UnitTests/GUI/TestSessionItemTags.cpp index afc93388f8cd6d814b05ee004455d04605e5e4d8..1ddadc7e3f214aa569586737a944d046cbe65436 100644 --- a/Tests/UnitTests/GUI/TestSessionItemTags.cpp +++ b/Tests/UnitTests/GUI/TestSessionItemTags.cpp @@ -1,5 +1,5 @@ +#include "GUI/Models/Error.h" #include "GUI/Models/SessionItemTags.h" -#include "GUI/utils/GUIHelpers.h" #include "Tests/GTestWrapper/google_test.h" class TestSessionItemTags : public ::testing::Test { @@ -73,7 +73,7 @@ TEST_F(TestSessionItemTags, tagStartIndex) EXPECT_EQ(tags.childCount("tag1"), 2); EXPECT_EQ(tags.childCount("tag2"), 0); // attempt to add too much - EXPECT_THROW(tags.addChild("tag1"), GUIHelpers::Error); + EXPECT_THROW(tags.addChild("tag1"), Error); // checking start index EXPECT_EQ(tags.tagStartIndex("tag1"), 0); @@ -86,7 +86,7 @@ TEST_F(TestSessionItemTags, tagStartIndex) // removing too much child tags.removeChild("tag1"); - EXPECT_THROW(tags.removeChild("tag1"), GUIHelpers::Error); + EXPECT_THROW(tags.removeChild("tag1"), Error); EXPECT_EQ(tags.tagStartIndex("tag1"), 0); EXPECT_EQ(tags.tagStartIndex("tag2"), 0); } @@ -106,8 +106,8 @@ TEST_F(TestSessionItemTags, indexFromTagRow) EXPECT_EQ(tags.indexFromTagRow("tag1", 0), 0); EXPECT_EQ(tags.indexFromTagRow("tag1", 1), 1); EXPECT_EQ(tags.indexFromTagRow("tag1", 2), 2); - EXPECT_THROW(tags.indexFromTagRow("tag1", 3), GUIHelpers::Error); - EXPECT_THROW(tags.indexFromTagRow("tag1", -1), GUIHelpers::Error); + EXPECT_THROW(tags.indexFromTagRow("tag1", 3), Error); + EXPECT_THROW(tags.indexFromTagRow("tag1", -1), Error); EXPECT_EQ(tags.indexFromTagRow("tag2", 0), 3); EXPECT_EQ(tags.indexFromTagRow("tag2", 1), 4); diff --git a/Tests/UnitTests/GUI/Utils.cpp b/Tests/UnitTests/GUI/Utils.cpp index d60f37d2284c1762590224f2b846c37db440c1a8..5391e9aa8e7eaf0b09fa4a4ef71ccec48f02b873 100644 --- a/Tests/UnitTests/GUI/Utils.cpp +++ b/Tests/UnitTests/GUI/Utils.cpp @@ -16,10 +16,10 @@ #include "Tests/UnitTests/GUI/Utils.h" #include "Device/Data/DataUtils.h" #include "Device/Histo/IntensityDataIOFactory.h" +#include "GUI/Models/Error.h" #include "GUI/Models/RealDataItem.h" #include "GUI/Models/SessionModel.h" #include "GUI/mainwindow/ProjectUtils.h" -#include "GUI/utils/GUIHelpers.h" #include <QDir> namespace { @@ -33,8 +33,8 @@ void GuiUnittestUtils::create_dir(const QString& dir_name) ProjectUtils::removeRecursively(dir_name); if (!QDir(".").mkdir(dir_name)) - throw GUIHelpers::Error("GuiUnittestUtils::create_dir() -> Error. Can't create '" + dir_name - + "' in parent directory '.'."); + throw Error("GuiUnittestUtils::create_dir() -> Error. Can't create '" + dir_name + + "' in parent directory '.'."); } std::unique_ptr<OutputData<double>> GuiUnittestUtils::createData(double value, DIM n_dim)