Salome HOME
Merge branch 'BR_internationalization'
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 7 Jun 2016 09:31:09 +0000 (12:31 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 7 Jun 2016 09:31:09 +0000 (12:31 +0300)
Conflicts:
src/Model/Model_SelectionNaming.cpp
src/ModuleBase/ModuleBase_Tools.cpp

71 files changed:
.gitignore
src/BuildPlugin/BuildPlugin_Validators.cpp
src/BuildPlugin/BuildPlugin_Wire.cpp
src/Config/CMakeLists.txt
src/Config/Config_Common.cpp
src/Config/Config_Common.h
src/Config/Config_DataModelReader.cpp
src/Config/Config_ModuleReader.cpp
src/Config/Config_Translator.cpp [new file with mode: 0644]
src/Config/Config_Translator.h [new file with mode: 0644]
src/Config/Config_ValidatorReader.cpp
src/Config/Config_XMLReader.cpp
src/Config/Config_XMLReader.h
src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py
src/Events/CMakeLists.txt
src/Events/Events.i
src/Events/Events_Error.cpp [deleted file]
src/Events/Events_Error.h [deleted file]
src/Events/Events_InfoMessage.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Validators.cpp
src/GeomValidators/GeomValidators_Face.cpp
src/GeomValidators/GeomValidators_ShapeType.cpp
src/InitializationPlugin/InitializationPlugin_Plugin.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Data.cpp
src/Model/Model_Document.cpp
src/Model/Model_Objects.cpp
src/Model/Model_SelectionNaming.cpp
src/Model/Model_Session.cpp
src/Model/Model_Update.cpp
src/Model/Model_Validator.cpp
src/ModelAPI/ModelAPI_Events.h
src/ModuleBase/ModuleBase_FilterFactory.cpp
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_WidgetCreatorFactory.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ParametersPlugin/CMakeLists.txt
src/ParametersPlugin/ParametersPlugin_EvalListener.cpp
src/ParametersPlugin/ParametersPlugin_msg_ru.ts [new file with mode: 0644]
src/PartSet/PartSet_OperationPrs.cpp
src/PartSet/PartSet_ResultSketchPrs.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_msg_en.ts [new file with mode: 0644]
src/SketchSolver/SketchSolver_Builder.cpp
src/SketchSolver/SketchSolver_Group.cpp
src/SketcherPrs/SketcherPrs_Angle.cpp
src/SketcherPrs/SketcherPrs_Coincident.cpp
src/SketcherPrs/SketcherPrs_Collinear.cpp
src/SketcherPrs/SketcherPrs_DimensionStyleListener.cpp
src/SketcherPrs/SketcherPrs_Equal.cpp
src/SketcherPrs/SketcherPrs_HVDirection.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_Middle.cpp
src/SketcherPrs/SketcherPrs_Radius.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_Tools.cpp
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_CustomPrs.cpp
src/XGUI/XGUI_DataModel.cpp
src/XGUI/XGUI_ErrorDialog.cpp
src/XGUI/XGUI_ErrorDialog.h
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_Tools.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_WorkshopListener.cpp
src/XGUI/XGUI_WorkshopListener.h
src/XGUI/XGUI_msg_fr.ts [new file with mode: 0644]

index 3361c41de623b070d566e552f43cb77123319d36..cafb0640d20fc54dbe9f62712cf9a5ae8f547983 100644 (file)
@@ -18,7 +18,6 @@ lib/
 *.pro.user
 moc_*.*
 *.qm
-*.ts
 #Resources
 resources
 !src/*/resources
index b3ede6d602d88b1c9bfd2610841ceb9d5202a293..234e697b2d7712f36986c76fca5aad3265a5b33c 100644 (file)
@@ -23,7 +23,7 @@
 #include <GeomValidators_FeatureKind.h>
 #include <GeomValidators_ShapeType.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 //=================================================================================================
 bool BuildPlugin_ValidatorBaseForBuild::isValid(const AttributePtr& theAttribute,
@@ -32,9 +32,9 @@ bool BuildPlugin_ValidatorBaseForBuild::isValid(const AttributePtr& theAttribute
 {
   // Get base objects list.
   if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
-    Events_Error::send("Error: BuildPlugin_ValidatorBaseForBuild does not support attribute type \""
-      + theAttribute->attributeType() + "\"\n Only \"" + ModelAPI_AttributeSelectionList::typeId()
-      + "\" supported.");
+    std::string aMsg = "Error: BuildPlugin_ValidatorBaseForBuild does not support attribute type '%1'\nOnly '%2' is supported.";
+    Events_InfoMessage("BuildPlugin_Validators", aMsg).
+      arg(theAttribute->attributeType()).arg(ModelAPI_AttributeSelectionList::typeId()).send();
     return false;
   }
   AttributeSelectionListPtr aSelectionList =
@@ -113,8 +113,8 @@ bool BuildPlugin_ValidatorBaseForWire::isValid(const std::shared_ptr<ModelAPI_Fe
 {
   // Get attribute.
   if(theArguments.size() != 1) {
-    Events_Error::send("Error: BuildPlugin_ValidatorBaseForWire should be used only with "
-      "1 parameter (ID of base objects list).");
+    std::string aMsg = "Error: BuildPlugin_ValidatorBaseForWire should be used only with 1 parameter (ID of base objects list).";
+    Events_InfoMessage("BuildPlugin_Validators", aMsg).send();
     return false;
   }
   AttributeSelectionListPtr aSelectionList = theFeature->selectionList(theArguments.front());
@@ -158,8 +158,9 @@ bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Fe
 {
   // Get attribute.
   if(theArguments.size() != 1) {
-    Events_Error::send("Error: BuildPlugin_ValidatorBaseForFace should be used only with "
-      "1 parameter (ID of base objects list).");
+    std::string aMsg = "Error: BuildPlugin_ValidatorBaseForFace should be used only with "
+      "1 parameter (ID of base objects list).";
+    Events_InfoMessage("BuildPlugin_Validators", aMsg).send();
     return false;
   }
   AttributeSelectionListPtr aSelectionList = theFeature->selectionList(theArguments.front());
@@ -231,16 +232,18 @@ bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAtt
                                                       std::string& theError) const
 {
   if(theArguments.size() != 1) {
-    Events_Error::send("Error: BuildPlugin_ValidatorSubShapesSelection should be used only with "
-      "1 parameter(Sketch feature id).");
+    std::string aMsg = "Error: BuildPlugin_ValidatorSubShapesSelection should be used only with "
+      "1 parameter(Sketch feature id).";
+    Events_InfoMessage("BuildPlugin_Validators", aMsg).send();
     return false;
   }
 
   // Get base objects list.
   if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
-    Events_Error::send("Error: BuildPlugin_ValidatorSubShapesSelection does not support attribute type \""
-      + theAttribute->attributeType() + "\"\n Only \"" + ModelAPI_AttributeSelectionList::typeId()
-      + "\" supported.");
+    std::string aMsg = "Error: BuildPlugin_ValidatorSubShapesSelection does not support attribute type \""
+      "%1\"\n Only \"%2\" supported.";
+    Events_InfoMessage("BuildPlugin_Validators", aMsg).
+      arg(theAttribute->attributeType()).arg(ModelAPI_AttributeSelectionList::typeId()).send();
     return false;
   }
   AttributeSelectionListPtr aSelectionList =
index 14d5158945d7b90c37d8caf0ad884013228bad24..6acb80b235d9adaa03896da81799fbe910459172 100644 (file)
@@ -10,7 +10,7 @@
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <GeomAPI_PlanarEdges.h>
 #include <GeomAPI_ShapeExplorer.h>
@@ -88,7 +88,8 @@ bool BuildPlugin_Wire::customAction(const std::string& theActionId)
   if(theActionId == "add_contour") {
     return addContour();
   } else {
-    Events_Error::send("Error: Feature \"" + getKind() + "\" does not support action \"" + theActionId + "\".");
+    std::string aMsg = "Error: Feature \"%1\" does not support action \"%2\".";
+    Events_InfoMessage("BuildPlugin_Wire", aMsg).arg(getKind()).arg(theActionId).send();
   }
 
   return false;
@@ -100,7 +101,7 @@ bool BuildPlugin_Wire::addContour()
   // Get base objects list.
   AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
   if(aSelectionList->size() == 0) {
-    Events_Error::send("Error: Empty selection list.");
+    Events_InfoMessage("BuildPlugin_Wire", "Error: Empty selection list.").send();
     return false;
   }
 
@@ -189,7 +190,8 @@ bool BuildPlugin_Wire::addContour()
   }
 
   if(!isAnyContourAdded) {
-    Events_Error::send("Error: Contours already closed or no contours found for selected edges.");
+    Events_InfoMessage("BuildPlugin_Wire", 
+      "Error: Contours already closed or no contours found for selected edges.").send();
     return false;
   }
 
index 65106e5973ac53ca0a6300f3fef0f39f362d4150..5e0123e9c57aca894ffb7004a54f2eb352a6b1e8 100644 (file)
@@ -24,6 +24,7 @@ SET(PROJECT_HEADERS
   Config_SelectionFilterMessage.h
   Config_ValidatorReader.h
   Config_DataModelReader.h
+  Config_Translator.h
  )
 
 SET(PROJECT_SOURCES
@@ -42,6 +43,7 @@ SET(PROJECT_SOURCES
   Config_SelectionFilterMessage.cpp
   Config_ValidatorReader.cpp
   Config_DataModelReader.cpp
+  Config_Translator.cpp
 )
 
 SET(XML_RESOURCES
index ce096355a766652d76447cd60d0a40ee58847b82..aaf1ed9cbc1e24d641f5d55303e3eb15a48aaef8 100644 (file)
@@ -225,10 +225,11 @@ bool BothAreSpaces(char lhs, char rhs) { return (lhs == rhs) && (lhs == ' '); }
 std::string getProperty(xmlNodePtr theNode, const char* thePropName)\r
 {\r
   std::string result = "";\r
-  char* aPropChars = (char*) xmlGetProp(theNode, BAD_CAST thePropName);\r
+  xmlChar* aPropChars = xmlGetProp(theNode, BAD_CAST thePropName);\r
   if (!aPropChars || aPropChars[0] == 0)\r
     return result;\r
-  result = std::string(aPropChars);\r
+  result = std::string((char*)aPropChars);\r
+  xmlFree(aPropChars);\r
 \r
   std::string::iterator new_end = std::unique(result.begin(), result.end(), BothAreSpaces);\r
   result.erase(new_end, result.end()); \r
@@ -236,6 +237,17 @@ std::string getProperty(xmlNodePtr theNode, const char* thePropName)
   return result;\r
 }\r
 \r
+std::string getContent(xmlNodePtr theNode)\r
+{\r
+  std::string result = "";\r
+  xmlChar* aContent = xmlNodeGetContent(theNode);\r
+  if (!aContent || aContent[0] == 0)\r
+    return result;\r
+  result = std::string((char*)aContent);\r
+  xmlFree(aContent);\r
+  return result;\r
+}\r
+\r
 std::string getNormalizedProperty(xmlNodePtr theNode, const char* thePropName)\r
 {\r
   return normalize(getProperty(theNode, thePropName));\r
index 52776d764f7623c1b75ea912f176d713e68e2b91..0998a6b73d6899c269951560757ee9fb559172c0 100644 (file)
@@ -111,6 +111,11 @@ CONFIG_EXPORT std::string library(const std::string& theLibName);
  */
 CONFIG_EXPORT std::string getProperty(xmlNodePtr theNode, const char* thePropName);
 
+/*!
+ * Returns content of the node as std::string if it is exists.
+ */
+CONFIG_EXPORT std::string getContent(xmlNodePtr theNode);
+
 /*!
  * Returns normalized (lower case) named property for a given node as std::string.
  */
index b02ae823c92bbfda2cb7be86ab79f224d2a11a90..afd688ed538e072fd344c88d5feb6c786e53a39a 100644 (file)
@@ -11,7 +11,7 @@
 #include <Config_Keywords.h>
 #include "Config_Common.h"
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 
 Config_DataModelReader::Config_DataModelReader()
@@ -29,7 +29,7 @@ void Config_DataModelReader::processNode(xmlNodePtr theNode)
     std::string aName = getProperty(theNode, FOLDER_NAME);
     std::string aGroupType = getProperty(theNode, GROUP_TYPE);
     if (aName.empty() || aGroupType.empty())
-      Events_Error::send("Reading dataModel.xml: wrong folder definition");
+      Events_InfoMessage("Config_DataModelReader", "Reading dataModel.xml: wrong folder definition.").send();
    
     std::string aIcon = getProperty(theNode, NODE_ICON);
     std::string aEmpty = getProperty(theNode, SHOW_EMPTY);
index 2fd33f6cda947d90b50a1a065d6902ede4152340..dfd442b7e6012a70d6938d8fb800ffcb7d3de71c 100644 (file)
@@ -13,7 +13,7 @@
 #include <Config_Common.h>
 #include <Config_ModuleReader.h>
 #include <Config_FeatureReader.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <libxml/parser.h>
 #include <libxml/tree.h>
@@ -70,9 +70,9 @@ void Config_ModuleReader::addFeature(const std::string& theFeatureName,
                                      const std::string& thePluginConfig)
 {
   if (myFeaturesInFiles.count(theFeatureName)) {
-    std::string anErrorMsg = "Can not register feature '" + theFeatureName + "' in plugin '"
-        + thePluginConfig + "'. There is a feature with the same ID.";
-    Events_Error::send(anErrorMsg);
+    std::string anErrorMsg = "Can not register feature '%1' in plugin '%2'."
+      " There is a feature with the same ID.";
+    Events_InfoMessage("Config_ModuleReader", anErrorMsg).arg(theFeatureName).arg(thePluginConfig).send();
     return;
   }
 
@@ -194,7 +194,7 @@ void Config_ModuleReader::loadScript(const std::string& theFileName)
       Py_XDECREF(pvalue);
       Py_XDECREF(ptraceback);
     }
-    Events_Error::send(anErrorMsg);
+    Events_InfoMessage("Config_ModuleReader", anErrorMsg).send();
   }
 
   /* release python thread */
