Salome HOME
Issue #3237: Allow usage of accented characters in ObjectBrowser
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Wed, 29 Jul 2020 21:08:59 +0000 (00:08 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Wed, 29 Jul 2020 21:09:42 +0000 (00:09 +0300)
Usage of Unicode characters as names of parameters.

55 files changed:
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_MultiRotation.cpp
src/FeaturesAPI/FeaturesAPI_MultiRotation.h
src/GeomData/GeomData_Point.cpp
src/GeomData/GeomData_Point.h
src/GeomData/GeomData_Point2D.cpp
src/GeomData/GeomData_Point2D.h
src/GeomDataAPI/GeomDataAPI.i
src/GeomDataAPI/GeomDataAPI_Point.h
src/GeomDataAPI/GeomDataAPI_Point2D.h
src/InitializationPlugin/CMakeLists.txt
src/InitializationPlugin/InitializationPlugin_EvalListener.cpp
src/InitializationPlugin/InitializationPlugin_EvalListener.h
src/InitializationPlugin/InitializationPlugin_PyInterp.cpp
src/InitializationPlugin/InitializationPlugin_PyInterp.h
src/Model/Model_AttributeDouble.cpp
src/Model/Model_AttributeDouble.h
src/Model/Model_AttributeInteger.cpp
src/Model/Model_AttributeInteger.h
src/Model/Model_Data.cpp
src/Model/Model_Expression.cpp
src/Model/Model_Expression.h
src/ModelAPI/ModelAPI_AttributeDouble.h
src/ModelAPI/ModelAPI_AttributeInteger.h
src/ModelAPI/ModelAPI_Events.cpp
src/ModelAPI/ModelAPI_Events.h
src/ModelAPI/ModelAPI_Expression.cpp
src/ModelAPI/ModelAPI_Expression.h
src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h
src/ModelHighAPI/ModelHighAPI.i
src/ModelHighAPI/ModelHighAPI_Double.cpp
src/ModelHighAPI/ModelHighAPI_Double.h
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp
src/ModelHighAPI/ModelHighAPI_Integer.cpp
src/ModelHighAPI/ModelHighAPI_Integer.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_ParamIntSpinBox.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetExprEditor.cpp
src/ModuleBase/ModuleBase_WidgetIntValue.cpp
src/ModuleBase/ModuleBase_WidgetLineEdit.cpp
src/ModuleBase/ModuleBase_WidgetPointInput.cpp
src/ParametersPlugin/ParametersPlugin_EvalListener.cpp
src/ParametersPlugin/ParametersPlugin_EvalListener.h
src/ParametersPlugin/ParametersPlugin_Parameter.cpp
src/ParametersPlugin/ParametersPlugin_Parameter.h
src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp
src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp
src/SketchPlugin/SketchPlugin_Fillet.cpp
src/SketchPlugin/SketchPlugin_Tools.cpp
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_DimensionStyle.cpp
src/XGUI/XGUI_Tools.cpp

index d98babe2e23f57ebf8989fc337c79dda176f4879..b76fd2dc433da48ec55917f838656249d29c963a 100644 (file)
   } else if (PyFloat_Check($input) || PyLong_Check($input)) {
     temp = std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>(ModelHighAPI_Selection(), ModelHighAPI_Double(PyFloat_AsDouble($input)));
   } else if (PyUnicode_Check($input)) {
-    temp = std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>(ModelHighAPI_Selection(), ModelHighAPI_Double(PyUnicode_AsUTF8($input)));
+    Py_ssize_t size;
+    temp = std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>(ModelHighAPI_Selection(), ModelHighAPI_Double(PyUnicode_AsWideCharString($input, &size)));
   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
     temp = std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>($1->first, $1->second);
   } else {
index 86558686c73f02f3f6aec8e8222918b8df10b604..2d90446a46a5cbfea16e8c0fd2d05f6b876e3b71 100644 (file)
@@ -156,8 +156,8 @@ MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& theP
   if (theNumber.string().empty()) {
     // rotate for the whole circle
     double aStepVal = theStep.value();
-    std::string aStepStr = theStep.string();
-    std::ostringstream aStepValAsStr;
+    std::wstring aStepStr = theStep.string();
+    std::wostringstream aStepValAsStr;
     aStepValAsStr << aStepVal;
 
     ModelHighAPI_Integer aNumber = aStepStr == aStepValAsStr.str()
index eb3b81ae4ff94d31d677153d0e0b40075330d784..92aa64b92b0b581c3403bc98f8e8fc8337e2f82c 100644 (file)
@@ -109,7 +109,7 @@ MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& theP
                                   const std::list<ModelHighAPI_Selection>& theMainObjects,
                                   const ModelHighAPI_Selection& theAxis,
                                   const ModelHighAPI_Double& theStep,
-                                  const ModelHighAPI_Integer& theNumber = ModelHighAPI_Integer(""),
+                                  const ModelHighAPI_Integer& theNumber = ModelHighAPI_Integer(L""),
                                   const bool keepSubResults = false);
 
 #endif // FEATURESAPI_MULTIROTATION_H_
index 02b516f20451514768736e84000bfb7d8b0f6973..0f46fc1694bf140c41f5e66c507e14cdc157149e 100644 (file)
@@ -85,7 +85,7 @@ void GeomData_Point::setX(const double theX)
     setCalculatedValue(theX, 0, 0);
   } else if (x() != theX) {
     myExpression[0]->setValue(theX);
-    myExpression[0]->setText(""); // uninitialize the text
+    myExpression[0]->setText(L""); // uninitialize the text
     owner()->data()->sendAttributeUpdated(this);
   }
 }
@@ -96,7 +96,7 @@ void GeomData_Point::setY(const double theY)
     setCalculatedValue(0, theY, 0);
   } else if (y() != theY) {
     myExpression[1]->setValue(theY);
-    myExpression[1]->setText(""); // uninitialize the text
+    myExpression[1]->setText(L""); // uninitialize the text
     owner()->data()->sendAttributeUpdated(this);
   }
 }
@@ -108,7 +108,7 @@ void GeomData_Point::setZ(const double theZ)
   }
   else if (z() != theZ) {
     myExpression[2]->setValue(theZ);
-    myExpression[2]->setText(""); // uninitialize the text
+    myExpression[2]->setText(L""); // uninitialize the text
     owner()->data()->sendAttributeUpdated(this);
   }
 }
@@ -120,9 +120,9 @@ std::shared_ptr<GeomAPI_Pnt> GeomData_Point::pnt()
   return aResult;
 }
 
-void GeomData_Point::setText(const std::string& theX,
-                             const std::string& theY,
-                             const std::string& theZ)
+void GeomData_Point::setText(const std::wstring& theX,
+                             const std::wstring& theY,
+                             const std::wstring& theZ)
 {
   if (!myIsInitialized || textX() != theX || textY() != theY || textZ() != theZ) {
     myExpression[0]->setText(theX);
@@ -134,10 +134,10 @@ void GeomData_Point::setText(const std::string& theX,
   }
 }
 
-void GeomData_Point::setTextX(const std::string& theX)
+void GeomData_Point::setTextX(const std::wstring& theX)
 {
   if (!myIsInitialized) {
-    static const std::string aDefaultText = "0";
+    static const std::wstring aDefaultText = L"0";
     setText(theX, aDefaultText, aDefaultText);
   }
   else if (textX() != theX) {
@@ -148,10 +148,10 @@ void GeomData_Point::setTextX(const std::string& theX)
   }
 }
 
-void GeomData_Point::setTextY(const std::string& theY)
+void GeomData_Point::setTextY(const std::wstring& theY)
 {
   if (!myIsInitialized) {
-    static const std::string aDefaultText = "0";
+    static const std::wstring aDefaultText = L"0";
     setText(aDefaultText, theY, aDefaultText);
   }
   else if (textY() != theY) {
@@ -162,10 +162,10 @@ void GeomData_Point::setTextY(const std::string& theY)
   }
 }
 
-void GeomData_Point::setTextZ(const std::string& theZ)
+void GeomData_Point::setTextZ(const std::wstring& theZ)
 {
   if (!myIsInitialized) {
-    static const std::string aDefaultText = "0";
+    static const std::wstring aDefaultText = L"0";
     setText(aDefaultText, aDefaultText, theZ);
   }
   else if (textZ() != theZ) {
@@ -176,15 +176,15 @@ void GeomData_Point::setTextZ(const std::string& theZ)
   }
 }
 
-std::string GeomData_Point::textX()
+std::wstring GeomData_Point::textX()
 {
   return myExpression[0]->text();
 }
-std::string GeomData_Point::textY()
+std::wstring GeomData_Point::textY()
 {
   return myExpression[1]->text();
 }
-std::string GeomData_Point::textZ()
+std::wstring GeomData_Point::textZ()
 {
   return myExpression[2]->text();
 }
@@ -216,13 +216,13 @@ std::string GeomData_Point::expressionError(int theComponent)
 }
 
 void GeomData_Point::setUsedParameters(int theComponent,
-                                       const std::set<std::string>& theUsedParameters)
+                                       const std::set<std::wstring>& theUsedParameters)
 {
   assert(theComponent >= 0 && theComponent < NUM_COMPONENTS);
   myExpression[theComponent]->setUsedParameters(theUsedParameters);
 }
 
-std::set<std::string> GeomData_Point::usedParameters(int theComponent) const
+std::set<std::wstring> GeomData_Point::usedParameters(int theComponent) const
 {
   assert(theComponent >= 0 && theComponent < NUM_COMPONENTS);
   return myExpression[theComponent]->usedParameters();
index 72f7211c9d71791de3d20313d927ae23a04e9239..b59e225a1c4b7fecbc380e857b951e9d29704e9f 100644 (file)
@@ -63,22 +63,22 @@ class GeomData_Point : public GeomDataAPI_Point
     void setCalculatedValue(const double theX, const double theY, const double theZ);
 
   /// Defines the text values
-  GEOMDATA_EXPORT virtual void setText(const std::string& theX,
-                                       const std::string& theY,
-                                       const std::string& theZ);
+  GEOMDATA_EXPORT virtual void setText(const std::wstring& theX,
+                                       const std::wstring& theY,
+                                       const std::wstring& theZ);
   /// Defines the X text value
-  GEOMDATA_EXPORT virtual void setTextX(const std::string& theX);
+  GEOMDATA_EXPORT virtual void setTextX(const std::wstring& theX);
   /// Defines the Y text value
-  GEOMDATA_EXPORT virtual void setTextY(const std::string& theY);
+  GEOMDATA_EXPORT virtual void setTextY(const std::wstring& theY);
   /// Defines the Z text value
-  GEOMDATA_EXPORT virtual void setTextZ(const std::string& theZ);
+  GEOMDATA_EXPORT virtual void setTextZ(const std::wstring& theZ);
 
   /// Returns the X text value
-  GEOMDATA_EXPORT virtual std::string textX();
+  GEOMDATA_EXPORT virtual std::wstring textX();
   /// Returns the Y text value
-  GEOMDATA_EXPORT virtual std::string textY();
+  GEOMDATA_EXPORT virtual std::wstring textY();
   /// Returns the Z text value
-  GEOMDATA_EXPORT virtual std::string textZ();
+  GEOMDATA_EXPORT virtual std::wstring textZ();
 
   /// Allows to set expression (text) as invalid (by the parameters listener)
   GEOMDATA_EXPORT virtual void setExpressionInvalid(int, const bool theFlag);
@@ -94,10 +94,10 @@ class GeomData_Point : public GeomDataAPI_Point
 
   /// Defines the used parameters
   GEOMDATA_EXPORT virtual void setUsedParameters(int theComponent,
-    const std::set<std::string>& theUsedParameters);
+    const std::set<std::wstring>& theUsedParameters);
 
   /// Returns the used parameters
-  GEOMDATA_EXPORT virtual std::set<std::string> usedParameters(int theComponent) const;
+  GEOMDATA_EXPORT virtual std::set<std::wstring> usedParameters(int theComponent) const;
 
  protected:
   /// Initializes attributes
index 031a846bd07ea5ead5a011eac467c5bce9a7febe..ee9c77cac19bff60fa96c1c08c645f8af8ef4714 100644 (file)
@@ -86,8 +86,8 @@ std::shared_ptr<GeomAPI_Pnt2d> GeomData_Point2D::pnt()
   return aResult;
 }
 
-void GeomData_Point2D::setText(const std::string& theX,
-                               const std::string& theY)
+void GeomData_Point2D::setText(const std::wstring& theX,
+                               const std::wstring& theY)
 {
   if (!myIsInitialized && theX.empty() && theY.empty())
     return; // empty strings are not good initializers
@@ -100,11 +100,11 @@ void GeomData_Point2D::setText(const std::string& theX,
   }
 }
 
-std::string GeomData_Point2D::textX()
+std::wstring GeomData_Point2D::textX()
 {
   return myExpression[0]->text();
 }
-std::string GeomData_Point2D::textY()
+std::wstring GeomData_Point2D::textY()
 {
   return myExpression[1]->text();
 }
@@ -136,13 +136,13 @@ std::string GeomData_Point2D::expressionError(int theComponent)
 }
 
 void GeomData_Point2D::setUsedParameters(int theComponent,
-                                         const std::set<std::string>& theUsedParameters)
+                                         const std::set<std::wstring>& theUsedParameters)
 {
   assert(theComponent >= 0 && theComponent < NUM_COMPONENTS);
   myExpression[theComponent]->setUsedParameters(theUsedParameters);
 }
 
