]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task #3237: Allow usage of accented characters in ObjectBrowser
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 29 Jun 2020 12:53:57 +0000 (15:53 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 29 Jun 2020 12:53:57 +0000 (15:53 +0300)
Move string conversion to the separate package.

45 files changed:
CMakeLists.txt
src/Events/CMakeLists.txt
src/Events/Events_InfoMessage.cpp
src/ExchangePlugin/CMakeLists.txt
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/ExchangePlugin/ExchangePlugin_Import.cpp
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ImportPart.cpp
src/Locale/CMakeLists.txt [new file with mode: 0644]
src/Locale/Locale_Convert.cpp [new file with mode: 0644]
src/Locale/Locale_Convert.h [new file with mode: 0644]
src/Locale/Locale_def.h [new file with mode: 0644]
src/Model/CMakeLists.txt
src/Model/Model_Application.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_BodyBuilder.cpp
src/Model/Model_Data.cpp
src/Model/Model_Document.cpp
src/Model/Model_Objects.cpp
src/Model/Model_ResultField.cpp
src/Model/Model_ResultPart.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h
src/ModelHighAPI/CMakeLists.txt
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp
src/ModelHighAPI/ModelHighAPI_Tools.cpp
src/ParametersPlugin/CMakeLists.txt
src/ParametersPlugin/ParametersPlugin_EvalListener.cpp
src/ParametersPlugin/ParametersPlugin_Parameter.cpp
src/ParametersPlugin/ParametersPlugin_Validators.cpp
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Validators.cpp
src/Selector/CMakeLists.txt
src/Selector/Selector_Modify.cpp
src/Selector/Selector_Primitive.cpp
src/SketchAPI/CMakeLists.txt
src/SketchAPI/SketchAPI_BSpline.cpp
src/SketchAPI/SketchAPI_Ellipse.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_MacroBSpline.cpp
src/SketchPlugin/SketchPlugin_Split.cpp
src/SketchPlugin/SketchPlugin_Tools.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp

index 1b7e24ed3227ac9502f5785083b7225102043984..6ac77169ebeb36ddf3ec2ab95ce0e33ddf26f9c7 100644 (file)
@@ -126,6 +126,7 @@ SET(MAKE_TRANSLATION YES)
 
     ADD_DEFINITIONS( -DMAKE_TRANSLATION )
 ADD_SUBDIRECTORY (src/Config)
+ADD_SUBDIRECTORY (src/Locale)
 ADD_SUBDIRECTORY (src/Events)
 ADD_SUBDIRECTORY (src/Selector)
 ADD_SUBDIRECTORY (src/Model)
index 1fd4485debc759d6d61e0b1a0e115c19f4ec607e..b01d4055964b89bd64e35804a5108f57d563ba73 100644 (file)
@@ -41,6 +41,10 @@ SET(PROJECT_SOURCES
     Events_InfoMessage.cpp
 )
 
+SET(PROJECT_LIBRARIES
+    Locale
+)
+
 ADD_DEFINITIONS(-DEVENTS_EXPORTS)
 ADD_LIBRARY(Events SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
 
@@ -50,6 +54,7 @@ SET_SOURCE_FILES_PROPERTIES(Events.i PROPERTIES CPLUSPLUS ON)
 SET_SOURCE_FILES_PROPERTIES(Events.i PROPERTIES SWIG_DEFINITIONS "-shadow")
 
 INCLUDE_DIRECTORIES(
+    ../Locale
 )
 
 TARGET_LINK_LIBRARIES(Events ${PROJECT_LIBRARIES})
index ba26c145f734935d98e8bb31886a6e237f341eed..ee0483c2af09355aa1dd24b0e9b79efd980c05b7 100644 (file)
 //
 
 #include "Events_InfoMessage.h"
+#include <Locale_Convert.h>
 #include <sstream>
 
-// To support old types of GCC (less than 5.0), check the wide-string conversion is working
-#if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)  && \
-    (__cplusplus >= 201402L || !defined(__GLIBCXX__)   || \
-    (defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE > 4))
-#define HAVE_WORKING_WIDESTRING 1
-#else
-#define HAVE_WORKING_WIDESTRING 0
-#endif
-
-#if HAVE_WORKING_WIDESTRING
-#include <codecvt>
-#endif
-
 void Events_InfoMessage::addParameter(double theParam)
 {
   std::stringstream aStream;
@@ -55,16 +43,6 @@ void Events_InfoMessage::send()
 
 Events_InfoMessage& Events_InfoMessage::arg(const std::wstring& theParam)
 {
-#if HAVE_WORKING_WIDESTRING
-  static std::wstring_convert<std::codecvt_utf8<wchar_t> > aConvertor;
-  addParameter(aConvertor.to_bytes(theParam));
-#else
-  char* aBuf = new char[2 * (theParam.size() + 1)];
-  size_t aNbChars = std::wcstombs(aBuf, theParam.c_str(), theParam.size());
-  if (aNbChars != (size_t)-1)
-    aBuf[aNbChars] = '\0';
-  addParameter(aBuf);
-  delete[] aBuf;
-#endif
+  addParameter(Locale::Convert::toString(theParam));
   return *this;
 }
index 30e5036e08c9f7e1656f0a249d57e8822f63be59..d35a2a6e4ee9de9b8c6b4d72211a4fa1035ab3b6 100644 (file)
@@ -22,6 +22,7 @@ INCLUDE(UnitTest)
 
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
                     ${PROJECT_SOURCE_DIR}/src/Config
+                    ${PROJECT_SOURCE_DIR}/src/Locale
                     ${PROJECT_SOURCE_DIR}/src/ModelAPI
                     ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
                     ${PROJECT_SOURCE_DIR}/src/GeomAPI
@@ -70,6 +71,7 @@ SET(TEXT_RESOURCES
 SET(PROJECT_LIBRARIES
     Events
     Config
+    Locale
     ModelAPI
     ModelHighAPI
     GeomAPI
index d27a170860c6b4eb80c99e6fbf8ae0a171090e31..a67e1bbe2de0a21e0bf40c6aac1076f88a7406e1 100644 (file)
@@ -41,6 +41,8 @@
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_Trsf.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_AttributeStringArray.h>
@@ -394,7 +396,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName)
   if (aGeometryName.empty() && aResults.size() == 1) {
     // get the name from the first result
     ResultPtr aResultBody = *aResults.begin();
-    aGeometryName = ModelAPI_Tools::toString(aResultBody->data()->name());
+    aGeometryName = Locale::Convert::toString(aResultBody->data()->name());
   }
 
   aXao.getGeometry()->setName(aGeometryName);
@@ -429,7 +431,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName)
       XAO::Dimension aGroupDimension = XAO::XaoUtils::stringToDimension(aDimensionString);
 
       XAO::Group* aXaoGroup = aXao.addGroup(aGroupDimension,
-        ModelAPI_Tools::toString(aResultGroup->data()->name()));
+        Locale::Convert::toString(aResultGroup->data()->name()));
 
       try {
         GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType);
@@ -448,7 +450,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName)
       } catch (XAO::XAO_Exception& e) {
         // LCOV_EXCL_START
         std::string msg = "An error occurred while exporting group " +
-          ModelAPI_Tools::toString(aResultGroup->data()->name());
+          Locale::Convert::toString(aResultGroup->data()->name());
         msg += ".\n";
         msg += e.what();
         msg += "\n";
@@ -485,7 +487,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName)
       XAO::Type aFieldType = XAO::XaoUtils::stringToFieldType(aTypeString);
 
       XAO::Field* aXaoField = aXao.addField(aFieldType, aFieldDimension, aTables->columns(),
-        ModelAPI_Tools::toString(aResultField->data()->name()));
+        Locale::Convert::toString(aResultField->data()->name()));
 
 
       try {
@@ -546,7 +548,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName)
       } catch (XAO::XAO_Exception& e) {
         // LCOV_EXCL_START
         std::string msg = "An error occurred while exporting field " +
-          ModelAPI_Tools::toString(aResultField->data()->name());
+          Locale::Convert::toString(aResultField->data()->name());
         msg += ".\n";
         msg += e.what();
         msg += "\n";
index f6d04041dfafa89f7b09dae8f670d75eca9f8a5e..ecaf3d821fddeb81db559a73d9bc6b24adb8b221 100644 (file)
@@ -20,6 +20,8 @@
 #include "ExchangePlugin_Import.h"
 #include "ExchangePlugin_ImportFeature.h"
 
+#include <Locale_Convert.h>
+
 #include <PartSetPlugin_Part.h>
 
 #include <ModelAPI_AttributeString.h>
@@ -101,7 +103,7 @@ void ExchangePlugin_Import::execute()
   SessionPtr aSession = ModelAPI_Session::get();
   DocumentPtr aDoc =
     findDocument(aSession->moduleDocument(),
-      ModelAPI_Tools::toWString(aPartsAttr->value(aTargetAttr->value())));
+      Locale::Convert::toWString(aPartsAttr->value(aTargetAttr->value())));
 
   if (aDoc.get()) {
     FeaturePtr aImportFeature = aDoc->addFeature(ExchangePlugin_ImportFeature::ID());
@@ -145,7 +147,7 @@ void ExchangePlugin_Import::attributeChanged(const std::string& theID)
       aPartsAttr->setSize((int)anAcceptedValues.size());
       std::list<std::wstring>::iterator anIt = anAcceptedValues.begin();
       for (int anInd = 0; anIt != anAcceptedValues.end(); ++anIt, ++anInd)
-        aPartsAttr->setValue(anInd, ModelAPI_Tools::toString(*anIt));
+        aPartsAttr->setValue(anInd, Locale::Convert::toString(*anIt));
     }
     else {
       // keep only the name of the current part
@@ -153,7 +155,7 @@ void ExchangePlugin_Import::attributeChanged(const std::string& theID)
         FeaturePtr aPartFeature = ModelAPI_Tools::findPartFeature(aSession->moduleDocument(), aDoc);
 
         aPartsAttr->setSize(1);
-        aPartsAttr->setValue(0, ModelAPI_Tools::toString(aPartFeature->name()));
+        aPartsAttr->setValue(0, Locale::Convert::toString(aPartFeature->name()));
         aTargetAttr->setValue(0);
       }
     }