@@ -229,7 +229,7 @@ void Config_ModuleReader::loadLibrary(const std::string& theLibName)
     anErrorMsg += ": " + std::string(dlerror());
     #endif
     std::cerr << anErrorMsg << std::endl;
-    Events_Error::send(anErrorMsg);
+    Events_InfoMessage("Config_ModuleReader", anErrorMsg).send();
   }
 }
 
diff --git a/src/Config/Config_Translator.cpp b/src/Config/Config_Translator.cpp
new file mode 100644 (file)
index 0000000..9a03118
--- /dev/null
@@ -0,0 +1,207 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Config_Translator.cpp
+// Created:     31 May 2016
+// Author:      Vitaly SMETANNIKOV
+
+#include "Config_Translator.h"
+#include "Config_XMLReader.h"
+#include "Config_Common.h"
+
+#include <fstream>
+#include <ostream>
+
+class Config_TSReader : public Config_XMLReader
+{
+public:
+  Config_TSReader(const std::string& theTSFile) : Config_XMLReader(theTSFile) {}
+
+  const Config_Translator::Translator& translator() const { return myTranslator; }
+  const Config_Translator::Dictionary& codecs() const { return myCodecs; }
+
+protected:
+  /// Overloaded method. Defines how to process each node
+  virtual void processNode(xmlNodePtr theNode);
+private:
+  Config_Translator::Translator myTranslator;
+  Config_Translator::Dictionary myCodecs;
+};
+
+void Config_TSReader::processNode(xmlNodePtr theNode)
+{
+  static std::string aName;
+  static std::string aSource;
+  std::string aTranslat;
+
+  if (isNode(theNode, "context", NULL)) {
+    aName = "";
+  } else if (isNode(theNode, "name", NULL)) {
+    aName = getContent(theNode);
+    myCodecs[aName] = encoding();
+  } else if (isNode(theNode, "message", NULL)) {
+    aSource = "";
+  } else if (isNode(theNode, "source", NULL)) {
+    aSource = getContent(theNode);
+  } else if (isNode(theNode, "translation", NULL)) {
+    aTranslat = getContent(theNode);
+    if ((aName.size() > 0) && (aSource.size() > 0))
+      myTranslator[aName][aSource] = aTranslat;
+  }
+}
+
+//******************************************************************************
+//******************************************************************************
+//******************************************************************************
+Config_Translator::Translator Config_Translator::myTranslator;
+Config_Translator::Dictionary Config_Translator::myCodecs;
+
+#ifdef _DEBUG
+#ifdef MISSED_TRANSLATION
+Config_Translator::Translator Config_Translator::myMissed;
+#endif
+#endif
+
+bool Config_Translator::load(const std::string& theFileName)
+{
+  Config_TSReader aReader(theFileName);
+  aReader.readAll();
+
+  const Translator& aTranslator = aReader.translator();
+  Translator::const_iterator aIt;
+  std::string aContext;
+  Dictionary aDictionary;
+  for (aIt = aTranslator.cbegin(); aIt != aTranslator.cend(); aIt++) {
+    aContext = (*aIt).first;
+    aDictionary = (*aIt).second;
+    if (myTranslator.count(aContext) == 0) {
+      myTranslator[aContext] = aDictionary;
+    } else {
+      Dictionary::const_iterator aDictIt;
+      for (aDictIt = aDictionary.cbegin(); aDictIt != aDictionary.cend(); aDictIt++) {
+        myTranslator[aContext][(*aDictIt).first] = (*aDictIt).second;
+      }
+    }
+  }
+
+  const Dictionary aCodecs = aReader.codecs();
+  Dictionary::const_iterator aDictIt;
+  for (aDictIt = aCodecs.cbegin(); aDictIt != aCodecs.cend(); aDictIt++) {
+    myCodecs[aDictIt->first] = aDictIt->second;
+  }
+  return true;
+}
+
+std::string Config_Translator::translate(std::shared_ptr<Events_InfoMessage> theInfo)
+{
+  std::string aContext = theInfo->context();
+  std::string aMessage = theInfo->message();
+  std::list<std::string> aParameters = theInfo->parameters();
+  return translate(aContext, aMessage, aParameters);
+}
+
+
+std::string insertParameters(const std::string& theString, const std::list<std::string>& theParams)
+{
+  std::string aResult = theString;
+  std::list<std::string>::const_iterator aIt;
+  int i;
+  char aBuf[20];
+  std::string aParam;
+  for (i=1, aIt = theParams.cbegin(); aIt != theParams.cend(); aIt++, i++) {
+    aParam = (*aIt);
+    sprintf_s(aBuf, "%d", i);
+    std::string aCode = std::string("%") + std::string(aBuf);
+    size_t aPos = aResult.find(aCode);
+    if (aPos != std::string::npos) {
+      std::string aFirst = aResult.substr(0, aPos);
+      std::string aLast = aResult.substr(aPos + aCode.length(), std::string::npos);
+      aResult = aFirst + aParam + aLast;
+    }
+  }
+  return aResult;
+}
+
+std::string Config_Translator::translate(const std::string& theContext,
+                                         const std::string& theMessage, 
+                                         const std::list<std::string>& theParams)
+{
+  if (myTranslator.count(theContext) > 0) {
+    if (myTranslator[theContext].count(theMessage) > 0) {
+      std::string aTranslation = myTranslator[theContext][theMessage];
+      if (theParams.size() > 0) {
+        aTranslation = insertParameters(aTranslation, theParams);
+      }
+      return aTranslation;
+    }
+  }
+  std::string aMsg = theMessage;
+  if (theParams.size() > 0) {
+    aMsg = insertParameters(aMsg, theParams);
+  }
+#ifdef _DEBUG
+#ifdef MISSED_TRANSLATION
+  myMissed[theContext][theMessage] = "";
+#endif
+#endif
+  return aMsg;
+}
+
+
+std::string Config_Translator::codec(const std::string& theContext)
+{ 
+  return (myCodecs.count(theContext) > 0)? myCodecs[theContext] : "UTF-8"; 
+}
+
+
+#ifdef _DEBUG
+#ifdef MISSED_TRANSLATION
+void Config_Translator::saveMissedTranslations()
+{
+  if (myMissed.size() == 0)
+    return;
+
+  char* aPath = getenv("ROOT_DIR");
+#ifdef WIN32
+  std::string aFile = aPath + std::string("\\MissedTranslation.ts");
+#else
+  std::string aFile = aPath + std::string("/MissedTranslation.ts");
+#endif
+  std::ofstream oFStream;
+
+  // Delete old file
+  int aa = remove(aFile.c_str());
+
+  oFStream.open(aFile, std::ofstream::out | std::ofstream::app);
+  if (oFStream.is_open()) {
+    Translator::const_iterator aContIt;
+    Dictionary::const_iterator aDictIt;
+    std::string aContext;
+    std::string aSrc;
+    Dictionary aDict;
+
+    oFStream << "<TS version=\"2.0\">" << std::endl;
+    for(aContIt = myMissed.cbegin(); aContIt != myMissed.cend(); aContIt++) {
+      oFStream << "<context>" << std::endl;
+
+      aContext = aContIt->first;
+      oFStream << "  <name>" << aContext << "</name>" << std::endl;
+
+      aDict = aContIt->second;
+      for(aDictIt = aDict.cbegin(); aDictIt != aDict.cend(); aDictIt++) {
+        oFStream << "  <message>" << std::endl;
+        aSrc = aDictIt->first;
+
+        oFStream << "    <source>" << aSrc << "</source>" << std::endl;
+        oFStream << "    <translation>" << "</translation>" << std::endl;
+
+        oFStream << "  </message>" << std::endl;
+      }
+      oFStream << "</context>" << std::endl;
+    }
+
+    oFStream << "</TS>" << std::endl;
+    oFStream.close();
+  }
+}
+#endif
+#endif
diff --git a/src/Config/Config_Translator.h b/src/Config/Config_Translator.h
new file mode 100644 (file)
index 0000000..72a305e
--- /dev/null
@@ -0,0 +1,87 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Config_Translator.h
+// Created:     31 May 2016
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef Config_Translator_H
+#define Config_Translator_H
+
+#include "Config_def.h"
+#include <Events_InfoMessage.h>
+
+#include <string>
+#include <map>
+
+//#define MISSED_TRANSLATION
+
+/**
+ * \class Config_Translator
+ * \ingroup Config
+ * \brief Class for messages translation on different languages. It can load TS
+ * files wich contain translation string and provides translations of messages from source code
+ */
+class Config_Translator
+{
+public:
+  /// A data type of dictionary <KeyString, ResultString>
+  typedef std::map<std::string, std::string> Dictionary;
+
+  /// A data type of Translator with structure <Context, Dictionary>
+  typedef std::map<std::string, Dictionary> Translator;
+
+  /**
+  * Load translations from TS file
+  * \param theFileName a TS file name with full path
+  */
+  static CONFIG_EXPORT bool load(const std::string& theFileName);
+
+  /**
+  * Returns translation from the given info message.
+  * If transdlation 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<Events_InfoMessage> theInfo);
+
+  /**
+  * Returns translation from the given data.
+  * If transdlation is not exists then it returns a string 
+  * from the info data without translation
+  * \param theContext context of the message (Feature Id)
+  * \param theMessage a message which dave to be translated
+  * \param theParams a list of parameters (can be empty)
+  */
+  static CONFIG_EXPORT std::string translate(const std::string& theContext,
+    const std::string& theMessage, 
+    const std::list<std::string>& theParams = std::list<std::string>());
+
+
+  /**
+  * Returns codec for the context
+  * \param theContext the context
+  */ 
+  static CONFIG_EXPORT std::string codec(const std::string& theContext);
+
+#ifdef _DEBUG
+#ifdef MISSED_TRANSLATION
+  static CONFIG_EXPORT void saveMissedTranslations();
+#endif
+#endif
+
+
+private:
+  /// A map of translations
+  static Translator myTranslator;
+
+  /// aMap of codecs for contexts
+  static Dictionary myCodecs;
+
+#ifdef _DEBUG
+#ifdef MISSED_TRANSLATION
+  static Translator myMissed;
+#endif
+#endif
+};
+
+#endif
\ No newline at end of file
index dfeb81cc70cfdf13891910749fbc77285de94d82..8a7236b212eaf09c3f002f0078a3b5d6b9f7e280 100644 (file)
@@ -15,7 +15,6 @@
 #include <Config_PropManager.h>
 
 #include <Events_Loop.h>