-std::set<std::string> GeomData_Point2D::usedParameters(int theComponent) const
+std::set<std::wstring> GeomData_Point2D::usedParameters(int theComponent) const
 {
   assert(theComponent >= 0 && theComponent < NUM_COMPONENTS);
   return myExpression[theComponent]->usedParameters();
index 36c83e5e27e17726a120749421fd8b7411bfeeee..245a571858cee8e2d80295ea09a8efd43d829cc6 100644 (file)
@@ -53,12 +53,12 @@ class GeomData_Point2D : public GeomDataAPI_Point2D
   GEOMDATA_EXPORT virtual void setCalculatedValue(const double theX, const double theY);
 
   /// Defines the text values
-  GEOMDATA_EXPORT virtual void setText(const std::string& theX,
-                                       const std::string& theY);
+  GEOMDATA_EXPORT virtual void setText(const std::wstring& theX,
+                                       const std::wstring& theY);
 
   /// Returns the text values
-  GEOMDATA_EXPORT virtual std::string textX();
-  GEOMDATA_EXPORT virtual std::string textY();
+  GEOMDATA_EXPORT virtual std::wstring textX();
+  GEOMDATA_EXPORT virtual std::wstring textY();
 
   /// Allows to set expression (text) as invalid (by the parameters listener)
   GEOMDATA_EXPORT virtual void setExpressionInvalid(int, const bool theFlag);
@@ -74,10 +74,10 @@ class GeomData_Point2D : public GeomDataAPI_Point2D
 
   /// Defines the used parameters
   GEOMDATA_EXPORT virtual void setUsedParameters(int theComponent,
-    const std::set<std::string>& theUsedParameters);
+    const std::set<std::wstring>& theUsedParameters);
 
   /// Returns the used parameters
-  GEOMDATA_EXPORT virtual std::set<std::string> usedParameters(int theComponent) const;
+  GEOMDATA_EXPORT virtual std::set<std::wstring> usedParameters(int theComponent) const;
 
  protected:
   /// Initializes attributes
index af9295f812e1d8b25f48e24916cd13566e75df46..62c0949940f0d961fa3336734d13aa2675a8c591 100644 (file)
@@ -21,6 +21,8 @@
 %module GeomDataAPI
 %{
   #include "GeomDataAPI_swig.h"
+
+  #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj))
 %}
 
 // import other modules
index d345dbf9459a06e2340527a9272293fe40c2a015..da810ccfe6cdc68725a83a037e71f305909f565e 100644 (file)
@@ -62,23 +62,23 @@ class GeomDataAPI_Point : public ModelAPI_Attribute
   GEOMDATAAPI_EXPORT virtual void setZ(const double theZ) = 0;
 
   /// Defines the text values
-  GEOMDATAAPI_EXPORT virtual void setText(const std::string& theX,
-                                          const std::string& theY,
-                                          const std::string& theZ) = 0;
+  GEOMDATAAPI_EXPORT virtual void setText(const std::wstring& theX,
+                                          const std::wstring& theY,
+                                          const std::wstring& theZ) = 0;
 
   /// Defines the X text value
-  GEOMDATAAPI_EXPORT virtual void setTextX(const std::string& theX) = 0;
+  GEOMDATAAPI_EXPORT virtual void setTextX(const std::wstring& theX) = 0;
   /// Defines the Y text value
-  GEOMDATAAPI_EXPORT virtual void setTextY(const std::string& theY) = 0;
+  GEOMDATAAPI_EXPORT virtual void setTextY(const std::wstring& theY) = 0;
   /// Defines the Z text value
-  GEOMDATAAPI_EXPORT virtual void setTextZ(const std::string& theZ) = 0;
+  GEOMDATAAPI_EXPORT virtual void setTextZ(const std::wstring& theZ) = 0;
 
   /// Returns the text value for X
-  GEOMDATAAPI_EXPORT virtual std::string textX() = 0;
+  GEOMDATAAPI_EXPORT virtual std::wstring textX() = 0;
   /// Returns the text value for Y
-  GEOMDATAAPI_EXPORT virtual std::string textY() = 0;
+  GEOMDATAAPI_EXPORT virtual std::wstring textY() = 0;
   /// Returns the text value for Z
-  GEOMDATAAPI_EXPORT virtual std::string textZ() = 0;
+  GEOMDATAAPI_EXPORT virtual std::wstring textZ() = 0;
 
   /// Point component (x,y,z)
   enum PointComponent { C_X = 0,
@@ -101,10 +101,10 @@ class GeomDataAPI_Point : public ModelAPI_Attribute
 
   /// Defines the used parameters
   GEOMDATAAPI_EXPORT virtual void setUsedParameters(int theComponent,
-    const std::set<std::string>& theUsedParameters) = 0;
+    const std::set<std::wstring>& theUsedParameters) = 0;
 
   /// Returns the used parameters
-  GEOMDATAAPI_EXPORT virtual std::set<std::string> usedParameters(int theComponent) const = 0;
+  GEOMDATAAPI_EXPORT virtual std::set<std::wstring> usedParameters(int theComponent) const = 0;
 
   /// Returns the type of this class of attributes
   static std::string typeId()
index 845de75ab0bffb796caae687d50408c585e5651c..db6f737ca906af315617550cf6e323ea4f22041e 100644 (file)
@@ -52,13 +52,13 @@ class GeomDataAPI_Point2D : public ModelAPI_Attribute
   GEOMDATAAPI_EXPORT virtual void setCalculatedValue(const double theX, const double theY) = 0;
 
   /// Defines the text values
-  GEOMDATAAPI_EXPORT virtual void setText(const std::string& theX,
-                                          const std::string& theY) = 0;
+  GEOMDATAAPI_EXPORT virtual void setText(const std::wstring& theX,
+                                          const std::wstring& theY) = 0;
 
   /// Returns the text value for X
-  GEOMDATAAPI_EXPORT virtual std::string textX() = 0;
+  GEOMDATAAPI_EXPORT virtual std::wstring textX() = 0;
   /// Returns the text value for Y
-  GEOMDATAAPI_EXPORT virtual std::string textY() = 0;
+  GEOMDATAAPI_EXPORT virtual std::wstring textY() = 0;
 
   /// Point component (x,y)
   enum PointComponent { C_X = 0,
@@ -80,10 +80,10 @@ class GeomDataAPI_Point2D : public ModelAPI_Attribute
 
   /// Defines the used parameters
   GEOMDATAAPI_EXPORT virtual void setUsedParameters(int theComponent,
-    const std::set<std::string>& theUsedParameters) = 0;
+    const std::set<std::wstring>& theUsedParameters) = 0;
 
   /// Returns the used parameters
-  GEOMDATAAPI_EXPORT virtual std::set<std::string> usedParameters(int theComponent) const = 0;
+  GEOMDATAAPI_EXPORT virtual std::set<std::wstring> usedParameters(int theComponent) const = 0;
 
   /// Appends the delta values to point
   GEOMDATAAPI_EXPORT void move(const double theDeltaX, const double theDeltaY);
index 38c871a2b32559d89e774ddab564c2c68e8d8f48..a9518f877e54d45ea856962b16f9a7b496cc9cfc 100644 (file)
@@ -24,6 +24,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
                     ${PROJECT_SOURCE_DIR}/src/ModelAPI
                     ${PROJECT_SOURCE_DIR}/src/GeomAPI
                     ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+                    ${PROJECT_SOURCE_DIR}/src/Locale
                     ${PROJECT_SOURCE_DIR}/src/ParametersPlugin
                     ${SUIT_INCLUDE}
                     ${PYTHON_INCLUDE_DIR}
@@ -48,6 +49,7 @@ SET(PROJECT_LIBRARIES
     Events
     Config
     ModelAPI
+    Locale
     ${PyInterp}
     ${PYTHON_LIBRARIES}
 )
index 6e5e7d29c10a3589d4ba72945f7e90f75dcdca96..1245e4abf0c0419879944b39456769304d7e17e9 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <Events_InfoMessage.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeRefList.h>
@@ -46,9 +48,9 @@
 //------------------------------------------------------------------------------
 // Tools
 
-std::string toStdString(double theValue)
+std::wstring toString(double theValue)
 {
-  std::ostringstream sstream;
+  std::wostringstream sstream;
   // write value in scientific format with 16 digits,
   // thus, not check the dot position
   sstream.precision(16);
@@ -56,9 +58,9 @@ std::string toStdString(double theValue)
   return sstream.str();
 }
 
-std::set<std::string> toSet(const std::list<std::string>& theContainer)
+std::set<std::wstring> toSet(const std::list<std::wstring>& theContainer)
 {
-  return std::set<std::string>(theContainer.begin(), theContainer.end());
+  return std::set<std::wstring>(theContainer.begin(), theContainer.end());
 }
 
 //------------------------------------------------------------------------------
