]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Translated messages providing for SOLVER_ERROR attribute, code improvement
authornds <nds@opencascade.com>
Thu, 16 Jun 2016 08:22:46 +0000 (11:22 +0300)
committernds <nds@opencascade.com>
Thu, 16 Jun 2016 08:22:46 +0000 (11:22 +0300)
src/Config/Config_Translator.h
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/ModuleBase/ModuleBase_WidgetLabel.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/SketchSolver/CMakeLists.txt
src/SketchSolver/SketchSolver_msg_en.ts [new file with mode: 0755]

index cab88afdfc72eca3012fd227de8097b8ff132679..6f79f81d1459a3e1548846d59f3d945de02599de 100644 (file)
@@ -48,7 +48,7 @@ public:
 
   /**
   * Returns translation from the given data.
-  * If transdlation is not exists then it returns a string 
+  * If translation is not exists then it returns a string 
   * from the info data without translation
   * \param theContext context of the message (Feature Id)
   * \param theMessage a message which dave to be translated
index 1287a605abc02332a147ba7e6b1f0bdc3b8c966c..9442ddc27d871e05eafc0c7cfedff0ec33793e3e 100644 (file)
@@ -23,7 +23,6 @@
 #include <Config_PointerMessage.h>
 #include <Config_WidgetReader.h>
 #include <Config_ModuleReader.h>
-#include <Config_Translator.h>
 
 #include <QAction>
 #include <QMainWindow>
@@ -31,7 +30,6 @@
 #include <QLayout>
 #include <QDialogButtonBox>
 #include <QPushButton>
-#include <QTextCodec>
 
 ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent)
   : QObject(theParent), myWorkshop(theParent) 
@@ -108,13 +106,10 @@ bool ModuleBase_IModule::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const
 
 QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature)
 {
-  QString aMsg = ModelAPI_Tools::getFeatureError(theFeature).c_str();
-  if (!aMsg.isEmpty()) {
-    std::string aStr = Config_Translator::translate(theFeature->getKind(), aMsg.toStdString());
-    std::string aCodec = Config_Translator::codec(theFeature->getKind());
-    aMsg = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
-  }
-  return aMsg;
+  std::string aMsg = ModelAPI_Tools::getFeatureError(theFeature);
+  ModuleBase_Tools::translate(theFeature->getKind(), aMsg);
+
+  return aMsg.c_str();
 }
 
 void ModuleBase_IModule::grantedOperationIds(ModuleBase_Operation* theOperation,
index 82cf7906b46389333501c75b28d77f7769f83750..ea72d23076a387e66377043d0d122d6ad1b1409a 100755 (executable)
@@ -102,6 +102,7 @@ bool ModuleBase_OperationFeature::isValid() const
     return true;
 
   std::string anError = ModelAPI_Tools::getFeatureError(myFeature);
+  ModuleBase_Tools::translate(myFeature->getKind(), anError);
   return anError.empty();
 }
 
index a4890633ae0cf4a2ad726d83b83a98fa2eeb6fc0..169f911d3a0655e8053ee26f71d6579a7953d2e4 100755 (executable)
@@ -39,6 +39,7 @@
 #include <GeomAPI_ShapeExplorer.h>
 
 #include <Config_PropManager.h>
+#include <Config_Translator.h>
 
 #include <QWidget>
 #include <QLayout>
@@ -50,6 +51,7 @@
 #include <QApplication>
 #include <QMessageBox>
 #include <QAction>
+#include <QTextCodec>
 
 #include <sstream>
 #include <string>
@@ -1137,6 +1139,17 @@ void convertToFeatures(const QObjectPtrList& theObjects, std::set<FeaturePtr>& t
   }
 }
 
+void translate(const std::string& theContext, std::string& theMessage)
+{
+  if (!theMessage.empty()) {
+    std::string aStr = Config_Translator::translate(theContext, theMessage);
+    if (!aStr.empty()) {
+      std::string aCodec = Config_Translator::codec(theContext);
+      theMessage = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str()).toStdString();
+    }
+  }
+}
+
 } // namespace ModuleBase_Tools
 
 
index 2e19e0f731e873527fc0d12da6d466a4447bc039..ad735c09b6d0d36947b59a6b941977d59cd1770d 100755 (executable)
@@ -302,6 +302,15 @@ bool MODULEBASE_EXPORT askToDelete(const std::set<FeaturePtr> aFeatures,
 /// \param theFeatures an out conteiner of features
 void MODULEBASE_EXPORT convertToFeatures(const QObjectPtrList& theObjects, std::set<FeaturePtr>& theFeatures);
 
+
+/// Returns translation from the given data.
+/// If translation 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)
+void MODULEBASE_EXPORT translate(const std::string& theContext, std::string& theMessage);
+
 }
 
 #endif
index 31fe1f6c73f358393d9b57b6216a191cbb8e103f..bab0894cb1f93c92c993f8c613754aef6053a7e2 100644 (file)
@@ -55,6 +55,7 @@ bool ModuleBase_WidgetLabel::restoreValueCustom()
     if (aStrAttr.get()) {
       aMsg = aStrAttr->value();
     }
+    ModuleBase_Tools::translate(myFeature->getKind(), aMsg);
     myLabel->setText(aMsg.c_str());
   }
   return true;
index 7fcebed5a10f52421f9874413936c0f65e1b59a4..beb3206c7e83bb674612a6af929206f5da2cbdfb 100755 (executable)
@@ -717,16 +717,17 @@ bool PartSet_SketcherMgr::sketchSolverError()
 
 QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature)
 {
-  QString anError = "";
+  std::string anError = "";
   if (!theFeature.get() || !theFeature->data()->isValid())
-    return anError;
+    return anError.c_str();
 
   CompositeFeaturePtr aSketch = activeSketch();
   if (aSketch.get() && aSketch == theFeature) {
     AttributeStringPtr aAttributeString = aSketch->string(SketchPlugin_Sketch::SOLVER_ERROR());
-    anError = aAttributeString->value().c_str();
+    anError = aAttributeString->value();
+    ModuleBase_Tools::translate(aSketch->getKind(), anError);
   }
-  return anError;
+  return anError.c_str();
 }
 
 void PartSet_SketcherMgr::clearClickedFlags()
index ac4117627f2fa573e001bc6f34558a5b52675edd..e9d81431616c6317a278438d0b309c7c34abdd81 100644 (file)
@@ -62,6 +62,10 @@ SET(PROJECT_LIBRARIES
     GeomDataAPI
 )
 
+SET(TEXT_RESOURCES
+    SketchSolver_msg_en.ts
+)
+
 INCLUDE_DIRECTORIES(
     ${PROJECT_SOURCE_DIR}/src/Config
     ${PROJECT_SOURCE_DIR}/src/SketchPlugin
@@ -71,15 +75,18 @@ INCLUDE_DIRECTORIES(
     ${PROJECT_SOURCE_DIR}/src/Events
 )
 
+SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES})
+
 ADD_DEFINITIONS(-DSKETCHSOLVER_EXPORTS)
 
-ADD_LIBRARY(SketchSolver SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}
+ADD_LIBRARY(SketchSolver SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${TEXT_RESOURCES}
 )
 
 TARGET_LINK_LIBRARIES(SketchSolver ${PROJECT_LIBRARIES}
 )
 
 INSTALL(TARGETS SketchSolver DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
+INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
 
 
 # Include specific solvers
diff --git a/src/SketchSolver/SketchSolver_msg_en.ts b/src/SketchSolver/SketchSolver_msg_en.ts
new file mode 100755 (executable)
index 0000000..424f5d4
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US">
+  <context>
+    <name>Sketch</name>
+    <message>
+      <source>The constraint is conflicting with others. To fix this, you can either undo your operation or remove a conflicting constraint.</source>
+      <translation>The constraint is conflicting with others. To fix this, you can either undo your operation or remove a conflicting constraint.</translation>
+    </message>
+    <message>
+      <source>Caution: SolveSpace crash! Constraints are wrong</source>
+      <translation>Caution: SolveSpace crash! Constraints are wrong</translation>
+    </message>
+  </context>
+</TS>
+