index b2619119eb90d1715c436dfb58ce5982261135eb..278ebf4125a7d7a80e192965b3b7d4338c7c2ca8 100644 (file)
@@ -34,6 +34,8 @@
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_ShapeExplorer.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
@@ -138,7 +140,7 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
 
   // Pass the results into the model
   std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName);
-  data()->setName(ModelAPI_Tools::toWString(anObjectName));
+  data()->setName(Locale::Convert::toWString(anObjectName));
 
   setResult(createResultBody(aGeomShape));
 }
@@ -162,7 +164,7 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName)
   std::string aBodyName = aXaoGeometry->getName();
   if (aBodyName.empty())
     aBodyName = GeomAlgoAPI_Tools::File_Tools::name(theFileName);
-  data()->setName(ModelAPI_Tools::toWString(aBodyName));
+  data()->setName(Locale::Convert::toWString(aBodyName));
 
   ResultBodyPtr aResultBody = createResultBody(aGeomShape);
   setResult(aResultBody);
@@ -188,7 +190,7 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName)
 
     // group name
     if (!aXaoGroup->getName().empty())
-      aGroupFeature->data()->setName(ModelAPI_Tools::toWString(aXaoGroup->getName()));
+      aGroupFeature->data()->setName(Locale::Convert::toWString(aXaoGroup->getName()));
 
     // fill selection
     AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
@@ -218,7 +220,7 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName)
 
     // group name
     if (!aXaoField->getName().empty())
-      aFieldFeature->data()->setName(ModelAPI_Tools::toWString(aXaoField->getName()));
+      aFieldFeature->data()->setName(Locale::Convert::toWString(aXaoField->getName()));
 
     // fill selection
     AttributeSelectionListPtr aSelectionList = aFieldFeature->selectionList("selected");
index 2dfedff11beefb7b2954903bf60d5af3fc7a25f8..c0930ef872075a8d9eb9d319f0a25947d3c2a75b 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <ExchangePlugin_ImportPart.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_AttributeStringArray.h>
@@ -103,7 +105,7 @@ void ExchangePlugin_ImportPart::attributeChanged(const std::string& theID)
       for (std::list<FeaturePtr>::iterator aFIt = aSubFeatures.begin();
            aFIt != aSubFeatures.end(); ++aFIt) {
         if ((*aFIt)->getKind() == PartSetPlugin_Part::ID())
-          anAcceptedValues.push_back(ModelAPI_Tools::toString((*aFIt)->name()));
+          anAcceptedValues.push_back(Locale::Convert::toString((*aFIt)->name()));
       }
 
       if (aPartsAttr->size() != anAcceptedValues.size())
@@ -120,7 +122,7 @@ void ExchangePlugin_ImportPart::attributeChanged(const std::string& theID)
         FeaturePtr aPartFeature = ModelAPI_Tools::findPartFeature(aSession->moduleDocument(), aDoc);
 
         aPartsAttr->setSize(1);
-        aPartsAttr->setValue(0, ModelAPI_Tools::toString(aPartFeature->name()));
+        aPartsAttr->setValue(0, Locale::Convert::toString(aPartFeature->name()));
         aTargetAttr->setValue(0);
       }
     }