-#include <Events_Error.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 
index 184fcdf61fa1656a7b395cf0d8ed6c0095f1b82c..1dab4ac3d46667278c11936eeba332ec55bb1b57 100644 (file)
@@ -13,7 +13,7 @@
 #include <Config_PropManager.h>
 
 #include <Events_Loop.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 
@@ -51,7 +51,8 @@ Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName)
 
   myDocumentPath = prefix + FSEP + theXmlFileName;
   std::ifstream aTestFile(myDocumentPath);
-  if (!aTestFile) Events_Error::send("Unable to open " + myDocumentPath);
+  if (!aTestFile) 
+    Events_InfoMessage("Config_XMLReader", "Unable to open %1").arg(myDocumentPath).send();
   aTestFile.close();
 }
 
@@ -198,3 +199,8 @@ bool Config_XMLReader::cleanupAttribute(const char* theNodeName, const char* the
   }
   return result;
 }
+
+const char* Config_XMLReader::encoding() const
+{ 
+  return (const char*) myXmlDoc->encoding; 
+}
\ No newline at end of file
index 62173af3155810e23726be7d22f34d3633e1fc87..851ff1b28c617c473dc4a830be518cfbd69d4125 100644 (file)
@@ -60,6 +60,8 @@ class Config_XMLReader
    */
   CONFIG_EXPORT xmlNodePtr findRoot();
 
+  CONFIG_EXPORT const char* encoding() const;
+
  protected:
   /*!
    * \brief Allows to customize reader's behavior for a node. Virtual.
index e9cb9804f1813430747dd8965363f74c09982532..1e8f814882788a28a2f3f7ef468c4a9c1525eb61 100644 (file)
@@ -55,7 +55,7 @@ class ExportFeature(ModelAPI.ModelAPI_Feature):
         kResultBodyType = "Bodies"
         aPartSize = self.Part.size(kResultBodyType)
         if aPartSize == 0:
-            EventsAPI.Events_Error_send("No results in the active document")
+            EventsAPI.Events_InfoMessage("ExportFeature","No results in the active document").send()
             return
 
         anObjList = [self.Part.object(kResultBodyType, idx) for idx in xrange(aPartSize)]
index 5c5d99a083ae2547cbb8e5a31df90b34d050cc70..9b3f7773f480309e679b8cb9e0f6d6d2c53df201 100644 (file)
@@ -11,8 +11,8 @@ SET(PROJECT_HEADERS
     Events_MessageGroup.h
     Events_Listener.h
     Events_Loop.h
-    Events_Error.h
     Events_LongOp.h
+       Events_InfoMessage.h
 )
 
 SET(PROJECT_SOURCES
@@ -20,7 +20,6 @@ SET(PROJECT_SOURCES
     Events_MessageGroup.cpp
     Events_Listener.cpp
     Events_Loop.cpp
-    Events_Error.cpp
     Events_LongOp.cpp
 )
 
index 005c05758ccc050a43049eea179d32abb252f030..733170ffc5f869d029a239ae1e060488fd679fbb 100644 (file)
@@ -2,7 +2,7 @@
 %module EventsAPI
 %{
   #include "Events.h"
-  #include "Events_Error.h"
+  #include "Events_InfoMessage.h"
   #include "Events_Message.h"
 %}
 
@@ -16,4 +16,4 @@
 
 // all supported interfaces
 %include "Events_Message.h"
-%include "Events_Error.h"
+%include "Events_InfoMessage.h"
diff --git a/src/Events/Events_Error.cpp b/src/Events/Events_Error.cpp
deleted file mode 100644 (file)
index 1dc1012..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-/*
- * Events_Error.cpp
- *
- *  Created on: Apr 28, 2014
- *      Author: sbh
- */
-
-#include <Events_Error.h>
-#include <Events_Loop.h>
-
-#define THROW_EMPTY_AIS_EXCEPTION
-
-Events_Error::Events_Error(const std::string& theDescription, const void* theSender)
-    : Events_Message(Events_Error::errorID(), theSender)
-{
-  myDescription = theDescription;
-}
-
-Events_Error::~Events_Error()
-{
-}
-
-Events_ID Events_Error::errorID()
-{
-  Events_Loop* aLoop = Events_Loop::loop();
-  return aLoop->eventByName("ApplicationError");
-}
-
-const char* Events_Error::description() const
-{
-  return myDescription.c_str();
-}
-
-void Events_Error::send(const std::string& theDescription, const void* theSender)
-{
-  std::shared_ptr<Events_Message> aNewOne = 
-    std::shared_ptr<Events_Message>(new Events_Error(theDescription, theSender));
-  Events_Loop::loop()->send(aNewOne);
-}
-
-void Events_Error::throwException(const std::string& theDescription)
-{
-#ifdef THROW_EMPTY_AIS_EXCEPTION
-  Events_Error::send(
-      std::string("An exception: ") + theDescription);
-#endif
-}
diff --git a/src/Events/Events_Error.h b/src/Events/Events_Error.h
deleted file mode 100644 (file)
index aefa5dd..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-/*
- * Events_Error.h
- *
- *  Created on: Apr 28, 2014
- *      Author: sbh
- */
-
-#ifndef EVENTS_ERROR_H_
-#define EVENTS_ERROR_H_
-
-#include <Events.h>
-#include <Events_Message.h>
-
-#include <string>
-
-/**\class Events_Error
- * \ingroup EventsLoop
- * \brief An error message event.
- *
- * Is generated by any algorithm or GUI of the application to inform the user about
- * the problem. In GUI mode all such errors are collected in the message log window.
- */
-class Events_Error : public Events_Message
-{
-  std::string myDescription;  ///< the description of the error
-
-public:
-  /// default destructor   
-  EVENTS_EXPORT virtual ~Events_Error();
-
-  /// Identifier of this event (one for all errors)
-  EVENTS_EXPORT static Events_ID errorID();
-  /// Specific error string
-  EVENTS_EXPORT const char* description() const;
-  /// Allows to send an error quickly: it creates and sends the error object automatically
-  EVENTS_EXPORT static void send(const std::string& theDescription, const void* theSender = 0);
-
-  /// Throws a C++ exception about using an empty AIS object
-  /// \param theDescription an exception information
-  EVENTS_EXPORT static void throwException(const std::string& theDescription);
-
-protected:
-  /// Default constructor. Use "send" message for generation an error.
-  EVENTS_EXPORT Events_Error(const std::string& theDescription, const void* theSender = 0);
-};
-
-#endif /* EVENTS_ERROR_H_ */
diff --git a/src/Events/Events_InfoMessage.h b/src/Events/Events_InfoMessage.h
new file mode 100644 (file)
index 0000000..bf92b3a
--- /dev/null
@@ -0,0 +1,113 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:       Events_InfoMessage.hxx
+// Created:    31 May 2016
+// Author:     Vitaly SMETANNIKOV
+
+#ifndef Events_InfoMessage_H_
+#define Events_InfoMessage_H_
+
+#include <Events.h>
+#include <Events_Message.h>
+#include <Events_Loop.h>
+
+/**\class Events_InfoMessage
+ * \ingroup EventsLoop
+ * \brief An event message for sending a string message which has to be translated.
+ */
+class Events_InfoMessage: public Events_Message
+{
+public:
+
+  /// Constructor
+  /// \param theSender a pointer on sender object
+  Events_InfoMessage(const void* theSender = 0):Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {}
+
+  /// Constructor
+  /// \param theSender a pointer on sender object
+  Events_InfoMessage(const std::string& theContext, 
+    const std::string& theMsg, const void* theSender = 0):
+  Events_Message(Events_Loop::eventByName("InfoMessage"), theSender),
+    myContext(theContext), myMessage(theMsg) {}
+
+  /// default destructor   
+  virtual ~Events_InfoMessage() {}
+
+  /// Identifier of this event (one for all errors)
+  static Events_ID errorID()  { return Events_Loop::loop()->eventByName("InfoMessage"); }
+
+  /// Set a context string
+  /// \param theContext a context string
+  void  setContext(const std::string& theContext) { myContext = theContext; } 
+
+
+  /// Returns context string
+  std::string context() const { return myContext; }
+
+  /// Set message string for translation
+  /// \param theMsg the string of message
+  void setMessage(const std::string& theMsg) { myMessage = theMsg; } 
+
+  /// Returns message
+  std::string message() const { return myMessage; }
+
+  /// Add parameter for message string of string type
+  /// \param theParam the parameter
+  void addParameter(const std::string& theParam) 
+  { 
+    myParameters.push_back(theParam); 
+  }
+
+  /// Add parameter for message string of double type
+  /// \param theParam the parameter
+  void addParameter(double theParam) 
+  { 
+    char aBuf[50];
+    int n = sprintf_s(aBuf, "%g", theParam);
+    std::string aStr(aBuf);
+    myParameters.push_back(aStr); 
+  }
+
+  /// Add parameter for message string of integer type
+  /// \param theParam the parameter
+  void addParameter(int theParam) 
+  { 
+    char aBuf[50];
+    int n = sprintf_s(aBuf, "%d", theParam);
+    std::string aStr(aBuf);
+    myParameters.push_back(aStr); 
+  }
+
+  /// Returns list of parameters
+  std::list<std::string> parameters() const { return myParameters; }
+
+  /// Add parameter for message string of string type
+  /// \param theParam the parameter
+  Events_InfoMessage& arg(const std::string& theParam) { addParameter(theParam); return *this; }
+
+  /// Add parameter for message string of integer type
+  /// \param theParam the parameter
+  Events_InfoMessage& arg(int theParam) { addParameter(theParam); return *this; }
+
+  /// Add parameter for message string of double type
+  /// \param theParam the parameter
+  Events_InfoMessage& arg(double theParam) { addParameter(theParam); return *this; }
+
+  void send() { 
+    std::shared_ptr<Events_Message> aMsg(new Events_InfoMessage(*this));
+    Events_Loop::loop()->send(aMsg); 
+  }
+
+private:
+
+  /// Context of the messgae
+  std::string myContext;
+
+  /// String of the message
+  std::string myMessage;
+
+  /// Parameters of the message
+  std::list<std::string> myParameters;
+};
+
+#endif
\ No newline at end of file
index c2f90be01bd81b04712b7119e503e8756617b202..2ab3adbb06d75f78451ff4e0abf2e655636eb5b0 100644 (file)
@@ -15,8 +15,6 @@
 #include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_ResultConstruction.h>
 
-#include <Events_Error.h>
-
 #include <GeomValidators_BodyShapes.h>
 #include <GeomValidators_FeatureKind.h>
 #include <GeomValidators_ShapeType.h>
index d3b075fde59c5f4d976d512719cf50fca579bc96..f91066da277bdea6b64fcf8cb859b36b40a48773 100644 (file)
@@ -10,7 +10,7 @@
 
 #include <GeomAbs_SurfaceType.hxx>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <QString>
 #include <QMap>
@@ -28,7 +28,7 @@ GeomAbs_SurfaceType faceType(const std::string& theType)
   if (MyFaceTypes.find(aType) != MyFaceTypes.end())
     return MyFaceTypes[aType];
   
-  Events_Error::send("Face type defined in XML is not implemented!");
+  Events_InfoMessage("GeomValidators_Face", "Face type defined in XML is not implemented!").send();
   return GeomAbs_Plane;
 }
 
index f9a4e517de50d6dc3691d4501dd87259360c1efa..8bc0d9fbdd6c9db30d44e7c08dae6d69ca80ea69 100755 (executable)
@@ -13,7 +13,7 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeReference.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <string>
 #include <map>
