From 7e9e955376b504dc7d9e0a5e79a9a38943a53fcd Mon Sep 17 00:00:00 2001 From: spo Date: Thu, 23 Jun 2016 17:33:12 +0300 Subject: [PATCH] Validators return InfoMessage instead of string as an error --- src/BuildPlugin/BuildPlugin_Validators.cpp | 8 ++-- src/BuildPlugin/BuildPlugin_Validators.h | 8 ++-- src/Config/Config_Translator.cpp | 9 ++--- src/Config/Config_Translator.h | 6 +-- src/Events/Events_InfoMessage.h | 13 +++++- .../ExchangePlugin_Validators.cpp | 4 +- .../ExchangePlugin_Validators.h | 2 +- .../FeaturesPlugin_ValidatorTransform.cpp | 4 +- .../FeaturesPlugin_ValidatorTransform.h | 2 +- .../FeaturesPlugin_Validators.cpp | 40 ++++++++++--------- .../FeaturesPlugin_Validators.h | 26 ++++++------ .../GeomValidators_BodyShapes.cpp | 4 +- .../GeomValidators_BodyShapes.h | 2 +- .../GeomValidators_BooleanArguments.cpp | 4 +- .../GeomValidators_BooleanArguments.h | 2 +- .../GeomValidators_ConstructionComposite.cpp | 4 +- .../GeomValidators_ConstructionComposite.h | 2 +- .../GeomValidators_Different.cpp | 4 +- src/GeomValidators/GeomValidators_Different.h | 2 +- .../GeomValidators_DifferentShapes.cpp | 4 +- .../GeomValidators_DifferentShapes.h | 2 +- src/GeomValidators/GeomValidators_Face.cpp | 2 +- src/GeomValidators/GeomValidators_Face.h | 2 +- .../GeomValidators_FeatureKind.cpp | 4 +- .../GeomValidators_FeatureKind.h | 2 +- src/GeomValidators/GeomValidators_Finite.cpp | 4 +- src/GeomValidators/GeomValidators_Finite.h | 2 +- .../GeomValidators_IntersectionSelection.cpp | 9 +++-- .../GeomValidators_IntersectionSelection.h | 2 +- .../GeomValidators_MinObjectsSelected.cpp | 4 +- .../GeomValidators_MinObjectsSelected.h | 2 +- .../GeomValidators_PartitionArguments.cpp | 4 +- .../GeomValidators_PartitionArguments.h | 2 +- .../GeomValidators_Positive.cpp | 5 ++- src/GeomValidators/GeomValidators_Positive.h | 2 +- .../GeomValidators_ShapeType.cpp | 8 ++-- src/GeomValidators/GeomValidators_ShapeType.h | 8 ++-- .../GeomValidators_ZeroOffset.cpp | 4 +- .../GeomValidators_ZeroOffset.h | 2 +- src/Model/Model_AttributeValidator.cpp | 4 +- src/Model/Model_AttributeValidator.h | 2 +- src/Model/Model_FeatureValidator.cpp | 5 ++- src/Model/Model_FeatureValidator.h | 2 +- src/Model/Model_Validator.cpp | 14 +++---- src/Model/Model_Validator.h | 2 +- src/ModelAPI/ModelAPI_AttributeValidator.h | 2 +- src/ModelAPI/ModelAPI_FeatureValidator.h | 2 +- src/ModelAPI/ModelAPI_Validator.h | 3 +- src/ModuleBase/ModuleBase_ModelWidget.cpp | 13 ++++-- src/ModuleBase/ModuleBase_WidgetValidated.cpp | 5 ++- .../ParametersPlugin_EvalListener.cpp | 3 +- .../ParametersPlugin_Validators.cpp | 6 ++- .../ParametersPlugin_Validators.h | 4 +- .../ParametersPlugin_WidgetParamsMgr.cpp | 7 +++- src/PartSet/PartSet_Validators.cpp | 6 ++- src/PartSet/PartSet_Validators.h | 4 +- src/PartSet/PartSet_WidgetSketchCreator.cpp | 11 +++-- .../SketchPlugin_ExternalValidator.cpp | 4 +- .../SketchPlugin_ExternalValidator.h | 2 +- src/SketchPlugin/SketchPlugin_Validators.cpp | 32 ++++++++------- src/SketchPlugin/SketchPlugin_Validators.h | 26 ++++++------ src/XGUI/XGUI_ErrorDialog.cpp | 2 +- 62 files changed, 227 insertions(+), 154 deletions(-) diff --git a/src/BuildPlugin/BuildPlugin_Validators.cpp b/src/BuildPlugin/BuildPlugin_Validators.cpp index 234e697b2..9c2be0bae 100644 --- a/src/BuildPlugin/BuildPlugin_Validators.cpp +++ b/src/BuildPlugin/BuildPlugin_Validators.cpp @@ -28,7 +28,7 @@ //================================================================================================= bool BuildPlugin_ValidatorBaseForBuild::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { // Get base objects list. if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) { @@ -109,7 +109,7 @@ bool BuildPlugin_ValidatorBaseForBuild::isValid(const AttributePtr& theAttribute //================================================================================================= bool BuildPlugin_ValidatorBaseForWire::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { // Get attribute. if(theArguments.size() != 1) { @@ -154,7 +154,7 @@ bool BuildPlugin_ValidatorBaseForWire::isNotObligatory(std::string theFeature, s //================================================================================================= bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { // Get attribute. if(theArguments.size() != 1) { @@ -229,7 +229,7 @@ bool BuildPlugin_ValidatorBaseForFace::isNotObligatory(std::string theFeature, s //================================================================================================= bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if(theArguments.size() != 1) { std::string aMsg = "Error: BuildPlugin_ValidatorSubShapesSelection should be used only with " diff --git a/src/BuildPlugin/BuildPlugin_Validators.h b/src/BuildPlugin/BuildPlugin_Validators.h index 2bd253f9d..a72a882f1 100644 --- a/src/BuildPlugin/BuildPlugin_Validators.h +++ b/src/BuildPlugin/BuildPlugin_Validators.h @@ -23,7 +23,7 @@ public: //! \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class BuildPlugin_ValidatorBaseForWire @@ -39,7 +39,7 @@ public: //! \param theError error message. virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// \return true if the attribute in feature is not obligatory for the feature execution virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); @@ -58,7 +58,7 @@ public: //! \param theError error message. virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// \return true if the attribute in feature is not obligatory for the feature execution virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); @@ -76,7 +76,7 @@ public: //! \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif diff --git a/src/Config/Config_Translator.cpp b/src/Config/Config_Translator.cpp index 1210b2bbc..058acfca3 100644 --- a/src/Config/Config_Translator.cpp +++ b/src/Config/Config_Translator.cpp @@ -101,15 +101,14 @@ bool Config_Translator::load(const std::string& theFileName) return true; } -std::string Config_Translator::translate(std::shared_ptr theInfo) +std::string Config_Translator::translate(const Events_InfoMessage& theInfo) { - std::string aContext = theInfo->context(); - std::string aMessage = theInfo->messageString(); - std::list aParameters = theInfo->parameters(); + std::string aContext = theInfo.context(); + std::string aMessage = theInfo.messageString(); + std::list aParameters = theInfo.parameters(); return translate(aContext, aMessage, aParameters); } - std::string insertParameters(const std::string& theString, const std::list& theParams) { std::string aResult = theString; diff --git a/src/Config/Config_Translator.h b/src/Config/Config_Translator.h index 6f79f81d1..158091be3 100644 --- a/src/Config/Config_Translator.h +++ b/src/Config/Config_Translator.h @@ -40,11 +40,11 @@ public: /** * Returns translation from the given info message. - * If transdlation is not exists then it returns a string + * If translation is not exists then it returns a string * from the info data without translation * \param theInfo an info message */ - static CONFIG_EXPORT std::string translate(std::shared_ptr theInfo); + static CONFIG_EXPORT std::string translate(const Events_InfoMessage& theInfo); /** * Returns translation from the given data. @@ -86,4 +86,4 @@ private: #endif }; -#endif \ No newline at end of file +#endif diff --git a/src/Events/Events_InfoMessage.h b/src/Events/Events_InfoMessage.h index 959001c43..2924df181 100644 --- a/src/Events/Events_InfoMessage.h +++ b/src/Events/Events_InfoMessage.h @@ -24,7 +24,7 @@ public: /// Constructor /// \param theSender a pointer on sender object - Events_InfoMessage(const void* theSender = 0):Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {} + explicit Events_InfoMessage(const void* theSender = 0):Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {} /// Constructor /// \param theSender a pointer on sender object @@ -54,6 +54,15 @@ public: /// Returns message std::string messageString() const { return myMessage; } + Events_InfoMessage& operator=(const std::string& theMsg) { + setMessageString(theMsg); + return *this; + } + + bool empty() const { + return myMessage.empty(); + } + /// Add parameter for message string of string type /// \param theParam the parameter void addParameter(const std::string& theParam) @@ -99,4 +108,4 @@ private: std::list myParameters; }; -#endif \ No newline at end of file +#endif diff --git a/src/ExchangePlugin/ExchangePlugin_Validators.cpp b/src/ExchangePlugin/ExchangePlugin_Validators.cpp index e08b9854a..a0117d84e 100644 --- a/src/ExchangePlugin/ExchangePlugin_Validators.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Validators.cpp @@ -8,6 +8,8 @@ #include +#include + #include #include #include @@ -39,7 +41,7 @@ bool ExchangePlugin_FormatValidator::parseFormats(const std::list& bool ExchangePlugin_FormatValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (!theAttribute->isInitialized()) { theError = "Is not initialized."; diff --git a/src/ExchangePlugin/ExchangePlugin_Validators.h b/src/ExchangePlugin/ExchangePlugin_Validators.h index ab1a142f9..61613f35e 100644 --- a/src/ExchangePlugin/ExchangePlugin_Validators.h +++ b/src/ExchangePlugin/ExchangePlugin_Validators.h @@ -35,7 +35,7 @@ public: */ virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /** diff --git a/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.cpp b/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.cpp index 570d1fb6f..9722f8836 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.cpp @@ -2,6 +2,8 @@ #include "FeaturesPlugin_ValidatorTransform.h" +#include + #include "ModelAPI_AttributeSelectionList.h" #include "ModelAPI_ResultPart.h" #include "ModelAPI_ResultBody.h" @@ -10,7 +12,7 @@ bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { bool aValid = true; std::string anAttributeType = theAttribute->attributeType(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.h b/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.h index b957253e3..f57f2f9bd 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.h +++ b/src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.h @@ -23,7 +23,7 @@ class FeaturesPlugin_ValidatorTransform : public ModelAPI_AttributeValidator */ virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index db8348cd2..58c77cdd4 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -8,6 +8,8 @@ #include "FeaturesPlugin_Union.h" +#include + #include #include #include @@ -38,7 +40,7 @@ //================================================================================================== bool FeaturesPlugin_ValidatorPipePath::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { AttributeSelectionPtr aPathAttrSelection = std::dynamic_pointer_cast(theAttribute); if(!aPathAttrSelection.get()) { @@ -64,7 +66,7 @@ bool FeaturesPlugin_ValidatorPipePath::isValid(const AttributePtr& theAttribute, //================================================================================================== bool FeaturesPlugin_ValidatorPipeLocations::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { static const std::string aCreationMethodID = "creation_method"; static const std::string aBaseObjectsID = "base_objects"; @@ -114,7 +116,7 @@ bool FeaturesPlugin_ValidatorPipeLocations::isNotObligatory(std::string theFeatu //================================================================================================== bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if(theArguments.empty()) { theError = "Error: Validator parameters is empty."; @@ -207,7 +209,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA //================================================================================================== bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if(!theAttribute.get()) { theError = "Error: Empty attribute."; @@ -275,12 +277,14 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute GeomValidators_ShapeType aShapeTypeValidator; if(!aShapeTypeValidator.isValid(anAttr, theArguments, theError)) { theError = "Error: Selected shape has unacceptable type. Acceptable types are: faces or wires on sketch, " - "whole sketch(if it has at least one face), and whole objects with shape types: "; - std::list::const_iterator anIt = theArguments.cbegin(); - theError += *anIt; - for(++anIt; anIt != theArguments.cend(); ++anIt) { - theError += ", " + *anIt; + "whole sketch(if it has at least one face), and whole objects with shape types: %1"; + std::string anArgumentString; + for(auto anIt = theArguments.cbegin(); anIt != theArguments.cend(); ++anIt) { + if (!anArgumentString.empty()) + anArgumentString += ", "; + anArgumentString += *anIt; } + theError.arg(anArgumentString); return false; } @@ -295,7 +299,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute //================================================================================================== bool FeaturesPlugin_ValidatorCompositeLauncher::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeReference::typeId()) { theError = "Error: The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -340,7 +344,7 @@ bool FeaturesPlugin_ValidatorCompositeLauncher::isValid(const AttributePtr& theA //================================================================================================== bool FeaturesPlugin_ValidatorExtrusionDir::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if(theArguments.size() != 2) { theError = "Error: Validator should be used with 2 parameters for extrusion."; @@ -427,7 +431,7 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isNotObligatory(std::string theFeatur //================================================================================================== bool FeaturesPlugin_ValidatorExtrusionDir::isShapesCanBeEmpty(const AttributePtr& theAttribute, - std::string& theError) const + Events_InfoMessage& theError) const { if(!theAttribute.get()) { return true; @@ -474,7 +478,7 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isShapesCanBeEmpty(const AttributePtr //================================================================================================== bool FeaturesPlugin_ValidatorBooleanSelection::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { AttributeSelectionListPtr anAttrSelectionList = std::dynamic_pointer_cast(theAttribute); if(!anAttrSelectionList.get()) { @@ -536,7 +540,7 @@ bool FeaturesPlugin_ValidatorBooleanSelection::isValid(const AttributePtr& theAt //================================================================================================== bool FeaturesPlugin_ValidatorPartitionSelection::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { AttributeSelectionListPtr anAttrSelectionList = std::dynamic_pointer_cast(theAttribute); if(!anAttrSelectionList.get()) { @@ -580,7 +584,7 @@ bool FeaturesPlugin_ValidatorPartitionSelection::isValid(const AttributePtr& the //================================================================================================== bool FeaturesPlugin_ValidatorRemoveSubShapesSelection::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { AttributeSelectionListPtr aSubShapesAttrList = std::dynamic_pointer_cast(theAttribute); if(!aSubShapesAttrList.get()) { @@ -633,7 +637,7 @@ bool FeaturesPlugin_ValidatorRemoveSubShapesSelection::isValid(const AttributePt //================================================================================================== bool FeaturesPlugin_ValidatorRemoveSubShapesResult::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { static const std::string aBaseShapeID = "base_shape"; static const std::string aSubShapesID = "subshapes"; @@ -689,7 +693,7 @@ bool FeaturesPlugin_ValidatorRemoveSubShapesResult::isNotObligatory(std::string //================================================================================================== bool FeaturesPlugin_ValidatorUnionSelection::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { AttributeSelectionListPtr aBaseObjectsAttrList = std::dynamic_pointer_cast(theAttribute); if(!aBaseObjectsAttrList.get()) { @@ -716,7 +720,7 @@ bool FeaturesPlugin_ValidatorUnionSelection::isValid(const AttributePtr& theAttr //================================================================================================== bool FeaturesPlugin_ValidatorUnionArguments::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { // Check feature kind. if(theFeature->getKind() != FeaturesPlugin_Union::ID()) { diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.h b/src/FeaturesPlugin/FeaturesPlugin_Validators.h index c806e754b..ce3fe042e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.h @@ -22,7 +22,7 @@ public: //! \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorPipeLocations @@ -37,7 +37,7 @@ class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator //! \param theError error message virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// Returns true if the attribute in feature is not obligatory for the feature execution virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); @@ -56,12 +56,12 @@ public: //! \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; private: bool isValidAttribute(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorCompositeLauncher @@ -76,7 +76,7 @@ public: //! \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorExtrusionDir @@ -92,14 +92,14 @@ public: //! \param[out] theError error message. virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// \return true if the attribute in feature is not obligatory for the feature execution virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); private: bool isShapesCanBeEmpty(const AttributePtr& theAttribute, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorBooleanSelection @@ -115,7 +115,7 @@ public: /// \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorPartitionSelection @@ -131,7 +131,7 @@ public: /// \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection @@ -147,7 +147,7 @@ public: /// \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult @@ -162,7 +162,7 @@ class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureVali //! \param theError error message virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// \return true if the attribute in feature is not obligatory for the feature execution virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); @@ -181,7 +181,7 @@ public: /// \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorUnionArguments @@ -196,7 +196,7 @@ class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator //! \param theError error message virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// \return true if the attribute in feature is not obligatory for the feature execution virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); diff --git a/src/GeomValidators/GeomValidators_BodyShapes.cpp b/src/GeomValidators/GeomValidators_BodyShapes.cpp index 18bd9918a..a681fbe5d 100644 --- a/src/GeomValidators/GeomValidators_BodyShapes.cpp +++ b/src/GeomValidators/GeomValidators_BodyShapes.cpp @@ -6,13 +6,15 @@ #include "GeomValidators_BodyShapes.h" +#include + #include #include #include bool GeomValidators_BodyShapes::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { std::string anAttributeType = theAttribute->attributeType(); if(anAttributeType == ModelAPI_AttributeSelection::typeId()) { diff --git a/src/GeomValidators/GeomValidators_BodyShapes.h b/src/GeomValidators/GeomValidators_BodyShapes.h index 33e2f8f50..5058cfcb8 100644 --- a/src/GeomValidators/GeomValidators_BodyShapes.h +++ b/src/GeomValidators/GeomValidators_BodyShapes.h @@ -25,7 +25,7 @@ public: /// \param[out] theError error message. GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif diff --git a/src/GeomValidators/GeomValidators_BooleanArguments.cpp b/src/GeomValidators/GeomValidators_BooleanArguments.cpp index b54344510..1db13e607 100644 --- a/src/GeomValidators/GeomValidators_BooleanArguments.cpp +++ b/src/GeomValidators/GeomValidators_BooleanArguments.cpp @@ -6,13 +6,15 @@ #include +#include + #include #include //================================================================================================= bool GeomValidators_BooleanArguments::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if(theArguments.size() != 3) { theError = "Wrong number of arguments (expected 3)."; diff --git a/src/GeomValidators/GeomValidators_BooleanArguments.h b/src/GeomValidators/GeomValidators_BooleanArguments.h index 1686c8ee4..42a46d53a 100644 --- a/src/GeomValidators/GeomValidators_BooleanArguments.h +++ b/src/GeomValidators/GeomValidators_BooleanArguments.h @@ -26,7 +26,7 @@ public: */ GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// \return true if the attribute in feature is not obligatory for the feature execution. GEOMVALIDATORS_EXPORT virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); diff --git a/src/GeomValidators/GeomValidators_ConstructionComposite.cpp b/src/GeomValidators/GeomValidators_ConstructionComposite.cpp index b19719831..c748c2cdc 100644 --- a/src/GeomValidators/GeomValidators_ConstructionComposite.cpp +++ b/src/GeomValidators/GeomValidators_ConstructionComposite.cpp @@ -2,13 +2,15 @@ #include "GeomValidators_ConstructionComposite.h" +#include + #include "ModelAPI_AttributeSelection.h" #include "ModelAPI_ResultConstruction.h" #include "ModelAPI_CompositeFeature.h" bool GeomValidators_ConstructionComposite::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { bool aValid = true; if (theAttribute->attributeType() != ModelAPI_AttributeSelection::typeId()) { diff --git a/src/GeomValidators/GeomValidators_ConstructionComposite.h b/src/GeomValidators/GeomValidators_ConstructionComposite.h index fb37f95bc..67a2a3a30 100644 --- a/src/GeomValidators/GeomValidators_ConstructionComposite.h +++ b/src/GeomValidators/GeomValidators_ConstructionComposite.h @@ -24,7 +24,7 @@ class GeomValidators_ConstructionComposite : public ModelAPI_AttributeValidator //! \param[out] theError error message. GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif diff --git a/src/GeomValidators/GeomValidators_Different.cpp b/src/GeomValidators/GeomValidators_Different.cpp index 94c369c5a..617161f9c 100644 --- a/src/GeomValidators/GeomValidators_Different.cpp +++ b/src/GeomValidators/GeomValidators_Different.cpp @@ -6,6 +6,8 @@ #include +#include + #include #include @@ -54,7 +56,7 @@ public: bool GeomValidators_Different::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { std::map > anAttributesMap; // For all attributes referred by theArguments diff --git a/src/GeomValidators/GeomValidators_Different.h b/src/GeomValidators/GeomValidators_Different.h index a5be84f7b..e5d7e15bf 100644 --- a/src/GeomValidators/GeomValidators_Different.h +++ b/src/GeomValidators/GeomValidators_Different.h @@ -26,7 +26,7 @@ public: */ GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; GEOMVALIDATORS_EXPORT virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); }; diff --git a/src/GeomValidators/GeomValidators_DifferentShapes.cpp b/src/GeomValidators/GeomValidators_DifferentShapes.cpp index e9470daf4..7eefe2626 100644 --- a/src/GeomValidators/GeomValidators_DifferentShapes.cpp +++ b/src/GeomValidators/GeomValidators_DifferentShapes.cpp @@ -6,12 +6,14 @@ #include "GeomValidators_DifferentShapes.h" +#include + #include #include "ModelAPI_Object.h" bool GeomValidators_DifferentShapes::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); AttributeSelectionPtr aSelectionAttribute = diff --git a/src/GeomValidators/GeomValidators_DifferentShapes.h b/src/GeomValidators/GeomValidators_DifferentShapes.h index ac3dd5b58..2bfef9711 100644 --- a/src/GeomValidators/GeomValidators_DifferentShapes.h +++ b/src/GeomValidators/GeomValidators_DifferentShapes.h @@ -25,7 +25,7 @@ public: /// \param[out] theError error message. GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif diff --git a/src/GeomValidators/GeomValidators_Face.cpp b/src/GeomValidators/GeomValidators_Face.cpp index f91066da2..391ae4f82 100644 --- a/src/GeomValidators/GeomValidators_Face.cpp +++ b/src/GeomValidators/GeomValidators_Face.cpp @@ -34,7 +34,7 @@ GeomAbs_SurfaceType faceType(const std::string& theType) bool GeomValidators_Face::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { std::string anAttributeType = theAttribute->attributeType(); if (anAttributeType != ModelAPI_AttributeSelection::typeId()) { diff --git a/src/GeomValidators/GeomValidators_Face.h b/src/GeomValidators/GeomValidators_Face.h index f547dbb47..c3b802658 100644 --- a/src/GeomValidators/GeomValidators_Face.h +++ b/src/GeomValidators/GeomValidators_Face.h @@ -24,7 +24,7 @@ class GeomValidators_Face : public ModelAPI_AttributeValidator //! \param[out] theError error message. GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif diff --git a/src/GeomValidators/GeomValidators_FeatureKind.cpp b/src/GeomValidators/GeomValidators_FeatureKind.cpp index 9c663a1f7..c6036e414 100755 --- a/src/GeomValidators/GeomValidators_FeatureKind.cpp +++ b/src/GeomValidators/GeomValidators_FeatureKind.cpp @@ -6,6 +6,8 @@ #include "GeomValidators_FeatureKind.h" +#include + #include #include #include @@ -19,7 +21,7 @@ bool GeomValidators_FeatureKind::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { bool isSketchEntities = true; std::set anEntityKinds; diff --git a/src/GeomValidators/GeomValidators_FeatureKind.h b/src/GeomValidators/GeomValidators_FeatureKind.h index 894992753..4884aed1d 100755 --- a/src/GeomValidators/GeomValidators_FeatureKind.h +++ b/src/GeomValidators/GeomValidators_FeatureKind.h @@ -25,7 +25,7 @@ public: /// \param[out] theError error message. GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif diff --git a/src/GeomValidators/GeomValidators_Finite.cpp b/src/GeomValidators/GeomValidators_Finite.cpp index 150415cb1..6668b8bba 100755 --- a/src/GeomValidators/GeomValidators_Finite.cpp +++ b/src/GeomValidators/GeomValidators_Finite.cpp @@ -6,12 +6,14 @@ #include +#include + #include #include bool GeomValidators_Finite::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { bool aValid = true; diff --git a/src/GeomValidators/GeomValidators_Finite.h b/src/GeomValidators/GeomValidators_Finite.h index 85b5b9803..78c6b7c45 100755 --- a/src/GeomValidators/GeomValidators_Finite.h +++ b/src/GeomValidators/GeomValidators_Finite.h @@ -23,7 +23,7 @@ public: //! \param[out] theError error message. GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif diff --git a/src/GeomValidators/GeomValidators_IntersectionSelection.cpp b/src/GeomValidators/GeomValidators_IntersectionSelection.cpp index e3899d7f5..ec2a886e0 100644 --- a/src/GeomValidators/GeomValidators_IntersectionSelection.cpp +++ b/src/GeomValidators/GeomValidators_IntersectionSelection.cpp @@ -6,13 +6,15 @@ #include "GeomValidators_IntersectionSelection.h" +#include + #include #include #include bool GeomValidators_IntersectionSelection::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if(!theAttribute.get()) { theError = "Error: empty selection."; @@ -40,9 +42,8 @@ bool GeomValidators_IntersectionSelection::isValid(const AttributePtr& theAttrib if(aFeatureKind == "Sketch" || aFeatureKind == "Plane" || aFeatureKind == "Axis") { - theError = "Error: "; - theError += aFeatureKind; - theError += " shape is not allowed for selection."; + theError = "Error: %1 shape is not allowed for selection."; + theError.arg(aFeatureKind); return false; } std::shared_ptr aShape = anAttrSelection->value(); diff --git a/src/GeomValidators/GeomValidators_IntersectionSelection.h b/src/GeomValidators/GeomValidators_IntersectionSelection.h index 35a78c04b..b3de2da03 100644 --- a/src/GeomValidators/GeomValidators_IntersectionSelection.h +++ b/src/GeomValidators/GeomValidators_IntersectionSelection.h @@ -25,7 +25,7 @@ public: /// \param[out] theError error message. GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif diff --git a/src/GeomValidators/GeomValidators_MinObjectsSelected.cpp b/src/GeomValidators/GeomValidators_MinObjectsSelected.cpp index 58e39b3a0..aa4088daa 100644 --- a/src/GeomValidators/GeomValidators_MinObjectsSelected.cpp +++ b/src/GeomValidators/GeomValidators_MinObjectsSelected.cpp @@ -6,13 +6,15 @@ #include +#include + #include #include //================================================================================================= bool GeomValidators_MinObjectsSelected::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if(theArguments.size() != 2) { theError = "Error: Wrong number of arguments (expected 2): selection list id and min number of objects"; diff --git a/src/GeomValidators/GeomValidators_MinObjectsSelected.h b/src/GeomValidators/GeomValidators_MinObjectsSelected.h index cdcb20a27..27f860c81 100644 --- a/src/GeomValidators/GeomValidators_MinObjectsSelected.h +++ b/src/GeomValidators/GeomValidators_MinObjectsSelected.h @@ -24,7 +24,7 @@ public: /// \returns true if feature is valid. GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// \return true if the attribute in feature is not obligatory for the feature execution. GEOMVALIDATORS_EXPORT virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); diff --git a/src/GeomValidators/GeomValidators_PartitionArguments.cpp b/src/GeomValidators/GeomValidators_PartitionArguments.cpp index e94ebca48..9d017b017 100644 --- a/src/GeomValidators/GeomValidators_PartitionArguments.cpp +++ b/src/GeomValidators/GeomValidators_PartitionArguments.cpp @@ -6,13 +6,15 @@ #include +#include + #include #include //================================================================================================= bool GeomValidators_PartitionArguments::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if(theArguments.size() != 3) { theError = "Wrong number of arguments (expected 3)."; diff --git a/src/GeomValidators/GeomValidators_PartitionArguments.h b/src/GeomValidators/GeomValidators_PartitionArguments.h index 1b3207001..6d7c3a833 100644 --- a/src/GeomValidators/GeomValidators_PartitionArguments.h +++ b/src/GeomValidators/GeomValidators_PartitionArguments.h @@ -26,7 +26,7 @@ public: */ GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// \return true if the attribute in feature is not obligatory for the feature execution. GEOMVALIDATORS_EXPORT virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); diff --git a/src/GeomValidators/GeomValidators_Positive.cpp b/src/GeomValidators/GeomValidators_Positive.cpp index b127ffe03..17c38fb19 100644 --- a/src/GeomValidators/GeomValidators_Positive.cpp +++ b/src/GeomValidators/GeomValidators_Positive.cpp @@ -5,6 +5,9 @@ // Author: Mikhail PONIKAROV #include "GeomValidators_Positive.h" + +#include + #include #include #include @@ -25,7 +28,7 @@ GeomValidators_Positive::GeomValidators_Positive() bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { double aMinValue = 1.e-5; if(theArguments.size() == 1) { diff --git a/src/GeomValidators/GeomValidators_Positive.h b/src/GeomValidators/GeomValidators_Positive.h index 0e15c77d2..08a30d288 100644 --- a/src/GeomValidators/GeomValidators_Positive.h +++ b/src/GeomValidators/GeomValidators_Positive.h @@ -24,7 +24,7 @@ public: //! \param[out] theError error message. GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; diff --git a/src/GeomValidators/GeomValidators_ShapeType.cpp b/src/GeomValidators/GeomValidators_ShapeType.cpp index 8bc0d9fbd..2027c50ea 100755 --- a/src/GeomValidators/GeomValidators_ShapeType.cpp +++ b/src/GeomValidators/GeomValidators_ShapeType.cpp @@ -64,7 +64,7 @@ std::string getShapeTypeDescription(const GeomValidators_ShapeType::TypeOfShape& bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { bool aValid = false; @@ -99,7 +99,7 @@ bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute, bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute, const TypeOfShape theShapeType, - std::string& theError) const + Events_InfoMessage& theError) const { bool aValid = true; @@ -160,7 +160,7 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject, const TypeOfShape theShapeType, - std::string& theError) const + Events_InfoMessage& theError) const { bool aValid = true; if (!theObject.get()) { @@ -191,7 +191,7 @@ bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject, bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape, const TypeOfShape theShapeType, - std::string& theError) const + Events_InfoMessage& theError) const { bool aValid = true; diff --git a/src/GeomValidators/GeomValidators_ShapeType.h b/src/GeomValidators/GeomValidators_ShapeType.h index 3d2c60e65..0146cfda7 100644 --- a/src/GeomValidators/GeomValidators_ShapeType.h +++ b/src/GeomValidators/GeomValidators_ShapeType.h @@ -49,7 +49,7 @@ class GeomValidators_ShapeType : public ModelAPI_AttributeValidator //! \param[out] theError error message. GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; protected: /// Convert string to TypeOfShape value /// \param theType a string value @@ -61,7 +61,7 @@ protected: /// \param[out] theError error message. bool isValidAttribute(const AttributePtr& theAttribute, const TypeOfShape theShapeType, - std::string& theError) const; + Events_InfoMessage& theError) const; /// Returns true if the attibute's object type satisfies the argument value /// \param[in] theObject a checked object @@ -69,7 +69,7 @@ protected: /// \param[out] theError error message. bool isValidObject(const ObjectPtr& theObject, const TypeOfShape theShapeType, - std::string& theError) const; + Events_InfoMessage& theError) const; /// Returns true if the attibute's object type satisfies the argument value /// \param[in] theShape a checked shape @@ -77,7 +77,7 @@ protected: /// \param[out] theError error message. bool isValidShape(const GeomShapePtr theShape, const TypeOfShape theShapeType, - std::string& theError) const; + Events_InfoMessage& theError) const; }; diff --git a/src/GeomValidators/GeomValidators_ZeroOffset.cpp b/src/GeomValidators/GeomValidators_ZeroOffset.cpp index f898a2297..20d324edd 100644 --- a/src/GeomValidators/GeomValidators_ZeroOffset.cpp +++ b/src/GeomValidators/GeomValidators_ZeroOffset.cpp @@ -6,6 +6,8 @@ #include +#include + #include #include #include @@ -21,7 +23,7 @@ //================================================================================================= bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if(theArguments.size() != 9) { theError = "Wrong number of validator arguments in xml(expected 9)."; diff --git a/src/GeomValidators/GeomValidators_ZeroOffset.h b/src/GeomValidators/GeomValidators_ZeroOffset.h index 64fd4ab63..3d5c3b864 100644 --- a/src/GeomValidators/GeomValidators_ZeroOffset.h +++ b/src/GeomValidators/GeomValidators_ZeroOffset.h @@ -26,7 +26,7 @@ public: */ GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// \return true if the attribute in feature is not obligatory for the feature execution. GEOMVALIDATORS_EXPORT virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); diff --git a/src/Model/Model_AttributeValidator.cpp b/src/Model/Model_AttributeValidator.cpp index 93e321832..8cf601921 100644 --- a/src/Model/Model_AttributeValidator.cpp +++ b/src/Model/Model_AttributeValidator.cpp @@ -6,6 +6,8 @@ #include "Model_AttributeValidator.h" +#include + #include #include @@ -14,7 +16,7 @@ bool Model_AttributeValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() == ModelAPI_AttributeInteger::typeId()) { AttributeIntegerPtr anAttribue = diff --git a/src/Model/Model_AttributeValidator.h b/src/Model/Model_AttributeValidator.h index 3e8240cdf..0379fbe4e 100644 --- a/src/Model/Model_AttributeValidator.h +++ b/src/Model/Model_AttributeValidator.h @@ -26,7 +26,7 @@ public: /// \returns true if attribute is valid MODEL_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif // Model_AttributeValidator_H diff --git a/src/Model/Model_FeatureValidator.cpp b/src/Model/Model_FeatureValidator.cpp index 303a46567..06923d324 100644 --- a/src/Model/Model_FeatureValidator.cpp +++ b/src/Model/Model_FeatureValidator.cpp @@ -5,6 +5,9 @@ // Author: Vitaly SMETANNIKOV #include + +#include + #include #include #include @@ -17,7 +20,7 @@ bool Model_FeatureValidator::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { static Model_ValidatorsFactory* aValidators = static_cast(ModelAPI_Session::get()->validators()); diff --git a/src/Model/Model_FeatureValidator.h b/src/Model/Model_FeatureValidator.h index 010ad505c..47c091937 100644 --- a/src/Model/Model_FeatureValidator.h +++ b/src/Model/Model_FeatureValidator.h @@ -35,7 +35,7 @@ public: /// \returns true if feature is valid MODEL_EXPORT virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// sets not obligatory attributes, not checked for initialization virtual void registerNotObligatory(std::string theFeature, std::string theAttribute); diff --git a/src/Model/Model_Validator.cpp b/src/Model/Model_Validator.cpp index dafa19583..1d420229f 100644 --- a/src/Model/Model_Validator.cpp +++ b/src/Model/Model_Validator.cpp @@ -177,12 +177,12 @@ bool Model_ValidatorsFactory::validate(const std::shared_ptr& const ModelAPI_FeatureValidator* aFValidator = dynamic_cast(validator(aValidatorID)); if (aFValidator) { - std::string anError; + Events_InfoMessage anError; if (!aFValidator->isValid(theFeature, anArguments, anError)) { if (anError.empty()) anError = "Unknown error."; - anError = aValidatorID + ": " + anError; - theFeature->setError(anError, false); + anError = aValidatorID + ": " + anError.messageString(); + theFeature->setError(anError.messageString(), false); theFeature->data()->execState(ModelAPI_StateInvalidArgument); return false; } @@ -221,12 +221,12 @@ bool Model_ValidatorsFactory::validate(const std::shared_ptr& AttributePtr anAttribute = theFeature->data()->attribute(anAttributeID); std::string aValidatorID; - std::string anError; + Events_InfoMessage anError; if (!validate(anAttribute, aValidatorID, anError)) { if (anError.empty()) anError = "Unknown error."; - anError = anAttributeID + " - " + aValidatorID + ": " + anError; - theFeature->setError(anError, false); + anError = anAttributeID + " - " + aValidatorID + ": " + anError.messageString(); + theFeature->setError(anError.messageString(), false); theFeature->data()->execState(ModelAPI_StateInvalidArgument); return false; } @@ -237,7 +237,7 @@ bool Model_ValidatorsFactory::validate(const std::shared_ptr& bool Model_ValidatorsFactory::validate(const std::shared_ptr& theAttribute, std::string& theValidator, - std::string& theError) const + Events_InfoMessage& theError) const { FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner()); if (!aFeature.get()) { diff --git a/src/Model/Model_Validator.h b/src/Model/Model_Validator.h index 0040d8c2b..2fd016478 100644 --- a/src/Model/Model_Validator.h +++ b/src/Model/Model_Validator.h @@ -78,7 +78,7 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory /// Returns true if the attribute is valid. MODEL_EXPORT virtual bool validate(const std::shared_ptr& theAttribute, - std::string& theValidator, std::string& theError) const; + std::string& theValidator, Events_InfoMessage& theError) const; /// register that this attribute in feature is not obligatory for the feature execution /// so, it is not needed for the standard validation mechanism diff --git a/src/ModelAPI/ModelAPI_AttributeValidator.h b/src/ModelAPI/ModelAPI_AttributeValidator.h index 142c91c23..54e5679ec 100644 --- a/src/ModelAPI/ModelAPI_AttributeValidator.h +++ b/src/ModelAPI/ModelAPI_AttributeValidator.h @@ -23,7 +23,7 @@ public: //! \param theError the error string message if validation fails virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const = 0; + Events_InfoMessage& theError) const = 0; MODELAPI_EXPORT ~ModelAPI_AttributeValidator(); }; diff --git a/src/ModelAPI/ModelAPI_FeatureValidator.h b/src/ModelAPI/ModelAPI_FeatureValidator.h index f051c1e0d..3b995c6c1 100644 --- a/src/ModelAPI/ModelAPI_FeatureValidator.h +++ b/src/ModelAPI/ModelAPI_FeatureValidator.h @@ -32,7 +32,7 @@ class MODELAPI_EXPORT ModelAPI_FeatureValidator : public ModelAPI_Validator /// \param theError the error string message if validation fails virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const = 0; + Events_InfoMessage& theError) const = 0; /// Returns true if the attribute in feature is not obligatory for the feature execution virtual bool isNotObligatory(std::string theFeature, std::string theAttribute) = 0; diff --git a/src/ModelAPI/ModelAPI_Validator.h b/src/ModelAPI/ModelAPI_Validator.h index af9eb2839..7fddb71ac 100644 --- a/src/ModelAPI/ModelAPI_Validator.h +++ b/src/ModelAPI/ModelAPI_Validator.h @@ -13,6 +13,7 @@ #include class ModelAPI_Feature; +class Events_InfoMessage; /**\class ModelAPI_Validator * \ingroup DataModel @@ -84,7 +85,7 @@ class MODELAPI_EXPORT ModelAPI_ValidatorsFactory /// Returns true if the attribute is valid. virtual bool validate(const std::shared_ptr& theAttribute, - std::string& theValidator, std::string& theError) const = 0; + std::string& theValidator, Events_InfoMessage& theError) const = 0; /// register that this attribute in feature is not obligatory for the feature execution /// so, it is not needed for the standard validation mechanism diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index ba4948376..69cd60c46 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -9,6 +9,8 @@ #include "ModuleBase_Tools.h" #include "ModuleBase_WidgetValidator.h" +#include + #include #include #include @@ -121,16 +123,21 @@ QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) const return anError; std::string aValidatorID; - std::string anErrorMsg; + Events_InfoMessage anErrorMsg; static ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators(); if (!aValidators->validate(anAttribute, aValidatorID, anErrorMsg)) { if (anErrorMsg.empty()) anErrorMsg = "unknown error."; - anErrorMsg = anAttributeID + " - " + aValidatorID + ": " + anErrorMsg; + anErrorMsg = anAttributeID + " - " + aValidatorID + ": " + anErrorMsg.messageString(); + } + + if (!anErrorMsg.empty()) { + std::string aStr = Config_Translator::translate(anErrorMsg); + std::string aCodec = Config_Translator::codec(anErrorMsg.context()); + anError = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str()); } - anError = QString::fromStdString(anErrorMsg); if (anError.isEmpty() && theValueStateChecked) anError = getValueStateError(); diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index fd5e7e96a..daecef19f 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -7,6 +7,8 @@ #include #include +#include + #include #include #include @@ -190,7 +192,8 @@ bool ModuleBase_WidgetValidated::isValidAttribute(const AttributePtr& theAttribu { SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - std::string aValidatorID, anError; + std::string aValidatorID; + Events_InfoMessage anError; return aFactory->validate(theAttribute, aValidatorID, anError); } diff --git a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp index c2deeff2d..d63741c9f 100644 --- a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp +++ b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp @@ -338,7 +338,8 @@ void ParametersPlugin_EvalListener::renameInDependents(std::shared_ptrvalidators()->validate(theAttribute, aValidator, anError); } diff --git a/src/ParametersPlugin/ParametersPlugin_Validators.cpp b/src/ParametersPlugin/ParametersPlugin_Validators.cpp index d751c36ba..ec550aeca 100644 --- a/src/ParametersPlugin/ParametersPlugin_Validators.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Validators.cpp @@ -9,6 +9,8 @@ #include +#include + #include #include #include @@ -24,7 +26,7 @@ ParametersPlugin_VariableValidator::~ParametersPlugin_VariableValidator() bool ParametersPlugin_VariableValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { AttributeStringPtr aStrAttr = std::dynamic_pointer_cast(theAttribute); if (!aStrAttr->isInitialized()) { @@ -95,7 +97,7 @@ ParametersPlugin_ExpressionValidator::~ParametersPlugin_ExpressionValidator() bool ParametersPlugin_ExpressionValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); ResultParameterPtr aParam = diff --git a/src/ParametersPlugin/ParametersPlugin_Validators.h b/src/ParametersPlugin/ParametersPlugin_Validators.h index cc1812abc..421c681b3 100644 --- a/src/ParametersPlugin/ParametersPlugin_Validators.h +++ b/src/ParametersPlugin/ParametersPlugin_Validators.h @@ -34,7 +34,7 @@ class ParametersPlugin_VariableValidator : public ModelAPI_AttributeValidator */ PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; protected: /// Returns true if theString is a valid variable name. @@ -63,7 +63,7 @@ class ParametersPlugin_ExpressionValidator: public ModelAPI_AttributeValidator */ PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; diff --git a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp index 35df874aa..7ab7fbf73 100644 --- a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp +++ b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp @@ -8,6 +8,8 @@ #include "ParametersPlugin_Parameter.h" #include "ParametersPlugin_Validators.h" +#include + #include #include #include @@ -252,11 +254,12 @@ bool ParametersPlugin_WidgetParamsMgr::storeValueCustom() ParametersPlugin_ExpressionValidator aValidator; std::list aArgs; std::string aAttrId = ParametersPlugin_Parameter::VARIABLE_ID(); - std::string aErr; + Events_InfoMessage aErr; int aId = 0; foreach(FeaturePtr aFeature, myParametersList) { if (!aValidator.isValid(aFeature->attribute(aAttrId), aArgs, aErr)) { - QMessageBox::warning(this, tr("Warning"), aErr.c_str()); + // TODO(spo): translate + QMessageBox::warning(this, tr("Warning"), aErr.messageString().c_str()); selectItemScroll(myParameters->child(aId)); return false; } diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 9766c0a9e..26ae2e277 100755 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -19,6 +19,8 @@ #include #include +#include + #include #include #include @@ -354,7 +356,7 @@ std::string PartSet_DifferentObjectsValidator::errorMessage( bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); @@ -524,7 +526,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; diff --git a/src/PartSet/PartSet_Validators.h b/src/PartSet/PartSet_Validators.h index 2111ef63d..0b25943aa 100644 --- a/src/PartSet/PartSet_Validators.h +++ b/src/PartSet/PartSet_Validators.h @@ -154,7 +154,7 @@ class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator //! \param theError an output error string virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; private: //! Returns error message for the error type //! \param theType a type of error @@ -179,7 +179,7 @@ class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator //! \param theError an output error string virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index 8daeb546d..c4035cc22 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -22,6 +22,8 @@ #include +#include + #include #include #include @@ -461,7 +463,8 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute); - std::string aValidatorID, anError; + std::string aValidatorID; + Events_InfoMessage anError; aSelList->append(aRes, GeomShapePtr()); if (aFactory->validate(anAttribute, aValidatorID, anError)) updateObject(aCompFeature); @@ -479,12 +482,14 @@ bool PartSet_WidgetSketchCreator::validateSelectionList() const SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - std::string aValidatorID, anError; + std::string aValidatorID; + Events_InfoMessage anError; bool isValidPComposite = aFactory->validate(anAttrList, aValidatorID, anError); if (!isValidPComposite) { XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop()); + // TODO(spo): translate QMessageBox::question(aWorkshop->desktop(), tr("Apply current feature"), - tr("Sketch is invalid and will be deleted.\nError: %1").arg(anError.c_str()), + tr("Sketch is invalid and will be deleted.\nError: %1").arg(anError.messageString().c_str()), QMessageBox::Ok); } return isValidPComposite; diff --git a/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp b/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp index 362dd94f1..9c9fc3345 100644 --- a/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp +++ b/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp @@ -7,6 +7,8 @@ #include "SketchPlugin_ExternalValidator.h" #include "SketchPlugin_Feature.h" +#include + #include #include #include @@ -14,7 +16,7 @@ bool SketchPlugin_ExternalValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theArguments.size() != 1) return true; diff --git a/src/SketchPlugin/SketchPlugin_ExternalValidator.h b/src/SketchPlugin/SketchPlugin_ExternalValidator.h index 821b27de7..303e62650 100644 --- a/src/SketchPlugin/SketchPlugin_ExternalValidator.h +++ b/src/SketchPlugin/SketchPlugin_ExternalValidator.h @@ -26,7 +26,7 @@ public: /// \param theError error message SKETCHPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; protected: /// returns true if the feature of the attribute is external diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index c2f1badd6..93152b1cb 100755 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -20,6 +20,8 @@ #include "SketcherPrs_Tools.h" +#include + #include #include #include @@ -45,7 +47,7 @@ const double tolerance = 1.e-7; bool SketchPlugin_DistanceAttrValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -70,7 +72,7 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const AttributePtr& theAttribut dynamic_cast(aFactory->validator("GeomValidators_ShapeType")); std::list anArguments; anArguments.push_back("circle"); - std::string aCircleError; + Events_InfoMessage aCircleError; bool aShapeValid = aShapeValidator->isValid(aRefAttr, anArguments, aCircleError); // the circle line is not a valid case if (aShapeValid) { @@ -80,7 +82,7 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const AttributePtr& theAttribut anArguments.clear(); anArguments.push_back("line"); - std::string aLineError; + Events_InfoMessage aLineError; aShapeValid = aShapeValidator->isValid(aRefAttr, anArguments, aLineError); // if the attribute value is not a line, that means it is a vertex. A vertex is always valid if (aShapeValid) { @@ -146,7 +148,7 @@ static bool hasCoincidentPoint(FeaturePtr theFeature1, FeaturePtr theFeature2) bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -217,7 +219,7 @@ bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute bool SketchPlugin_NotFixedValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -259,7 +261,7 @@ bool SketchPlugin_NotFixedValidator::isValid(const AttributePtr& theAttribute, bool SketchPlugin_EqualAttrValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -314,7 +316,7 @@ bool SketchPlugin_EqualAttrValidator::isValid(const AttributePtr& theAttribute, bool SketchPlugin_MirrorAttrValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeRefList::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -343,7 +345,7 @@ bool SketchPlugin_MirrorAttrValidator::isValid(const AttributePtr& theAttribute, bool SketchPlugin_CoincidenceAttrValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -402,7 +404,7 @@ bool SketchPlugin_CoincidenceAttrValidator::isValid(const AttributePtr& theAttri bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeRefList::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -442,7 +444,7 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, bool SketchPlugin_SolverErrorValidator::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { AttributeStringPtr aAttributeString = theFeature->string(SketchPlugin_Sketch::SOLVER_ERROR()); @@ -500,7 +502,7 @@ static bool hasSameTangentFeature(const std::set& theRefsList, con bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { std::shared_ptr aFilletFeature = std::dynamic_pointer_cast(theAttribute->owner()); AttributeRefAttrListPtr aPointsRefList = std::dynamic_pointer_cast(theAttribute); @@ -673,7 +675,7 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut bool SketchPlugin_MiddlePointAttrValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -719,7 +721,7 @@ bool SketchPlugin_MiddlePointAttrValidator::isValid(const AttributePtr& theAttri bool SketchPlugin_ArcTangentPointValidator::isValid(const AttributePtr& theAttribute, const std::list& /*theArguments*/, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -773,7 +775,7 @@ bool SketchPlugin_ArcTangentPointValidator::isValid(const AttributePtr& theAttri bool SketchPlugin_IntersectionValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeSelection::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; @@ -819,7 +821,7 @@ bool SketchPlugin_IntersectionValidator::isValid(const AttributePtr& theAttribut bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { if (theAttribute->attributeType() != ModelAPI_AttributeSelection::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; diff --git a/src/SketchPlugin/SketchPlugin_Validators.h b/src/SketchPlugin/SketchPlugin_Validators.h index f201e1b3a..2ebb8ad76 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.h +++ b/src/SketchPlugin/SketchPlugin_Validators.h @@ -26,7 +26,7 @@ class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /**\class SketchPlugin_TangentAttrValidator @@ -44,7 +44,7 @@ class SketchPlugin_TangentAttrValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; @@ -63,7 +63,7 @@ class SketchPlugin_NotFixedValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /**\class SketchPlugin_EqualAttrValidator @@ -81,7 +81,7 @@ class SketchPlugin_EqualAttrValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /**\class SketchPlugin_MirrorAttrValidator @@ -99,7 +99,7 @@ class SketchPlugin_MirrorAttrValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; @@ -118,7 +118,7 @@ class SketchPlugin_CoincidenceAttrValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; @@ -138,7 +138,7 @@ class SketchPlugin_CopyValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /**\class SketchPlugin_SolverErrorValidator @@ -156,7 +156,7 @@ class SketchPlugin_SolverErrorValidator : public ModelAPI_FeatureValidator //! \param theError error message virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; /// Returns true if the attribute in feature is not obligatory for the feature execution virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); @@ -177,7 +177,7 @@ public: //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; @@ -196,7 +196,7 @@ class SketchPlugin_MiddlePointAttrValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; @@ -215,7 +215,7 @@ class SketchPlugin_ArcTangentPointValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /**\class SketchPlugin_IntersectionValidator @@ -231,7 +231,7 @@ class SketchPlugin_IntersectionValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /**\class SketchPlugin_ProjectionValidator @@ -247,7 +247,7 @@ class SketchPlugin_ProjectionValidator : public ModelAPI_AttributeValidator //! \param theError error message virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; #endif diff --git a/src/XGUI/XGUI_ErrorDialog.cpp b/src/XGUI/XGUI_ErrorDialog.cpp index 04a3f5316..511d1f578 100644 --- a/src/XGUI/XGUI_ErrorDialog.cpp +++ b/src/XGUI/XGUI_ErrorDialog.cpp @@ -60,7 +60,7 @@ void XGUI_ErrorDialog::clear() void XGUI_ErrorDialog::addError(std::shared_ptr theMsg) { - std::string aError = Config_Translator::translate(theMsg); + std::string aError = Config_Translator::translate(*theMsg); std::string aCodec = Config_Translator::codec(theMsg->context()); QString aMsg = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aError.c_str()); myErrors.append(aMsg); -- 2.39.2