@@ -149,7 +151,7 @@ DocumentPtr findDocument(DocumentPtr thePartSetDoc, const std::string& thePartNa
       for (std::list<FeaturePtr>::iterator aFIt = aSubFeatures.begin();
            aFIt != aSubFeatures.end(); ++aFIt) {
         if ((*aFIt)->getKind() == PartSetPlugin_Part::ID() &&
-          ModelAPI_Tools::toString((*aFIt)->name()) == thePartName) {
+          Locale::Convert::toString((*aFIt)->name()) == thePartName) {
           aPartFeature = *aFIt;
           break;
         }
diff --git a/src/Locale/CMakeLists.txt b/src/Locale/CMakeLists.txt
new file mode 100644 (file)
index 0000000..aab6541
--- /dev/null
@@ -0,0 +1,43 @@
+# Copyright (C) 2020  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+INCLUDE(Common)
+
+INCLUDE_DIRECTORIES(
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${Boost_INCLUDE_DIR}
+)
+
+SET(PROJECT_HEADERS
+    Locale_def.h
+    Locale_Convert.h
+)
+
+SET(PROJECT_SOURCES
+    Locale_Convert.cpp
+)
+
+SET(PROJECT_LIBRARIES
+)
+
+ADD_DEFINITIONS(-DLOCALE_EXPORTS)
+ADD_LIBRARY(Locale SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(Locale ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS Locale DESTINATION ${SHAPER_INSTALL_BIN})
diff --git a/src/Locale/Locale_Convert.cpp b/src/Locale/Locale_Convert.cpp
new file mode 100644 (file)
index 0000000..f3263d8
--- /dev/null
@@ -0,0 +1,83 @@
+// Copyright (C) 2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <Locale_Convert.h>
+
+#include <boost/locale/encoding_utf.hpp>
+
+////// To support old types of GCC (less than 5.0), check the wide-string conversion is working
+////#if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)  && \
+////    (__cplusplus >= 201402L || !defined(__GLIBCXX__)   || \
+////    (defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE > 4))
+////#define HAVE_WORKING_WIDESTRING 1
+////#else
+////#define HAVE_WORKING_WIDESTRING 0
+////#endif
+////
+////#if HAVE_WORKING_WIDESTRING
+////#include <codecvt>
+////#endif
+
+namespace Locale
+{
+  std::string Convert::toString(const std::wstring& theWStr)
+  {
+////#if HAVE_WORKING_WIDESTRING
+////    static std::wstring_convert<std::codecvt_utf8<wchar_t> > aConvertor;
+////    return aConvertor.to_bytes(theWStr);
+////#else
+////    char* aBuf = new char[2 * (theWStr.size() + 1)];
+////    size_t aNbChars = std::wcstombs(aBuf, theWStr.c_str(), theWStr.size());
+////    if (aNbChars != (size_t)-1)
+////      aBuf[aNbChars] = '\0';
+////    std::string aStr(aBuf);
+////    delete[] aBuf;
+////    return aStr;
+////#endif
+    return boost::locale::conv::utf_to_utf<char>(theWStr);
+  }
+
+  std::string Convert::toString(const char16_t* theExtStr)
+  {
+    return boost::locale::conv::utf_to_utf<char>(theExtStr);
+  }
+
+  std::wstring Convert::toWString(const std::string& theStr)
+  {
+////#if HAVE_WORKING_WIDESTRING
+////    static std::wstring_convert<std::codecvt_utf8<wchar_t> > aConvertor;
+////    return aConvertor.from_bytes(theStr);
+////#else
+////    wchar_t* aBuf = new wchar_t[theStr.size() + 1];
+////    size_t aNbWChars = std::mbstowcs(aBuf, theStr.c_str(), theStr.size());
+////    if (aNbWChars != (size_t)-1)
+////      aBuf[aNbWChars] = L'\0';
+////    std::wstring aWStr(aBuf);
+////    delete[] aBuf;
+////    return aWStr;
+////#endif
+    return boost::locale::conv::utf_to_utf<wchar_t>(theStr);
+  }
+
+  std::wstring Convert::toWString(const char16_t* theExtStr)
+  {
+    return boost::locale::conv::utf_to_utf<wchar_t>(theExtStr);
+  }
+
+}
diff --git a/src/Locale/Locale_Convert.h b/src/Locale/Locale_Convert.h
new file mode 100644 (file)
index 0000000..9a44323
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright (C) 2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef LOCALE_CONVERT_H
+#define LOCALE_CONVERT_H
+
+#include <Locale_def.h>
+
+#include <string>
+
+namespace Locale
+{
+  /// Convert strings
+  namespace Convert
+  {
+    /// Converts a wide-string to a simple (byte) string
+    /// \param theWStr a wide-string
+    LOCALE_EXPORT std::string toString(const std::wstring& theWStr);
+
+    /// Converts an extended string to a simple (byte) string
+    /// \param theExtStr an extended string
+    LOCALE_EXPORT std::string toString(const char16_t* theExtStr);
+
+    /// Converts a byte string to a wide-string
+    /// \param theStr a byte string
+    LOCALE_EXPORT std::wstring toWString(const std::string& theStr);
+
+    /// Converts an extended string to a wide-string
+    /// \param theStr a byte string
+    LOCALE_EXPORT std::wstring toWString(const char16_t* theExtStr);
+
+  }
+}
+
+#endif // Locale_Convert_H
diff --git a/src/Locale/Locale_def.h b/src/Locale/Locale_def.h
new file mode 100644 (file)
index 0000000..36587c9
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (C) 2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef LOCALE_DEF_H
+#define LOCALE_DEF_H
+
+#if defined WIN32
+# if defined LOCALE_EXPORTS
+#  define LOCALE_EXPORT __declspec( dllexport )
+# else
+#  define LOCALE_EXPORT __declspec( dllimport )
+# endif
+#else
+# define LOCALE_EXPORT
+#endif
+
+#endif
index eaac6b906a332e4eddcde3e7621f0c4de4a8d630..81e140d18eaeebf0b266d9aaca296f48ce27e997 100644 (file)
@@ -104,6 +104,7 @@ SET(PROJECT_LIBRARIES
     GeomData
     GeomAPI
     GeomAlgoAPI
+    Locale
     ModelGeomAlgo
     ${OpenCASCADE_ApplicationFramework_LIBRARIES}
 )
@@ -116,6 +117,7 @@ SET(PROJECT_INCLUDES
   ../GeomDataAPI
   ../GeomAlgoAPI
   ../GeomAPI
+  ../Locale
   ../ModelGeomAlgo
   ../ConstructionPlugin
   ${OpenCASCADE_INCLUDE_DIR}
index 36634ff15c608251553bed5be3e7d4a31ed42f0c..ecdb234d4174fcdf86d52af5b4c141ec0796c575 100644 (file)
@@ -23,6 +23,8 @@
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Tools.h>
 
+#include <Locale_Convert.h>
+
 #include <BinDrivers_DocumentRetrievalDriver.hxx>
 #include <BinDrivers_DocumentStorageDriver.hxx>
 
@@ -71,7 +73,7 @@ bool Model_Application::loadDocument(const std::wstring theDocName, const int th
   bool aRes = true;
   // load it if it must be loaded by demand
   if (myLoadedByDemand.find(theDocName) != myLoadedByDemand.end() && !myPath.empty()) {
-    aRes = aNew->load(myPath.c_str(), ModelAPI_Tools::toString(theDocName).c_str(), aNew);
+    aRes = aNew->load(myPath.c_str(), Locale::Convert::toString(theDocName).c_str(), aNew);
     myLoadedByDemand.erase(theDocName);  // done, don't do it anymore
   } else { // error
     aRes = false;
index 3127aeb8549ad702cdee3c5f6693fce7fa80d549..180fb85e58ac865b25f12a9dffd93be85e77cfe7 100644 (file)
@@ -46,6 +46,8 @@
 #include <GeomAlgoAPI_NExplode.h>
 #include <Selector_Selector.h>
 
+#include <Locale_Convert.h>
+
 #include <TNaming_NamedShape.hxx>
 #include <TNaming_Tool.hxx>
 #include <TNaming_Builder.hxx>
@@ -368,7 +370,7 @@ std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::internalValue(CenterTyp
               std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1);
               int anIndex;
               std::string aType; // to reuse already existing selection the type is not needed
-              return aPart->shapeInPart(ModelAPI_Tools::toWString(aNameInPart), aType, anIndex);
+              return aPart->shapeInPart(Locale::Convert::toWString(aNameInPart), aType, anIndex);
             }
           }
         }
@@ -763,7 +765,7 @@ std::wstring Model_AttributeSelection::namingName(const std::wstring& theDefault
       aShape = context()->shape();
     std::wstring aName;
     if (aShape.get()) {
-      aName = ModelAPI_Tools::toWString(aShape->shapeTypeStr());
+      aName = Locale::Convert::toWString(aShape->shapeTypeStr());
       if (myParent) {
         std::wostringstream aStream;
         aStream << "_" << selectionLabel().Father().Tag();
@@ -781,7 +783,7 @@ std::wstring Model_AttributeSelection::namingName(const std::wstring& theDefault
     std::wstring aResName;
     // checking part-owner
     if (aContFeature->document() != owner()->document())
-        aResName += ModelAPI_Tools::toWString(aContFeature->document()->kind()) + L"/";
+        aResName += Locale::Convert::toWString(aContFeature->document()->kind()) + L"/";
     // selection of a full feature
     if (aContFeature.get()) {
       return aResName + kWHOLE_FEATURE + aContFeature->name();
@@ -874,7 +876,7 @@ void Model_AttributeSelection::selectSubShape(
     if (aPartEnd != std::string::npos) {
       std::wstring aPartName = aSubShapeName.substr(0, aPartEnd);
       DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
-      if (aPartName == ModelAPI_Tools::toWString(aRootDoc->kind())) {
+      if (aPartName == Locale::Convert::toWString(aRootDoc->kind())) {
         aDoc = std::dynamic_pointer_cast<Model_Document>(aRootDoc);
         aSubShapeName = aSubShapeName.substr(aPartEnd + 1);
       }
@@ -1135,7 +1137,7 @@ std::wstring Model_AttributeSelection::contextName(const ResultPtr& theContext)
   std::wstring aResult;
   if (owner()->document() != theContext->document()) {
     if (theContext->document() == ModelAPI_Session::get()->moduleDocument()) {
-      aResult = ModelAPI_Tools::toWString(theContext->document()->kind()) + L"/";
+      aResult = Locale::Convert::toWString(theContext->document()->kind()) + L"/";
     } else {
       ResultPtr aDocRes = ModelAPI_Tools::findPartResult(
         ModelAPI_Session::get()->moduleDocument(), theContext->document());
@@ -1883,7 +1885,7 @@ std::wstring Model_AttributeSelection::contextName(const TDF_Label theSelectionL
         aNumInHistoryNames--;
       }
       if (aBaseDocumnetUsed)
-        aContextName = ModelAPI_Tools::toWString(aDoc->kind()) + L"/" + aContextName;
+        aContextName = Locale::Convert::toWString(aDoc->kind()) + L"/" + aContextName;
       return aContextName;
     }
   }
@@ -1914,7 +1916,7 @@ bool Model_AttributeSelection::restoreContext(std::wstring theName,
     // name in PartSet?
     aDoc = std::dynamic_pointer_cast<Model_Document>(
       ModelAPI_Session::get()->moduleDocument());
-    if (theName.find(ModelAPI_Tools::toWString(aDoc->kind())) == 0) {
+    if (theName.find(Locale::Convert::toWString(aDoc->kind())) == 0) {
       // remove the document identifier from name if exists
       aSubShapeName = theName.substr(aDoc->kind().size() + 1);
       aName = aSubShapeName;
index fa9fc4468c09ec3a0b9e2fca84eec806689e9e24..3311c7bcb0767ca4dae44ea128e808263fec975a 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <Model_BodyBuilder.h>
 
+#include <Locale_Convert.h>
+
 #include <Model_Data.h>
 #include <Model_Document.h>
 #include <ModelAPI_Session.h>
@@ -202,7 +204,7 @@ void Model_BodyBuilder::store(const GeomShapePtr& theShape,
     if(!aBuilder.NamedShape()->IsEmpty()) {
       Handle(TDataStd_Name) anAttr;
       if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
-        std::wstring aName ((wchar_t*)anAttr->Get().ToExtString());
+        std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
         if(!aName.empty()) {
           std::shared_ptr<Model_Document> aDoc =
             std::dynamic_pointer_cast<Model_Document>(document());
@@ -255,7 +257,7 @@ void Model_BodyBuilder::storeGenerated(const GeomShapePtr& theFromShape,
     if(!aBuilder->NamedShape()->IsEmpty()) {
       Handle(TDataStd_Name) anAttr;
       if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
-        std::wstring aName((wchar_t*)anAttr->Get().ToExtString());
+        std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
         if(!aName.empty()) {
           std::shared_ptr<Model_Document> aDoc =
             std::dynamic_pointer_cast<Model_Document>(document());
@@ -347,7 +349,7 @@ void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape,
     if(!aBuilder->NamedShape()->IsEmpty()) {
       Handle(TDataStd_Name) anAttr;
       if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
-        std::wstring aName ((wchar_t*)anAttr->Get().ToExtString());
+        std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
         if(!aName.empty()) {
           std::shared_ptr<Model_Document> aDoc =
             std::dynamic_pointer_cast<Model_Document>(document());
index dea65b8a5295184cfdb70dbd7be41e206feea005..f667942f8ba721310b5fff9d4398d9926e495111 100644 (file)
@@ -58,6 +58,8 @@
 #include <Events_Loop.h>
 #include <Events_InfoMessage.h>
 
+#include <Locale_Convert.h>
+
 #include <TDataStd_Name.hxx>
 #include <TDataStd_AsciiString.hxx>
 #include <TDataStd_UAttribute.hxx>
@@ -113,8 +115,7 @@ std::wstring Model_Data::name()
 #ifdef DEBUG_NAMES
     myObject->myName = TCollection_AsciiString(aName->Get()).ToCString();
 #endif
-    return std::wstring((wchar_t*)aName->Get().ToExtString());
-    //return std::wstring(TCollection_AsciiString(aName->Get()).ToCString());
+    return Locale::Convert::toWString(aName->Get().ToExtString());
   }
   return L"";  // not defined
 }
index a1babc01586062a6454655efbc7a6831b47b0c53..4ce8f1184b8742be27e8c5e9bbb655b918bf0959 100644 (file)
@@ -34,6 +34,8 @@
 #include <Events_InfoMessage.h>
 #include <GeomAPI_Tools.h>
 
+#include <Locale_Convert.h>
+
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_Comment.hxx>
 #include <TDF_ChildIDIterator.hxx>
@@ -522,7 +524,7 @@ bool Model_Document::save(
       ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aPartRes);
       if (!aPart->isActivated()) {
         // copy not-activated document that is not in the memory
-        std::string aDocName = ModelAPI_Tools::toString(aPart->data()->name());
+        std::string aDocName = Locale::Convert::toString(aPart->data()->name());
         if (!aDocName.empty()) {
           // just copy file
           TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName));
@@ -539,7 +541,7 @@ bool Model_Document::save(
           }
         }
       } else { // simply save opened document
-        std::string aDocName = ModelAPI_Tools::toString(aPart->data()->name());
+        std::string aDocName = Locale::Convert::toString(aPart->data()->name());
         isDone = std::dynamic_pointer_cast<Model_Document>(aPart->partDoc())->
           save(theDirName, aDocName.c_str(), theResults);
       }
@@ -1706,7 +1708,7 @@ void Model_Document::changeNamingName(const std::wstring theOldName,
         TDF_ChildIDIterator aChild(theLabel, TDataStd_Name::GetID());
         for(; aChild.More(); aChild.Next()) {
           Handle(TDataStd_Name) aSubName = Handle(TDataStd_Name)::DownCast(aChild.Value());
-          std::wstring aName = (wchar_t*)aSubName->Get().ToExtString();
+          std::wstring aName = Locale::Convert::toWString(aSubName->Get().ToExtString());
           if (aName.find(theOldName) == 0) { // started from parent name
             std::wstring aNewSubName = theNewName + aName.substr(theOldName.size());
             changeNamingName(aName, aNewSubName, aSubName->Label());
index ef4d72a523fa5ab81bf905ba36e0a16156de3ca6..3a9cfe58347dd2f5e68287f0037fc36ac2197bff 100644 (file)
@@ -38,6 +38,8 @@
 #include <Events_Loop.h>
 #include <Events_InfoMessage.h>
 
+#include <Locale_Convert.h>
+
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_Comment.hxx>
 #include <TDF_ChildIDIterator.hxx>
@@ -734,7 +736,7 @@ static std::wstring composeName(const std::string& theFeatureKind, const int the
 {
   std::stringstream aNameStream;
   aNameStream << theFeatureKind << "_" << theIndex;
-  return ModelAPI_Tools::toWString(aNameStream.str());
+  return Locale::Convert::toWString(aNameStream.str());
 }
 
 void Model_Objects::setUniqueName(FeaturePtr theFeature)
index ed6f3bece0454d21127a033f648de17d6316e998..fad43f23db38335a27f20e85256368494cfa89c9 100644 (file)
@@ -28,6 +28,8 @@
 
 #include <GeomAlgoAPI_CompoundBuilder.h>
 
+#include <Locale_Convert.h>
+
 #include <Config_PropManager.h>
 
 Model_ResultField::Model_ResultField(std::shared_ptr<ModelAPI_Data> theOwnerData)
@@ -156,7 +158,7 @@ std::shared_ptr<ModelAPI_ResultField::ModelAPI_FieldStep> Model_ResultField::ste
 std::wstring Model_ResultField::Model_FieldStep::name() {
   std::wostringstream aStream;
   aStream<<myParent->data()->name()<<std::endl;
-  aStream<<"Step "<<(myId + 1)<<" "<< ModelAPI_Tools::toWString(myParent->textLine(myId));
+  aStream<<"Step "<<(myId + 1)<<" "<< Locale::Convert::toWString(myParent->textLine(myId));
   return aStream.str();
 }
 // LCOV_EXCL_STOP
index e6dc4545382087425e5a3c64b5be7540b0f19dcd..1ecd9ce3923121462831d5bae57593c329b0c8d0 100644 (file)
@@ -36,6 +36,8 @@
 
 #include <GeomAPI_Trsf.h>
 
+#include <Locale_Convert.h>
+
 #include <TNaming_Tool.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TDataStd_Name.hxx>
@@ -91,7 +93,7 @@ void Model_ResultPart::activate()
   SessionPtr aMgr = ModelAPI_Session::get();
   if (!aMgr->isOperation()) {
     // open transaction even document is not created to set current docs in setActiveDocument
-    std::string aMsg = "Activation " + ModelAPI_Tools::toString(data()->name());
+    std::string aMsg = "Activation " + Locale::Convert::toString(data()->name());
     aMgr->startOperation(aMsg);
     isNewTransaction = true;
   }
index 6df21ce5b1399a6c2d51103efd22ffe54de47511..e3767a069d751b038851695d7c9183401387ad62 100644 (file)
@@ -117,6 +117,7 @@ SET(PROJECT_SOURCES
 SET(PROJECT_LIBRARIES
     Config
     GeomAPI
+    Locale
 )
 SET(CMAKE_SWIG_FLAGS -threads -w325,321,362,383,302,403,451,473)
 ADD_DEFINITIONS(-DMODELAPI_EXPORTS)
@@ -129,6 +130,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Config
                     ${PROJECT_SOURCE_DIR}/src/Events
                     ${PROJECT_SOURCE_DIR}/src/GeomAPI
                     ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
+                    ${PROJECT_SOURCE_DIR}/src/Locale
 )
 
 
index 8922813f0e401fc32c4ab68b3d481b80fd022611..1baf30d0c5ef0fc806789b4158acc57b6ca87227 100644 (file)
 #include <iostream>
 #include <sstream>
 
-// To support old types of GCC (less than 5.0), check the wide-string conversion is working
-#if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L)  && \
-    (__cplusplus >= 201402L || !defined(__GLIBCXX__)   || \
-    (defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE > 4))
-#define HAVE_WORKING_WIDESTRING 1
-#else
-#define HAVE_WORKING_WIDESTRING 0
-#endif
-
-#if HAVE_WORKING_WIDESTRING
-#include <codecvt>
-#endif
-
 #include <Events_Loop.h>
+#include <Locale_Convert.h>
 #include <ModelAPI_Events.h>
 
 #include <GeomAPI_ShapeHierarchy.h>
@@ -185,7 +173,7 @@ std::string getFeatureError(const FeaturePtr& theFeature)
 ObjectPtr objectByName(const DocumentPtr& theDocument, const std::string& theGroup,
                        const std::string& theName)
 {
-  std::wstring aName = toWString(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)
@@ -1117,41 +1105,5 @@ std::list<FeaturePtr> referencedFeatures(
 }
 
 // LCOV_EXCL_STOP
-std::string toString(const std::wstring& theWStr)
-{
-#if HAVE_WORKING_WIDESTRING
-  static std::wstring_convert<std::codecvt_utf8<wchar_t> > aConvertor;
-  return aConvertor.to_bytes(theWStr);
-#else
-  char* aBuf = new char[2 * (theWStr.size() + 1)];
-  size_t aNbChars = std::wcstombs(aBuf, theWStr.c_str(), theWStr.size());
-  if (aNbChars != (size_t)-1)
-    aBuf[aNbChars] = '\0';
-  std::string aStr(aBuf);
-  delete[] aBuf;
-  return aStr;
-#endif
-}
-
-/*! Converts a byte string to an extended string
-*  \param theStr a byte string
-*/
-std::wstring toWString(const std::string& theStr)
-{
-#if HAVE_WORKING_WIDESTRING
-  static std::wstring_convert<std::codecvt_utf8<wchar_t> > aConvertor;
-  return aConvertor.from_bytes(theStr);
-#else
-  wchar_t* aBuf = new wchar_t[theStr.size() + 1];
-  size_t aNbWChars = std::mbstowcs(aBuf, theStr.c_str(), theStr.size());
-  if (aNbWChars != (size_t)-1)
-    aBuf[aNbWChars] = L'\0';
-  std::wstring aWStr(aBuf);
-  delete[] aBuf;
-  return aWStr;
-#endif
-}
-
-
 
 } // namespace ModelAPI_Tools
index f927a67c75dfcf4598a5699d52fcf460b4daf0b2..3956b6621001cdf90416b67e00e88d0701d6d8de 100644 (file)
@@ -299,17 +299,6 @@ MODELAPI_EXPORT void copyVisualizationAttrs(std::shared_ptr<ModelAPI_Result> the
 MODELAPI_EXPORT std::list<std::shared_ptr<ModelAPI_Feature> > referencedFeatures(
   std::shared_ptr<ModelAPI_Result> theTarget, const std::string& theFeatureKind,
   const bool theSortResults);
-
-/*! Converts an extended string to a simple (byte) string
-*  \param theWStr an extended string
-*/
-MODELAPI_EXPORT std::string toString(const std::wstring& theWStr);
-
-/*! Converts a byte string to an extended string
-*  \param theStr a byte string
-*/
-MODELAPI_EXPORT std::wstring toWString(const std::string& theStr);
-
 }
 
 #endif
index 41a55586c303483fbe86e9fb2e063b9243c909f3..4b65cc8b4779c1761581788871eb1cb6000af383 100644 (file)
@@ -55,6 +55,7 @@ SET(PROJECT_LIBRARIES
   GeomAPI
   GeomDataAPI
   GeomAlgoAPI
+  Locale
   ModelAPI
   ModelGeomAlgo
 )
@@ -83,6 +84,7 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/GeomAPI
   ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
   ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+  ${PROJECT_SOURCE_DIR}/src/Locale
   ${PROJECT_SOURCE_DIR}/src/ModelAPI
   ${PROJECT_SOURCE_DIR}/src/ModelGeomAlgo
   ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
index 1031cf85498a1868ece8135255c77fa4a94591e7..d818d9406ef3e62e5dcb257b221805183cdf8fde 100644 (file)
@@ -37,6 +37,8 @@
 #include <GeomDataAPI_Point2D.h>
 #include <GeomDataAPI_Point2DArray.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeDoubleArray.h>
@@ -315,7 +317,7 @@ void ModelHighAPI_Dumper::DumpStorage::write(const AttributeSelectionPtr& theAtt
 
   if (aShape.get()) {
     myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \""
-                 << ModelAPI_Tools::toString(theAttrSelect->namingName()) << "\"";
+                 << Locale::Convert::toString(theAttrSelect->namingName()) << "\"";
   }
 
   myDumpBuffer << ")";
@@ -496,7 +498,7 @@ void ModelHighAPI_Dumper::DumpStorageWeak::write(const AttributeSelectionPtr& th
     int anIndex = aNExplode.index(aShape);
     if (anIndex != 0) { // found a week-naming index, so, export it
       myDumpBuffer << "model.selection(\"" << aShape->shapeTypeStr() << "\", \""
-                   << ModelAPI_Tools::toString(theAttrSelect->contextName(aContext))
+                   << Locale::Convert::toString(theAttrSelect->contextName(aContext))
                    << "\", " << anIndex << ")";
       aStandardDump = false;
     }
@@ -588,12 +590,12 @@ const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity,
   std::ostringstream aDefaultName;
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theEntity);
   if (aFeature) {
-    aName = ModelAPI_Tools::toString(aFeature->name());
+    aName = Locale::Convert::toString(aFeature->name());
     aKind = aFeature->getKind();
   } else {
     FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(theEntity);
     if (aFolder) {
-      aName = ModelAPI_Tools::toString(aFolder->data()->name());
+      aName = Locale::Convert::toString(aFolder->data()->name());
       aKind = ModelAPI_Folder::ID();
       isSaveNotDumped = false;
     }
@@ -687,8 +689,8 @@ void ModelHighAPI_Dumper::saveResultNames(const FeaturePtr& theFeature)
   ModelAPI_Tools::allResults(theFeature, allRes);
   for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
     std::pair<std::wstring, bool> aName = ModelAPI_Tools::getDefaultName(*aRes);
-    std::string aDefaultName = ModelAPI_Tools::toString(aName.first);
-    std::string aResName = ModelAPI_Tools::toString((*aRes)->data()->name());
+    std::string aDefaultName = Locale::Convert::toString(aName.first);
+    std::string aResName = Locale::Convert::toString((*aRes)->data()->name());
     bool isUserDefined = !(isFeatureDefaultName && aDefaultName == aResName);
     myNames[*aRes] =
       EntityName(aResName, (isUserDefined ? aResName : std::string()), !isUserDefined);
@@ -873,14 +875,14 @@ void ModelHighAPI_Dumper::dumpSubFeatureNameAndColor(const std::string theSubFea
 {
   name(theSubFeature, false);
   myNames[theSubFeature] =
-    EntityName(theSubFeatureGet, ModelAPI_Tools::toString(theSubFeature->name()), false);
+    EntityName(theSubFeatureGet, Locale::Convert::toString(theSubFeature->name()), false);
 
   // store results if they have user-defined names or colors
   std::list<ResultPtr> aResultsWithNameOrColor;
   const std::list<ResultPtr>& aResults = theSubFeature->results();
   std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
   for (; aResIt != aResults.end(); ++aResIt) {
-    std::string aResName = ModelAPI_Tools::toString((*aResIt)->data()->name());
+    std::string aResName = Locale::Convert::toString((*aResIt)->data()->name());
     myNames[*aResIt] = EntityName(aResName, aResName, false);
     aResultsWithNameOrColor.push_back(*aResIt);
   }
@@ -1093,7 +1095,7 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::string& theStrin
 
 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::wstring& theString)
 {
-  *myDumpStorage << ModelAPI_Tools::toString(theString);
+  *myDumpStorage << Locale::Convert::toString(theString);
   return *this;
 }
 
index 6bbc96cecd44a02827618d91bf08f16543c54d23..38d839ed50ca34cd010432fde646df674219baa0 100644 (file)
@@ -46,6 +46,8 @@
 #include <GeomAlgoAPI_ShapeTools.h>
 #include <GeomAPI_Pnt.h>
 
+#include <Locale_Convert.h>
+
 #include <TopoDS_Shape.hxx>
 #include <TopExp_Explorer.hxx>
 
@@ -75,7 +77,7 @@ ModelHighAPI_FeatureStore::ModelHighAPI_FeatureStore(ObjectPtr theObject) {
 std::string ModelHighAPI_FeatureStore::compare(ObjectPtr theObject) {
   std::string anError = compareData(theObject->data(), myAttrs);
   if (!anError.empty()) {
-    return "Features '" + ModelAPI_Tools::toString(theObject->data()->name()) +
+    return "Features '" + Locale::Convert::toString(theObject->data()->name()) +
       "' differ:" + anError;
   }
 
@@ -88,13 +90,13 @@ std::string ModelHighAPI_FeatureStore::compare(ObjectPtr theObject) {
     for(; aRes != allResults.end() && aResIter != myRes.end(); aRes++, aResIter++) {
       anError = compareData((*aRes)->data(), *aResIter);
       if (!anError.empty())
-        return "Results of feature '" + ModelAPI_Tools::toString(aFeature->name()) +
-        "' '" + ModelAPI_Tools::toString((*aRes)->data()->name()) +
+        return "Results of feature '" + Locale::Convert::toString(aFeature->name()) +
+        "' '" + Locale::Convert::toString((*aRes)->data()->name()) +
         "' differ:" + anError;
     }
     if (aRes != allResults.end()) {
       return "Current model has more results '" +
-        ModelAPI_Tools::toString((*aRes)->data()->name()) + "'";
+        Locale::Convert::toString((*aRes)->data()->name()) + "'";
     }
     if (aResIter != myRes.end()) {
       return "Original model had more results '" + (*aResIter)["__name__"] + "'";
@@ -107,7 +109,7 @@ void ModelHighAPI_FeatureStore::storeData(std::shared_ptr<ModelAPI_Data> theData
   std::map<std::string, std::string>& theAttrs)
 {
   // store name to keep also this information and output if needed
-  theAttrs["__name__"] = ModelAPI_Tools::toString(theData->name());
+  theAttrs["__name__"] = Locale::Convert::toString(theData->name());
   std::list<std::shared_ptr<ModelAPI_Attribute> > allAttrs = theData->attributes("");
   std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = allAttrs.begin();
   for(; anAttr != allAttrs.end(); anAttr++) {
@@ -193,7 +195,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) {
       ResultPtr aRes = ModelAPI_Tools::findPartResult(aDoc, anAttr->value());
       if (aRes.get()) {
         // Part result name (the same as saved file name)
-        aResult<< ModelAPI_Tools::toString(aRes->data()->name());
+        aResult<< Locale::Convert::toString(aRes->data()->name());
       }
     } else {
       aResult<<aDoc->kind(); // PartSet
@@ -247,7 +249,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) {
     AttributeReferencePtr anAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttr);
     if (anAttr->value().get()) {
-      aResult<< ModelAPI_Tools::toString(anAttr->value()->data()->name());
+      aResult<< Locale::Convert::toString(anAttr->value()->data()->name());
     } else {
       aResult<<"__empty__";
     }
@@ -255,7 +257,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) {
     AttributeSelectionPtr anAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttr);
     if (anAttr->context().get())
-      aResult<< ModelAPI_Tools::toString(anAttr->namingName());
+      aResult<< Locale::Convert::toString(anAttr->namingName());
     else
       aResult<<"__notinitialized__";
   } else if (aType == ModelAPI_AttributeSelectionList::typeId()) {
@@ -264,14 +266,14 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) {
     for(int a = 0; a < anAttr->size(); a++) {
       if (a != 0)
         aResult<<" ";
-      aResult<< ModelAPI_Tools::toString(anAttr->value(a)->namingName());
+      aResult<< Locale::Convert::toString(anAttr->value(a)->namingName());
     }
   } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
     AttributeRefAttrPtr anAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttr);
     ObjectPtr anObj = anAttr->isObject() ? anAttr->object() : anAttr->attr()->owner();
     if (anObj.get()) {
-      aResult<< ModelAPI_Tools::toString(anObj->data()->name());
+      aResult<< Locale::Convert::toString(anObj->data()->name());
       if (!anAttr->isObject()) {
         aResult<<" "<<anAttr->attr()->id();
       }
@@ -297,7 +299,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) {
           if (aStr == "SketchConstraint")
             continue; // no need to dump and check constraints
         }
-        aResList.push_back(ModelAPI_Tools::toString((*aL)->data()->name()));
+        aResList.push_back(Locale::Convert::toString((*aL)->data()->name()));
       } else if (!isSketchFeatures) {
         aResList.push_back("__empty__");
       }
@@ -317,7 +319,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) {
         aResult<<" ";
       ObjectPtr anObj = aL->second.get() ? aL->second->owner() : aL->first;
       if (anObj.get()) {
-        aResult<< ModelAPI_Tools::toString(anObj->data()->name());
+        aResult<< Locale::Convert::toString(anObj->data()->name());
         if (aL->second.get()) {
           aResult<<" "<<aL->second->id();
         }
index 0eed22d5845c07c628e00315f2f82c3e5e782fce..f3a28048810519d2b992eae3202396a92350fba1 100644 (file)
@@ -29,6 +29,8 @@
 #include <GeomDataAPI_Point2D.h>
 #include <GeomDataAPI_Point2DArray.h>
 //--------------------------------------------------------------------------------------
+#include <Locale_Convert.h>
+//--------------------------------------------------------------------------------------
 #include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_AttributeDouble.h>
@@ -415,7 +417,7 @@ std::string storeFeatures(const std::wstring& theDocName, DocumentPtr theDoc,
   if (theCompare) {
      aDocFind = theStore.find(theDocName);
      if (aDocFind == theStore.end()) {
-       return "Document '" + ModelAPI_Tools::toString(theDocName) + "' not found";
+       return "Document '" + Locale::Convert::toString(theDocName) + "' not found";
      }
   }
   // store the model features information: iterate all features
@@ -439,12 +441,12 @@ std::string storeFeatures(const std::wstring& theDocName, DocumentPtr theDoc,
       std::map<std::wstring, ModelHighAPI_FeatureStore>::iterator
         anObjFind = aDocFind->second.find(anObject->data()->name());
       if (anObjFind == aDocFind->second.end()) {
-        return "Document '" + ModelAPI_Tools::toString(theDocName)
-          + "' feature '" + ModelAPI_Tools::toString(anObject->data()->name()) + "' not found";
+        return "Document '" + Locale::Convert::toString(theDocName)
+          + "' feature '" + Locale::Convert::toString(anObject->data()->name()) + "' not found";
       }
       std::string anError = anObjFind->second.compare(anObject);
       if (!anError.empty()) {
-        anError = "Document " + ModelAPI_Tools::toString(theDocName) + " " + anError;
+        anError = "Document " + Locale::Convert::toString(theDocName) + " " + anError;
         return anError;
       }
       anObjectsCount++;
@@ -483,9 +485,9 @@ std::string storeFeatures(const std::wstring& theDocName, DocumentPtr theDoc,
           aLostName = aLostIter->first;
         }
       }
-      return "For document '" + ModelAPI_Tools::toString(theDocName) +
+      return "For document '" + Locale::Convert::toString(theDocName) +
         "' the number of features is decreased, there is no feature '" +
-        ModelAPI_Tools::toString(aLostName) + "'";
+        Locale::Convert::toString(aLostName) + "'";
     }
   }
   return ""; // ok
@@ -539,7 +541,7 @@ static bool checkDump(SessionPtr theSession,
 
   // compare with the stored data
   std::string anError =
-    storeFeatures(ModelAPI_Tools::toWString(theSession->moduleDocument()->kind()),
+    storeFeatures(Locale::Convert::toWString(theSession->moduleDocument()->kind()),
     theSession->moduleDocument(), theStorage, true);
   if (!anError.empty()) {
     std::cout << anError << std::endl;
@@ -580,7 +582,7 @@ bool checkPyDump(const std::string& theFilenameNaming,
    // map from document name to feature name to feature data
   std::map<std::wstring, std::map<std::wstring, ModelHighAPI_FeatureStore> > aStore;
   std::string anError =
-    storeFeatures(ModelAPI_Tools::toWString(aSession->moduleDocument()->kind()),
+    storeFeatures(Locale::Convert::toWString(aSession->moduleDocument()->kind()),
     aSession->moduleDocument(), aStore, false);
   if (!anError.empty()) {
     Events_InfoMessage anErrorMsg(std::string("checkPythonDump"), anError);
index 8887619f9a1c652bf2f72663bf85ff8fc8eb5a0c..c0d5a754412dced2b7c02b14f75ac3e0ba14954d 100644 (file)
@@ -22,7 +22,10 @@ INCLUDE(UnitTest)
 INCLUDE(UseQtExt)
 
 # additional include directories
-INCLUDE_DIRECTORIES(${QT_INCLUDES})
+INCLUDE_DIRECTORIES(
+    ../Locale
+    ${QT_INCLUDES}
+)
 
 # additional preprocessor / compiler flags
 ADD_DEFINITIONS(${QT_DEFINITIONS})
@@ -68,6 +71,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
 SET(PROJECT_LIBRARIES
     Events
     Config
+    Locale
     ModelAPI
     ModuleBase
     ${QT_LIBRARIES}
index dec451209fb63b72464cf6a32034456d0f7f889a..6f0efee2cbf92a3f47b100c2a90d0ad61a2959fb 100644 (file)
@@ -24,6 +24,8 @@
 
 #include <Events_InfoMessage.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeRefList.h>
@@ -244,16 +246,16 @@ bool isValidAttribute(const AttributePtr& theAttribute)
 void setParameterName(ResultParameterPtr theResultParameter, const std::string& theName)
 {
   bool aWasBlocked = theResultParameter->data()->blockSendAttributeUpdated(true);
-  theResultParameter->data()->setName(ModelAPI_Tools::toWString(theName));
+  theResultParameter->data()->setName(Locale::Convert::toWString(theName));
   theResultParameter->data()->blockSendAttributeUpdated(aWasBlocked, false);
 
   std::shared_ptr<ParametersPlugin_Parameter> aParameter =
       std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
           ModelAPI_Feature::feature(theResultParameter));
 
-  std::string anOldName = ModelAPI_Tools::toString(aParameter->name());
+  std::string anOldName = Locale::Convert::toString(aParameter->name());
   aWasBlocked = aParameter->data()->blockSendAttributeUpdated(true);
-  aParameter->data()->setName(ModelAPI_Tools::toWString(theName));
+  aParameter->data()->setName(Locale::Convert::toWString(theName));
   aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID())->setValue(theName);
   aParameter->data()->blockSendAttributeUpdated(aWasBlocked);
 }
@@ -295,28 +297,29 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent(
         ModuleBase_Tools::translate(aMsg),
         QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
     if (aRes != QMessageBox::Yes) {
-      setParameterName(aResultParameter, ModelAPI_Tools::toString(aMessage->oldName()));
+      setParameterName(aResultParameter, Locale::Convert::toString(aMessage->oldName()));
       return;
     }
   }
 
   // try to update the parameter feature according the new name
-  setParameterName(aResultParameter, ModelAPI_Tools::toString(aMessage->newName()));
+  setParameterName(aResultParameter, Locale::Convert::toString(aMessage->newName()));
   if (!isValidAttribute(aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID()))) {
     //setParameterName(aResultParameter, aMessage->oldName());
     if (myOldNames.find(aParameter.get()) == myOldNames.end())
-      myOldNames[aParameter.get()] = ModelAPI_Tools::toString(aMessage->oldName());
+      myOldNames[aParameter.get()] = Locale::Convert::toString(aMessage->oldName());
     return;
   }
 
-  std::string anOldName = ModelAPI_Tools::toString(aMessage->oldName());
+  std::string anOldName = Locale::Convert::toString(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, ModelAPI_Tools::toString(aMessage->newName()));
+  renameInDependents(aResultParameter, anOldName,
+                     Locale::Convert::toString(aMessage->newName()));
 }
 
 void ParametersPlugin_EvalListener::processReplaceParameterEvent(
@@ -341,6 +344,7 @@ void ParametersPlugin_EvalListener::processReplaceParameterEvent(
   double aRealValue = aResultParameter->data()->real(ModelAPI_ResultParameter::VALUE())->value();
   std::string aValue = toStdString(aRealValue);
 
-  renameInDependents(aResultParameter, ModelAPI_Tools::toString(aResultParameter->data()->name()),
-    aValue);
+  renameInDependents(aResultParameter,
+                     Locale::Convert::toString(aResultParameter->data()->name()),
+                     aValue);
 }
index b49507befdee9afa4efdd78ace80d44682e8c243..ac993a9cb3e0f9e6e20be1af94de3be30b7cb1e7 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "ParametersPlugin_Parameter.h"
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_AttributeDouble.h>
@@ -74,11 +76,11 @@ void ParametersPlugin_Parameter::attributeChanged(const std::string& theID)
 void ParametersPlugin_Parameter::updateName()
 {
   std::string aName = string(VARIABLE_ID())->value();
-  data()->setName(ModelAPI_Tools::toWString(aName));
+  data()->setName(Locale::Convert::toWString(aName));
 
   ResultParameterPtr aParam = document()->createParameter(data());
-  std::string anOldName = ModelAPI_Tools::toString(aParam->data()->name());
-  aParam->data()->setName(ModelAPI_Tools::toWString(aName));
+  std::string anOldName = Locale::Convert::toString(aParam->data()->name());
+  aParam->data()->setName(Locale::Convert::toWString(aName));
   setResult(aParam);
 
 
index 47b5ac0b253fca88c828359b5e7c702f94056f5b..d8ccf52f922c74fc17fa3fdd146887c90d35b92d 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <Events_InfoMessage.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_ResultParameter.h>
@@ -71,7 +73,7 @@ bool ParametersPlugin_VariableValidator::isUnique(const AttributePtr& theAttribu
   for (int anIndex = 0, aSize = aDocument->size(ModelAPI_ResultParameter::group());
        anIndex < aSize; ++anIndex) {
     ObjectPtr aParamObj = aDocument->object(ModelAPI_ResultParameter::group(), anIndex);
-    if (ModelAPI_Tools::toString(aParamObj->data()->name()) != theString)
+    if (Locale::Convert::toString(aParamObj->data()->name()) != theString)
       continue;
     ResultParameterPtr aParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aParamObj);
     if (!aParam.get())
index 9f87f6c3f8e40628488edfaea216871c781fe977..d188c8dd841ec8a93abe6798a4a08555cdb1fe84 100644 (file)
@@ -131,6 +131,7 @@ SET(PROJECT_LIBRARIES
     ModuleBase
     ModelGeomAlgo
     Config
+    Locale
     GeomAPI
     GeomDataAPI
     SketcherPrs
@@ -165,6 +166,7 @@ SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES})
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/XGUI
                     ${PROJECT_SOURCE_DIR}/src/Config
                     ${PROJECT_SOURCE_DIR}/src/Events
+                    ${PROJECT_SOURCE_DIR}/src/Locale
                     ${PROJECT_SOURCE_DIR}/src/ModuleBase
                     ${PROJECT_SOURCE_DIR}/src/ModelAPI
                     ${PROJECT_SOURCE_DIR}/src/ModelGeomAlgo
index 76c8e61566cd287be78bc273012f5560eaae313a..da53f90fc677eb1740733e9b8d3b0123eed596f0 100644 (file)
@@ -53,6 +53,8 @@
 #include <SketchPlugin_Point.h>
 #include <GeomAPI_Edge.h>
 
+#include <Locale_Convert.h>
+
 #include <list>
 #include <unordered_map>
 #ifdef _DEBUG
@@ -436,7 +438,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
           if (isObject) {
             if (aRef->object() == anObject) {
               theError = errorMessage(EqualObjects,
-                anObject.get() ? ModelAPI_Tools::toString(anObject->data()->name()) : "",
+                anObject.get() ? Locale::Convert::toString(anObject->data()->name()) : "",
                 theAttribute->id(), aRef->id());
               return false;
             }
@@ -514,7 +516,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
           // check the object is already presented
           if (aRef->value() == anObject) {
             theError = errorMessage(EqualObjects,
-              anObject.get() ? ModelAPI_Tools::toString(anObject->data()->name()) : "",
+              anObject.get() ? Locale::Convert::toString(anObject->data()->name()) : "",
               theAttribute->id(), aRef->id());
             return false;
           }
@@ -611,7 +613,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
               if (aCurSelObject == aRefSelList->object(j)) {
                 theError = errorMessage(EqualObjects,
                   aCurSelObject.get()?
-                  ModelAPI_Tools::toString(aCurSelObject->data()->name()) : "",
+                  Locale::Convert::toString(aCurSelObject->data()->name()) : "",
                   theAttribute->id(), aCurSelList->id());
                 return false;
               }
index 573dff40b34037a8c7936ade84994ebc6fb2b570..aa649d287f67330d11819822a19b4157c3a639ae 100644 (file)
@@ -49,9 +49,11 @@ SET(PROJECT_SOURCES
 )
 
 SET(PROJECT_LIBRARIES
+    Locale
     ${OpenCASCADE_ApplicationFramework_LIBRARIES}
 )
 SET(PROJECT_INCLUDES
+  ../Locale
   ${OpenCASCADE_INCLUDE_DIR}
 )
 
index 149a8e89dd61d57c6d843b73a5ee13e179345d44..08ad66b0e6485fa0b887a3a2e8f545b24b017912 100644 (file)
@@ -22,6 +22,8 @@
 #include <Selector_NameGenerator.h>
 #include <Selector_NExplode.h>
 
+#include <Locale_Convert.h>
+
 #include <TNaming_NamedShape.hxx>
 #include <TNaming_Iterator.hxx>
 #include <TNaming_SameShapeIterator.hxx>
@@ -331,17 +333,17 @@ std::wstring Selector_Modify::name(Selector_NameGenerator* theNameGenerator)
   if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName))
     return L"";
   aResult += theNameGenerator->contextName(myFinal) + L"/";
-  aResult += (wchar_t*)aName->Get().ToExtString();
+  aResult += Locale::Convert::toWString(aName->Get().ToExtString());
   for(TDF_LabelList::iterator aBase = myBases.begin(); aBase != myBases.end(); aBase++) {
     if (!aBase->FindAttribute(TDataStd_Name::GetID(), aName))
       return L"";
     aResult += L"&";
     aResult += theNameGenerator->contextName(*aBase) + L"/";
-    aResult += (wchar_t*)aName->Get().ToExtString();
+    aResult += Locale::Convert::toWString(aName->Get().ToExtString());
   }
   if (myWeakIndex != -1) {
     std::wostringstream aWeakStr;
-    aWeakStr<<"&"<<weakNameID()<<myWeakIndex;
+    aWeakStr<<L"&"<<weakNameID()<<myWeakIndex;
     aResult += aWeakStr.str();
   }
   return aResult;
index 6b5706f8b317a3fd2bd230384ba5c397e0ebd78f..6825fdf9214055727da65b9d07352ab7d46bda5c 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <Selector_NameGenerator.h>
 
+#include <Locale_Convert.h>
+
 #include <TNaming_NamedShape.hxx>
 #include <TDataStd_Name.hxx>
 
@@ -80,7 +82,7 @@ std::wstring Selector_Primitive::name(Selector_NameGenerator* theNameGenerator)
   std::wstring aResult = theNameGenerator->contextName(myFinal);
   if (!aResult.empty()) {
     aResult += L"/";
-    aResult += ((wchar_t*)aName->Get().ToExtString());
+    aResult += Locale::Convert::toWString(aName->Get().ToExtString());
   }
   return aResult;
 }
index 3b5b813477e1100039fb5ae6081594a249aaba5e..bb8848804f7f9f29eb53116f9bdb786fddf9fac1 100644 (file)
@@ -72,6 +72,7 @@ SET(PROJECT_SOURCES
 
 SET(PROJECT_LIBRARIES
   GeomAlgoAPI
+  Locale
   ModelAPI
   ModelHighAPI
   SketcherPrs
@@ -88,8 +89,8 @@ INCLUDE_DIRECTORIES(
 
 # Plugin headers dependency
 INCLUDE_DIRECTORIES(
-  # TODO(spo): modify ConstructionPlugin headers to remove dependency on GeomAPI headers
   ${PROJECT_SOURCE_DIR}/src/Config
+  ${PROJECT_SOURCE_DIR}/src/Locale
   ${PROJECT_SOURCE_DIR}/src/GeomAPI
   ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
   ${PROJECT_SOURCE_DIR}/src/SketchPlugin
index c6667c55f004b710e376480cc9c2d5ee00dd5891..361f28be6564263595bd0a00e38fd8c78e86760a 100644 (file)
@@ -24,6 +24,8 @@
 
 #include <GeomAlgoAPI_EdgeBuilder.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelHighAPI_Double.h>
 #include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Integer.h>
@@ -155,7 +157,7 @@ static void createPole(const CompositeFeaturePtr& theSketch,
   aPointFeature->execute();
 
   std::wostringstream aName;
-  aName << theBSpline->name() << "_" << ModelAPI_Tools::toWString(thePoles->id())
+  aName << theBSpline->name() << "_" << Locale::Convert::toWString(thePoles->id())
                               << "_" << thePoleIndex;
   aPointFeature->data()->setName(aName.str());
   aPointFeature->lastResult()->data()->setName(aName.str());
index d05222b9f52a21b1a73c033531a7a54ea44ad7bb..88db2ec9a270bdd854938771a8ac975c90c2da1c 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <GeomAPI_Pnt2d.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
@@ -209,7 +211,7 @@ static void createPoint(const CompositeFeaturePtr& theSketch,
   aPointFeature->reference(SketchPlugin_Point::PARENT_ID())->setValue(theEllipse);
   aPointFeature->execute();
 
-  std::wstring aName = theEllipse->name() + L"_" + ModelAPI_Tools::toWString(theCoincident);
+  std::wstring aName = theEllipse->name() + L"_" + Locale::Convert::toWString(theCoincident);
   aPointFeature->data()->setName(aName);
   aPointFeature->lastResult()->data()->setName(aName);
 
index 6a281bc4df28265eb101c26d7fb01732891d1e45..b6362a29bd0326ac1f24fd6fb6f45527db43c8d1 100644 (file)
@@ -137,11 +137,12 @@ SET(PROJECT_LIBRARIES
     Config
     GeomAPI
     GeomAlgoAPI
+    GeomDataAPI
+    Locale
     ModelAPI
     ModelGeomAlgo
     ModuleBase
     SketcherPrs
-    GeomDataAPI
 )
 
 SET(XML_RESOURCES
@@ -168,6 +169,7 @@ TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES})
 INCLUDE_DIRECTORIES(
   ../Config
   ../Events
+  ../Locale
   ../ModelAPI
   ../ModelGeomAlgo
   ../ModuleBase
index 4aa8f5418159dcb3d79548ee29df07e1e27356b2..497288dfb5991d5035bab84d5c0afe6f5ee17742 100644 (file)
@@ -27,6 +27,8 @@
 #include <SketchPlugin_Tools.h>
 #include <SketchPlugin_Sketch.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeDoubleArray.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeRefAttrList.h>
@@ -270,7 +272,7 @@ void SketchPlugin_MacroBSpline::assignDefaultNameForAux(FeaturePtr theAuxFeature
   std::wostringstream aName;
   aName << aBSpline->name();
   if (theAuxFeature->getKind() == SketchPlugin_Point::ID())
-    aName << "_" << ModelAPI_Tools::toWString(theBSplinePoles->id()) << "_" << thePoleIndex1;
+    aName << "_" << Locale::Convert::toWString(theBSplinePoles->id()) << "_" << thePoleIndex1;
   else
     aName << "_segment_" << thePoleIndex1 << "_" << thePoleIndex2;
 
index f6b5b88ecbb05aad21672763f04af19e6bc615a1..98ce50d10db55d7d5464c3b792c4d24ddd45a85e 100644 (file)
@@ -28,6 +28,8 @@
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeRefAttr.h>
@@ -1389,7 +1391,7 @@ std::string SketchPlugin_Split::getFeatureInfo(const std::shared_ptr<ModelAPI_Fe
   }
 
   if (theFeature->data()->isValid())
-    anInfo.append(ModelAPI_Tools::toString(theFeature->data()->name()));
+    anInfo.append(Locale::Convert::toString(theFeature->data()->name()));
 
   if (isUseAttributesInfo) {
     std::string aPointsInfo = ModelGeomAlgo_Point2D::getPontAttributesInfo(theFeature,
index fd1475aca007fa4337207f0003accc4b7143d286..b5db72f77fa7407bbf3b4fd2ab51fc594b36f292 100644 (file)
@@ -37,6 +37,8 @@
 
 #include <SketcherPrs_Tools.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_Tools.h>
@@ -528,7 +530,7 @@ void createAuxiliaryPointOnEllipse(const FeaturePtr& theEllipseFeature,
 
   aPointFeature->execute();
   std::wstring aName = theEllipseFeature->name() + L"_" +
-    ModelAPI_Tools::toWString(theEllipsePoint);
+    Locale::Convert::toWString(theEllipsePoint);
   aPointFeature->data()->setName(aName);
   aPointFeature->lastResult()->data()->setName(aName);
 
index 883c0cbb13e9e0acde7c67cfea610eafc3be9256..42220392d37f5e1007ab042d4e389e7ca8180f36 100644 (file)
@@ -46,6 +46,8 @@
 
 #include <Events_InfoMessage.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_AttributeDouble.h>
@@ -329,7 +331,8 @@ bool SketchPlugin_NotFixedValidator::isValid(const AttributePtr& theAttribute,
     }
     else if (aRefAttr->attr() == aRAttr->attr()) {
       AttributePtr anAttribute = aRefAttr->attr();
-      std::wstring aName = anAttribute.get() ? ModelAPI_Tools::toWString(anAttribute->id()) : L"";
+      std::wstring aName =
+          anAttribute.get() ? Locale::Convert::toWString(anAttribute->id()) : L"";
       theError = "The attribute %1 has been already fixed.";
       theError.arg(aName);
       return false;