@@ -42,7 +42,7 @@ GeomValidators_ShapeType::TypeOfShape GeomValidators_ShapeType::shapeType(const
   if (MyShapeTypes.find(aType) != MyShapeTypes.end())
     return MyShapeTypes[aType];
 
-  Events_Error::send("Shape type defined in XML is not implemented!");
+  Events_InfoMessage("Shape type defined in XML is not implemented!").send();
   return AnyShape;
 }
 
index b896d594ba9ddb904b52d57dc81f17b682e71389..0c47e2a52586263d639d9e850d9f6a053846ee9c 100644 (file)
@@ -11,7 +11,7 @@
 #include <ModelAPI_Result.h>
 
 #include <Events_Message.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <memory>
 
@@ -79,9 +79,9 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptr<Events_Mess
     Events_Loop::loop()->send(aMsg);
 
   } else if (theMessage.get()) {
-    Events_Error::send(
-        std::string("InitializationPlugin_Plugin::processEvent: unhandled message caught: ")
-            + theMessage->eventID().eventText());
+    Events_InfoMessage("InitializationPlugin_Plugin",
+        "InitializationPlugin_Plugin::processEvent: unhandled message caught: %1")
+            .arg(theMessage->eventID().eventText()).send();
   }
 }
 
index be028e276f5cab1909cd0c0bdd9840588e7e1a4f..7f90352af3df27e5202b2185ba263432ab0cc501 100644 (file)
@@ -18,7 +18,7 @@
 #include <ModelAPI_Tools.h>
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_PlanarEdges.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <TNaming_Selector.hxx>
 #include <TNaming_NamedShape.hxx>
@@ -662,7 +662,7 @@ void Model_AttributeSelection::selectBody(
     if (aResult) {
       aContext = aResult->shape()->impl<TopoDS_Shape>();
     } else {
-      Events_Error::send("A result with shape is expected");
+      Events_InfoMessage("Model_AttributeSelection", "A result with shape is expected").send();
       return;
     }
   }
index 4dfabe551219209f63f169f9f102b549b8c5e17b..1e63282bb2690aebc2fb5c809bc7dc8c3c38574d 100644 (file)
@@ -36,7 +36,7 @@
 #include <GeomData_Point2D.h>
 #include <GeomData_Dir.h>
 #include <Events_Loop.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <TDataStd_Name.hxx>
 #include <TDataStd_AsciiString.hxx>
@@ -182,7 +182,7 @@ AttributePtr Model_Data::addAttribute(const std::string& theID, const std::strin
     anAttr->setObject(myObject);
     anAttr->setID(theID);
   } else {
-    Events_Error::send("Can not create unknown type of attribute " + theAttrType);
+    Events_InfoMessage("Model_Data", "Can not create unknown type of attribute %1").arg(theAttrType).send();
   }
   return aResult;
 }
@@ -370,7 +370,7 @@ void Model_Data::setError(const std::string& theError, bool theSend)
 {
   execState(ModelAPI_StateExecFailed);
   if (theSend) {
-    Events_Error::send(theError);
+    Events_InfoMessage("Model_Data", theError).send();
   }
   TDataStd_AsciiString::Set(myLab, theError.c_str());
 }
index 9994a1422612029e6873f1415bc07d9f8bf61e17..0c40c27230db30754d8036b080f676fbbbf0cb2a 100755 (executable)
@@ -18,7 +18,7 @@
 #include <ModelAPI_ResultBody.h>
 
 #include <Events_Loop.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_Comment.hxx>
@@ -120,61 +120,61 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum
     aStatus = anApp->Open(aPath, aLoaded);
   } catch (Standard_Failure) {
     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    Events_Error::send(
-        std::string("Exception in opening of document: ") + aFail->GetMessageString());
+    Events_InfoMessage("Model_Document",
+        "Exception in opening of document: %1").arg(aFail->GetMessageString()).send();
     return false;
   }
   bool isError = aStatus != PCDM_RS_OK;
   if (isError) {
     switch (aStatus) {
       case PCDM_RS_UnknownDocument:
-        Events_Error::send(std::string("Can not open document"));
+        Events_InfoMessage("Model_Document", "Can not open document").send();
         break;
       case PCDM_RS_AlreadyRetrieved:
-        Events_Error::send(std::string("Can not open document: already opened"));
+        Events_InfoMessage("Model_Document", "Can not open document: already opened").send();
         break;
       case PCDM_RS_AlreadyRetrievedAndModified:
-        Events_Error::send(
-            std::string("Can not open document: already opened and modified"));
+        Events_InfoMessage("Model_Document", 
+            "Can not open document: already opened and modified").send();
         break;
       case PCDM_RS_NoDriver:
-        Events_Error::send(std::string("Can not open document: driver library is not found"));
+        Events_InfoMessage("Model_Document", "Can not open document: driver library is not found").send();
         break;
       case PCDM_RS_UnknownFileDriver:
-        Events_Error::send(std::string("Can not open document: unknown driver for opening"));
+        Events_InfoMessage("Model_Document", "Can not open document: unknown driver for opening").send();
         break;
       case PCDM_RS_OpenError:
-        Events_Error::send(std::string("Can not open document: file open error"));
+        Events_InfoMessage("Model_Document", "Can not open document: file open error").send();
         break;
       case PCDM_RS_NoVersion:
-        Events_Error::send(std::string("Can not open document: invalid version"));
+        Events_InfoMessage("Model_Document", "Can not open document: invalid version").send();
         break;
       case PCDM_RS_NoModel:
-        Events_Error::send(std::string("Can not open document: no data model"));
+        Events_InfoMessage("Model_Document", "Can not open document: no data model").send();
         break;
       case PCDM_RS_NoDocument:
-        Events_Error::send(std::string("Can not open document: no document inside"));
+        Events_InfoMessage("Model_Document", "Can not open document: no document inside").send();
         break;
       case PCDM_RS_FormatFailure:
-        Events_Error::send(std::string("Can not open document: format failure"));
+        Events_InfoMessage("Model_Document", "Can not open document: format failure").send();
         break;
       case PCDM_RS_TypeNotFoundInSchema:
-        Events_Error::send(std::string("Can not open document: invalid object"));
+        Events_InfoMessage("Model_Document", "Can not open document: invalid object").send();
         break;
       case PCDM_RS_UnrecognizedFileFormat:
-        Events_Error::send(std::string("Can not open document: unrecognized file format"));
+        Events_InfoMessage("Model_Document", "Can not open document: unrecognized file format").send();
         break;
       case PCDM_RS_MakeFailure:
-        Events_Error::send(std::string("Can not open document: make failure"));
+        Events_InfoMessage("Model_Document", "Can not open document: make failure").send();
         break;
       case PCDM_RS_PermissionDenied:
-        Events_Error::send(std::string("Can not open document: permission denied"));
+        Events_InfoMessage("Model_Document", "Can not open document: permission denied").send();
         break;
       case PCDM_RS_DriverFailure:
-        Events_Error::send(std::string("Can not open document: driver failure"));
+        Events_InfoMessage("Model_Document", "Can not open document: driver failure").send();
         break;
       default:
-        Events_Error::send(std::string("Can not open document: unknown error"));
+        Events_InfoMessage("Model_Document", "Can not open document: unknown error").send();
         break;
     }
   }
@@ -232,22 +232,22 @@ bool Model_Document::save(
     aStatus = anApp->SaveAs(myDoc, aPath);
   } catch (Standard_Failure) {
     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    Events_Error::send(
-        std::string("Exception in saving of document: ") + aFail->GetMessageString());
+    Events_InfoMessage("Model_Document", 
+        "Exception in saving of document: %1").arg(aFail->GetMessageString()).send();
     return false;
   }
   bool isDone = aStatus == PCDM_SS_OK || aStatus == PCDM_SS_No_Obj;
   if (!isDone) {
     switch (aStatus) {
       case PCDM_SS_DriverFailure:
-        Events_Error::send(std::string("Can not save document: save driver-library failure"));
+        Events_InfoMessage("Model_Document", "Can not save document: save driver-library failure").send();
         break;
       case PCDM_SS_WriteFailure:
-        Events_Error::send(std::string("Can not save document: file writing failure"));
+        Events_InfoMessage("Model_Document", "Can not save document: file writing failure").send();
         break;
       case PCDM_SS_Failure:
       default:
-        Events_Error::send(std::string("Can not save document"));
+        Events_InfoMessage("Model_Document", "Can not save document").send();
         break;
     }
   }
@@ -274,8 +274,8 @@ bool Model_Document::save(
             aFile.Copy(aDestination);
             theResults.push_back(aDestinationDir.ToCString());
           } else {
-            Events_Error::send(
-              std::string("Can not open file ") + aSubPath.ToCString() + " for saving");
+            Events_InfoMessage("Model_Document", 
+              "Can not open file %1 for saving").arg(aSubPath.ToCString()).send();
           }
         }
       } else { // simply save opened document
index 44ab4cf593c62d5a50744a031a5511382d9b2663..0be76f106de57f717d525fceb2b6960113eedc0d 100644 (file)
@@ -20,7 +20,7 @@
 #include <ModelAPI_Tools.h>
 
 #include <Events_Loop.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_Comment.hxx>
@@ -224,8 +224,8 @@ void Model_Objects::refsToFeature(FeaturePtr theFeature,
   }
 
   if (!theRefs.empty() && isSendError) {
-    Events_Error::send(
-      "Feature '" + theFeature->data()->name() + "' is used and can not be deleted");
+    Events_InfoMessage("Model_Objects", 
+      "Feature '%1' is used and can not be deleted").arg(theFeature->data()->name()).send();
   }
 }
 
@@ -302,10 +302,10 @@ void Model_Objects::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis)
   if (!aPassedMovedFrom || !aPassedMovedTo) {// not found: unknown situation
     if (!aPassedMovedFrom) {
       static std::string aMovedFromError("The moved feature is not found");
-      Events_Error::send(aMovedFromError);
+      Events_InfoMessage("Model_Objects", aMovedFromError).send();
     } else {
       static std::string aMovedToError("The 'after' feature for movement is not found");
-      Events_Error::send(aMovedToError);
+      Events_InfoMessage("Model_Objects", aMovedToError).send();
     }
     return;
   }
@@ -643,7 +643,7 @@ void Model_Objects::synchronizeFeatures(
         TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get())
         .ToCString(), anOwner);
       if (!aFeature.get()) {  // somethig is wrong, most probably, the opened document has invalid structure
-        Events_Error::send("Invalid type of object in the document");
+        Events_InfoMessage("Model_Objects", "Invalid type of object in the document").send();
         aLabIter.Value()->Label().ForgetAllAttributes();
         continue;
       }
@@ -1082,8 +1082,8 @@ void Model_Objects::updateResults(FeaturePtr theFeature)
           theFeature->attributeChanged("expression"); // just produce a value
           break;
         } else {
-          Events_Error::send(std::string("Unknown type of result is found in the document:") +
-            TCollection_AsciiString(aGroup->Get()).ToCString());
+          Events_InfoMessage("Model_Objects", "Unknown type of result is found in the document:")
+            .arg(TCollection_AsciiString(aGroup->Get()).ToCString()).send();
         }
       }
       if (aNewBody && !aNewBody->data()->isDeleted()) {
index 7db813549c5c0d2e216a8a5a73403b3c3d4f565b..c577080b136565379a1a3e006e05db9dfb84acbe 100644 (file)
@@ -7,7 +7,7 @@
 #include "Model_SelectionNaming.h"
 #include "Model_Document.h"
 #include <ModelAPI_Feature.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <TopoDS_Iterator.hxx>
 #include <TopoDS.hxx>
@@ -299,7 +299,7 @@ TopAbs_ShapeEnum translateType (const std::string& theType)
   }
   if (aShapeTypes.find(theType) != aShapeTypes.end())
     return aShapeTypes[theType];
-  Events_Error::send("Shape type defined in XML is not implemented!");
+  Events_InfoMessage("Model_SelectionNaming", "Shape type defined in XML is not implemented!").send();
   return TopAbs_SHAPE;
 }
 