@@ -91,7 +93,10 @@ void InitializationPlugin_EvalListener::processEvent(
     std::shared_ptr<ModelAPI_ParameterEvalMessage> aMsg =
       std::dynamic_pointer_cast<ModelAPI_ParameterEvalMessage>(theMessage);
     FeaturePtr aParam = aMsg->parameter();
-    std::string anExp = aParam->string(ParametersPlugin_Parameter::EXPRESSION_ID())->value();
+    AttributeStringPtr anExprAttr = aParam->string(ParametersPlugin_Parameter::EXPRESSION_ID());
+    std::wstring anExp = anExprAttr->isUValue() ?
+        Locale::Convert::toWString(anExprAttr->valueU()) :
+        Locale::Convert::toWString(anExprAttr->value());
     std::string anError;
     std::list<std::shared_ptr<ModelAPI_ResultParameter> > aParamsList;
     double aResult = evaluate(aParam, anExp, anError, aParamsList, true);
@@ -104,14 +109,14 @@ void InitializationPlugin_EvalListener::processEvent(
 }
 
 double InitializationPlugin_EvalListener::evaluate(FeaturePtr theParameter,
-  const std::string& theExpression, std::string& theError,
+  const std::wstring& theExpression, std::string& theError,
   std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
   const bool theIsParameter)
 {
-  std::list<std::string> anExprParams = myInterp->compile(theExpression);
+  std::list<std::wstring> anExprParams = myInterp->compile(theExpression);
   // find expression's params in the model
-  std::list<std::string> aContext;
-  std::list<std::string>::iterator it = anExprParams.begin();
+  std::list<std::wstring> aContext;
+  std::list<std::wstring>::iterator it = anExprParams.begin();
   for ( ; it != anExprParams.end(); it++) {
     double aValue;
     ResultParameterPtr aParamRes;
@@ -124,7 +129,7 @@ double InitializationPlugin_EvalListener::evaluate(FeaturePtr theParameter,
 
     if (theIsParameter)
       theParamsList.push_back(aParamRes);
-    aContext.push_back(*it + "=" + toStdString(aValue));
+    aContext.push_back(*it + L"=" + toString(aValue));
   }
   myInterp->extendLocalContext(aContext);
   double result = myInterp->evaluate(theExpression, theError);
@@ -150,7 +155,7 @@ void InitializationPlugin_EvalListener::processEvaluationEvent(
     if (isValid)
       anAttribute->setCalculatedValue(aValue);
     anAttribute->setUsedParameters(isValid ?
-      toSet(myInterp->compile(anAttribute->text())) : std::set<std::string>());
+      toSet(myInterp->compile(anAttribute->text())) : std::set<std::wstring>());
     anAttribute->setExpressionInvalid(!isValid);
     anAttribute->setExpressionError(anAttribute->text().empty() ? "" : anError);
   } else
@@ -163,14 +168,14 @@ void InitializationPlugin_EvalListener::processEvaluationEvent(
     if (isValid)
       anAttribute->setCalculatedValue(aValue);
     anAttribute->setUsedParameters(isValid ?
-      toSet(myInterp->compile(anAttribute->text())) : std::set<std::string>());
+      toSet(myInterp->compile(anAttribute->text())) : std::set<std::wstring>());
     anAttribute->setExpressionInvalid(!isValid);
     anAttribute->setExpressionError(anAttribute->text().empty() ? "" : anError);
   } else
   if (aMessage->attribute()->attributeType() == GeomDataAPI_Point::typeId()) {
     AttributePointPtr anAttribute =
         std::dynamic_pointer_cast<GeomDataAPI_Point>(aMessage->attribute());
-    std::string aText[] = {
+    std::wstring aText[] = {
       anAttribute->textX(),
       anAttribute->textY(),
       anAttribute->textZ()
@@ -186,7 +191,7 @@ void InitializationPlugin_EvalListener::processEvaluationEvent(
       bool isValid = anError.empty();
       if (isValid) aCalculatedValue[i] = aValue;
       anAttribute->setUsedParameters(i,
-        isValid ? toSet(myInterp->compile(aText[i])) : std::set<std::string>());
+        isValid ? toSet(myInterp->compile(aText[i])) : std::set<std::wstring>());
       anAttribute->setExpressionInvalid(i, !isValid);
       anAttribute->setExpressionError(i, aText[i].empty() ? "" : anError);
     }
@@ -197,7 +202,7 @@ void InitializationPlugin_EvalListener::processEvaluationEvent(
   if (aMessage->attribute()->attributeType() == GeomDataAPI_Point2D::typeId()) {
     AttributePoint2DPtr anAttribute =
         std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aMessage->attribute());
-    std::string aText[] = {
+    std::wstring aText[] = {
       anAttribute->textX(),
       anAttribute->textY()
     };
@@ -211,7 +216,7 @@ void InitializationPlugin_EvalListener::processEvaluationEvent(
       bool isValid = anError.empty();
       if (isValid) aCalculatedValue[i] = aValue;
       anAttribute->setUsedParameters(i,
-        isValid ? toSet(myInterp->compile(aText[i])) : std::set<std::string>());
+        isValid ? toSet(myInterp->compile(aText[i])) : std::set<std::wstring>());
       anAttribute->setExpressionInvalid(i, !isValid);
       anAttribute->setExpressionError(i, aText[i].empty() ? "" : anError);
     }
index 5b6f3d7be7cf7a5b59378166204790a5ebcbaf69..756b335ec0a739ee10c9bd1d63f7255338b87b3e 100644 (file)
@@ -51,7 +51,7 @@ class InitializationPlugin_EvalListener : public Events_Listener
  protected:
   /// Evaluates theExpression and returns its value.
    double evaluate(std::shared_ptr<ModelAPI_Feature> theParameter,
-                  const std::string& theExpression, std::string& theError,
+                  const std::wstring& theExpression, std::string& theError,
                   std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
                   const bool theIsParameter = false);
 
index 0e07f96967e4d972b16ac40f379422cc40ea219e..675e30190573bf93b15daaca93a1eee3cd50e651 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <InitializationPlugin_PyInterp.h>
 
+#include <Locale_Convert.h>
+
 #include <string>
 #include <stdexcept>
 #include <clocale>
@@ -44,17 +46,17 @@ const char* aSearchCode =
 
 // make the expression be correct for the python interpreter even for the
 // beta=alfa*2 expressions
-static std::string adjustExpression(const std::string& theExpression) {
-  std::string anExpression = theExpression;
-  if (!anExpression.empty() && anExpression.back() == '=') {
+static std::wstring adjustExpression(const std::wstring& theExpression) {
+  std::wstring anExpression = theExpression;
+  if (!anExpression.empty() && anExpression.back() == L'=') {
     anExpression = anExpression.substr(0, anExpression.length() - 1);
   }
   return anExpression;
 }
 
 std::list<std::pair<int, int> >
-InitializationPlugin_PyInterp::positions(const std::string& theExpression,
-                                     const std::string& theName)
+InitializationPlugin_PyInterp::positions(const std::wstring& theExpression,
+                                         const std::wstring& theName)
 {
   PyLockWrapper lck; // Acquire GIL until the end of the method
 
@@ -64,10 +66,11 @@ InitializationPlugin_PyInterp::positions(const std::string& theExpression,
   PyObject* aContext = PyDict_New();
   PyDict_SetItemString(aContext, "__builtins__", PyEval_GetBuiltins());
 
-  std::string anExpression = adjustExpression(theExpression);
+  std::wstring anExpression = adjustExpression(theExpression);
   // extend aContext with variables
-  PyDict_SetItemString(aContext, "expression", PyUnicode_FromString(anExpression.c_str()));
-  PyDict_SetItemString(aContext, "name", PyUnicode_FromString(theName.c_str()));
+  PyDict_SetItemString(aContext, "expression",
+      PyUnicode_FromWideChar(anExpression.c_str(), anExpression.size()));
+  PyDict_SetItemString(aContext, "name", PyUnicode_FromWideChar(theName.c_str(), theName.size()));
   PyDict_SetItemString(aContext, "positions", Py_BuildValue("[]"));
 
   // run the search code
@@ -93,21 +96,21 @@ InitializationPlugin_PyInterp::positions(const std::string& theExpression,
 }
 
 
-std::list<std::string> InitializationPlugin_PyInterp::compile(const std::string& theExpression)
+std::list<std::wstring> InitializationPlugin_PyInterp::compile(const std::wstring& theExpression)
 {
   PyLockWrapper lck; // Acquire GIL until the end of the method
-  std::list<std::string> aResult;
+  std::list<std::wstring> aResult;
   PyObject *aCodeopModule = PyImport_AddModule("codeop");
   if(!aCodeopModule) { // Fatal error. No way to go on.
     PyErr_Print();
     return aResult;
   }
   // support "variable_name=" expression as "variable_name"
-  std::string anExpression = adjustExpression(theExpression);
+  std::wstring anExpression = adjustExpression(theExpression);
 
   PyObject *aCodePyObj =
     PyObject_CallMethod(aCodeopModule, (char*)"compile_command", (char*)"(s)",
-                        anExpression.c_str());
+                        Locale::Convert::toString(anExpression).c_str());
 
   if(!aCodePyObj || aCodePyObj == Py_None || !PyCode_Check(aCodePyObj)) {
     Py_XDECREF(aCodePyObj);
@@ -126,7 +129,8 @@ std::list<std::string> InitializationPlugin_PyInterp::compile(const std::string&
     for (size_t i = 0; i < params_size; i++) {
       PyObject* aParamObj = PyTuple_GetItem(aCodeObj->co_names, i);
       PyObject* aParamObjStr = PyObject_Str(aParamObj);
-      std::string aParamName(PyUnicode_AsUTF8(aParamObjStr));
+      Py_ssize_t aSize;
+      std::wstring aParamName(PyUnicode_AsWideCharString(aParamObjStr, &aSize));
       aResult.push_back(aParamName);
       Py_XDECREF(aParamObjStr);
     }
@@ -135,14 +139,14 @@ std::list<std::string> InitializationPlugin_PyInterp::compile(const std::string&
   return aResult;
 }
 
-void InitializationPlugin_PyInterp::extendLocalContext(const std::list<std::string>& theParameters)
+void InitializationPlugin_PyInterp::extendLocalContext(const std::list<std::wstring>& theParameters)
 {
   PyLockWrapper lck; // Acquire GIL until the end of the method
   if (theParameters.empty())
     return;
-  std::list<std::string>::const_iterator it = theParameters.begin();
+  std::list<std::wstring>::const_iterator it = theParameters.begin();
   for ( ; it != theParameters.cend(); it++) {
-    std::string aParamValue = *it;
+    std::string aParamValue = Locale::Convert::toString(*it);
     simpleRun(aParamValue.c_str(), false);
   }
 }
@@ -153,16 +157,17 @@ void InitializationPlugin_PyInterp::clearLocalContext()
   PyDict_Clear(_local_context);
 }
 
-double InitializationPlugin_PyInterp::evaluate(const std::string& theExpression,
+double InitializationPlugin_PyInterp::evaluate(const std::wstring& theExpression,
                                                std::string& theError)
 {
   // support "variable_name=" expression as "variable_name"
-  std::string anExpression = adjustExpression(theExpression);
+  std::wstring anExpression = adjustExpression(theExpression);
 
   PyLockWrapper lck; // Acquire GIL until the end of the method
   PyCompilerFlags aFlags = {CO_FUTURE_DIVISION};
   aFlags.cf_flags = CO_FUTURE_DIVISION;
-  PyCodeObject* anExprCode = (PyCodeObject *) Py_CompileStringFlags(anExpression.c_str(),
+  PyCodeObject* anExprCode = (PyCodeObject *) Py_CompileStringFlags(
+                                Locale::Convert::toString(anExpression).c_str(),
                                 "<string>", Py_eval_input, &aFlags);
   if(!anExprCode) {
     theError = errorMessage();
index b34a8df82ba0b213c71c2b2f81f49722eb3579ee..163c265b22cf41fb649774061d928402b6f59bc0 100644 (file)
@@ -39,16 +39,16 @@ class INITIALIZATIONPLUGIN_EXPORT InitializationPlugin_PyInterp : public PyInter
   virtual ~InitializationPlugin_PyInterp();
 
   /// Returns a list of positions for theName in theExpression.
-  std::list<std::pair<int, int> > positions(const std::string& theExpression,
-                                            const std::string& theName);
+  std::list<std::pair<int, int> > positions(const std::wstring& theExpression,
+                                            const std::wstring& theName);
   /// Compiles theExpression and returns a list of parameters used in theExpression.
-  std::list<std::string> compile(const std::string& theExpression);
+  std::list<std::wstring> compile(const std::wstring& theExpression);
   /// Extends local context with the list of parameters.
-  void extendLocalContext(const std::list<std::string>& theParameters);
+  void extendLocalContext(const std::list<std::wstring>& theParameters);
   /// Clears local context.
   void clearLocalContext();
   /// Evaluates theExpression and returns its value.
-  double evaluate(const std::string& theExpression, std::string& theError);
+  double evaluate(const std::wstring& theExpression, std::string& theError);
 
   /// Runs the string command in the python interpreter. Returns true if no error is in result.
   bool runString(std::string theString);
index 2f84c69eefba73b458d9e7e7911c4e318c96eb5f..f3b200492c7f375bce8543b4d2d5148274b38149 100644 (file)
@@ -61,7 +61,7 @@ double Model_AttributeDouble::value()
   return myExpression->value();
 }
 
-void Model_AttributeDouble::setText(const std::string& theValue)
+void Model_AttributeDouble::setText(const std::wstring& theValue)
 {
   if (text() != theValue) {
     myExpression->setText(theValue);
@@ -71,7 +71,7 @@ void Model_AttributeDouble::setText(const std::string& theValue)
   }
 }
 
-std::string Model_AttributeDouble::text()
+std::wstring Model_AttributeDouble::text()
 {
   return myExpression->text();
 }
@@ -97,12 +97,12 @@ std::string Model_AttributeDouble::expressionError()
   return myExpression->error();
 }
 
-void Model_AttributeDouble::setUsedParameters(const std::set<std::string>& theUsedParameters)
+void Model_AttributeDouble::setUsedParameters(const std::set<std::wstring>& theUsedParameters)
 {
   myExpression->setUsedParameters(theUsedParameters);
 }
 
-std::set<std::string> Model_AttributeDouble::usedParameters() const
+std::set<std::wstring> Model_AttributeDouble::usedParameters() const
 {
   return myExpression->usedParameters();
 }
index a6fa0075a817a35a639286989d757f12a4fb14c2..b8c6662badcfe236a8cdd034306f013dc919bd68 100644 (file)
@@ -47,10 +47,10 @@ class Model_AttributeDouble : public ModelAPI_AttributeDouble
   MODEL_EXPORT virtual void setCalculatedValue(const double theValue);
 
   /// Defines the text value
-  MODEL_EXPORT virtual void setText(const std::string& theText);
+  MODEL_EXPORT virtual void setText(const std::wstring& theText);
 
   /// Returns the text value
-  MODEL_EXPORT virtual std::string text();
+  MODEL_EXPORT virtual std::wstring text();
 
   /// Allows to set expression (text) as invalid (by the parameters listener)
   MODEL_EXPORT virtual void setExpressionInvalid(const bool theFlag);
@@ -65,10 +65,10 @@ class Model_AttributeDouble : public ModelAPI_AttributeDouble
   MODEL_EXPORT virtual std::string expressionError();
 
   /// Defines the used parameters
-  MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters);
+  MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters);
 
   /// Returns the used parameters
-  MODEL_EXPORT virtual std::set<std::string> usedParameters() const;
+  MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const;
 
  protected:
   /// Initializes attributes
index 5229faebca9ab9575b6dc99c54877ecb270e0c7b..d4948e1399d199428510ac5852954913cef58a4b 100644 (file)
@@ -55,7 +55,7 @@ int Model_AttributeInteger::value()
   return myExpression->value();
 }
 
-void Model_AttributeInteger::setText(const std::string& theValue)
+void Model_AttributeInteger::setText(const std::wstring& theValue)
 {
   if (text() != theValue) {
     myExpression->setText(theValue);
@@ -65,7 +65,7 @@ void Model_AttributeInteger::setText(const std::string& theValue)
   }
 }
 
-std::string Model_AttributeInteger::text()
+std::wstring Model_AttributeInteger::text()
 {
   return myExpression->text();
 }
@@ -91,12 +91,12 @@ std::string Model_AttributeInteger::expressionError()
   return myExpression->error();
 }
 
-void Model_AttributeInteger::setUsedParameters(const std::set<std::string>& theUsedParameters)
+void Model_AttributeInteger::setUsedParameters(const std::set<std::wstring>& theUsedParameters)
 {
   myExpression->setUsedParameters(theUsedParameters);
 }
 
-std::set<std::string> Model_AttributeInteger::usedParameters() const
+std::set<std::wstring> Model_AttributeInteger::usedParameters() const
 {
   return myExpression->usedParameters();
 }
index d3c1ac08792eb387246651c62deab869de7f2c1e..88b3bf2f4eab315a4d7bcb7fba70dbed0f1c8387 100644 (file)
@@ -45,10 +45,10 @@ class Model_AttributeInteger : public ModelAPI_AttributeInteger
   MODEL_EXPORT virtual void setCalculatedValue(const int theValue);
 
   /// Defines the text value
-  MODEL_EXPORT virtual void setText(const std::string& theText);
+  MODEL_EXPORT virtual void setText(const std::wstring& theText);
 
   /// Returns the text value
-  MODEL_EXPORT virtual std::string text();
+  MODEL_EXPORT virtual std::wstring text();
 
   /// Allows to set expression (text) as invalid (by the parameters listener)
   MODEL_EXPORT virtual void setExpressionInvalid(const bool theFlag);
@@ -63,10 +63,10 @@ class Model_AttributeInteger : public ModelAPI_AttributeInteger
   MODEL_EXPORT virtual std::string expressionError();
 
   /// Defines the used parameters
-  MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters);
+  MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters);
 
   /// Returns the used parameters
-  MODEL_EXPORT virtual std::set<std::string> usedParameters() const;
+  MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const;
 
  protected:
   /// Initializes attributes
index 4ca69f024c2eba87c005830be800e322f61de481..fcccca5369263060fe270b22aa72c197716b4933 100644 (file)
@@ -675,38 +675,38 @@ void Model_Data::updateConcealmentFlag()
   }
 }
 
-std::set<std::string> set_union(const std::set<std::string>& theLeft,
-                                const std::set<std::string>& theRight)
+std::set<std::wstring> set_union(const std::set<std::wstring>& theLeft,
+                                 const std::set<std::wstring>& theRight)
 {
-  std::set<std::string> aResult;
+  std::set<std::wstring> aResult;
   aResult.insert(theLeft.begin(), theLeft.end());
   aResult.insert(theRight.begin(), theRight.end());
   return aResult;
 }
 
-std::set<std::string> usedParameters(const AttributePointPtr& theAttribute)
+std::set<std::wstring> usedParameters(const AttributePointPtr& theAttribute)
 {
-  std::set<std::string> anUsedParameters;
+  std::set<std::wstring> anUsedParameters;
   for (int aComponent = 0; aComponent < 3; ++aComponent)
     anUsedParameters = set_union(anUsedParameters, theAttribute->usedParameters(aComponent));
   return anUsedParameters;
 }
 
-std::set<std::string> usedParameters(const AttributePoint2DPtr& theAttribute)
+std::set<std::wstring> usedParameters(const AttributePoint2DPtr& theAttribute)
 {
-  std::set<std::string> anUsedParameters;
+  std::set<std::wstring> anUsedParameters;
   for (int aComponent = 0; aComponent < 2; ++aComponent)
     anUsedParameters = set_union(anUsedParameters, theAttribute->usedParameters(aComponent));
   return anUsedParameters;
 }
 
-std::list<ResultParameterPtr> findVariables(const std::set<std::string>& theParameters,
+std::list<ResultParameterPtr> findVariables(const std::set<std::wstring>& theParameters,
                                             const DocumentPtr& theDocument)
 {
   std::list<ResultParameterPtr> aResult;
-  std::set<std::string>::const_iterator aParamIt = theParameters.cbegin();
+  std::set<std::wstring>::const_iterator aParamIt = theParameters.cbegin();
   for (; aParamIt != theParameters.cend(); ++aParamIt) {
-    const std::string& aName = *aParamIt;
+    const std::wstring& aName = *aParamIt;
     double aValue;
     ResultParameterPtr aParam;
     // theSearcher is not needed here: in expressions
@@ -790,28 +790,28 @@ void Model_Data::referencesToObjects(
     } else if (aType == ModelAPI_AttributeInteger::typeId()) { // integer attribute
       AttributeIntegerPtr anAttribute =
           std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(anAttr);
-      std::set<std::string> anUsedParameters = anAttribute->usedParameters();
+      std::set<std::wstring> anUsedParameters = anAttribute->usedParameters();
       std::list<ResultParameterPtr> aParameters =
         findVariables(anUsedParameters, owner()->document());
       aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
     } else if (aType == ModelAPI_AttributeDouble::typeId()) { // double attribute
       AttributeDoublePtr anAttribute =
           std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(anAttr);
-      std::set<std::string> anUsedParameters = anAttribute->usedParameters();
+      std::set<std::wstring> anUsedParameters = anAttribute->usedParameters();
       std::list<ResultParameterPtr> aParameters =
         findVariables(anUsedParameters, owner()->document());
       aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
     } else if (aType == GeomDataAPI_Point::typeId()) { // point attribute
       AttributePointPtr anAttribute =
         std::dynamic_pointer_cast<GeomDataAPI_Point>(anAttr);
-      std::set<std::string> anUsedParameters = usedParameters(anAttribute);
+      std::set<std::wstring> anUsedParameters = usedParameters(anAttribute);
       std::list<ResultParameterPtr> aParameters =
         findVariables(anUsedParameters, owner()->document());
       aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
     } else if (aType == GeomDataAPI_Point2D::typeId()) { // point attribute
       AttributePoint2DPtr anAttribute =
         std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr);
-      std::set<std::string> anUsedParameters = usedParameters(anAttribute);
+      std::set<std::wstring> anUsedParameters = usedParameters(anAttribute);
       std::list<ResultParameterPtr> aParameters =
         findVariables(anUsedParameters, owner()->document());
       aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
index 23b60fa7e72a33eedf5b2ca2cba4ec463f8b055d..934e910dd170968ac8c176123fe7a95dfe117c1b 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "Model_Expression.h"
 
+#include <Locale_Convert.h>
+
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_ExtendedString.hxx>
 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
@@ -45,7 +47,7 @@ Model_Expression::Model_Expression(TDF_Label& theLabel)
   }
 }
 
-void Model_Expression::setText(const std::string& theValue)
+void Model_Expression::setText(const std::wstring& theValue)
 {
   if (text() != theValue) {
     myText->Set(TCollection_ExtendedString(theValue.c_str()));
@@ -55,9 +57,9 @@ void Model_Expression::setText(const std::string& theValue)
   setError(text().empty() ? "" : "Not a double value.");
 }
 
-std::string Model_Expression::text() const
+std::wstring Model_Expression::text() const
 {
-  return TCollection_AsciiString(myText->Get()).ToCString();
+  return Locale::Convert::toWString(myText->Get().ToExtString());
 }
 
 void Model_Expression::setError(const std::string& theError)
@@ -71,20 +73,20 @@ std::string Model_Expression::error()
   return TCollection_AsciiString(myError->Get()).ToCString();
 }
 
-void Model_Expression::setUsedParameters(const std::set<std::string>& theUsedParameters)
+void Model_Expression::setUsedParameters(const std::set<std::wstring>& theUsedParameters)
 {
   myUsedParameters->Clear();
-  std::set<std::string>::const_iterator anIt = theUsedParameters.begin();
+  std::set<std::wstring>::const_iterator anIt = theUsedParameters.begin();
   for (; anIt != theUsedParameters.end(); ++anIt)
     myUsedParameters->Append(TCollection_ExtendedString(anIt->c_str()));
 }
 
-std::set<std::string> Model_Expression::usedParameters() const
+std::set<std::wstring> Model_Expression::usedParameters() const
 {
-  std::set<std::string> aResult;
+  std::set<std::wstring> aResult;
   TDataStd_ListIteratorOfListOfExtendedString aIt;
   for (aIt.Initialize(myUsedParameters->List()); aIt.More(); aIt.Next())
-    aResult.insert(TCollection_AsciiString(aIt.Value()).ToCString());
+    aResult.insert(Locale::Convert::toWString(aIt.Value().ToExtString()));
   return aResult;
 }
 
index 53d7a502785e58095a2e2580755ea338c3219867..6ad194ee4878f67cbd52ea4cb09bffa3fb28eac5 100644 (file)
@@ -39,10 +39,10 @@ class Model_Expression : public virtual ModelAPI_Expression
 {
  public:
   /// Sets the text of this Expression
-  MODEL_EXPORT virtual void setText(const std::string& theText);
+  MODEL_EXPORT virtual void setText(const std::wstring& theText);
 
   /// Returns the text of this Expression
-  MODEL_EXPORT virtual std::string text() const;
+  MODEL_EXPORT virtual std::wstring text() const;
 
   /// Allows to set expression (text) error (by the parameters listener)
   MODEL_EXPORT virtual void setError(const std::string& theError);
@@ -51,10 +51,10 @@ class Model_Expression : public virtual ModelAPI_Expression
   MODEL_EXPORT virtual std::string error();
 
   /// Defines the used parameters (by the parameters listener)
-  MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters);
+  MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters);
 
   /// Returns the used parameters
-  MODEL_EXPORT virtual std::set<std::string> usedParameters() const;
+  MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const;
 
  protected:
   /// Initializes attributes
@@ -77,12 +77,12 @@ class Model_ExpressionDouble :
 {
  public:
   /// Sets the text of this Expression
-  MODEL_EXPORT virtual void setText(const std::string& theText) {
+  MODEL_EXPORT virtual void setText(const std::wstring& theText) {
     Model_Expression::setText(theText);
   };
 
   /// Returns the text of this Expression
-  MODEL_EXPORT virtual std::string text() const {
+  MODEL_EXPORT virtual std::wstring text() const {
     return Model_Expression::text();
   };
 
@@ -97,12 +97,12 @@ class Model_ExpressionDouble :
   };
 
   /// Defines the used parameters (by the parameters listener)
-  MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters) {
+  MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters) {
     Model_Expression::setUsedParameters(theUsedParameters);
   };
 
   /// Returns the used parameters
-  MODEL_EXPORT virtual std::set<std::string> usedParameters() const {
+  MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const {
     return Model_Expression::usedParameters();
   };
 
@@ -142,12 +142,12 @@ class Model_ExpressionInteger :
 {
  public:
   /// Sets the text of this Expression
-  MODEL_EXPORT virtual void setText(const std::string& theText) {
+  MODEL_EXPORT virtual void setText(const std::wstring& theText) {
     Model_Expression::setText(theText);
   };
 
   /// Returns the text of this Expression
-  MODEL_EXPORT virtual std::string text() const {
+  MODEL_EXPORT virtual std::wstring text() const {
     return Model_Expression::text();
   };
 
@@ -162,12 +162,12 @@ class Model_ExpressionInteger :
   };
 
   /// Defines the used parameters (by the parameters listener)
-  MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters) {
+  MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters) {
     Model_Expression::setUsedParameters(theUsedParameters);
   };
 
   /// Returns the used parameters
-  MODEL_EXPORT virtual std::set<std::string> usedParameters() const {
+  MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const {
     return Model_Expression::usedParameters();
   };
 
index eae4e43b5915322ab92266a62525fc3303d78054..22cd3338c65bf9130a59470120877af02c8f1ebf 100644 (file)
@@ -43,10 +43,10 @@ class ModelAPI_AttributeDouble : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual void setCalculatedValue(const double theValue) = 0;
 
   /// Defines the text value
-  MODELAPI_EXPORT virtual void setText(const std::string& theText) = 0;
+  MODELAPI_EXPORT virtual void setText(const std::wstring& theText) = 0;
 
   /// Returns the text value
-  MODELAPI_EXPORT virtual std::string text() = 0;
+  MODELAPI_EXPORT virtual std::wstring text() = 0;
 
   /// Allows to set expression (text) as invalid (by the parameters listener)
   MODELAPI_EXPORT virtual void setExpressionInvalid(const bool theFlag) = 0;
@@ -62,10 +62,10 @@ class ModelAPI_AttributeDouble : public ModelAPI_Attribute
 
   /// Defines the used parameters
   MODELAPI_EXPORT virtual
-    void setUsedParameters(const std::set<std::string>& theUsedParameters) = 0;
+    void setUsedParameters(const std::set<std::wstring>& theUsedParameters) = 0;
 
   /// Returns the used parameters
-  MODELAPI_EXPORT virtual std::set<std::string> usedParameters() const = 0;
+  MODELAPI_EXPORT virtual std::set<std::wstring> usedParameters() const = 0;
 
   /// Returns the type of this class of attributes
   MODELAPI_EXPORT static std::string typeId()
index 54c550cbb3754305a1a037404155415688c549f1..2b8383f4dcd279c29a8abe3f18fb265408191402 100644 (file)
@@ -43,10 +43,10 @@ class ModelAPI_AttributeInteger : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual void setCalculatedValue(const int theValue) = 0;
 
   /// Defines the text value
-  MODELAPI_EXPORT virtual void setText(const std::string& theText) = 0;
+  MODELAPI_EXPORT virtual void setText(const std::wstring& theText) = 0;
 
   /// Returns the text value
-  MODELAPI_EXPORT virtual std::string text() = 0;
+  MODELAPI_EXPORT virtual std::wstring text() = 0;
 
   /// Allows to set expression (text) as invalid (by the parameters listener)
   MODELAPI_EXPORT virtual void setExpressionInvalid(const bool theFlag) = 0;
@@ -62,10 +62,10 @@ class ModelAPI_AttributeInteger : public ModelAPI_Attribute
 
   /// Defines the used parameters
   MODELAPI_EXPORT virtual
-    void setUsedParameters(const std::set<std::string>& theUsedParameters) = 0;
+    void setUsedParameters(const std::set<std::wstring>& theUsedParameters) = 0;
 
   /// Returns the used parameters
-  MODELAPI_EXPORT virtual std::set<std::string> usedParameters() const = 0;
+  MODELAPI_EXPORT virtual std::set<std::wstring> usedParameters() const = 0;
 
   /// Returns the type of this class of attributes
   MODELAPI_EXPORT static std::string typeId()
index 4bc97466a39d8396e0500f2c72518ec857c7c080..cebf9ca791fcf5133e83da9a5f31436ab5c704e3 100644 (file)
@@ -196,18 +196,18 @@ ModelAPI_ComputePositionsMessage::ModelAPI_ComputePositionsMessage(
 ModelAPI_ComputePositionsMessage::~ModelAPI_ComputePositionsMessage()
 {}
 
-const std::string& ModelAPI_ComputePositionsMessage::expression() const
+const std::wstring& ModelAPI_ComputePositionsMessage::expression() const
 {
   return myExpression;
 }
 
-const std::string& ModelAPI_ComputePositionsMessage::parameter() const
+const std::wstring& ModelAPI_ComputePositionsMessage::parameter() const
 {
   return myParamName;
 }
 
 void ModelAPI_ComputePositionsMessage::set(
-  const std::string& theExpression, const std::string& theParameter)
+  const std::wstring& theExpression, const std::wstring& theParameter)
 {
   myExpression = theExpression;
   myParamName = theParameter;
index 0bfb4d53ed64fd0741bb1f029681405fe4c0208b..fccf6e24002965de8378e7c4553460eb6808d3b3 100644 (file)
@@ -356,8 +356,8 @@ class ModelAPI_ParameterEvalMessage : public Events_Message
 /// Message to ask compute the positions of parameters in the expression
 class ModelAPI_ComputePositionsMessage : public Events_Message
 {
-  std::string myExpression; ///< the expression string
-  std::string myParamName; ///< name of the parameter to be searched
+  std::wstring myExpression; ///< the expression string
+  std::wstring myParamName; ///< name of the parameter to be searched
   std::list<std::pair<int, int> > myPositions; ///< computation result: start-end position indices
 
 public:
@@ -372,7 +372,7 @@ public:
   /// Useful method that creates and sends the AttributeEvalMessage event
   /// Returns the message, processed, with the resulting fields filled
   MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ComputePositionsMessage>
-    send(const std::string& theExpression, const std::string& theParameter, const void* theSender)
+    send(const std::wstring& theExpression, const std::wstring& theParameter, const void* theSender)
   {
     std::shared_ptr<ModelAPI_ComputePositionsMessage> aMessage =
       std::shared_ptr<ModelAPI_ComputePositionsMessage>(
@@ -389,11 +389,11 @@ public:
   MODELAPI_EXPORT virtual ~ModelAPI_ComputePositionsMessage();
 
   /// Returns an expression stored in the message
-  MODELAPI_EXPORT const std::string& expression() const;
+  MODELAPI_EXPORT const std::wstring& expression() const;
   /// Returns a parameter name stored in the message
-  MODELAPI_EXPORT const std::string& parameter() const;
+  MODELAPI_EXPORT const std::wstring& parameter() const;
   /// Sets an expression and parameter needed for computation
-  MODELAPI_EXPORT void set(const std::string& theExpression, const std::string& theParameter);
+  MODELAPI_EXPORT void set(const std::wstring& theExpression, const std::wstring& theParameter);
   /// Sets the results of processing
   MODELAPI_EXPORT void setPositions(const std::list<std::pair<int, int> >& thePositions);
   /// Returns the results of processing: position start and end indices
index 3359e598859d2618b46d8214122df7670955b4d6..026c9c0f42eecd59852e9af28425d4e0f21ef6d4 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "ModelAPI_Expression.h"
 
+#include <Locale_Convert.h>
+
 ModelAPI_Expression::ModelAPI_Expression()
 {
 
@@ -49,17 +51,23 @@ ModelAPI_ExpressionInteger::ModelAPI_ExpressionInteger()
 
 
 }
+
 bool ModelAPI_Expression::isVariable(const std::string& theString)
+{
+  return isVariable(Locale::Convert::toWString(theString));
+}
+
+bool ModelAPI_Expression::isVariable(const std::wstring& theString)
 {
   if (theString.empty())
     return false;
   try {
-    std::string::const_iterator it = theString.begin();
-    if (!(isalpha(*it) || (*it) == '_') || it == theString.end())
+    std::wstring::const_iterator it = theString.begin();
+    if (!(iswalpha(*it) || (*it) == L'_') || it == theString.end())
       return false;
     it++;
     for ( ; it != theString.end(); ++it ) {
-      if(!(isalnum(*it) || (*it) == '_')) {
+      if(!(iswalnum(*it) || (*it) == L'_')) {
         return false;
       }
     }
index 94d768f3fdbab3565649acc1531703cd25a8d28a..b32addf66e0c253f0c582649f5cb6386f521c49f 100644 (file)
@@ -43,10 +43,10 @@ class ModelAPI_Expression
   MODELAPI_EXPORT virtual void setInitialized();
 
   /// Sets the text of this Expression
-  MODELAPI_EXPORT virtual void setText(const std::string& theText) = 0;
+  MODELAPI_EXPORT virtual void setText(const std::wstring& theText) = 0;
 
   /// Returns the text of this Expression
-  MODELAPI_EXPORT virtual std::string text() const = 0;
+  MODELAPI_EXPORT virtual std::wstring text() const = 0;
 
   /// Allows to set expression (text) as invalid (by the parameters listener)
   MODELAPI_EXPORT virtual void setInvalid(const bool theFlag) = 0;
@@ -62,14 +62,17 @@ class ModelAPI_Expression
 
   /// Defines the used parameters (by the parameters listener)
   MODELAPI_EXPORT virtual
-    void setUsedParameters(const std::set<std::string>& theUsedParameters) = 0;
+    void setUsedParameters(const std::set<std::wstring>& theUsedParameters) = 0;
 
   /// Returns the used parameters
-  MODELAPI_EXPORT virtual std::set<std::string> usedParameters() const = 0;
+  MODELAPI_EXPORT virtual std::set<std::wstring> usedParameters() const = 0;
 
   /// Returns True if the given string can be defined as a name of an expression variable
   MODELAPI_EXPORT static bool isVariable(const std::string& theString);
 
+  /// Returns True if the given string can be defined as a name of an expression variable
+  MODELAPI_EXPORT static bool isVariable(const std::wstring& theString);
+
  protected:
   /// Objects are created for features automatically
   MODELAPI_EXPORT ModelAPI_Expression();
index e3b007bb84872f735ce7459170f441e063aedb72..69a882af62a66593745301585c3a47b7b5006a77 100644 (file)
@@ -171,12 +171,11 @@ std::string getFeatureError(const FeaturePtr& theFeature)
 // LCOV_EXCL_STOP
 
 ObjectPtr objectByName(const DocumentPtr& theDocument, const std::string& theGroup,
-                       const std::string& theName)
+                       const std::wstring& theName)
 {
-  std::wstring aName = Locale::Convert::toWString(theName);
   for (int anIndex = 0; anIndex < theDocument->size(theGroup); ++anIndex) {
     ObjectPtr anObject = theDocument->object(theGroup, anIndex);
-    if (anObject->data()->name() == aName)
+    if (anObject->data()->name() == theName)
       return anObject;
   }
   // not found
@@ -184,7 +183,7 @@ ObjectPtr objectByName(const DocumentPtr& theDocument, const std::string& theGro
 }
 
 bool findVariable(const DocumentPtr& theDocument, FeaturePtr theSearcher,
-                  const std::string& theName, double& outValue, ResultParameterPtr& theParam)
+                  const std::wstring& theName, double& outValue, ResultParameterPtr& theParam)
 {
   ObjectPtr aParamObj = objectByName(theDocument, ModelAPI_ResultParameter::group(), theName);
   theParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aParamObj);
@@ -202,7 +201,7 @@ bool findVariable(const DocumentPtr& theDocument, FeaturePtr theSearcher,
   return true;
 }
 
-bool findVariable(FeaturePtr theSearcher, const std::string& theName, double& outValue,
+bool findVariable(FeaturePtr theSearcher, const std::wstring& theName, double& outValue,
                   ResultParameterPtr& theParam, const DocumentPtr& theDocument)
 {
   SessionPtr aSession = ModelAPI_Session::get();
index 27021498a53bf2fee1cf1eb51c4bb49123107fd2..5fd96b9177157036ded985c774a4c140491f9535 100644 (file)
@@ -56,7 +56,7 @@ MODELAPI_EXPORT std::string getFeatureError(const std::shared_ptr<ModelAPI_Featu
  */
 MODELAPI_EXPORT bool findVariable(const std::shared_ptr<ModelAPI_Document>& theDocument,
                                   std::shared_ptr<ModelAPI_Feature> theSearcher,
-                                  const std::string& theName, double& outValue,
+                                  const std::wstring& theName, double& outValue,
                                   std::shared_ptr<ModelAPI_ResultParameter>& theParam);
 
 /*!
@@ -66,7 +66,7 @@ MODELAPI_EXPORT bool findVariable(const std::shared_ptr<ModelAPI_Document>& theD
  * theSearcher must be located later in the history than the found variable.
  */
 MODELAPI_EXPORT bool findVariable(std::shared_ptr<ModelAPI_Feature> theSearcher,
-  const std::string& theName,
+  const std::wstring& theName,
   double& outValue, std::shared_ptr<ModelAPI_ResultParameter>& theParam,
   const std::shared_ptr<ModelAPI_Document>& theDocument = std::shared_ptr<ModelAPI_Document>());
 
index f1ec7251fe4aa34b681e826452a78f39608a814a..109d13bc6927db5b615d538b978d409844ee7529 100644 (file)
@@ -66,7 +66,8 @@
     temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
     $1 = &temp;
   } else if (PyUnicode_Check($input)) {
-    temp = ModelHighAPI_Double(PyUnicode_AsUTF8($input));
+    Py_ssize_t size;
+    temp = ModelHighAPI_Double(PyUnicode_AsWideCharString($input, &size));
     $1 = &temp;
   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
   } else {
@@ -83,7 +84,8 @@
     temp = ModelHighAPI_Integer(static_cast<int>(PyLong_AsLong($input)));
     $1 = &temp;
   } else if (PyUnicode_Check($input)) {
-    temp = ModelHighAPI_Integer(PyUnicode_AsUTF8($input));
+    Py_ssize_t size;
+    temp = ModelHighAPI_Integer(PyUnicode_AsWideCharString($input, &size));
     $1 = &temp;
   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
   } else {
       if (PyFloat_Check(item) || PyLong_Check(item)) {
         temp.push_back(ModelHighAPI_Double(PyFloat_AsDouble(item)));
       } else if (PyUnicode_Check(item)) {
-        temp.push_back(ModelHighAPI_Double(PyUnicode_AsUTF8(item)));
+        Py_ssize_t size;
+        temp.push_back(ModelHighAPI_Double(PyUnicode_AsWideCharString(item, &size)));
       } else if ((SWIG_ConvertPtr(item, (void **)&temp_double, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
         temp.push_back(*temp_double);
       } else {
       if (PyLong_Check(item)) {
         temp.push_back(ModelHighAPI_Integer(PyLong_AsLong(item)));
       } else if (PyUnicode_Check(item)) {
-        temp.push_back(ModelHighAPI_Integer(PyUnicode_AsUTF8(item)));
+        Py_ssize_t size;
+        temp.push_back(ModelHighAPI_Integer(PyUnicode_AsWideCharString(item, &size)));
       } else if ((SWIG_ConvertPtr(item, (void **)&temp_int, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
         temp.push_back(*temp_int);
       } else {
index 8b4c2f04848a3646cc5bf5ac09144a8088655982..121e85fe4d37bd08990c9133045082a0aab320f8 100644 (file)
@@ -32,13 +32,13 @@ ModelHighAPI_Double::ModelHighAPI_Double(double theValue)
 {
 }
 
-ModelHighAPI_Double::ModelHighAPI_Double(const std::string & theValue)
+ModelHighAPI_Double::ModelHighAPI_Double(const std::wstring & theValue)
 : myVariantType(VT_STRING)
 , myString(theValue)
 {
 }
 
-ModelHighAPI_Double::ModelHighAPI_Double(const char * theValue)
+ModelHighAPI_Double::ModelHighAPI_Double(const wchar_t * theValue)
 : myVariantType(VT_STRING)
 , myString(theValue)
 {
@@ -54,12 +54,12 @@ double ModelHighAPI_Double::value() const
   return myDouble;
 }
 
-std::string ModelHighAPI_Double::string() const
+std::wstring ModelHighAPI_Double::string() const
 {
   if (myVariantType == VT_STRING)
     return myString;
 
-  std::ostringstream anOut;
+  std::wostringstream anOut;
   anOut << myDouble;
   return anOut.str();
 }
index 02ddcd197c9839697adaa2bdd46904d0134b444d..2811c6668a4f70203948677f1b526ba17bdc03ff 100644 (file)
@@ -41,10 +41,10 @@ public:
   ModelHighAPI_Double(double theValue = 0.);
   /// Constructor for std::string
   MODELHIGHAPI_EXPORT
-  ModelHighAPI_Double(const std::string & theValue);
+  ModelHighAPI_Double(const std::wstring & theValue);
   /// Constructor for char *
   MODELHIGHAPI_EXPORT
-  ModelHighAPI_Double(const char * theValue);
+  ModelHighAPI_Double(const wchar_t * theValue);
   /// Destructor
   MODELHIGHAPI_EXPORT
   virtual ~ModelHighAPI_Double();
@@ -64,12 +64,12 @@ public:
   MODELHIGHAPI_EXPORT double value() const;
 
   /// Returns a string representation of the value
-  MODELHIGHAPI_EXPORT virtual std::string string() const;
+  MODELHIGHAPI_EXPORT virtual std::wstring string() const;
 
 private:
   enum VariantType { VT_DOUBLE, VT_STRING } myVariantType;
   double myDouble;
-  std::string myString;
+  std::wstring myString;
 };
 
 //--------------------------------------------------------------------------------------
index c46e05119e81084360c7540aecad99d68defe322..6d8affba893069289e3e0b5ae1a3b8d62f4a3d9c 100644 (file)
@@ -1144,7 +1144,11 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
 {
   static const int aSize = 3;
   double aValues[aSize] = {thePoint->x(), thePoint->y(), thePoint->z()};
-  std::string aTexts[aSize] = {thePoint->textX(), thePoint->textY(), thePoint->textZ()};
+  std::string aTexts[aSize] = {
+      Locale::Convert::toString(thePoint->textX()),
+      Locale::Convert::toString(thePoint->textY()),
+      Locale::Convert::toString(thePoint->textZ())
+  };
   myDumpStorage->dumpArray(aSize, aValues, aTexts);
   return *this;
 }
@@ -1154,7 +1158,10 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
 {
   static const int aSize = 2;
   double aValues[aSize] = {thePoint->x(), thePoint->y()};
-  std::string aTexts[aSize] = {thePoint->textX(), thePoint->textY()};
+  std::string aTexts[aSize] = {
+      Locale::Convert::toString(thePoint->textX()),
+      Locale::Convert::toString(thePoint->textY())
+  };
   myDumpStorage->dumpArray(aSize, aValues, aTexts);
   return *this;
 }
@@ -1206,7 +1213,7 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
     const std::shared_ptr<ModelAPI_AttributeInteger>& theAttrInt)
 {
-  std::string aText = theAttrInt->text();
+  std::string aText = Locale::Convert::toString(theAttrInt->text());
   if (aText.empty())
     *myDumpStorage << theAttrInt->value();
   else
@@ -1231,7 +1238,7 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
     const std::shared_ptr<ModelAPI_AttributeDouble>& theAttrReal)
 {
-  std::string aText = theAttrReal->text();
+  std::string aText = Locale::Convert::toString(theAttrReal->text());
   if (aText.empty())
     *myDumpStorage << theAttrReal->value();
   else
index 1493d104b49ab504eab8bdc6a2918ec1cdb31315..58e32136f2cd9decca891e655dcaf325fbd8b13a 100644 (file)
@@ -211,7 +211,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) {
     if (anAttr->text().empty())
       aResult<<anAttr->value();
     else
-      aResult<<anAttr->text();
+      aResult << Locale::Convert::toString(anAttr->text());
   } else if (aType == ModelAPI_AttributeDouble::typeId()) {
     AttributeDoublePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttr);
     if (anAttr->id() == "ConstraintValue") {
@@ -230,7 +230,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) {
       double aVal = anAttr->value();
       dumpArray(aResult, &aVal, 1, aPrecision);
     } else
-      aResult<<anAttr->text();
+      aResult << Locale::Convert::toString(anAttr->text());
   } else if (aType == ModelAPI_AttributeBoolean::typeId()) {
     AttributeBooleanPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(theAttr);
     // do not dump internal flags of ConstraintAngle
index ea9ecc57205f6a2c01daf333a18faae5d45c8ef3..6f7a9ae7b766b67a82a2b66b4def03ff41072aa9 100644 (file)
@@ -31,13 +31,13 @@ ModelHighAPI_Integer::ModelHighAPI_Integer(int theValue)
 {
 }
 
-ModelHighAPI_Integer::ModelHighAPI_Integer(const std::string & theValue)
+ModelHighAPI_Integer::ModelHighAPI_Integer(const std::wstring & theValue)
 : myVariantType(VT_STRING)
 , myString(theValue)
 {
 }
 
-ModelHighAPI_Integer::ModelHighAPI_Integer(const char * theValue)
+ModelHighAPI_Integer::ModelHighAPI_Integer(const wchar_t * theValue)
 : myVariantType(VT_STRING)
 , myString(theValue)
 {
@@ -63,12 +63,12 @@ int ModelHighAPI_Integer::intValue() const
   return myInt;
 }
 
-std::string ModelHighAPI_Integer::string() const
+std::wstring ModelHighAPI_Integer::string() const
 {
   if (myVariantType == VT_STRING)
     return myString;
 
-  std::ostringstream anOut;
+  std::wostringstream anOut;
   anOut << myInt;
   return anOut.str();
 }
index 459c74da289704089f95fbc28dd70c46f238a96c..da433e1c0a95409d41742cb5659f7cfe40237f4a 100644 (file)
@@ -40,10 +40,10 @@ public:
   ModelHighAPI_Integer(int theValue = 0);
   /// Constructor for std::string
   MODELHIGHAPI_EXPORT
-  ModelHighAPI_Integer(const std::string & theValue);
+  ModelHighAPI_Integer(const std::wstring & theValue);
   /// Constructor for char *
   MODELHIGHAPI_EXPORT
-  ModelHighAPI_Integer(const char * theValue);
+  ModelHighAPI_Integer(const wchar_t * theValue);
   /// Destructor
   MODELHIGHAPI_EXPORT
   virtual ~ModelHighAPI_Integer();
@@ -56,12 +56,12 @@ public:
   MODELHIGHAPI_EXPORT virtual int intValue() const;
 
   /// Returns a string representation of the value
-  MODELHIGHAPI_EXPORT virtual std::string string() const;
+  MODELHIGHAPI_EXPORT virtual std::wstring string() const;
 
 private:
   enum VariantType { VT_INT, VT_STRING } myVariantType;
   int myInt;
-  std::string myString;
+  std::wstring myString;
 };
 
 //--------------------------------------------------------------------------------------
index 2f06c5f28339fba69d6909f9f637e63ecbd5d5c5..43b268aab2e772f9b64fb51f225255eb43f1b1e6 100644 (file)
@@ -242,6 +242,7 @@ SET(PROJECT_LIBRARIES
        GeomAPI
        GeomDataAPI
        GeomAlgoAPI
+        Locale
        ${QT_LIBRARIES}
        ${OpenCASCADE_FoundationClasses_LIBRARIES}
        ${OpenCASCADE_Visualization_LIBRARIES}
@@ -278,6 +279,7 @@ INCLUDE_DIRECTORIES(
     ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
     ${PROJECT_SOURCE_DIR}/src/GeomAPI
     ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
+    ${PROJECT_SOURCE_DIR}/src/Locale
     ${SUIT_INCLUDE}
 )
 
index e8e5d7409f66d0a84191bd28202f72c5c94002b7..488e81c59bd050609b41d52ad95714dd3bc96ab0 100644 (file)
@@ -213,7 +213,7 @@ bool ModuleBase_ParamIntSpinBox::findVariable(const QString& theName,
                                               double& outValue) const
 {
   ResultParameterPtr aParam;
-  return ModelAPI_Tools::findVariable(FeaturePtr(), theName.toStdString(), outValue, aParam);
+  return ModelAPI_Tools::findVariable(FeaturePtr(), theName.toStdWString(), outValue, aParam);
 }
 
 /*!
index 37ada0461968378870ac8df5b479ce2106ffae6b..ddc7679cfc04e2f19bf0387e41cce86d504212ff 100644 (file)
@@ -172,7 +172,7 @@ bool ModuleBase_WidgetDoubleValue::storeValueCustom()
       // Nullyfy the parameter reference without deletion of the created
       myParameter = FeaturePtr();
     }
-    aReal->setText(aText.toStdString());
+    aReal->setText(aText.toStdWString());
   } else {
     // it is important to set the empty text value to the attribute before set the value
     // because setValue tries to calculate the attribute value according to the
@@ -181,7 +181,7 @@ bool ModuleBase_WidgetDoubleValue::storeValueCustom()
       aReal->setExpressionError("");
       aReal->setExpressionInvalid(false);
     }
-    aReal->setText("");
+    aReal->setText(L"");
     aReal->setValue(mySpinBox->value());
   }
   updateObject(myFeature);
@@ -192,9 +192,9 @@ bool ModuleBase_WidgetDoubleValue::restoreValueCustom()
 {
   DataPtr aData = myFeature->data();
   AttributeDoublePtr aRef = aData->real(attributeID());
-  std::string aTextRepr = aRef->text();
+  std::wstring aTextRepr = aRef->text();
   if (!aTextRepr.empty()) {
-    QString aText = QString::fromStdString(aTextRepr);
+    QString aText = QString::fromStdWString(aTextRepr);
     ModuleBase_Tools::setSpinText(mySpinBox, aText);
   }
   else {
index e70a75f1574d0ec9f0e5fce3c7fbd968a9f861be..3050e10e8228df8ecd195abdbce979bd4cf56bce 100644 (file)
@@ -20,6 +20,8 @@
 #include <ModuleBase_WidgetExprEditor.h>
 #include <ModuleBase_Tools.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Validator.h>
@@ -268,7 +270,7 @@ bool ModuleBase_WidgetExprEditor::storeValueCustom()
   AttributeStringPtr aStringAttr = aData->string(attributeID());
 
   QString aWidgetValue = myEditor->toPlainText();
-  aStringAttr->setValue(aWidgetValue.toStdString());
+  aStringAttr->setValue(aWidgetValue.toStdWString());
   updateObject(myFeature);
 
   // Try to get the value
@@ -303,8 +305,12 @@ bool ModuleBase_WidgetExprEditor::restoreValueCustom()
   bool isBlocked = myEditor->blockSignals(true);
   QTextCursor aCursor = myEditor->textCursor();
   int pos = aCursor.position();
-  std::string aRestoredStr = aStringAttr->value();
-  myEditor->setPlainText(QString::fromStdString(aRestoredStr));
+  QString aRestoredStr;
+  if (aStringAttr->isUValue())
+    aRestoredStr = QString::fromStdWString(Locale::Convert::toWString(aStringAttr->valueU()));
+  else
+    aRestoredStr = QString::fromStdString(aStringAttr->value());
+  myEditor->setPlainText(aRestoredStr);
   aCursor.setPosition(pos);
   myEditor->setTextCursor(aCursor);
   myEditor->blockSignals(isBlocked);
index 81dffa9ee2d794caef8b33bab472455e96d093f8..7922ecae14a5538e6154a860e22d217813e902d2 100644 (file)
@@ -160,7 +160,7 @@ bool ModuleBase_WidgetIntValue::storeValueCustom()
       // Nullyfy the parameter reference without deletion of the created
       myParameter = FeaturePtr();
     }
-    anAttribute->setText(aText.toStdString());
+    anAttribute->setText(aText.toStdWString());
   } else {
     // it is important to set the empty text value to the attribute before set the value
     // because setValue tries to calculate the attribute value according to the
@@ -169,7 +169,7 @@ bool ModuleBase_WidgetIntValue::storeValueCustom()
       anAttribute->setExpressionError("");
       anAttribute->setExpressionInvalid(false);
     }
-    anAttribute->setText("");
+    anAttribute->setText(L"");
     anAttribute->setValue(mySpinBox->value());
   }
   updateObject(myFeature);
@@ -180,9 +180,9 @@ bool ModuleBase_WidgetIntValue::restoreValueCustom()
 {
   DataPtr aData = myFeature->data();
   AttributeIntegerPtr anAttribute = aData->integer(attributeID());
-  std::string aTextRepr = anAttribute->text();
+  std::wstring aTextRepr = anAttribute->text();
   if (!aTextRepr.empty()) {
-    QString aText = QString::fromStdString(aTextRepr);
+    QString aText = QString::fromStdWString(aTextRepr);
     //if (aText.endsWith('=')) {
     //  if (!myParameter.get()) {
     //    QString aName = aText.left(aText.indexOf('=')).trimmed();
index 70d19c65db39e63b71dd633a8ea04444f6b74148..a2025b6f598667a4f5a42c38dc5ef7adac80aac4 100644 (file)
@@ -21,6 +21,8 @@
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_IconFactory.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
@@ -124,7 +126,7 @@ bool ModuleBase_WidgetLineEdit::storeValueCustom()
   DataPtr aData = myFeature->data();
   AttributeStringPtr aStringAttr = aData->string(attributeID());
   QString aWidgetValue = myLineEdit->text();
-  aStringAttr->setValue(aWidgetValue.toStdString());
+  aStringAttr->setValue(aWidgetValue.toStdWString());
   updateObject(myFeature);
   return true;
 }
@@ -138,7 +140,12 @@ bool ModuleBase_WidgetLineEdit::restoreValueCustom()
   AttributeStringPtr aStringAttr = aData->string(attributeID());
 
   bool isBlocked = myLineEdit->blockSignals(true);
-  myLineEdit->setText(QString::fromStdString(aStringAttr->value()));
+  QString aText;
+  if (aStringAttr->isUValue())
+    aText = QString::fromStdWString(Locale::Convert::toWString(aStringAttr->valueU()));
+  else
+    aText = QString::fromStdString(aStringAttr->value());
+  myLineEdit->setText(aText);
   myLineEdit->blockSignals(isBlocked);
 
   return true;
index 8b8d85e3e224cbbaf98bb1a663fd9255a2b5d29e..860cf15ae1735a97777cb83da9f9d10bf4b84357 100644 (file)
@@ -34,7 +34,7 @@
 #include <QLabel>
 
 
-#define ERR_STRING "ERROR"
+#define ERR_STRING L"ERROR"
 
 ModuleBase_WidgetPointInput::ModuleBase_WidgetPointInput(QWidget* theParent,
   ModuleBase_IWorkshop* theWorkshop,
@@ -103,7 +103,7 @@ QList<QWidget*> ModuleBase_WidgetPointInput::getControls() const
   return aList;
 }
 
-std::string getParmText(ModuleBase_ParamSpinBox* theSpin, FeaturePtr& theParam)
+std::wstring getParmText(ModuleBase_ParamSpinBox* theSpin, FeaturePtr& theParam)
 {
   QString aText = theSpin->text();
   if (aText.contains('=')) {
@@ -118,7 +118,7 @@ std::string getParmText(ModuleBase_ParamSpinBox* theSpin, FeaturePtr& theParam)
     }
     aText = aText.split('=').at(0);
   }
-  return aText.toStdString();
+  return aText.toStdWString();
 }
 
 //********************************************************************
@@ -128,21 +128,21 @@ bool ModuleBase_WidgetPointInput::storeValueCustom()
   if (aAttr.get()) {
     if (aAttr->isInitialized()) {
       if (myXSpin->hasVariable() || myYSpin->hasVariable() || myZSpin->hasVariable()) {
-        std::string aXText = getParmText(myXSpin, myXParam);
+        std::wstring aXText = getParmText(myXSpin, myXParam);
         if (aXText == ERR_STRING) {
           aAttr->setExpressionError(0, "Parameter cannot be created");
           aAttr->setExpressionInvalid(0, true);
           updateObject(myFeature);
           return false;
         }
-        std::string aYText = getParmText(myYSpin, myYParam);
+        std::wstring aYText = getParmText(myYSpin, myYParam);
         if (aYText == ERR_STRING) {
           aAttr->setExpressionError(1, "Parameter cannot be created");
           aAttr->setExpressionInvalid(1, true);
           updateObject(myFeature);
           return false;
         }
-        std::string aZText = getParmText(myZSpin, myZParam);
+        std::wstring aZText = getParmText(myZSpin, myZParam);
         if (aZText == ERR_STRING) {
           aAttr->setExpressionError(2, "Parameter cannot be created");
           aAttr->setExpressionInvalid(2, true);
@@ -151,7 +151,7 @@ bool ModuleBase_WidgetPointInput::storeValueCustom()
         }
         aAttr->setText(aXText, aYText, aZText);
       } else {
-        aAttr->setText("", "", "");
+        aAttr->setText(L"", L"", L"");
         aAttr->setValue(myXSpin->value(), myYSpin->value(), myZSpin->value());
       }
     } else {
@@ -169,26 +169,26 @@ bool ModuleBase_WidgetPointInput::restoreValueCustom()
   AttributePointPtr aAttr = std::dynamic_pointer_cast<GeomDataAPI_Point>(attribute());
   if (aAttr.get()) {
     if (aAttr->isInitialized()) {
-      std::string aXText = aAttr->textX();
+      std::wstring aXText = aAttr->textX();
       if (aXText.empty()) {
         myXSpin->setValue(aAttr->x());
       }
       else {
-        myXSpin->setText(aXText.c_str());
+        myXSpin->setText(QString::fromStdWString(aXText));
       }
-      std::string aYText = aAttr->textY();
+      std::wstring aYText = aAttr->textY();
       if (aYText.empty()) {
         myYSpin->setValue(aAttr->y());
       }
       else {
-        myYSpin->setText(aYText.c_str());
+        myYSpin->setText(QString::fromStdWString(aYText));
       }
-      std::string aZText = aAttr->textZ();
+      std::wstring aZText = aAttr->textZ();
       if (aZText.empty()) {
         myZSpin->setValue(aAttr->z());
       }
       else {
-        myZSpin->setText(aZText.c_str());
+        myZSpin->setText(QString::fromStdWString(aZText));
       }
     }
     else {
index 56cefb18287f12da86e9edb2854d12af73e2ce2b..5dc61ed52da5f132000cb37da68e8dbc16c2a9ec 100644 (file)
 //------------------------------------------------------------------------------
 // Tools
 
-static std::string toStdString(double theValue)
+static std::wstring toStdWString(double theValue)
 {
-  std::ostringstream sstream;
+  std::wostringstream sstream;
   sstream << theValue;
-  size_t aPos = sstream.str().find(".");
-  std::string aPnt = "";
-  if (aPos == std::string::npos)
-    aPnt = ".";
+  size_t aPos = sstream.str().find(L".");
+  std::wstring aPnt = L"";
+  if (aPos == std::wstring::npos)
+    aPnt = L".";
   return sstream.str() + aPnt;
 }
 
@@ -97,12 +97,12 @@ void ParametersPlugin_EvalListener::processEvent(
   }
 }
 
-std::string ParametersPlugin_EvalListener::renameInPythonExpression(
-    const std::string& theExpression,
-    const std::string& theOldName,
-    const std::string& theNewName)
+std::wstring ParametersPlugin_EvalListener::renameInPythonExpression(
+    const std::wstring& theExpression,
+    const std::wstring& theOldName,
+    const std::wstring& theNewName)
 {
-  std::string anExpressionString = theExpression;
+  std::wstring anExpressionString = theExpression;
 
   // ask interpreter to compute the positions in the expression
   std::shared_ptr<ModelAPI_ComputePositionsMessage> aMsg =
@@ -124,7 +124,7 @@ std::string ParametersPlugin_EvalListener::renameInPythonExpression(
     int aLineNo = ritLine->first - 1;
     size_t aLineStart = 0;
     for (int i = 0; i < aLineNo; ++i)
-      aLineStart = anExpressionString.find("\n", aLineStart) + 1;
+      aLineStart = anExpressionString.find(L"\n", aLineStart) + 1;
 
     const std::list<int>& aColOffsets = ritLine->second;
     std::list<int>::const_reverse_iterator ritOffset = aColOffsets.rbegin();
@@ -139,13 +139,15 @@ std::string ParametersPlugin_EvalListener::renameInPythonExpression(
 
 void ParametersPlugin_EvalListener::renameInParameter(
     std::shared_ptr<ParametersPlugin_Parameter> theParameter,
-    const std::string& theOldName,
-    const std::string& theNewName)
+    const std::wstring& theOldName,
+    const std::wstring& theNewName)
 {
   std::shared_ptr<ModelAPI_AttributeString> anExpressionAttribute =
       theParameter->string(ParametersPlugin_Parameter::EXPRESSION_ID());
 
-  std::string anExpressionString = anExpressionAttribute->value();
+  std::wstring anExpressionString = anExpressionAttribute->isUValue() ?
+      Locale::Convert::toWString(anExpressionAttribute->valueU()) :
+      Locale::Convert::toWString(anExpressionAttribute->value());
   anExpressionString = renameInPythonExpression(anExpressionString,
                                                 theOldName,
                                                 theNewName);
@@ -158,13 +160,13 @@ void ParametersPlugin_EvalListener::renameInParameter(
 
 void ParametersPlugin_EvalListener::renameInAttribute(
     std::shared_ptr<ModelAPI_Attribute> theAttribute,
-    const std::string& theOldName,
-    const std::string& theNewName)
+    const std::wstring& theOldName,
+    const std::wstring& theNewName)
 {
   if (theAttribute->attributeType() == ModelAPI_AttributeInteger::typeId()) {
     AttributeIntegerPtr anAttribute =
         std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(theAttribute);
-    std::string anExpressionString = anAttribute->text();
+    std::wstring anExpressionString = anAttribute->text();
     anExpressionString = renameInPythonExpression(anExpressionString,
                                                   theOldName, theNewName);
     anAttribute->setText(anExpressionString);
@@ -172,7 +174,7 @@ void ParametersPlugin_EvalListener::renameInAttribute(
   if (theAttribute->attributeType() == ModelAPI_AttributeDouble::typeId()) {
     AttributeDoublePtr anAttribute =
         std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
-    std::string anExpressionString = anAttribute->text();
+    std::wstring anExpressionString = anAttribute->text();
     anExpressionString = renameInPythonExpression(anExpressionString,
                                                   theOldName, theNewName);
     anAttribute->setText(anExpressionString);
@@ -180,7 +182,7 @@ void ParametersPlugin_EvalListener::renameInAttribute(
   if (theAttribute->attributeType() == GeomDataAPI_Point::typeId()) {
     AttributePointPtr anAttribute =
         std::dynamic_pointer_cast<GeomDataAPI_Point>(theAttribute);
-    std::string anExpressionString[3] = {
+    std::wstring anExpressionString[3] = {
       anAttribute->textX(),
       anAttribute->textY(),
       anAttribute->textZ()
@@ -195,7 +197,7 @@ void ParametersPlugin_EvalListener::renameInAttribute(
   if (theAttribute->attributeType() == GeomDataAPI_Point2D::typeId()) {
     AttributePoint2DPtr anAttribute =
         std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theAttribute);
-    std::string anExpressionString[2] = {
+    std::wstring anExpressionString[2] = {
       anAttribute->textX(),
       anAttribute->textY()
     };
@@ -209,8 +211,8 @@ void ParametersPlugin_EvalListener::renameInAttribute(
 
 void ParametersPlugin_EvalListener::renameInDependents(
               std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
-              const std::string& theOldName,
-              const std::string& theNewName)
+              const std::wstring& theOldName,
+              const std::wstring& theNewName)
 {
   std::set<std::shared_ptr<ModelAPI_Attribute> > anAttributes =
     theResultParameter->data()->refsToMe();
@@ -302,19 +304,18 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent(
   if (!isValidAttribute(aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID()))) {
     //setParameterName(aResultParameter, aMessage->oldName());
     if (myOldNames.find(aParameter.get()) == myOldNames.end())
-      myOldNames[aParameter.get()] = Locale::Convert::toString(aMessage->oldName());
+      myOldNames[aParameter.get()] = aMessage->oldName();
     return;
   }
 
-  std::string anOldName = Locale::Convert::toString(aMessage->oldName());
+  std::wstring anOldName = aMessage->oldName();
   if (myOldNames.find(aParameter.get()) != myOldNames.end()) {
     anOldName = myOldNames[aParameter.get()];
     myOldNames.erase(aParameter.get());
     aParameter->execute(); // to enable result because of previously incorrect name
   }
 
-  renameInDependents(aResultParameter, anOldName,
-                     Locale::Convert::toString(aMessage->newName()));
+  renameInDependents(aResultParameter, anOldName, aMessage->newName());
 }
 
 void ParametersPlugin_EvalListener::processReplaceParameterEvent(
@@ -337,9 +338,7 @@ void ParametersPlugin_EvalListener::processReplaceParameterEvent(
     return;
 
   double aRealValue = aResultParameter->data()->real(ModelAPI_ResultParameter::VALUE())->value();
-  std::string aValue = toStdString(aRealValue);
+  std::wstring aValue = toStdWString(aRealValue);
 
-  renameInDependents(aResultParameter,
-                     Locale::Convert::toString(aResultParameter->data()->name()),
-                     aValue);
+  renameInDependents(aResultParameter, aResultParameter->data()->name(), aValue);
 }
index f12c5cef149689bc98898566abaa392ff8b2c09e..089fba80feb9b1ed91518f69cc48d6500ca6112c 100644 (file)
@@ -38,7 +38,7 @@ class ParametersPlugin_EvalListener : public Events_Listener
 {
   /// map of old names, that were valid for perameres, but now parameter name is changed to invalid
   /// stored not shared pointers to features to avoid memory keeping on the feature delete
-  std::map<ParametersPlugin_Parameter*, std::string> myOldNames;
+  std::map<ParametersPlugin_Parameter*, std::wstring> myOldNames;
  public:
   PARAMETERSPLUGIN_EXPORT ParametersPlugin_EvalListener();
   PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_EvalListener();
@@ -54,21 +54,21 @@ class ParametersPlugin_EvalListener : public Events_Listener
   void processReplaceParameterEvent(const std::shared_ptr<Events_Message>& theMessage);
 
   /// Renames theOldName in theExpression by theNewName.
-  std::string renameInPythonExpression(const std::string& theExpression,
-                                       const std::string& theOldName,
-                                       const std::string& theNewName);
+  std::wstring renameInPythonExpression(const std::wstring& theExpression,
+                                        const std::wstring& theOldName,
+                                        const std::wstring& theNewName);
   /// Renames theOldName in the expression attribute of theParameter by theNewName.
   void renameInParameter(std::shared_ptr<ParametersPlugin_Parameter> theParameter,
-                         const std::string& theOldName,
-                         const std::string& theNewName);
+                         const std::wstring& theOldName,
+                         const std::wstring& theNewName);
   /// Renames theOldName in the text fields of theAttribute by theNewName.
   void renameInAttribute(std::shared_ptr<ModelAPI_Attribute> theAttribute,
-                         const std::string& theOldName,
-                         const std::string& theNewName);
+                         const std::wstring& theOldName,
+                         const std::wstring& theNewName);
   /// Renames theOldName in all dependents of theResultParameter by theNewName.
   void renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
-                          const std::string& theOldName,
-                          const std::string& theNewName);
+                          const std::wstring& theOldName,
+                          const std::wstring& theNewName);
 };
 
 #endif /* SRC_PARAMETERSPLUGIN_PARAMETERSPLUGIN_EVALLISTENER_H_ */
index 02010379877b7221d700704b4e4ef1de3aa1f0ba..c7b6bd76327b921a32a9fbb066a340f95eaafc5d 100644 (file)
@@ -75,12 +75,14 @@ void ParametersPlugin_Parameter::attributeChanged(const std::string& theID)
 
 void ParametersPlugin_Parameter::updateName()
 {
-  std::string aName = string(VARIABLE_ID())->value();
-  data()->setName(Locale::Convert::toWString(aName));
+  std::wstring aName = string(VARIABLE_ID())->isUValue() ?
+      Locale::Convert::toWString(string(VARIABLE_ID())->valueU()) :
+      Locale::Convert::toWString(string(VARIABLE_ID())->value());
+  data()->setName(aName);
 
   ResultParameterPtr aParam = document()->createParameter(data());
-  std::string anOldName = Locale::Convert::toString(aParam->data()->name());
-  aParam->data()->setName(Locale::Convert::toWString(aName));
+  std::wstring anOldName = aParam->data()->name();
+  aParam->data()->setName(aName);
   setResult(aParam);
 
 
@@ -88,12 +90,12 @@ void ParametersPlugin_Parameter::updateName()
   // update the depended expressions
   DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
   if (aParam->document() != aRootDoc) {
-    std::list<std::string> aNames; // collect names in the root document that must be checked
+    std::list<std::wstring> aNames; // collect names in the root document that must be checked
     aNames.push_back(aName);
     if (anOldName != aName) {
       aNames.push_back(anOldName);
     }
-    std::list<std::string>::iterator aNIter = aNames.begin();
+    std::list<std::wstring>::iterator aNIter = aNames.begin();
     for (; aNIter != aNames.end(); aNIter++) {
       double aValue;
       ResultParameterPtr aRootParam;
@@ -115,7 +117,9 @@ void ParametersPlugin_Parameter::updateName()
 
 bool ParametersPlugin_Parameter::updateExpression()
 {
-  std::string anExpression = string(EXPRESSION_ID())->value();
+  std::wstring anExpression = string(EXPRESSION_ID())->isUValue() ?
+      Locale::Convert::toWString(string(EXPRESSION_ID())->valueU()) :
+      Locale::Convert::toWString(string(EXPRESSION_ID())->value());
 
   std::string outErrorMessage;
   double aValue = evaluate(anExpression, outErrorMessage);
@@ -139,7 +143,7 @@ void ParametersPlugin_Parameter::execute()
     setError("Expression error.", false);
 }
 
-double ParametersPlugin_Parameter::evaluate(const std::string& /*theExpression*/,
+double ParametersPlugin_Parameter::evaluate(const std::wstring& /*theExpression*/,
                                             std::string& theError)
 {
   FeaturePtr aMyPtr = std::dynamic_pointer_cast<ModelAPI_Feature>(data()->owner());
index bc4d92e47d134fd02aa5dcdc246da7f0a3335f74..1875e46c1abc9287bc82b9021aefef33abcfe7c0 100644 (file)
@@ -100,7 +100,7 @@ class ParametersPlugin_Parameter : public ModelAPI_Feature
 
  protected:
   /// Evaluates theExpression and returns its value.
-  double evaluate(const std::string& theExpression, std::string& theError);
+  double evaluate(const std::wstring& theExpression, std::string& theError);
   /// Updates name of the parameter
   void updateName();
   /// Updates expression of the parameter
index e85dc9a3521ccb8d84c44b58f06b265585576ee6..1d7c377614b1ae42728c5eaee379ee7b9a4f9c89 100644 (file)
@@ -391,21 +391,22 @@ QList<QStringList> ParametersPlugin_WidgetParamsMgr::
             if (aId == ModelAPI_AttributeDouble::typeId()) {
               AttributeDoublePtr aDouble =
                 std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aAttr);
-              aValNames << aDouble->text().c_str();
+              aValNames << QString::fromStdWString(aDouble->text());
               aValNames << QString::number(aDouble->value());
             }
             else if (aId == ModelAPI_AttributeInteger::typeId()) {
               AttributeIntegerPtr aInt =
                 std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(aAttr);
-              aValNames << aInt->text().c_str();
+              aValNames << QString::fromStdWString(aInt->text());
               aValNames << QString::number(aInt->value());
             }
             else if (aId == GeomDataAPI_Point::typeId()) {
               std::shared_ptr<GeomDataAPI_Point> aPnt =
                 std::dynamic_pointer_cast<GeomDataAPI_Point>(aAttr);
 
-              QString aExpr = QString("%1,%2,%3").arg(aPnt->textX().c_str()).
-                arg(aPnt->textY().c_str()).arg(aPnt->textZ().c_str());
+              QString aExpr = QString("%1,%2,%3").arg(QString::fromStdWString(aPnt->textX())).
+                                                  arg(QString::fromStdWString(aPnt->textY())).
+                                                  arg(QString::fromStdWString(aPnt->textZ()));
               aValNames << aExpr;
 
               QString aRes = QString("%1,%2,%3").arg(aPnt->x()).arg(aPnt->y()).arg(aPnt->z());
@@ -415,8 +416,8 @@ QList<QStringList> ParametersPlugin_WidgetParamsMgr::
               std::shared_ptr<GeomDataAPI_Point2D> aPnt =
                 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);
 
-              QString aExpr = QString("%1,%2").arg(aPnt->textX().c_str()).
-                arg(aPnt->textY().c_str());
+              QString aExpr = QString("%1,%2").arg(QString::fromStdWString(aPnt->textX())).
+                                               arg(QString::fromStdWString(aPnt->textY()));
               aValNames << aExpr;
 
               QString aRes = QString("%1,%2").arg(aPnt->x()).arg(aPnt->y());
index d8b7d5bca4475f1faa4f5262f92c0273fd3e46b0..20c25e9cd553f29ec8b41af0c05d49a77a18e677 100644 (file)
@@ -28,6 +28,8 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
+#include <Locale_Convert.h>
+
 #include <GeomDataAPI_Point2D.h>
 
 #include <GeomAPI_Angle2d.h>
@@ -322,38 +324,38 @@ double SketchPlugin_ConstraintAngle::getAngleForType(double theAngle,
 }
 
 #if !HAVE_WORKING_REGEX
-static bool parseString(const std::string& theString, std::ostringstream* theResult)
+static bool parseString(const std::wstring& theString, std::wostringstream* theResult)
 {
   // skip leading spaces
   size_t aLength = theString.size();
-  size_t aPos = theString.find_first_not_of(' ');
-  if (aPos == std::string::npos)
+  size_t aPos = theString.find_first_not_of(L' ');
+  if (aPos == std::wstring::npos)
     return false;
   // first should be a value
-  if (theString[aPos] == '-' || theString[aPos] == '+')
+  if (theString[aPos] == L'-' || theString[aPos] == L'+')
     theResult[1] << theString[aPos++];
-  while (aPos < aLength && theString[aPos] >= '0' && theString[aPos] <= '9')
+  while (aPos < aLength && theString[aPos] >= L'0' && theString[aPos] <= L'9')
     theResult[1] << theString[aPos++];
-  if (theString[aPos] != ' ') {
-    if (theString[aPos] != '.')
+  if (theString[aPos] != L' ') {
+    if (theString[aPos] != L'.')
       return false;
     theResult[1] << theString[aPos++];
-    while (aPos < aLength && theString[aPos] >= '0' && theString[aPos] <= '9')
+    while (aPos < aLength && theString[aPos] >= L'0' && theString[aPos] <= L'9')
       theResult[1] << theString[aPos++];
   }
 
   // next, find the sign
-  aPos = theString.find_first_not_of(' ', aPos);
-  if (aPos == std::string::npos)
+  aPos = theString.find_first_not_of(L' ', aPos);
+  if (aPos == std::wstring::npos)
     return false;
-  if (theString[aPos] == '-' || theString[aPos] == '+')
+  if (theString[aPos] == L'-' || theString[aPos] == L'+')
     theResult[2] << theString[aPos++];
 
   // a variable should be at the end
-  aPos = theString.find_first_not_of(' ', aPos);
-  if (aPos == std::string::npos)
+  aPos = theString.find_first_not_of(L' ', aPos);
+  if (aPos == std::wstring::npos)
     return false;
-  if (theString[aPos] != '(' || theString.back() != ')')
+  if (theString[aPos] != L'(' || theString.back() != L')')
     return false;
   theResult[3] << theString.substr(aPos + 1, aLength - aPos - 2);
 
@@ -376,25 +378,25 @@ static void convertAngle(AttributeDoublePtr theAngle,
     }
     else {
       // process the parametric value
-      std::string anAngleText = theAngle->text();
+      std::wstring anAngleText = theAngle->text();
 #if HAVE_WORKING_REGEX
-      std::regex anAngleRegex("\\s*([-+]?[0-9]*\\.?[0-9]*)\\s*([-+])\\s*\\((.*)\\)$",
-                              std::regex_constants::ECMAScript);
+      std::wregex anAngleRegex(L"\\s*([-+]?[0-9]*\\.?[0-9]*)\\s*([-+])\\s*\\((.*)\\)$",
+                               std::regex_constants::ECMAScript);
 #endif
 
       double anAnglePrefix = 0.0;
-      static const char aSignPrefix[2] = { '-', '+' };
+      static const wchar_t aSignPrefix[2] = { L'-', L'+' };
       int aSignInd = 1;
 
 #if HAVE_WORKING_REGEX
-      std::smatch aResult;
+      std::wsmatch aResult;
       if (std::regex_search(anAngleText, aResult, anAngleRegex)) {
 #else
       // workaround to support old versions of GCC (less than 4.9)
-      std::ostringstream aResult[4];
+      std::wostringstream aResult[4];
       if (parseString(anAngleText, aResult)) {
 #endif
-        anAnglePrefix = std::atof(aResult[1].str().c_str());
+        anAnglePrefix = std::atof(Locale::Convert::toString(aResult[1].str()).c_str());
         aSignInd = aResult[2].str()[0] == aSignPrefix[0] ? 0 : 1;
         anAngleText = aResult[3].str();
       }
@@ -407,15 +409,15 @@ static void convertAngle(AttributeDoublePtr theAngle,
         aSignInd = 1 - aSignInd;
       anAnglePrefix = angleForType(anAnglePrefix, theNewType);
 
-      std::ostringstream aText;
+      std::wostringstream aText;
       bool isPrintSign = true;
       if (fabs(anAnglePrefix) > tolerance)
         aText << anAnglePrefix;
       else
         isPrintSign = aSignInd == 0;
       if (isPrintSign)
-        aText << " " << aSignPrefix[aSignInd] << " (";
-      aText << anAngleText << (isPrintSign ? ")" : "");
+        aText << L" " << aSignPrefix[aSignInd] << L" (";
+      aText << anAngleText << (isPrintSign ? L")" : L"");
       theAngle->setText(aText.str());
     }
   }
index 54f6805ba73abf53dc5005228db23b543b06066b..f4281991921b6c78589dde6ec7f2f8555553fc72 100644 (file)
@@ -385,7 +385,7 @@ FeaturePtr SketchPlugin_Fillet::createFilletApex(const GeomPnt2dPtr& theCoordina
 
 struct Length {
   AttributePtr myPoints[2];
-  std::string myValueText;
+  std::wstring myValueText;
   double myValueDouble;
   GeomPnt2dPtr myFlyoutPoint;
   int myLocationType;
index 836071aae1bde7627e2242d87364cc3d990ba690..f6db08feccd65c9eaf8ed9172d515b151bd61018 100644 (file)
@@ -65,17 +65,17 @@ namespace SketchPlugin_Tools {
 
 void clearExpressions(AttributeDoublePtr theAttribute)
 {
-  theAttribute->setText(std::string());
+  theAttribute->setText(std::wstring());
 }
 
 void clearExpressions(AttributePointPtr theAttribute)
 {
-  theAttribute->setText(std::string(), std::string(), std::string());
+  theAttribute->setText(std::wstring(), std::wstring(), std::wstring());
 }
 
 void clearExpressions(AttributePoint2DPtr theAttribute)
 {
-  theAttribute->setText(std::string(), std::string());
+  theAttribute->setText(std::wstring(), std::wstring());
 }
 
 void clearExpressions(AttributePtr theAttribute)
index 8a123c733f78bdc00e018658afe14e8d04e993f1..b8fde5065c784ebb44ed2a7c348d770e290c413d 100644 (file)
@@ -44,7 +44,7 @@ SET(PROJECT_HEADERS
     SketcherPrs_Mirror.h
     SketcherPrs_Transformation.h
     SketcherPrs_Angle.h
-       SketcherPrs_Offset.h
+    SketcherPrs_Offset.h
 )
 
 SET(PROJECT_SOURCES
@@ -68,7 +68,7 @@ SET(PROJECT_SOURCES
     SketcherPrs_Mirror.cpp
     SketcherPrs_Transformation.cpp
     SketcherPrs_Angle.cpp
-       SketcherPrs_Offset.cpp
+    SketcherPrs_Offset.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -78,6 +78,7 @@ SET(PROJECT_LIBRARIES
     GeomAPI
     GeomDataAPI
     Events
+    Locale
     ${OpenCASCADE_FoundationClasses_LIBRARIES}
     ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
     ${OpenCASCADE_Visualization_LIBRARIES}
@@ -117,6 +118,7 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/ModelGeomAlgo
   ${PROJECT_SOURCE_DIR}/src/GeomAPI
   ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+  ${PROJECT_SOURCE_DIR}/src/Locale
   ${PROJECT_SOURCE_DIR}/src/SketchPlugin
   ${OpenCASCADE_INCLUDE_DIR}
   ${FREETYPE_INCLUDE_DIRS}
index d79b2571d03104b9babb595d87e0c1cdea9da5c2..90444ba5d96f6d601d9a3a427a408859d6216068 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <Events_Loop.h>
 
+#include <Locale_Convert.h>
+
 #include <AIS_Dimension.hxx>
 #include <TCollection_ExtendedString.hxx>
 
@@ -49,7 +51,7 @@ void SketcherPrs_DimensionStyle::DimensionValue::init(
 {
   myDoubleValue = theAttributeValue->value();
   myHasParameters = theAttributeValue->usedParameters().size() > 0;
-  myTextValue = theAttributeValue->text();
+  myTextValue = Locale::Convert::toString(theAttributeValue->text());
 }
 
 SketcherPrs_DimensionStyle::SketcherPrs_DimensionStyle()
index 4ca26b798ef4d8bfc41a36657ed1bbb6f108617d..96fa5f4b806f478ff780aabe2149bfbf931ef1e7 100644 (file)
@@ -194,7 +194,7 @@ bool canRename(const ObjectPtr& theObject, const QString& theName)
     double aValue;
     ResultParameterPtr aParam;
     if (ModelAPI_Tools::findVariable(theObject->document(),
-          FeaturePtr(), qPrintable(theName), aValue, aParam)) {
+          FeaturePtr(), theName.toStdWString(), aValue, aParam)) {
       const char* aKeyStr = "Selected parameter can not be renamed to: %1. "
                             "There is a parameter with the same name. Its value is: %2.";
       QString aErrMsg(QObject::tr(aKeyStr).arg(theName).arg(aValue));