Move string conversion to the separate package.
ADD_DEFINITIONS( -DMAKE_TRANSLATION )
ADD_SUBDIRECTORY (src/Config)
+ADD_SUBDIRECTORY (src/Locale)
ADD_SUBDIRECTORY (src/Events)
ADD_SUBDIRECTORY (src/Selector)
ADD_SUBDIRECTORY (src/Model)
Events_InfoMessage.cpp
)
+SET(PROJECT_LIBRARIES
+ Locale
+)
+
ADD_DEFINITIONS(-DEVENTS_EXPORTS)
ADD_LIBRARY(Events SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
SET_SOURCE_FILES_PROPERTIES(Events.i PROPERTIES SWIG_DEFINITIONS "-shadow")
INCLUDE_DIRECTORIES(
+ ../Locale
)
TARGET_LINK_LIBRARIES(Events ${PROJECT_LIBRARIES})
//
#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;
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;
}
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
SET(PROJECT_LIBRARIES
Events
Config
+ Locale
ModelAPI
ModelHighAPI
GeomAPI
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_Trsf.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_AttributeStringArray.h>
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);
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);
} 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";
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 {
} 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";
#include "ExchangePlugin_Import.h"
#include "ExchangePlugin_ImportFeature.h"
+#include <Locale_Convert.h>
+
#include <PartSetPlugin_Part.h>
#include <ModelAPI_AttributeString.h>
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());
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
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);
}
}
#include <GeomAPI_Shape.h>
#include <GeomAPI_ShapeExplorer.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
// 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));
}
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);
// 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");
// 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");
#include <ExchangePlugin_ImportPart.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_AttributeStringArray.h>
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())
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);
}
}
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;
}
--- /dev/null
+# 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})
--- /dev/null
+// 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);
+ }
+
+}
--- /dev/null
+// 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
--- /dev/null
+// 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
GeomData
GeomAPI
GeomAlgoAPI
+ Locale
ModelGeomAlgo
${OpenCASCADE_ApplicationFramework_LIBRARIES}
)
../GeomDataAPI
../GeomAlgoAPI
../GeomAPI
+ ../Locale
../ModelGeomAlgo
../ConstructionPlugin
${OpenCASCADE_INCLUDE_DIR}
#include <ModelAPI_Events.h>
#include <ModelAPI_Tools.h>
+#include <Locale_Convert.h>
+
#include <BinDrivers_DocumentRetrievalDriver.hxx>
#include <BinDrivers_DocumentStorageDriver.hxx>
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;
#include <GeomAlgoAPI_NExplode.h>
#include <Selector_Selector.h>
+#include <Locale_Convert.h>
+
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
#include <TNaming_Builder.hxx>
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);
}
}
}
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();
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();
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);
}
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());
aNumInHistoryNames--;
}
if (aBaseDocumnetUsed)
- aContextName = ModelAPI_Tools::toWString(aDoc->kind()) + L"/" + aContextName;
+ aContextName = Locale::Convert::toWString(aDoc->kind()) + L"/" + aContextName;
return aContextName;
}
}
// 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;
#include <Model_BodyBuilder.h>
+#include <Locale_Convert.h>
+
#include <Model_Data.h>
#include <Model_Document.h>
#include <ModelAPI_Session.h>
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());
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());
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());
#include <Events_Loop.h>
#include <Events_InfoMessage.h>
+#include <Locale_Convert.h>
+
#include <TDataStd_Name.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TDataStd_UAttribute.hxx>
#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
}
#include <Events_InfoMessage.h>
#include <GeomAPI_Tools.h>
+#include <Locale_Convert.h>
+
#include <TDataStd_Integer.hxx>
#include <TDataStd_Comment.hxx>
#include <TDF_ChildIDIterator.hxx>
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));
}
}
} 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);
}
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());
#include <Events_Loop.h>
#include <Events_InfoMessage.h>
+#include <Locale_Convert.h>
+
#include <TDataStd_Integer.hxx>
#include <TDataStd_Comment.hxx>
#include <TDF_ChildIDIterator.hxx>
{
std::stringstream aNameStream;
aNameStream << theFeatureKind << "_" << theIndex;
- return ModelAPI_Tools::toWString(aNameStream.str());
+ return Locale::Convert::toWString(aNameStream.str());
}
void Model_Objects::setUniqueName(FeaturePtr theFeature)
#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <Locale_Convert.h>
+
#include <Config_PropManager.h>
Model_ResultField::Model_ResultField(std::shared_ptr<ModelAPI_Data> theOwnerData)
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
#include <GeomAPI_Trsf.h>
+#include <Locale_Convert.h>
+
#include <TNaming_Tool.hxx>
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Name.hxx>
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;
}
SET(PROJECT_LIBRARIES
Config
GeomAPI
+ Locale
)
SET(CMAKE_SWIG_FLAGS -threads -w325,321,362,383,302,403,451,473)
ADD_DEFINITIONS(-DMODELAPI_EXPORTS)
${PROJECT_SOURCE_DIR}/src/Events
${PROJECT_SOURCE_DIR}/src/GeomAPI
${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
+ ${PROJECT_SOURCE_DIR}/src/Locale
)
#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>
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)
}
// 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
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
GeomAPI
GeomDataAPI
GeomAlgoAPI
+ Locale
ModelAPI
ModelGeomAlgo
)
${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
#include <GeomDataAPI_Point2D.h>
#include <GeomDataAPI_Point2DArray.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeBoolean.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeDoubleArray.h>
if (aShape.get()) {
myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \""
- << ModelAPI_Tools::toString(theAttrSelect->namingName()) << "\"";
+ << Locale::Convert::toString(theAttrSelect->namingName()) << "\"";
}
myDumpBuffer << ")";
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;
}
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;
}
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);
{
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);
}
ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::wstring& theString)
{
- *myDumpStorage << ModelAPI_Tools::toString(theString);
+ *myDumpStorage << Locale::Convert::toString(theString);
return *this;
}
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAPI_Pnt.h>
+#include <Locale_Convert.h>
+
#include <TopoDS_Shape.hxx>
#include <TopExp_Explorer.hxx>
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;
}
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__"] + "'";
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++) {
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
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__";
}
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()) {
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();
}
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__");
}
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();
}
#include <GeomDataAPI_Point2D.h>
#include <GeomDataAPI_Point2DArray.h>
//--------------------------------------------------------------------------------------
+#include <Locale_Convert.h>
+//--------------------------------------------------------------------------------------
#include <ModelAPI_AttributeBoolean.h>
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_AttributeDouble.h>
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
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++;
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
// 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;
// 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);
INCLUDE(UseQtExt)
# additional include directories
-INCLUDE_DIRECTORIES(${QT_INCLUDES})
+INCLUDE_DIRECTORIES(
+ ../Locale
+ ${QT_INCLUDES}
+)
# additional preprocessor / compiler flags
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET(PROJECT_LIBRARIES
Events
Config
+ Locale
ModelAPI
ModuleBase
${QT_LIBRARIES}
#include <Events_InfoMessage.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeRefList.h>
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);
}
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(
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);
}
#include "ParametersPlugin_Parameter.h"
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_AttributeDouble.h>
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);
#include <Events_InfoMessage.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultParameter.h>
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())
ModuleBase
ModelGeomAlgo
Config
+ Locale
GeomAPI
GeomDataAPI
SketcherPrs
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
#include <SketchPlugin_Point.h>
#include <GeomAPI_Edge.h>
+#include <Locale_Convert.h>
+
#include <list>
#include <unordered_map>
#ifdef _DEBUG
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;
}
// 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;
}
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;
}
)
SET(PROJECT_LIBRARIES
+ Locale
${OpenCASCADE_ApplicationFramework_LIBRARIES}
)
SET(PROJECT_INCLUDES
+ ../Locale
${OpenCASCADE_INCLUDE_DIR}
)
#include <Selector_NameGenerator.h>
#include <Selector_NExplode.h>
+#include <Locale_Convert.h>
+
#include <TNaming_NamedShape.hxx>
#include <TNaming_Iterator.hxx>
#include <TNaming_SameShapeIterator.hxx>
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;
#include <Selector_NameGenerator.h>
+#include <Locale_Convert.h>
+
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Name.hxx>
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;
}
SET(PROJECT_LIBRARIES
GeomAlgoAPI
+ Locale
ModelAPI
ModelHighAPI
SketcherPrs
# 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
#include <GeomAlgoAPI_EdgeBuilder.h>
+#include <Locale_Convert.h>
+
#include <ModelHighAPI_Double.h>
#include <ModelHighAPI_Dumper.h>
#include <ModelHighAPI_Integer.h>
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());
#include <GeomAPI_Pnt2d.h>
+#include <Locale_Convert.h>
+
#include <ModelHighAPI_Dumper.h>
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
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);
Config
GeomAPI
GeomAlgoAPI
+ GeomDataAPI
+ Locale
ModelAPI
ModelGeomAlgo
ModuleBase
SketcherPrs
- GeomDataAPI
)
SET(XML_RESOURCES
INCLUDE_DIRECTORIES(
../Config
../Events
+ ../Locale
../ModelAPI
../ModelGeomAlgo
../ModuleBase
#include <SketchPlugin_Tools.h>
#include <SketchPlugin_Sketch.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeDoubleArray.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeRefAttrList.h>
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;
#include <GeomDataAPI_Point2D.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeBoolean.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeRefAttr.h>
}
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,
#include <SketcherPrs_Tools.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_Tools.h>
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);
#include <Events_InfoMessage.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_Data.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_AttributeDouble.h>
}
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;