index 886bfec9f304b3cdeda9ba47a89d2601dc7c6fad..fe35df17d218e244740d6a3b28e6e43407b282e4 100644 (file)
@@ -15,7 +15,7 @@
 #include <Model_Validator.h>
 #include <ModelAPI_Events.h>
 #include <Events_Loop.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 #include <Config_FeatureMessage.h>
 #include <Config_AttributeMessage.h>
 #include <Config_ValidatorMessage.h>
@@ -156,9 +156,9 @@ FeaturePtr Model_Session::createFeature(string theFeatureID, Model_Document* the
   if (myPlugins.find(theFeatureID) != myPlugins.end()) {
     std::pair<std::string, std::string>& aPlugin = myPlugins[theFeatureID]; // plugin and doc kind
     if (!aPlugin.second.empty() && aPlugin.second != theDocOwner->kind()) {
-      Events_Error::send(
-          string("Feature '") + theFeatureID + "' can be created only in document '"
-              + aPlugin.second + "' by the XML definition");
+      Events_InfoMessage("Model_Session",
+          "Feature '%1' can be created only in document '%2' by the XML definition")
+          .arg(theFeatureID).arg(aPlugin.second).send();
       return FeaturePtr();
     }
     myCurrentPluginName = aPlugin.first;
@@ -169,16 +169,16 @@ FeaturePtr Model_Session::createFeature(string theFeatureID, Model_Document* the
     if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) {
       FeaturePtr aCreated = myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID);
       if (!aCreated) {
-        Events_Error::send(
-            string("Can not initialize feature '") + theFeatureID + "' in plugin '"
-                + myCurrentPluginName + "'");
+        Events_InfoMessage("Model_Session",
+            "Can not initialize feature '%1' in plugin '%2'")
+            .arg(theFeatureID).arg(myCurrentPluginName).send();
       }
       return aCreated;
     } else {
-      Events_Error::send(string("Can not load plugin '") + myCurrentPluginName + "'");
+      Events_InfoMessage("Model_Session","Can not load plugin '%1'").arg(myCurrentPluginName).send();
     }
   } else {
-    Events_Error::send(string("Feature '") + theFeatureID + "' not found in any plugin");
+    Events_InfoMessage("Model_Session","Feature '%1' not found in any plugin").arg(theFeatureID).send();
   }
 
   return FeaturePtr();  // return nothing
@@ -394,7 +394,7 @@ void Model_Session::processEvent(const std::shared_ptr<Events_Message>& theMessa
     }
   } else {  // create/update/delete
     if (myCheckTransactions && !isOperation())
-      Events_Error::send("Modification of data structure outside of the transaction");
+      Events_InfoMessage("Model_Session", "Modification of data structure outside of the transaction").send();
     // if part is deleted, make the root as the current document (on undo of Parts creations)
     static const Events_ID kDeletedEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
     if (theMessage->eventID() == kDeletedEvent) {
index 2e0b1b34192f47095a41d1a7f6a600aeb700306a..2eb0e7dbe24b9532ae527ec2e36b08c79cdd8346 100755 (executable)
@@ -27,7 +27,7 @@
 #include <GeomDataAPI_Point2D.h>
 #include <Events_Loop.h>
 #include <Events_LongOp.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 #include <Config_PropManager.h>
 
 using namespace std;
@@ -351,8 +351,8 @@ bool Model_Update::processFeature(FeaturePtr theFeature)
   } else {
     int aCount = myProcessed[theFeature];
     if (aCount > 100) { // too many repetition of processing (in VS it may crash on 330 with stack overflow)
-      Events_Error::send(
-        "Feature '" + theFeature->data()->name() + "' is updated in infinitive loop");
+      Events_InfoMessage("Model_Update",
+        "Feature '%1' is updated in infinitive loop").arg(theFeature->data()->name()).send();
       return false;
     }
     myProcessed[theFeature] = aCount + 1;
@@ -726,8 +726,8 @@ void Model_Update::executeFeature(FeaturePtr theFeature)
     }
   } catch(...) {
     aState = ModelAPI_StateExecFailed;
-    Events_Error::send(
-      "Feature " + theFeature->getKind() + " has failed during the execution");
+    Events_InfoMessage("Model_Update",
+      "Feature %1 has failed during the execution").arg(theFeature->getKind()).send();
   }
   // The macro feature has to be deleted in any case even its execution is failed 
   myWaitForFinish.insert(theFeature);
index 6795e43e1b2b13cb7387d4ff8e3515534a25ac4b..dafa195830c7b5e6dcd6f439ecf1168f900d3cf2 100644 (file)
 #include <ModelAPI_Feature.h>
 #include <Model_Data.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 void Model_ValidatorsFactory::registerValidator(const std::string& theID,
   ModelAPI_Validator* theValidator)
 {
   if (myIDs.find(theID) != myIDs.end()) {
-    Events_Error::send(std::string("Validator ") + theID + " is already registered");
+    Events_InfoMessage("Model_Validator", "Validator %1 is already registered").arg(theID).send();
   } else {
     myIDs[theID] = theValidator;
   }
@@ -86,7 +86,8 @@ void Model_ValidatorsFactory::validators(const std::string& theFeatureID,
     AttrValidators::const_iterator aValidatorsIt = aFeatureIt->second.cbegin();
     for (; aValidatorsIt != aFeatureIt->second.cend(); aValidatorsIt++) {
       if (!validator(aValidatorsIt->first)) {
-        Events_Error::send(std::string("Validator ") + aValidatorsIt->first + " was not registered");
+        Events_InfoMessage("Model_Validator", "Validator %1 was not registered")
+          .arg(aValidatorsIt->first).send();
       } else {
         theValidators.push_back(std::make_pair(aValidatorsIt->first, aValidatorsIt->second));
       }
@@ -106,7 +107,8 @@ void Model_ValidatorsFactory::validators(const std::string& theFeatureID, const
       AttrValidators::const_iterator aValidatorsIt = anAttrIt->second.cbegin();
       for (; aValidatorsIt != anAttrIt->second.cend(); aValidatorsIt++) {
         if (!validator(aValidatorsIt->first)) {
-          Events_Error::send(std::string("Validator ") + aValidatorsIt->first + " was not registered");
+          Events_InfoMessage("Model_Validator", "Validator %1 was not registered")
+            .arg(aValidatorsIt->first).send();
         } else {
           theValidators.push_back(std::make_pair(aValidatorsIt->first, aValidatorsIt->second));
         }
index 1bbf8d2fb81413542cb027e73d9d1b0d616a07a5..93a8870b0b717b2c4eaa7bf5f66450d18a6796f0 100644 (file)
@@ -37,7 +37,7 @@ static const char * EVENT_OBJECT_TO_REDISPLAY = "ObjectsToRedisplay";
 /// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage)
 static const char * EVENT_OPERATION_LAUNCHED = "OperationLaunched";
 /// Event ID that plugin is loaded (comes with ModelAPI_ObjectUpdatedMessage)
-static const char * EVENT_PLUGIN_LOADED = "PliginLoaded";
+static const char * EVENT_PLUGIN_LOADED = "PluginLoaded";
 //
 static const char * EVENT_DOCUMENT_CHANGED = "CurrentDocumentChanged";
 
index e511e5223c6809d3ff82bcc5b4ceeba896078923..4320004afc94da2b6ff8274aa58b22b63b5caef4 100644 (file)
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_Data.h>
 //#include <ModelAPI_AttributeValidator.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 
 void ModuleBase_FilterFactory::registerFilter(const std::string& theID,
                                               ModuleBase_Filter* theFilter)
 {
   if (myIDs.find(theID) != myIDs.end()) {
-    Events_Error::send(std::string("Filter ") + theID + " is already registered");
+    Events_InfoMessage("ModuleBase_FilterFactory", "Filter %1 is already registered").arg(theID).send();
   } else {
     myIDs[theID] = theFilter;
   }
@@ -63,7 +63,8 @@ void ModuleBase_FilterFactory::filters(const std::string& theFeatureID,
         std::map<std::string, ModuleBase_Filter*>::const_iterator aFound = myIDs.find(
           aValIter->first);
         if (aFound == myIDs.end()) {
-          Events_Error::send(std::string("Filter ") + aValIter->first + " was not registered");
+          Events_InfoMessage("ModuleBase_FilterFactory", "Filter %1 was not registered")
+            .arg(aValIter->first).send();
         } else {
           ModuleBase_Filter* aFilter = aFound->second;
           aFilter->setArguments(aValIter->second);
index fa0395ad9462eafc374d70d71a4ef75486ff5df9..997c4134849595142d57bbe2c6d27cad00d83cc0 100644 (file)
@@ -23,6 +23,7 @@
 #include <Config_PointerMessage.h>
 #include <Config_WidgetReader.h>
 #include <Config_ModuleReader.h>
+#include <Config_Translator.h>
 
 #include <QAction>
 #include <QMainWindow>
@@ -30,6 +31,7 @@
 #include <QLayout>
 #include <QDialogButtonBox>
 #include <QPushButton>
+#include <QTextCodec>
 
 ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent)
   : QObject(theParent), myWorkshop(theParent) 
@@ -106,7 +108,13 @@ bool ModuleBase_IModule::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const
 
 QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature)
 {
-  return ModelAPI_Tools::getFeatureError(theFeature).c_str();
+  QString aMsg = ModelAPI_Tools::getFeatureError(theFeature).c_str();
+  if (!aMsg.isEmpty()) {
+    std::string aStr = Config_Translator::translate(theFeature->getKind(), aMsg.toStdString()).c_str();
+    std::string aCodec = Config_Translator::codec(theFeature->getKind());
+    aMsg = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
+  }
+  return aMsg;
 }
 
 void ModuleBase_IModule::grantedOperationIds(ModuleBase_Operation* theOperation,
index 3923c51c6a70fcbef0064ecdcf15207ebb5f65a6..75c326a27bd3b7a337f3d322706da0ffcc2b536b 100755 (executable)
@@ -12,7 +12,7 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <GeomAPI_PlanarEdges.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 #include <Events_Loop.h>
 
 #include <BRep_Builder.hxx>
@@ -75,7 +75,7 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
 
   if (!aReadyToDisplay) {
-    Events_Error::throwException("An empty AIS presentation: ModuleBase_ResultPrs");
+    Events_InfoMessage("ModuleBase_ResultPrs", "An empty AIS presentation: ModuleBase_ResultPrs").send();
     static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
     ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
   }
index d9114ea820ed8070291c58f1e927dd174df6cf36..a4890633ae0cf4a2ad726d83b83a98fa2eeb6fc0 100755 (executable)
@@ -35,8 +35,8 @@
 #include <TopoDS_Iterator.hxx>
 
 #include <GeomDataAPI_Point2D.h>
+#include <Events_InfoMessage.h>
 #include <GeomAPI_ShapeExplorer.h>
-#include <Events_Error.h>
 
 #include <Config_PropManager.h>
 
@@ -533,7 +533,7 @@ TopAbs_ShapeEnum shapeType(const QString& theType)
   QString aType = theType.toLower();
   if(myShapeTypes.contains(aType))
     return myShapeTypes[aType];
-  Events_Error::send("Shape type defined in XML is not implemented!");
+  Events_InfoMessage("ModuleBase_Tools", "Shape type defined in XML is not implemented!").send();
   return TopAbs_SHAPE;
 }
 
index 13c7bf571d9e5db21073f67610ebd1a15d7dc1c8..2d0ab9e2508c9fc85906f0dde7943ae69373d955 100755 (executable)
@@ -9,7 +9,7 @@
 
 #include <Config_WidgetAPI.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <QStringList>
 
@@ -43,8 +43,8 @@ void ModuleBase_WidgetCreatorFactory::registerCreator(const WidgetCreatorPtr& th
     if (!myPanelToCreator.contains(aKey))
       myPanelToCreator[aKey] = theCreator;
     else {
-      Events_Error::send("The" + aKey + " panel XML definition has been already \
-used by another widget creator");
+      Events_InfoMessage("ModuleBase_WidgetCreatorFactory", 
+        "The %1 panel XML definition has been already used by another widget creator").arg(aKey).send();
     }
   }
 
@@ -56,8 +56,8 @@ used by another widget creator");
     if (!myCreators.contains(aKey))
       myCreators[aKey] = theCreator;
     else {
-      Events_Error::send("The" + aKey + " widget XML definition has been already \
-used by another widget creator");
+      Events_InfoMessage("ModuleBase_WidgetCreatorFactory",
+        "The %1 widget XML definition has been already used by another widget creator").arg(aKey).send();
     }
   }
 
@@ -69,8 +69,8 @@ used by another widget creator");
     if (!myPageToCreator.contains(aKey))
       myPageToCreator[aKey] = theCreator;
     else {
-      Events_Error::send("The" + aKey + " page XML definition has been already \
-used by another widget creator");
+      Events_InfoMessage("ModuleBase_WidgetCreatorFactory",
+        "The %1 page XML definition has been already used by another widget creator").arg(aKey).send();
     }
   }
 }
index 119329071e8cf0fecad02d833ecc48bb845d86dc..4652227a84a180fd7921b20d6c9ef52974fc1881 100644 (file)
@@ -39,7 +39,6 @@
 #include <ModelAPI_AttributeValidator.h>
 
 #include <Config_WidgetAPI.h>
-#include <Events_Error.h>
 
 #include <GeomAPI_Shape.h>
 
index fbcab9c2d37e9274636b21a0e5d1e92114814a70..640773727c1fc53d55fff869fc6574de492cdde8 100644 (file)
@@ -54,12 +54,33 @@ SET(PROJECT_LIBRARIES
 )
 
 ADD_DEFINITIONS(-DPARAMETERSPLUGIN_EXPORTS -DHAVE_DEBUG_PYTHON ${CAS_DEFINITIONS})
-ADD_LIBRARY(ParametersPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
+
+SET(TEXT_RESOURCES
+       ParametersPlugin_msg_ru.ts
+)
+
+QT4_CREATE_TRANSLATION(QM_RESOURCES
+                                          ${PROJECT_SOURCES}
+                                          ${TEXT_RESOURCES}
+                                          OPTIONS -extensions cpp -no-recursive
+                                          )
+
+SET(PROJECT_AUTOMOC
+    ${CMAKE_CURRENT_BINARY_DIR}/ParametersPlugin_automoc.cpp
+)
+                       
+                       
+SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${QM_RESOURCES})
+SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES})
+
+ADD_LIBRARY(ParametersPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES} ${QM_RESOURCES})
+
 
 TARGET_LINK_LIBRARIES(ParametersPlugin ${PROJECT_LIBRARIES})
 
 INSTALL(TARGETS ParametersPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
 INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
+INSTALL(FILES ${QM_RESOURCES} DESTINATION ${SHAPER_INSTALL_QM_RESOURCES})
 
 ADD_UNIT_TESTS(TestParameterCreation.py
                TestParameterRename.py
index a588fc793f52ef00b2f4a78e8f4f49b97d2f6a93..fcd4b0dc808076245064ae35cd336edc6675e9e7 100644 (file)
@@ -11,7 +11,7 @@
 #include <ParametersPlugin_Parameter.h>
 #include <ParametersPlugin_PyInterp.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
@@ -91,8 +91,9 @@ void ParametersPlugin_EvalListener::processEvent(
   } else if (theMessage->eventID() == kReplaceParameterEvent) {
     processReplaceParameterEvent(theMessage);
   } else {
-    Events_Error::send(std::string("ParametersPlugin python interpreter, unhandled message caught: ")
-                       + theMessage->eventID().eventText());
+    Events_InfoMessage("ParametersPlugin_EvalListener", 
+      "ParametersPlugin python interpreter, unhandled message caught: ")
+      .arg(theMessage->eventID().eventText()).send();
   }
 }
 
diff --git a/src/ParametersPlugin/ParametersPlugin_msg_ru.ts b/src/ParametersPlugin/ParametersPlugin_msg_ru.ts
new file mode 100644 (file)
index 0000000..d65572f
--- /dev/null
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="ru_RU">
+<context>
+    <name>ParametersPlugin_WidgetParamsMgr</name>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="165"/>
+        <source>Name</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="165"/>
+        <source>Equation</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="165"/>
+        <source>Result</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="165"/>
+        <source>Comment</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="188"/>
+        <source>Parameters</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="194"/>
+        <source>Features</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="213"/>
+        <source>Add</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="217"/>
+        <source>Insert</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="221"/>
+        <source>Remove</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="258"/>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="698"/>
+        <source>Warning</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="ParametersPlugin_WidgetParamsMgr.cpp" line="420"/>
+        <source>Name %1 already exists.</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+</TS>
index 403bbe3005926430a2bdc70f0fce1c5ac6725d86..1f8d0c5606ed6349bc40c2236b9effb03db15400 100755 (executable)
@@ -30,7 +30,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ResultCompSolid.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 #include <Events_Loop.h>
 
 #include <GeomAPI_IPresentable.h>
@@ -130,7 +130,8 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   }
   Set(aComp);
   if (!aReadyToDisplay) {
-    Events_Error::throwException("An empty AIS presentation: PartSet_OperationPrs");
+    Events_InfoMessage("PartSet_OperationPrs", 
+      "An empty AIS presentation: PartSet_OperationPrs").send();
     std::shared_ptr<Events_Message> aMsg = std::shared_ptr<Events_Message>(
                 new Events_Message(Events_Loop::eventByName(EVENT_EMPTY_OPERATION_PRESENTATION)));
     Events_Loop::loop()->send(aMsg);
index a8617af00033efd3fde6a65d86e338b352372dcc..d23125683ca8ae9868af9b340982a876810e5b84 100755 (executable)
@@ -13,7 +13,7 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <GeomAPI_PlanarEdges.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 #include <Events_Loop.h>
 
 #include <SketchPlugin_SketchEntity.h>
@@ -99,7 +99,7 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
   }
 
   if (!aReadyToDisplay) {
-    Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs");
+    Events_InfoMessage("PartSet_ResultSketchPrs", "An empty AIS presentation: PartSet_ResultSketchPrs").send();
     static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
     ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
   }
index 944181bf545293cd4a633adaaf7955a086510ca8..3e3924954c2e6fab50a4bb4492bc0f487f404b04 100644 (file)
@@ -89,8 +89,14 @@ SET(XML_RESOURCES
   plugin-Sketch.xml
 )
 
+SET(TEXT_RESOURCES
+       SketchPlugin_msg_en.ts
+)
+
+SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES})
+
 ADD_DEFINITIONS(-DSKETCHPLUGIN_EXPORTS)
-ADD_LIBRARY(SketchPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
+ADD_LIBRARY(SketchPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES} ${TEXT_RESOURCES})
 TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES})
 
 INCLUDE_DIRECTORIES(
@@ -106,6 +112,7 @@ INCLUDE_DIRECTORIES(
 INSTALL(TARGETS SketchPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
 INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
 INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Sketch)
+INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
 
 ADD_UNIT_TESTS(TestSketchPointLine.py
                TestSketchArcCircle.py
diff --git a/src/SketchPlugin/SketchPlugin_msg_en.ts b/src/SketchPlugin/SketchPlugin_msg_en.ts
new file mode 100644 (file)
index 0000000..e228164
--- /dev/null
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US">
+  <context>
+    <name>Sketch</name>
+    <message>
+      <source>Model_FeatureValidator: Attribute "DirX" is not initialized.</source>
+      <translation>Select a plane for the sketch</translation>
+    </message>
+    <message>
+      <source>Model_FeatureValidator: Attribute "Features" is not initialized.</source>
+      <translation>Sketch objects are not defined</translation>
+    </message>
+  </context>
+  
+  <context>
+    <name>SketchCircle</name>
+    <message>
+      <source>CircleRadius - GeomValidators_Positive: Double is not positive.</source>
+      <translation>Set a positive number for the radius value</translation>
+    </message>
+    <message>
+      <source>Model_FeatureValidator: Attribute "CircleCenter" is not initialized.</source>
+      <translation>Select a center point</translation>
+    </message>
+  </context>
+  
+  <context>
+    <name>SketchConstraintHorizontal</name>
+    <message>
+      <source>Model_FeatureValidator: Attribute "ConstraintEntityA" is not initialized.</source>
+      <translation>Select a line for the constraint</translation>
+    </message>
+    <message>
+      <source>ModelAPI_StateInvalidArgument</source>
+      <translation>Wrong object is selected</translation>
+    </message>
+  </context>
+  
+  <context>
+    <name>SketchConstraintPerpendicular</name>
+    <message>
+      <source>Model_FeatureValidator: Attribute "ConstraintEntityA" is not initialized.</source>
+      <translation>Select first line for the perpendicular constraint</translation>
+    </message>
+    <message>
+      <source>Model_FeatureValidator: Attribute "ConstraintEntityB" is not initialized.</source>
+      <translation>Select second line for the perpendicular constraint</translation>
+    </message>
+  </context>
+  
+  <context>
+    <name>SketchConstraintRadius</name>
+    <message>
+      <source>Model_FeatureValidator: Attribute "ConstraintEntityA" is not initialized.</source>
+      <translation>Select a circle for the radius definition</translation>
+    </message>
+  </context>
+  
+  <context>
+    <name>SketchConstraintVertical</name>
+    <message>
+      <source>ModelAPI_StateInvalidArgument</source>
+      <translation>Wrong object is selected</translation>
+    </message>
+    <message>
+      <source>Model_FeatureValidator: Attribute "ConstraintEntityA" is not initialized.</source>
+      <translation>Select a line for the constraint</translation>
+    </message>
+  </context>
+  
+  <context>
+    <name>SketchLine</name>
+    <message>
+      <source>GeomValidators_Different: Attributes StartPoint and EndPoint are equal.</source>
+      <translation>Drag mouse pointer to select an end point</translation>
+    </message>
+    <message>
+      <source>Model_FeatureValidator: Attribute "EndPoint" is not initialized.</source>
+      <translation>Click to select an end point for the line</translation>
+    </message>
+  </context>
+</TS>
index ba7074e50c5447f3f292ef5b604a128de2c56f51..451e2141ff9f5778f1d3f0814ed51bd47586086f 100644 (file)
@@ -22,7 +22,7 @@
 #include <SketchSolver_ConstraintMovement.h>
 
 #ifdef _DEBUG
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <SketchSolver_Error.h>
@@ -61,7 +61,7 @@ SolverConstraintPtr SketchSolver_Builder::createConstraint(ConstraintPtr theCons
         ResultConstructionPtr aRC =
             std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aRefAttr->object());
         if (!aRC)
-          Events_Error::send(SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this);
+          Events_InfoMessage("SketchSolver_Builder", SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this).send();
       }
       continue;
     }
@@ -73,7 +73,7 @@ SolverConstraintPtr SketchSolver_Builder::createConstraint(ConstraintPtr theCons
         ResultConstructionPtr aRC =
             std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aListIter);
         if (*aListIter && !aRC)
-          Events_Error::send(SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this);
+          Events_InfoMessage("SketchSolver_Builder", SketchSolver_Error::NEED_OBJECT_NOT_FEATURE(), this).send();
       }
     }
   }
index bd07463b365b6399b5f3242e8f1b48035b52a260..144adbfe3e40b3b4d2c42ec9f5f3a9f1af4a413f 100644 (file)
@@ -12,7 +12,7 @@
 #include <SketchSolver_Error.h>
 #include <SketchSolver_Manager.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 #include <Events_Loop.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Events.h>
@@ -166,7 +166,7 @@ bool SketchSolver_Group::changeConstraint(
     if (!aConstraint->error().empty()) {
       if (aConstraint->error() == SketchSolver_Error::NOT_INITIALIZED())
         return false; // some attribute are not initialized yet, don't show message
-      Events_Error::send(aConstraint->error(), this);
+      Events_InfoMessage("SketchSolver_Group", aConstraint->error(), this).send();
     }
     myConstraints[theConstraint] = aConstraint;
 
index d46643fd9c375075d0a5ad7fd2a2114020239162..bbca46d507183835df37f5042b2f41ba259d55a6 100644 (file)
@@ -25,8 +25,6 @@
 #include <TopExp.hxx>
 #include <BRep_Tool.hxx>
 
-#include <Events_Error.h>
-
 #define PI 3.1415926535897932
 
 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Angle, AIS_AngleDimension_);
index 2b6c57b846dbeaa146caa129e13a9ba5d27dac8c..e7ae5a144043c45ace700547fe039cdccc6fb8e8 100644 (file)
@@ -18,8 +18,6 @@
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_Pnt2d.h>
 
-#include <Events_Error.h>
-
 #include <SketchPlugin_Constraint.h>
 
 #include <Graphic3d_AspectMarker3d.hxx>
index 36c68a41def93f79f5dd30d24a4feb07c0cf38ad..8b069825aca96ad221829f83d15276b23a7c5ffb 100755 (executable)
@@ -10,8 +10,6 @@
 
 #include <SketchPlugin_Constraint.h>
 
-#include "Events_Error.h"
-
 #include <Graphic3d_AspectLine3d.hxx>
 #include <Prs3d_Root.hxx>
 
index e8b950f383b72facb28039ec2b96c0164b3da744..4977b3f28e7771cfdd778c16361d19ff02428704 100755 (executable)
@@ -7,7 +7,6 @@
 #include "SketcherPrs_DimensionStyleListener.h"
 #include "SketcherPrs_Tools.h"
 
-#include <Events_Error.h>
 #include <Events_Loop.h>
 
 SketcherPrs_DimensionStyleListener::SketcherPrs_DimensionStyleListener()
index 4423ca592888c07774a96dd0eaf13bca751e84b0..74ed7d4db3ea51a21d4706146cc75e9066a6071b 100644 (file)
@@ -10,8 +10,6 @@
 
 #include <SketchPlugin_Constraint.h>
 
-#include "Events_Error.h"
-
 #include <Graphic3d_AspectLine3d.hxx>
 #include <Prs3d_Root.hxx>
 
index b532887d1052901106a2c5a6e376cd1e0f4eb868..b0a7066186a84653eae58ff24a4c623ddc3bf943 100644 (file)
@@ -13,8 +13,6 @@
 #include <Graphic3d_AspectLine3d.hxx>
 #include <Prs3d_Root.hxx>
 
-#include <Events_Error.h>
-
 
 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs);
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs);
index 2dc2a3b3daa6c65cb80baa1c1a6310779f11b12b..fd4ba79e1f7ca7e464fba031335af240420253bc 100644 (file)
@@ -15,8 +15,6 @@
 #include <SketchPlugin_Point.h>
 #include <SketchPlugin_Circle.h>
 
-#include <Events_Error.h>
-
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_XYZ.h>
index ceca64a9c96505baa8a018d3844a59a9de239d08..b3d22499470e5577a3a9656026cd1e865b58108c 100755 (executable)
@@ -10,8 +10,6 @@
 
 #include <SketchPlugin_Constraint.h>
 
-#include "Events_Error.h"
-
 #include <Graphic3d_AspectLine3d.hxx>
 #include <Prs3d_Root.hxx>
 
index e31b3e1d497d0df476a6d4b5df21ed09562624fb..9e7e61b655ffb6520c797e797f9825e5e4f039a5 100644 (file)
@@ -13,8 +13,6 @@
 #include <SketchPlugin_Circle.h>
 #include <SketchPlugin_Arc.h>
 
-#include <Events_Error.h>
-
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_Circ.h>
index 590f1abf8e4ebe2603943b0561a34b6556dfa3ef..5f551735422f9edec93bf358c2e54b06d7e97a39 100644 (file)
@@ -12,7 +12,7 @@
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_Curve.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_BndBox4f.hxx>
@@ -294,7 +294,7 @@ Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
   // The icon for constraint is not found
   static const char aMsg[] = "Error! constraint images are not found";
   cout<<aMsg<<endl;
-  Events_Error::send(aMsg);
+  Events_InfoMessage("SketcherPrs_SymbolPrs", aMsg).send();
   myIconsMap[iconName()] = Handle(Image_AlienPixMap)();
   return Handle(Image_AlienPixMap)();
 }
index 91a8d3df81ce5545857290465ac1e7328219d94d..7947c38a2c909bf475f9f5a4577527716adf0392 100644 (file)
@@ -17,7 +17,7 @@
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Events.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAPI_Lin2d.h>
@@ -376,7 +376,7 @@ void updateArrows(Handle(Prs3d_DimensionAspect) theDimAspect, double theDimValue
 
 void sendEmptyPresentationError(ModelAPI_Feature* theFeature, const std::string theError)
 {
-  Events_Error::throwException("An empty AIS presentation: SketcherPrs_LengthDimension");
+  Events_InfoMessage("SketcherPrs_Tools", "An empty AIS presentation: SketcherPrs_LengthDimension").send();
   static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
   std::shared_ptr<ModelAPI_Object> aConstraintPtr(theFeature);
   ModelAPI_EventCreator::get()->sendUpdated(aConstraintPtr, anEvent);
index 0435be1a6cafbf1aa7c3057f56aae249aef6c0c2..129a595daa13fc12b0df39660277a150701d20d2 100644 (file)
@@ -12,7 +12,7 @@
 #include <XGUI_SelectionMgr.h>
 
 #include <Events_Loop.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Events.h>
@@ -175,7 +175,7 @@ QKeySequence XGUI_ActionsMgr::registerShortcut(const QKeySequence& theKeySequenc
   if (myShortcuts.contains(theKeySequence)) {
     QString aMessage = tr("Shortcut %1 is already defined. Ignore.");
     aMessage = aMessage.arg(theKeySequence.toString());
-    Events_Error::send(aMessage.toStdString());
+    Events_InfoMessage("XGUI_ActionsMgr", aMessage.toStdString()).send();
     return QKeySequence();
   }
   myShortcuts.append(theKeySequence);
index 7948325d795e1442ceeff7b5521220b8d90e4605..f07582125e0a09dfb500ff2993be9c606d371892 100644 (file)
@@ -14,7 +14,7 @@
 #include <ModelAPI_Session.h>
 #include <Config_PropManager.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <vector>
 #include <QColor>
@@ -50,7 +50,8 @@ void XGUI_CustomPrs::getDefaultColor(ObjectPtr theObject, const bool isEmptyColo
     // all AIS objects, where the color is not set, are in black.
     // The color should be defined in XML or set in the attribute
     theColor = Config_PropManager::color("Visualization", "object_default_color", "#000000");
-    Events_Error::send("A default color is not defined in the preferences for this kind of result");
+    Events_InfoMessage("XGUI_CustomPrs", 
+      "A default color is not defined in the preferences for this kind of result").send();
   }
 }
 
index 44030e86a99553f038e47f2ca175db5d6dac9662..7b66c2bffe1991b8d0ec0ba93a151c4dcc1b11ca 100644 (file)
@@ -22,7 +22,6 @@
 #include <Config_DataModelReader.h>
 
 #include <Events_Loop.h>
-#include <Events_Error.h>
 
 #include <QIcon>
 #include <QBrush>
index d389e3b3f73d6a04ae35581c56f058acd5fe8ad2..04a3f5316c2f71e50b5e30cca4fc9f679d5a70d9 100644 (file)
@@ -9,12 +9,14 @@
 #include <XGUI_ErrorDialog.h>
 
 #include <ModuleBase_Tools.h>
+#include <Config_Translator.h>
 
 #include <QDialogButtonBox>
 #include <QHBoxLayout>
 #include <QLabel>
 #include <QVBoxLayout>
 #include <QTextEdit>
+#include <QTextCodec>
 
 XGUI_ErrorDialog::XGUI_ErrorDialog(QWidget* parent)
     : QDialog(parent)
@@ -56,9 +58,12 @@ void XGUI_ErrorDialog::clear()
   QDialog::reject();
 }
 
-void XGUI_ErrorDialog::addError(const QString& theError)
+void XGUI_ErrorDialog::addError(std::shared_ptr<Events_InfoMessage> theMsg)
 {
-  myErrors.append(theError);
+  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);
   refresh();
   if (!isVisible()) {
     show();
index b6f53e6bca1358b067159c52e2a73fbce521a022..3e3bb325a6d78723798158599875e48e0c61998c 100644 (file)
@@ -14,6 +14,7 @@
 #include <QDialog>
 
 class QTextEdit;
+class Events_InfoMessage;
 
 /**
 * \ingroup GUI
@@ -36,7 +37,7 @@ Q_OBJECT
   XGUI_EXPORT void clear();
 
   /// Add error message
-  XGUI_EXPORT void addError(const QString&);
+  XGUI_EXPORT void addError(std::shared_ptr<Events_InfoMessage> theMsg);
 
   /// Remove error message
   XGUI_EXPORT void removeError(const QString&);
index 4163952e319710d777fcd7b81f62fc5893dbd2e6..5fbeebf5e2f980add4cd55df549753374dd69521 100644 (file)
@@ -31,8 +31,6 @@ XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
 {
   XGUI_SelectionMgr* aSelector = myWorkshop->selector();
   connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
-  
-  XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
 }
 
 XGUI_ModuleConnector::~XGUI_ModuleConnector()
index df30667eb7e0881fc99ad190c0b0bff46d0ac8c4..15fba977ca2d02a3318d9a14d981641015534e74 100644 (file)
@@ -8,7 +8,6 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Tools.h>
-#include <Events_Error.h>
 
 #include <ModuleBase_Tools.h>
 
index c0bfb2685b2e6ac858a56ab72cc1714444b527c0..a60b1f2190ac49b646281c1a5fd8f4a8ac93d136 100644 (file)
@@ -18,7 +18,7 @@
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Tools.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <GeomAPI_Shape.h>
 
@@ -134,7 +134,7 @@ bool canRename(const ObjectPtr& theObject, const QString& theName)
       QString aErrMsg(QObject::tr("Selected parameter can not be renamed to: %1. \
  There is a parameter with the same name. Its value is: %2.").arg(qPrintable(theName)).arg(aValue));
       // We can not use here a dialog box for message - it will crash editing process in ObjectBrowser
-      Events_Error::send(aErrMsg.toStdString());
+      Events_InfoMessage("XGUI_Tools", aErrMsg.toStdString()).send();
       return false;
     }
   }
index 3dfe3076d82fa2832cb9784cceeb5b61682d271c..f36f9353eab2fd50b598b8d988e7a64f83255cb9 100755 (executable)
@@ -52,7 +52,7 @@
 //#include <PartSetPlugin_Part.h>
 
 #include <Events_Loop.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 #include <Events_LongOp.h>
 
 #include <ModuleBase_FilterFactory.h>
@@ -78,6 +78,7 @@
 #include <Config_PropManager.h>
 #include <Config_SelectionFilterMessage.h>
 #include <Config_DataModelReader.h>
+#include <Config_Translator.h>
 
 #include <SUIT_ResourceMgr.h>
 
@@ -125,6 +126,13 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
       myDisplayer(0)
       //myViewerSelMode(TopAbs_FACE)
 {
+  mySelector = new XGUI_SelectionMgr(this);
+  myModuleConnector = new XGUI_ModuleConnector(this);
+  myOperationMgr = new XGUI_OperationMgr(this, 0);
+  ModuleBase_IWorkshop* aWorkshop = moduleConnector();
+  // Has to be defined first in order to get errors and messages from other components
+  myEventsListener = new XGUI_WorkshopListener(aWorkshop);
+
 #ifndef HAVE_SALOME
   myMainWindow = new AppElements_MainWindow();
 
@@ -135,16 +143,24 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   else 
     QLocale::setDefault( QLocale::system() );
 #endif
+  QString aPath = Config_XMLReader::pluginConfigFile().c_str();
+  QDir aDir(aPath);
+
+  // Load translations
+  QStringList aFilters;
+  aFilters << "*_en.ts";
+  QStringList aTsFiles = aDir.entryList(aFilters, QDir::Files);
+  foreach(QString aFileName, aTsFiles) {
+    Config_Translator::load(aFileName.toStdString());
+  }
 
   myDataModelXMLReader = new Config_DataModelReader();
-  myDataModelXMLReader->readAll();
+  //myDataModelXMLReader->readAll();
 
   myDisplayer = new XGUI_Displayer(this);
 
-  mySelector = new XGUI_SelectionMgr(this);
   connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateCommandStatus()));
 
-  myOperationMgr = new XGUI_OperationMgr(this, 0);
   myActionsMgr = new XGUI_ActionsMgr(this);
   myMenuMgr = new XGUI_MenuMgr(this);
   myErrorDlg = new XGUI_ErrorDialog(QApplication::desktop());
@@ -156,13 +172,9 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   //connect(myViewerProxy, SIGNAL(selectionChanged()),
   //        myActionsMgr,  SLOT(updateOnViewSelection()));
 
-  myModuleConnector = new XGUI_ModuleConnector(this);
-
-  ModuleBase_IWorkshop* aWorkshop = moduleConnector();
   myOperationMgr->setWorkshop(aWorkshop);
 
   myErrorMgr = new XGUI_ErrorMgr(this, aWorkshop);
-  myEventsListener = new XGUI_WorkshopListener(aWorkshop);
 
   connect(myOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)), 
           SLOT(onOperationStarted(ModuleBase_Operation*)));
@@ -180,9 +192,8 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   onTrihedronVisibilityChanged(true);
 #endif
 
-  connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
-  connect(myEventsListener, SIGNAL(errorOccurred(const QString&)),
-          myErrorDlg, SLOT(addError(const QString&)));
+  connect(myEventsListener, SIGNAL(errorOccurred(std::shared_ptr<Events_InfoMessage>)),
+          myErrorDlg, SLOT(addError(std::shared_ptr<Events_InfoMessage>)));
 
   //Config_PropManager::registerProp("Visualization", "object_default_color", "Object color",
   //                                 Config_Prop::Color, "225,225,225");
@@ -207,6 +218,13 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
 //******************************************************
 XGUI_Workshop::~XGUI_Workshop(void)
 {
+#ifdef _DEBUG
+#ifdef MISSED_TRANSLATION
+  // Save Missed translations
+  Config_Translator::saveMissedTranslations();
+#endif
+#endif
+
   delete myDisplayer;
   delete myDataModelXMLReader;
 }
@@ -214,13 +232,15 @@ XGUI_Workshop::~XGUI_Workshop(void)
 //******************************************************
 void XGUI_Workshop::startApplication()
 {
+  //Initialize event listening
+  myEventsListener->initializeEventListening();
+
+  myDataModelXMLReader->readAll();
   initMenu();
 
   Config_PropManager::registerProp("Plugins", "default_path", "Default Path",
                                    Config_Prop::Directory, "");
 
-  //Initialize event listening
-  myEventsListener->initializeEventListening();
 
   registerValidators();
 
@@ -486,10 +506,9 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
   std::string aFeatureKind = aFeature->getKind();
   foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
     if (!aWidget->attributeID().empty() && !aFeature->attribute(aWidget->attributeID()).get()) {
-      std::string anErrorMsg = "The feature '" + aFeatureKind + "' has no attribute '"
-          + aWidget->attributeID() + "' used by widget '"
-          + aWidget->metaObject()->className() + "'.";
-      Events_Error::send(anErrorMsg);
+      std::string anErrorMsg = "The feature '%1' has no attribute '%2' used by widget '%3'.";
+      Events_InfoMessage("XGUI_Workshop", anErrorMsg)
+        .arg(aFeatureKind).arg(aWidget->attributeID()).arg(aWidget->metaObject()->className()).send();
       myPropertyPanel->cleanContent();
       return;
     }
@@ -1000,7 +1019,7 @@ ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
 
   if (!err.isEmpty()) {
     if (desktop()) {
-      Events_Error::send(err.toStdString());
+      Events_InfoMessage("XGUI_Workshop", err.toStdString()).send();
     } else {
       qWarning(qPrintable(err));
     }
index 835816cf41c8d5b64b2321ff1f33db093391f3cf..fea7600a04992929202324f2de8801d765861425 100755 (executable)
@@ -306,9 +306,6 @@ signals:
   /// Emitted when selection happens in Salome viewer
   void salomeViewerSelection();
 
-  /// Emitted when error in application happens
-  void errorOccurred(const QString&);
-
   //! the signal about the workshop actions states are updated.
   void commandStatusUpdated();
 
index e9e3e3601519ae9668cede5c3d8a43b225bd0668..366336a1f4307ed65b504699ec1c7dfbf52af5bc 100755 (executable)
@@ -29,7 +29,6 @@
 #include <ModelAPI_Tools.h>
 
 #include <Events_Loop.h>
-#include <Events_Error.h>
 #include <Events_LongOp.h>
 
 #include <ModuleBase_IWorkshop.h>
@@ -45,6 +44,7 @@
 #include <Config_PointerMessage.h>
 #include <Config_SelectionFilterMessage.h>
 #include <Config_Keywords.h>
+#include <Events_InfoMessage.h>
 
 #include <QApplication>
 #include <QMainWindow>
@@ -82,7 +82,7 @@ void XGUI_WorkshopListener::initializeEventListening()
 {
   //Initialize event listening
   Events_Loop* aLoop = Events_Loop::loop();
-  aLoop->registerListener(this, Events_Error::errorID());  //!< Listening application errors.
+  aLoop->registerListener(this, Events_InfoMessage::errorID());  //!< Listening application errors.
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
@@ -186,9 +186,9 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>&
     aDisplayer->enableUpdateViewer(true);
   } else {
     //Show error dialog if error message received.
-    std::shared_ptr<Events_Error> anAppError = std::dynamic_pointer_cast<Events_Error>(theMessage);
-    if (anAppError) {
-      emit errorOccurred(QString::fromLatin1(anAppError->description()));
+    std::shared_ptr<Events_InfoMessage> anIngfoMsg = std::dynamic_pointer_cast<Events_InfoMessage>(theMessage);
+    if (anIngfoMsg) {
+      emit errorOccurred(anIngfoMsg);
     }
     return;
   }
index 5358253b522d142f139ada0976def30db21e3acb..7da355e2e28590fbe222654877a80043ae047947 100755 (executable)
@@ -8,6 +8,7 @@
 #include <Events_Message.h>
 
 #include <ModelAPI_Feature.h>
+#include <Events_InfoMessage.h>
 
 #include <QObject>
 
@@ -19,6 +20,7 @@ class XGUI_Workshop;
 class ModuleBase_IWorkshop;
 
 class QString;
+class Events_InfoMessage;
 
 /**\class XGUI_WorkshopListener
  * \ingroup GUI
@@ -41,7 +43,7 @@ public:
 
 signals:
   /// Emitted when error in applivation happens
-  void errorOccurred(const QString&);
+  void errorOccurred(std::shared_ptr<Events_InfoMessage> theMsg);
 
 protected:
   /// Procedure to process postponed events
diff --git a/src/XGUI/XGUI_msg_fr.ts b/src/XGUI/XGUI_msg_fr.ts
new file mode 100644 (file)
index 0000000..d0a8fec
--- /dev/null
@@ -0,0 +1,367 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="fr_FR">
+<context>
+    <name>QObject</name>
+    <message>
+        <location filename="XGUI_Tools.cpp" line="119"/>
+        <source>Warning</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Tools.cpp" line="120"/>
+        <source>Selected objects can be used in Part documents which are not loaded: %1. Whould you like to continue?</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Tools.cpp" line="137"/>
+        <source>Selected parameter can not be renamed to: %1.  There is a parameter with the same name. Its value is: %2.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="113"/>
+        <source>Move to the end</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>XGUI_ActionsMgr</name>
+    <message>
+        <location filename="XGUI_ActionsMgr.cpp" line="176"/>
+        <source>Shortcut %1 is already defined. Ignore.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ActionsMgr.cpp" line="254"/>
+        <source>See preview</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>XGUI_ContextMenuMgr</name>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="67"/>
+        <source>Delete</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="74"/>
+        <source>Rename</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="83"/>
+        <source>Clean history</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="86"/>
+        <source>Color...</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="89"/>
+        <source>Show</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="92"/>
+        <source>Show only</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="96"/>
+        <source>Hide</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="100"/>
+        <source>Hide all</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="104"/>
+        <source>Shading</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="107"/>
+        <source>Wireframe</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="117"/>
+        <source>Vertices</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="123"/>
+        <source>Edges</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="129"/>
+        <source>Faces</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="135"/>
+        <source>Result</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="144"/>
+        <source>Select results</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="148"/>
+        <source>Select parent feature</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="561"/>
+        <source>Selection mode</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_ContextMenuMgr.cpp" line="610"/>
+        <source>Windows</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>XGUI_DataTree</name>
+    <message>
+        <location filename="XGUI_ObjectsBrowser.cpp" line="160"/>
+        <source>History change</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>XGUI_ErrorDialog</name>
+    <message>
+        <location filename="XGUI_ErrorDialog.cpp" line="25"/>
+        <source>Application errors</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>XGUI_ObjectsBrowser</name>
+    <message>
+        <location filename="XGUI_ObjectsBrowser.cpp" line="342"/>
+        <source>Part set</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>XGUI_OperationMgr</name>
+    <message>
+        <location filename="XGUI_OperationMgr.cpp" line="221"/>
+        <location filename="XGUI_OperationMgr.cpp" line="299"/>
+        <source>Abort operation</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_OperationMgr.cpp" line="222"/>
+        <source>All active operations will be aborted.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_OperationMgr.cpp" line="297"/>
+        <source>%1 operation will be aborted.</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>XGUI_PropertyPanel</name>
+    <message>
+        <location filename="XGUI_PropertyPanel.cpp" line="49"/>
+        <location filename="XGUI_PropertyPanel.cpp" line="130"/>
+        <source>Property Panel</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>XGUI_Workshop</name>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="310"/>
+        <location filename="XGUI_Workshop.cpp" line="364"/>
+        <source>Undo</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="311"/>
+        <location filename="XGUI_Workshop.cpp" line="364"/>
+        <source>Undo last command</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="314"/>
+        <source>INF_DESK_TOOLBAR_STANDARD</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="320"/>
+        <location filename="XGUI_Workshop.cpp" line="373"/>
+        <source>Redo</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="320"/>
+        <location filename="XGUI_Workshop.cpp" line="373"/>
+        <source>Redo last command</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="337"/>
+        <source>Export native...</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="337"/>
+        <source>Export the current document into a native file</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="342"/>
+        <source>Import native...</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="342"/>
+        <source>Import native file</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="354"/>
+        <location filename="XGUI_Workshop.cpp" line="842"/>
+        <source>Save</source>
+        <extracomment>Title of the dialog which asks user if he wants to save study in existing non-empty folder</extracomment>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="354"/>
+        <source>Save the document</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="359"/>
+        <source>Save as...</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="359"/>
+        <source>Save the document into a file</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="387"/>
+        <source>Open...</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="387"/>
+        <source>Open a new document</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="391"/>
+        <source>Preferences</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="391"/>
+        <source>Edit preferences</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="395"/>
+        <source>Exit</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="395"/>
+        <source>Exit application</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="704"/>
+        <location filename="XGUI_Workshop.cpp" line="760"/>
+        <source>Save current file</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="705"/>
+        <source>The document is modified, save before opening another?</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="716"/>
+        <source>Select directory</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="721"/>
+        <source>Warning</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="721"/>
+        <source>Unable to open the file.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="760"/>
+        <source>The document is modified, save before exit?</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="826"/>
+        <source>Select directory to save files...</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="828"/>
+        <source>Directories (*)</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="843"/>
+        <source>The directory already contains some files, save anyway?</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="976"/>
+        <source>Information about module &quot;%1&quot; doesn&apos;t exist.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="1107"/>
+        <source>Object browser</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="1439"/>
+        <source>Unused features are the following: %1.
+These features will be deleted.
+Would you like to continue?</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="1477"/>
+        <source>All features are relevant, there is nothing to be deleted</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="1977"/>
+        <source>Find results</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="XGUI_Workshop.cpp" line="1978"/>
+        <source>Results not found</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+</TS>