From: vsv Date: Tue, 9 Jun 2020 07:49:42 +0000 (+0300) Subject: Support of wide string X-Git-Tag: V9_6_0a1~60^2~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f14192492e36f4febc93b2ad7ab7f866cbbdf71b;p=modules%2Fshaper.git Support of wide string --- diff --git a/src/CollectionPlugin/CollectionPlugin_Group.cpp b/src/CollectionPlugin/CollectionPlugin_Group.cpp index 6af6734f2..f45454afa 100644 --- a/src/CollectionPlugin/CollectionPlugin_Group.cpp +++ b/src/CollectionPlugin/CollectionPlugin_Group.cpp @@ -49,12 +49,12 @@ void CollectionPlugin_Group::execute() } // returns name with suffix, not existing in the existing set -static std::string findName( - const std::string theOrigin, int& theSuffix, std::set& theExisting) +static std::wstring findName( + const std::wstring theOrigin, int& theSuffix, std::set& theExisting) { - std::string aRes; + std::wstring aRes; do { - std::ostringstream aName; + std::wostringstream aName; aName< aFeatNames, aResNames; + std::set aFeatNames, aResNames; std::list allFeat = aDoc->allFeatures(); std::list::iterator allFeatIter = allFeat.begin(); for(; allFeatIter != allFeat.end(); allFeatIter++) { @@ -197,7 +197,7 @@ bool CollectionPlugin_Group::customAction(const std::string& theActionId) aFeat->data()->setName(findName(name(), aSuffix, aFeatNames)); if (!aFeat->results().empty() && !results().empty()) { int aResSuf = aSuffix - 1; - std::string aResName = findName(firstResult()->data()->name(), aResSuf, aResNames); + std::wstring aResName = findName(firstResult()->data()->name(), aResSuf, aResNames); aFeat->firstResult()->data()->setName(aResName); ModelAPI_Tools::copyVisualizationAttrs(firstResult(), aFeat->firstResult()); } diff --git a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp index a2e291ed8..8fb703936 100644 --- a/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp +++ b/src/CollectionPlugin/CollectionPlugin_WidgetField.cpp @@ -578,9 +578,9 @@ bool CollectionPlugin_WidgetField::restoreValueCustom() // Add selection names AttributeSelectionPtr aAttr = aSelList->value(k - 1); if (aItem) { - aItem->setText(aAttr->namingName().c_str()); + aItem->setText(QString::fromStdWString(aAttr->namingName())); } else { - aItem = new QTableWidgetItem(aAttr->namingName().c_str()); + aItem = new QTableWidgetItem(QString::fromStdWString(aAttr->namingName())); aTable->setItem(k, j, aItem); } } else if (j > 0) { @@ -769,8 +769,8 @@ void CollectionPlugin_WidgetField::onAddStep() aTable->setItem(j, i, aItem); } AttributeSelectionPtr aAttr = aSelList->value(j - 1); - aItem->setText(aAttr->namingName().c_str()); - aItem->setToolTip(aAttr->namingName().c_str()); + aItem->setText(QString::fromStdWString(aAttr->namingName())); + aItem->setToolTip(QString::fromStdWString(aAttr->namingName())); } } else { QString aDefVal = aTable->item(0, i)->text(); @@ -885,8 +885,8 @@ bool CollectionPlugin_WidgetField:: aTable->setItem(j, i, aItem); } AttributeSelectionPtr aAttr = aSelList->value(j - 1); - aItem->setText(aAttr->namingName().c_str()); - aItem->setToolTip(aAttr->namingName().c_str()); + aItem->setText(QString::fromStdWString(aAttr->namingName())); + aItem->setToolTip(QString::fromStdWString(aAttr->namingName())); } } else { QString aDefVal = aTable->item(0, i)->text(); @@ -904,8 +904,8 @@ bool CollectionPlugin_WidgetField:: // Update only selection name for(int j = 1; j < aNewRows - 1; j++) { AttributeSelectionPtr aAttr = aSelList->value(j); - aTable->item(j, 0)->setText(aAttr->namingName().c_str()); - aTable->item(j, 0)->setToolTip(aAttr->namingName().c_str()); + aTable->item(j, 0)->setText(QString::fromStdWString(aAttr->namingName())); + aTable->item(j, 0)->setToolTip(QString::fromStdWString(aAttr->namingName())); } } } diff --git a/src/Events/Events.i b/src/Events/Events.i index 5b543e58c..23486b053 100644 --- a/src/Events/Events.i +++ b/src/Events/Events.i @@ -43,6 +43,7 @@ // standard definitions %include "typemaps.i" %include "std_string.i" +%include "std_wstring.i" // directors %feature("director") Events_Listener; diff --git a/src/Events/Events_InfoMessage.cpp b/src/Events/Events_InfoMessage.cpp index a9b3cd3fb..50f41d121 100644 --- a/src/Events/Events_InfoMessage.cpp +++ b/src/Events/Events_InfoMessage.cpp @@ -18,23 +18,21 @@ // #include "Events_InfoMessage.h" - -#ifdef WIN32 -#pragma warning(disable : 4996) // for sprintf -#endif +#include +#include void Events_InfoMessage::addParameter(double theParam) { - static char aBuf[50]; - sprintf(aBuf, "%g", theParam); - myParameters.push_back(std::string(aBuf)); + std::stringstream aStream; + aStream << theParam; + myParameters.push_back(aStream.str()); } void Events_InfoMessage::addParameter(int theParam) { - static char aBuf[50]; - sprintf(aBuf, "%d", theParam); - myParameters.push_back(std::string(aBuf)); + std::stringstream aStream; + aStream << theParam; + myParameters.push_back(aStream.str()); } void Events_InfoMessage::send() @@ -42,3 +40,10 @@ void Events_InfoMessage::send() std::shared_ptr aMsg(new Events_InfoMessage(*this)); Events_Loop::loop()->send(aMsg); } + +Events_InfoMessage& Events_InfoMessage::arg(const std::wstring& theParam) +{ + static std::wstring_convert > aConvertor; + addParameter(aConvertor.to_bytes(theParam)); + return *this; +} diff --git a/src/Events/Events_InfoMessage.h b/src/Events/Events_InfoMessage.h index a64b5e8bf..ea19ee115 100644 --- a/src/Events/Events_InfoMessage.h +++ b/src/Events/Events_InfoMessage.h @@ -95,6 +95,10 @@ public: /// Returns list of parameters std::list parameters() const { return myParameters; } + /// Add parameter for message string of wstring type + /// \param theParam the parameter + EVENTS_EXPORT Events_InfoMessage& arg(const std::wstring& theParam); + /// Add parameter for message string of string type /// \param theParam the parameter Events_InfoMessage& arg(const std::string& theParam) { addParameter(theParam); return *this; } diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 93500cc5e..d27a17086 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -394,7 +394,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 = aResultBody->data()->name(); + aGeometryName = ModelAPI_Tools::toString(aResultBody->data()->name()); } aXao.getGeometry()->setName(aGeometryName); @@ -429,7 +429,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) XAO::Dimension aGroupDimension = XAO::XaoUtils::stringToDimension(aDimensionString); XAO::Group* aXaoGroup = aXao.addGroup(aGroupDimension, - aResultGroup->data()->name()); + ModelAPI_Tools::toString(aResultGroup->data()->name())); try { GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType); @@ -448,7 +448,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 " + - aResultGroup->data()->name(); + ModelAPI_Tools::toString(aResultGroup->data()->name()); msg += ".\n"; msg += e.what(); msg += "\n"; @@ -485,7 +485,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(), - aResultField->data()->name()); + ModelAPI_Tools::toString(aResultField->data()->name())); try { @@ -546,7 +546,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 " + - aResultField->data()->name(); + ModelAPI_Tools::toString(aResultField->data()->name()); msg += ".\n"; msg += e.what(); msg += "\n"; diff --git a/src/ExchangePlugin/ExchangePlugin_ExportPart.cpp b/src/ExchangePlugin/ExchangePlugin_ExportPart.cpp index a0889ea27..84951f3ee 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportPart.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportPart.cpp @@ -50,7 +50,7 @@ static bool verifyExport(const std::list& theFeatures, std::list& theExportedParts, std::list& theReferredParts); // Collect names of features as a single string -static std::string namesOfFeatures(const std::list& theFeatures); +static std::wstring namesOfFeatures(const std::list& theFeatures); ExchangePlugin_ExportPart::ExchangePlugin_ExportPart() @@ -101,7 +101,7 @@ void ExchangePlugin_ExportPart::execute() std::list anExternalLinks, anExportedParts, aReferredParts; if (!verifyExport(aFeaturesToExport, anExternalLinks, anExportedParts, aReferredParts)) { if (!anExternalLinks.empty()) { - std::string aListOfFeatures = namesOfFeatures(anExternalLinks); + std::wstring aListOfFeatures = namesOfFeatures(anExternalLinks); std::string aMessage = "The selected results were created using external references " "outside of this Part from features %1. " @@ -110,7 +110,7 @@ void ExchangePlugin_ExportPart::execute() Events_InfoMessage(getKind(), aMessage).arg(aListOfFeatures).send(); } if (!aReferredParts.empty()) { - std::string aListOfParts = namesOfFeatures(aReferredParts); + std::wstring aListOfParts = namesOfFeatures(aReferredParts); std::string aMessage = "The selected results were created using references " "to the results of Parts: %1. Please, remove these references " @@ -118,7 +118,7 @@ void ExchangePlugin_ExportPart::execute() Events_InfoMessage(getKind(), aMessage).arg(aListOfParts).send(); } if (!anExportedParts.empty()) { - std::string aListOfParts = namesOfFeatures(anExportedParts); + std::wstring aListOfParts = namesOfFeatures(anExportedParts); std::string aMessage = "The export of Part's result is forbidden (%1)."; Events_InfoMessage(getKind(), aMessage).arg(aListOfParts).send(); @@ -273,9 +273,9 @@ bool verifyExport(const std::list& theFeatures, return theExternalReferences.empty() && theExportedParts.empty() && theReferredParts.empty(); } -std::string namesOfFeatures(const std::list& theFeatures) +std::wstring namesOfFeatures(const std::list& theFeatures) { - std::ostringstream aListOfFeatures; + std::wostringstream aListOfFeatures; for (std::list::const_iterator anIt = theFeatures.begin(); anIt != theFeatures.end(); ++anIt) { if (anIt != theFeatures.begin()) diff --git a/src/ExchangePlugin/ExchangePlugin_Import.cpp b/src/ExchangePlugin/ExchangePlugin_Import.cpp index 0f223698c..f6d04041d 100644 --- a/src/ExchangePlugin/ExchangePlugin_Import.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Import.cpp @@ -30,9 +30,9 @@ #include -static const std::string THE_NEW_PART_STR("New Part"); +static const std::wstring THE_NEW_PART_STR(L"New Part"); -DocumentPtr findDocument(DocumentPtr thePartSetDoc, const std::string& thePartName) +DocumentPtr findDocument(DocumentPtr thePartSetDoc, const std::wstring& thePartName) { DocumentPtr aDoc; FeaturePtr aPartFeature; @@ -100,7 +100,8 @@ void ExchangePlugin_Import::execute() AttributeIntegerPtr aTargetAttr = integer(TARGET_PART_ID()); SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aDoc = - findDocument(aSession->moduleDocument(), aPartsAttr->value(aTargetAttr->value())); + findDocument(aSession->moduleDocument(), + ModelAPI_Tools::toWString(aPartsAttr->value(aTargetAttr->value()))); if (aDoc.get()) { FeaturePtr aImportFeature = aDoc->addFeature(ExchangePlugin_ImportFeature::ID()); @@ -127,7 +128,7 @@ void ExchangePlugin_Import::attributeChanged(const std::string& theID) DocumentPtr aDoc = document(); bool isPartSet = aDoc == aSession->moduleDocument(); if (isPartSet) { - std::list anAcceptedValues; + std::list anAcceptedValues; anAcceptedValues.push_back(THE_NEW_PART_STR); // append names of all parts @@ -142,9 +143,9 @@ void ExchangePlugin_Import::attributeChanged(const std::string& theID) aTargetAttr->setValue(0); aPartsAttr->setSize((int)anAcceptedValues.size()); - std::list::iterator anIt = anAcceptedValues.begin(); + std::list::iterator anIt = anAcceptedValues.begin(); for (int anInd = 0; anIt != anAcceptedValues.end(); ++anIt, ++anInd) - aPartsAttr->setValue(anInd, *anIt); + aPartsAttr->setValue(anInd, ModelAPI_Tools::toString(*anIt)); } else { // keep only the name of the current part @@ -152,7 +153,7 @@ void ExchangePlugin_Import::attributeChanged(const std::string& theID) FeaturePtr aPartFeature = ModelAPI_Tools::findPartFeature(aSession->moduleDocument(), aDoc); aPartsAttr->setSize(1); - aPartsAttr->setValue(0, aPartFeature->name()); + aPartsAttr->setValue(0, ModelAPI_Tools::toString(aPartFeature->name())); aTargetAttr->setValue(0); } } diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index e6f2e8f3e..b2619119e 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -137,7 +138,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(anObjectName); + data()->setName(ModelAPI_Tools::toWString(anObjectName)); setResult(createResultBody(aGeomShape)); } @@ -161,7 +162,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(aBodyName); + data()->setName(ModelAPI_Tools::toWString(aBodyName)); ResultBodyPtr aResultBody = createResultBody(aGeomShape); setResult(aResultBody); @@ -187,7 +188,7 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName) // group name if (!aXaoGroup->getName().empty()) - aGroupFeature->data()->setName(aXaoGroup->getName()); + aGroupFeature->data()->setName(ModelAPI_Tools::toWString(aXaoGroup->getName())); // fill selection AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list"); @@ -217,7 +218,7 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName) // group name if (!aXaoField->getName().empty()) - aFieldFeature->data()->setName(aXaoField->getName()); + aFieldFeature->data()->setName(ModelAPI_Tools::toWString(aXaoField->getName())); // fill selection AttributeSelectionListPtr aSelectionList = aFieldFeature->selectionList("selected"); diff --git a/src/ExchangePlugin/ExchangePlugin_ImportPart.cpp b/src/ExchangePlugin/ExchangePlugin_ImportPart.cpp index 3b9ec7e06..2dfedff11 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportPart.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportPart.cpp @@ -30,6 +30,7 @@ #include #include +#include static const std::string THE_NEW_PART_STR("New Part"); static const std::string THE_PART_SET_STR("PartSet"); @@ -102,7 +103,7 @@ void ExchangePlugin_ImportPart::attributeChanged(const std::string& theID) for (std::list::iterator aFIt = aSubFeatures.begin(); aFIt != aSubFeatures.end(); ++aFIt) { if ((*aFIt)->getKind() == PartSetPlugin_Part::ID()) - anAcceptedValues.push_back((*aFIt)->name()); + anAcceptedValues.push_back(ModelAPI_Tools::toString((*aFIt)->name())); } if (aPartsAttr->size() != anAcceptedValues.size()) @@ -119,7 +120,7 @@ void ExchangePlugin_ImportPart::attributeChanged(const std::string& theID) FeaturePtr aPartFeature = ModelAPI_Tools::findPartFeature(aSession->moduleDocument(), aDoc); aPartsAttr->setSize(1); - aPartsAttr->setValue(0, aPartFeature->name()); + aPartsAttr->setValue(0, ModelAPI_Tools::toString(aPartFeature->name())); aTargetAttr->setValue(0); } } @@ -147,7 +148,8 @@ DocumentPtr findDocument(DocumentPtr thePartSetDoc, const std::string& thePartNa std::list aSubFeatures = thePartSetDoc->allFeatures(); for (std::list::iterator aFIt = aSubFeatures.begin(); aFIt != aSubFeatures.end(); ++aFIt) { - if ((*aFIt)->getKind() == PartSetPlugin_Part::ID() && (*aFIt)->name() == thePartName) { + if ((*aFIt)->getKind() == PartSetPlugin_Part::ID() && + ModelAPI_Tools::toString((*aFIt)->name()) == thePartName) { aPartFeature = *aFIt; break; } @@ -164,16 +166,16 @@ DocumentPtr findDocument(DocumentPtr thePartSetDoc, const std::string& thePartNa return aDoc; } -typedef std::map > > ObjectNameMap; +typedef std::map > > ObjectNameMap; -bool splitName(std::string& theName, int& theIndex) +bool splitName(std::wstring& theName, int& theIndex) { size_t aLastUndercore = theName.find_last_of('_'); bool isOk = aLastUndercore != std::string::npos; if (isOk) { - char* isNumber; - std::string anIndexStr = theName.substr(aLastUndercore + 1); - theIndex = std::strtol(anIndexStr.c_str(), &isNumber, 10); + size_t isNumber; + std::wstring anIndexStr = theName.substr(aLastUndercore + 1); + theIndex = std::stol(anIndexStr, &isNumber); isOk = isNumber != 0; if (isOk) theName.erase(aLastUndercore); @@ -183,7 +185,7 @@ bool splitName(std::string& theName, int& theIndex) void addIndexedName(const ObjectPtr& theObject, ObjectNameMap& theIndexedNames) { - std::string aName = theObject->data()->name(); + std::wstring aName =theObject->data()->name(); std::string aGroup = theObject->groupName(); int anIndex = 0; bool isIndexed = splitName(aName, anIndex); @@ -220,9 +222,9 @@ static void collectOldNames(DocumentPtr theDocument, std::list& theA } } -static std::string uniqueName(const ObjectPtr& theObject, ObjectNameMap& theExistingNames) +static std::wstring uniqueName(const ObjectPtr& theObject, ObjectNameMap& theExistingNames) { - std::string aName = theObject->data()->name(); + std::wstring aName = theObject->data()->name(); std::string aGroup = theObject->groupName(); int anIndex = 1; splitName(aName, anIndex); @@ -230,7 +232,7 @@ static std::string uniqueName(const ObjectPtr& theObject, ObjectNameMap& theExis ObjectNameMap::iterator aFoundGroup = theExistingNames.find(aGroup); bool isUnique = aFoundGroup == theExistingNames.end(); - std::map >::iterator aFound; + std::map >::iterator aFound; if (!isUnique) { aFound = aFoundGroup->second.find(aName); isUnique = aFound == aFoundGroup->second.end(); @@ -248,7 +250,7 @@ static std::string uniqueName(const ObjectPtr& theObject, ObjectNameMap& theExis if (anIndex != *aFoundIndex) break; // compose the new name - std::ostringstream aNewName; + std::wostringstream aNewName; aNewName << aName << "_" << anIndex; aName = aNewName.str(); // add new index @@ -266,7 +268,7 @@ void correntNonUniqueNames(DocumentPtr theDocument, std::list& theIm for (std::list::iterator anIt = theImported.begin(); anIt != theImported.end(); ++anIt) { // update name of feature - std::string aNewName = uniqueName(*anIt, aNames); + std::wstring aNewName = uniqueName(*anIt, aNames); (*anIt)->data()->setName(aNewName); // update names of results const std::list& aResults = (*anIt)->results(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Copy.cpp b/src/FeaturesPlugin/FeaturesPlugin_Copy.cpp index 76db7fa04..7f480891b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Copy.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Copy.cpp @@ -59,7 +59,7 @@ void FeaturesPlugin_Copy::execute() int aCopiesNum = integer(NUMBER())->value(); AttributeSelectionListPtr aList = selectionList(OBJECTS()); int aResultIndex = 0; - std::set anExistingNames; // to avoid names duplication + std::set anExistingNames; // to avoid names duplication for(int aCopy = 0; aCopy < aCopiesNum; aCopy++) { for (int aSelIndex = 0; aSelIndex < aList->size(); aSelIndex++) { AttributeSelectionPtr aSel = aList->value(aSelIndex); @@ -74,13 +74,13 @@ void FeaturesPlugin_Copy::execute() } GeomShapePtr aResult = aCopyBuilder->shape(); - std::string aBaseName = aSel->context() ? aSel->context()->data()->name() : + std::wstring aBaseName = aSel->context() ? aSel->context()->data()->name() : aSel->contextFeature()->firstResult()->data()->name(); - std::string aName; + std::wstring aName; int anInd = 0; do { anInd++; - std::ostringstream aNameStr; + std::wostringstream aNameStr; aNameStr << aBaseName << "_" << (aCopy + anInd); aName = aNameStr.str(); } while (anExistingNames.count(aName)); @@ -90,7 +90,7 @@ void FeaturesPlugin_Copy::execute() document()->createBody(data(), aResultIndex); aResultBody->data()->setName(aName); // to make sub-results also names with a similar name temporarily rename the feature - std::string anOrigName = name(); + std::wstring anOrigName = name(); data()->setName(aBaseName); aResultBody->store(aResult); data()->setName(anOrigName); diff --git a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp index 5920c21a7..462a2c3d8 100644 --- a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp +++ b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp @@ -71,7 +71,7 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptrsend(aMsg); - FeaturePtr aOrigin = createPoint(aDoc, "Origin", 0., 0., 0.); + FeaturePtr aOrigin = createPoint(aDoc, L"Origin", 0., 0., 0.); aFeatures.push_back(aOrigin); aFeatures.push_back(createAxis(aDoc, aOrigin, 100., 0., 0.)); aFeatures.push_back(createAxis(aDoc, aOrigin, 0., 100., 0.)); @@ -114,11 +114,11 @@ FeaturePtr InitializationPlugin_Plugin::createPlane(DocumentPtr theDoc, double t aPlane->real("D")->setValue(0.); if (theX) { - aPlane->data()->setName("YOZ"); + aPlane->data()->setName(L"YOZ"); } else if (theY) { - aPlane->data()->setName("XOZ"); + aPlane->data()->setName(L"XOZ"); } else if (theZ) { - aPlane->data()->setName("XOY"); + aPlane->data()->setName(L"XOY"); } // don't show automatically created feature in the features history aPlane->setInHistory(aPlane, false); @@ -134,7 +134,7 @@ FeaturePtr InitializationPlugin_Plugin::createPlane(DocumentPtr theDoc, double t return aPlane; } -FeaturePtr InitializationPlugin_Plugin::createPoint(DocumentPtr theDoc, const std::string& theName, +FeaturePtr InitializationPlugin_Plugin::createPoint(DocumentPtr theDoc, const std::wstring& theName, double theX, double theY, double theZ) { std::shared_ptr aPoint = theDoc->addFeature("Point"); @@ -169,11 +169,11 @@ FeaturePtr InitializationPlugin_Plugin::createAxis(DocumentPtr theDoc, FeaturePt aAxis->real("Z_Direction")->setValue(theZ); if (theX != 0) { - aAxis->data()->setName("OX"); + aAxis->data()->setName(L"OX"); } else if (theY != 0) { - aAxis->data()->setName("OY"); + aAxis->data()->setName(L"OY"); } else if (theZ != 0) { - aAxis->data()->setName("OZ"); + aAxis->data()->setName(L"OZ"); } // don't show automatically created feature in the features history aAxis->setInHistory(aAxis, false); diff --git a/src/InitializationPlugin/InitializationPlugin_Plugin.h b/src/InitializationPlugin/InitializationPlugin_Plugin.h index dca223f04..b70ff75af 100644 --- a/src/InitializationPlugin/InitializationPlugin_Plugin.h +++ b/src/InitializationPlugin/InitializationPlugin_Plugin.h @@ -58,7 +58,7 @@ class InitializationPlugin_Plugin : public Events_Listener /// \param theX - X coordinate /// \param theY - Y coordinate /// \param theZ - Z coordinate - FeaturePtr createPoint(DocumentPtr theDoc, const std::string& theName, + FeaturePtr createPoint(DocumentPtr theDoc, const std::wstring& theName, double theX, double theY, double theZ); /// Creates an axis which is started from origin point diff --git a/src/Model/Model_Application.cpp b/src/Model/Model_Application.cpp index c2772757f..36634ff15 100644 --- a/src/Model/Model_Application.cpp +++ b/src/Model/Model_Application.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -61,7 +62,7 @@ void Model_Application::createDocument(const int theDocID) } //======================================================================= -bool Model_Application::loadDocument(const std::string theDocName, const int theDocID) +bool Model_Application::loadDocument(const std::wstring theDocName, const int theDocID) { static const std::string thePartKind("Part"); // root document is never loaded here std::shared_ptr aNew(new Model_Document(theDocID, thePartKind)); @@ -70,7 +71,7 @@ bool Model_Application::loadDocument(const std::string theDocName, const int the 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(), theDocName.c_str(), aNew); + aRes = aNew->load(myPath.c_str(), ModelAPI_Tools::toString(theDocName).c_str(), aNew); myLoadedByDemand.erase(theDocName); // done, don't do it anymore } else { // error aRes = false; @@ -132,13 +133,13 @@ const std::string& Model_Application::loadPath() const } //======================================================================= -void Model_Application::setLoadByDemand(std::string theID, const int theDocID) +void Model_Application::setLoadByDemand(std::wstring theID, const int theDocID) { myLoadedByDemand[theID] = theDocID; } //======================================================================= -bool Model_Application::isLoadByDemand(std::string theID, const int theDocIndex) +bool Model_Application::isLoadByDemand(std::wstring theID, const int theDocIndex) { return myLoadedByDemand.find(theID) != myLoadedByDemand.end() && myLoadedByDemand[theID] == theDocIndex; @@ -152,7 +153,7 @@ int Model_Application::generateDocumentId() for(aResult = int(myDocs.size()); true; aResult++) { if (myDocs.find(aResult) == myDocs.end()) { bool aFound = false; - std::map::iterator aLBDIter = myLoadedByDemand.begin(); + std::map::iterator aLBDIter = myLoadedByDemand.begin(); for(; aLBDIter != myLoadedByDemand.end(); aLBDIter++) { if (aLBDIter->second == aResult) { aFound = true; diff --git a/src/Model/Model_Application.h b/src/Model/Model_Application.h index e0fb01c1a..4630c7359 100644 --- a/src/Model/Model_Application.h +++ b/src/Model/Model_Application.h @@ -66,16 +66,16 @@ public: //! \param theDocName name of the document file //! \param theDocID the identifier of the loaded document (to be created) //! \returns true if load is ok - MODEL_EXPORT bool loadDocument(const std::string theDocName, const int theDocID); + MODEL_EXPORT bool loadDocument(const std::wstring theDocName, const int theDocID); //! Set path for the loaded by demand documents void setLoadPath(std::string thePath); //! Returns the path for the loaded by demand documents const std::string& loadPath() const; //! Defines that specified document must be loaded by demand - void setLoadByDemand(std::string theID, const int theDocID); + void setLoadByDemand(std::wstring theID, const int theDocID); //! Returns true if specified document must be loaded by demand - bool isLoadByDemand(std::string theID, const int theDocIndex); + bool isLoadByDemand(std::wstring theID, const int theDocIndex); //! produces new unique identifier of the document int generateDocumentId(); @@ -98,7 +98,7 @@ public: /// Path for the loaded by demand documents std::string myPath; /// Path for the loaded by demand documents (and the persistent ID as the value) - std::map myLoadedByDemand; + std::map myLoadedByDemand; }; #endif diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 5c85b0237..88912aaca 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -94,7 +94,7 @@ Standard_GUID kELLIPSE_CENTER1("f70df04c-3168-4dc9-87a4-f1f840c1275d"); Standard_GUID kELLIPSE_CENTER2("1395ae73-8e02-4cf8-b204-06ff35873a32"); // prefix for the whole feature context identification -const static std::string kWHOLE_FEATURE = "all-in-"; +const static std::wstring kWHOLE_FEATURE = L"all-in-"; // on this label is stored: // TNaming_NamedShape - selected shape @@ -368,7 +368,7 @@ std::shared_ptr 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(aNameInPart, aType, anIndex); + return aPart->shapeInPart(ModelAPI_Tools::toWString(aNameInPart), aType, anIndex); } } } @@ -715,13 +715,13 @@ bool Model_AttributeSelection::selectPart( } // store the shape (in case part is not loaded it should be useful TopoDS_Shape aShape; - std::string aName = theContext->data()->name(); + std::wstring aName = theContext->data()->name(); if (!theSubShape.get() || theSubShape->isNull()) {// the whole part shape is selected aShape = theContext->shape()->impl(); } else { aShape = theSubShape->impl(); int anIndex; - aName += "/" + aPart->nameInPart(theSubShape, anIndex); + aName += L"/" + aPart->nameInPart(theSubShape, anIndex); TDataStd_Integer::Set(selectionLabel(), anIndex); } TNaming_Builder aBuilder(selectionLabel()); @@ -737,22 +737,22 @@ TDF_Label Model_AttributeSelection::selectionLabel() } /// prefixes of the shape names with centers defined -static std::map kCENTERS_PREFIX; +static std::map kCENTERS_PREFIX; /// returns the map that contains all possible prefixes of the center-names -static std::map& centersMap() +static std::map& centersMap() { if (kCENTERS_PREFIX.empty()) { // fill map by initial values - kCENTERS_PREFIX[ModelAPI_AttributeSelection::CIRCLE_CENTER] = "__cc"; - kCENTERS_PREFIX[ModelAPI_AttributeSelection::ELLIPSE_FIRST_FOCUS] = "__eff"; - kCENTERS_PREFIX[ModelAPI_AttributeSelection::ELLIPSE_SECOND_FOCUS] = "__esf"; + kCENTERS_PREFIX[ModelAPI_AttributeSelection::CIRCLE_CENTER] = L"__cc"; + kCENTERS_PREFIX[ModelAPI_AttributeSelection::ELLIPSE_FIRST_FOCUS] = L"__eff"; + kCENTERS_PREFIX[ModelAPI_AttributeSelection::ELLIPSE_SECOND_FOCUS] = L"__esf"; } return kCENTERS_PREFIX; } -std::string Model_AttributeSelection::namingName(const std::string& theDefaultName) +std::wstring Model_AttributeSelection::namingName(const std::wstring& theDefaultName) { - std::string aName(""); + std::wstring aName(L""); if(!this->isInitialized()) return !theDefaultName.empty() ? theDefaultName : aName; @@ -761,12 +761,13 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa GeomShapePtr aShape = value(); if (!aShape.get() && context().get()) aShape = context()->shape(); - std::string aName; + std::wstring aName; if (aShape.get()) { - aName = aShape->shapeTypeStr(); + aName = ModelAPI_Tools::toWString(aShape->shapeTypeStr()); if (myParent) { - aName += std::string("_") + - TCollection_AsciiString(selectionLabel().Father().Tag()).ToCString(); + std::wostringstream aStream; + aStream << "_" << selectionLabel().Father().Tag(); + aName += aStream.str(); } } return aName; @@ -777,21 +778,21 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa FeaturePtr aContFeature = contextFeature(); if (aContFeature.get()) { - std::string aResName; + std::wstring aResName; // checking part-owner if (aContFeature->document() != owner()->document()) - aResName += aContFeature->document()->kind() + "/"; + aResName += ModelAPI_Tools::toWString(aContFeature->document()->kind()) + L"/"; // selection of a full feature if (aContFeature.get()) { return aResName + kWHOLE_FEATURE + aContFeature->name(); } // in case of selection of removed result - return ""; + return L""; } ResultPtr aCont = context(); if (!aCont.get()) { - return ""; // invalid case + return L""; // invalid case } TDF_Label aSelLab = selectionLabel(); if (aSelLab.IsAttribute(kSIMPLE_REF_ID)) { // whole context, no value @@ -802,8 +803,9 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa if (aCont->groupName() == ModelAPI_ResultPart::group()) { ResultPartPtr aPart = std::dynamic_pointer_cast(aCont); int anIndex; - std::string aResult = aSubSh.get() ? - aPart->data()->name() + "/" + aPart->nameInPart(aSubSh, anIndex) : aPart->data()->name(); + std::wstring aResult = aSubSh.get() ? + aPart->data()->name() + L"/" + aPart->nameInPart(aSubSh, anIndex) + : aPart->data()->name(); if (aCenterType != NOT_CENTER) aResult += centersMap()[aCenterType]; return aResult; @@ -818,7 +820,7 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa } Selector_Selector aSelector(aSelLab, baseDocumentLab()); - std::string aResult; + std::wstring aResult; if (aCont->shape().get() && aSelector.restore(aCont->shape()->impl())) aResult = aSelector.name(this); if (aCenterType != NOT_CENTER) { @@ -828,9 +830,9 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa } // returns the center type and modifies the shape name if this name is center-name -static ModelAPI_AttributeSelection::CenterType centerTypeByName(std::string& theShapeName) +static ModelAPI_AttributeSelection::CenterType centerTypeByName(std::wstring& theShapeName) { - std::map::iterator aPrefixIter = + std::map::iterator aPrefixIter = centersMap().begin(); for(; aPrefixIter != centersMap().end(); aPrefixIter++) { std::size_t aFound = theShapeName.find(aPrefixIter->second); @@ -845,11 +847,11 @@ static ModelAPI_AttributeSelection::CenterType centerTypeByName(std::string& the // type ::= COMP | COMS | SOLD | SHEL | FACE | WIRE | EDGE | VERT void Model_AttributeSelection::selectSubShape( - const std::string& theType, const std::string& theSubShapeName) + const std::string& theType, const std::wstring& theSubShapeName) { if(theSubShapeName.empty() || theType.empty()) return; - std::string aSubShapeName = theSubShapeName; + std::wstring aSubShapeName = theSubShapeName; CenterType aCenterType = theType[0] == 'v' || theType[0] == 'V' ? // only for vertex-type centerTypeByName(aSubShapeName) : NOT_CENTER; std::string aType = aCenterType == NOT_CENTER ? theType : "EDGE"; // search for edge now @@ -870,9 +872,9 @@ void Model_AttributeSelection::selectSubShape( // check this is Part-name: 2 delimiters in the name std::size_t aPartEnd = aSubShapeName.find('/'); if (aPartEnd != std::string::npos) { - std::string aPartName = aSubShapeName.substr(0, aPartEnd); + std::wstring aPartName = aSubShapeName.substr(0, aPartEnd); DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - if (aPartName == aRootDoc->kind()) { + if (aPartName == ModelAPI_Tools::toWString(aRootDoc->kind())) { aDoc = std::dynamic_pointer_cast(aRootDoc); aSubShapeName = aSubShapeName.substr(aPartEnd + 1); } @@ -881,7 +883,7 @@ void Model_AttributeSelection::selectSubShape( owner()->document()->objectByName(ModelAPI_ResultPart::group(), aPartName); if (aFound.get()) { // found such part, so asking it for the name ResultPartPtr aPart = std::dynamic_pointer_cast(aFound); - std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1); + std::wstring aNameInPart = aSubShapeName.substr(aPartEnd + 1); if (aNameInPart.empty()) { // whole part setValue(aPart, anEmptyShape); return; @@ -924,7 +926,7 @@ void Model_AttributeSelection::selectSubShape( // check this is a whole feature context if (aSubShapeName.size() > kWHOLE_FEATURE.size() && aSubShapeName.substr(0, kWHOLE_FEATURE.size()) == kWHOLE_FEATURE) { - std::string aFeatureName = aSubShapeName.substr(kWHOLE_FEATURE.size()); + std::wstring aFeatureName = aSubShapeName.substr(kWHOLE_FEATURE.size()); ObjectPtr anObj = aDoc->objectByName(ModelAPI_Feature::group(), aFeatureName); if (anObj.get()) { setValue(anObj, anEmptyShape); @@ -1075,7 +1077,7 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType, } void Model_AttributeSelection::selectSubShape(const std::string& theType, - const std::string& theContextName, const int theIndex) + const std::wstring& theContextName, const int theIndex) { // selection of context by name selectSubShape(theType, theContextName); @@ -1128,17 +1130,17 @@ void Model_AttributeSelection::setId(int theID) setValue(aContextRes, aSelection); } -std::string Model_AttributeSelection::contextName(const ResultPtr& theContext) const +std::wstring Model_AttributeSelection::contextName(const ResultPtr& theContext) const { - std::string aResult; + std::wstring aResult; if (owner()->document() != theContext->document()) { if (theContext->document() == ModelAPI_Session::get()->moduleDocument()) { - aResult = theContext->document()->kind() + "/"; + aResult = ModelAPI_Tools::toWString(theContext->document()->kind()) + L"/"; } else { ResultPtr aDocRes = ModelAPI_Tools::findPartResult( ModelAPI_Session::get()->moduleDocument(), theContext->document()); if (aDocRes.get()) { - aResult = aDocRes->data()->name() + "/"; + aResult = aDocRes->data()->name() + L"/"; } } } @@ -1843,7 +1845,7 @@ void Model_AttributeSelection::setParent(Model_AttributeSelectionList* theParent myParent = theParent; } -std::string Model_AttributeSelection::contextName(const TDF_Label theSelectionLab) +std::wstring Model_AttributeSelection::contextName(const TDF_Label theSelectionLab) { std::shared_ptr aDoc = myRestoreDocument.get() ? myRestoreDocument : std::dynamic_pointer_cast(owner()->document()); @@ -1868,7 +1870,7 @@ std::string Model_AttributeSelection::contextName(const TDF_Label theSelectionLa } if (aResult.get()) { // this is to avoid duplicated names of results problem - std::string aContextName = aResult->data()->name(); + std::wstring aContextName = aResult->data()->name(); // myLab corresponds to the current time TDF_Label aCurrentLab = selectionLabel(); while(aCurrentLab.Depth() > 3) @@ -1877,29 +1879,29 @@ std::string Model_AttributeSelection::contextName(const TDF_Label theSelectionLa int aNumInHistoryNames = aDoc->numberOfNameInHistory(aResult, aCurrentLab); while(aNumInHistoryNames > 1) { // add "_" before name the needed number of times - aContextName = "_" + aContextName; + aContextName = L"_" + aContextName; aNumInHistoryNames--; } if (aBaseDocumnetUsed) - aContextName = aDoc->kind() + "/" + aContextName; + aContextName = ModelAPI_Tools::toWString(aDoc->kind()) + L"/" + aContextName; return aContextName; } } - return ""; // invalid case + return L""; // invalid case } /// This method restores by the context and value name the context label and /// sub-label where the value is. Returns true if it is valid. -bool Model_AttributeSelection::restoreContext(std::string theName, +bool Model_AttributeSelection::restoreContext(std::wstring theName, TDF_Label& theContext, TDF_Label& theValue) { static const GeomShapePtr anEmptyShape; // to store context only - std::string aName = theName; + std::wstring aName = theName; std::shared_ptr aDoc = myRestoreDocument.get() ? myRestoreDocument : std::dynamic_pointer_cast(owner()->document()); // remove the sub-value part if exists - std::string aSubShapeName = aName; + std::wstring aSubShapeName = aName; std::string::size_type n = aName.find('/'); if (n != std::string::npos) { aName = aName.substr(0, n); @@ -1912,7 +1914,7 @@ bool Model_AttributeSelection::restoreContext(std::string theName, // name in PartSet? aDoc = std::dynamic_pointer_cast( ModelAPI_Session::get()->moduleDocument()); - if (theName.find(aDoc->kind()) == 0) { // remove the document identifier from name if exists + if (theName.find(ModelAPI_Tools::toWString(aDoc->kind())) == 0) { // remove the document identifier from name if exists aSubShapeName = theName.substr(aDoc->kind().size() + 1); aName = aSubShapeName; std::string::size_type n = aName.find('/'); @@ -1933,7 +1935,7 @@ bool Model_AttributeSelection::restoreContext(std::string theName, if (theValue.IsNull() && aCont->groupName() == ModelAPI_ResultConstruction::group()) { std::string::size_type aSlash = aSubShapeName.rfind('/'); if (aSlash != std::string::npos) { - std::string aCompName = aSubShapeName.substr(aSlash + 1); + std::wstring aCompName = aSubShapeName.substr(aSlash + 1); CompositeFeaturePtr aComposite = std::dynamic_pointer_cast(aDoc->feature(aCont)); if (aComposite.get() && aComposite->numberOfSubs()) { @@ -2116,7 +2118,7 @@ void Model_AttributeSelection::combineGeometrical() Handle(TDataStd_Integer) anIndex; if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) { if (anIndex->Get()) { // special selection attribute was created, use it - std::string aNewName; + std::wstring aNewName; aPart->combineGeometrical(anIndex->Get(), aNewName); TDataStd_Name::Set(aSelLab, aNewName.c_str()); } diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 8e70cb28b..3b718a223 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -97,21 +97,21 @@ public: /// Returns a textual string of the selection /// \param theDefaultValue a name, which is returned if the naming name can not be obtained - MODEL_EXPORT virtual std::string namingName(const std::string& theDefaultValue = ""); + MODEL_EXPORT virtual std::wstring namingName(const std::wstring& theDefaultValue = L""); /// Defines the sub-shape by Id MODEL_EXPORT virtual void setId(int theID); /// Selects (i.e. creates Naming data structure) of sub-shape specified by textual name MODEL_EXPORT virtual void selectSubShape(const std::string& theType, - const std::string& theSubShapeName); + const std::wstring& theSubShapeName); /// Selects sub-shape by its inner point MODEL_EXPORT virtual void selectSubShape(const std::string& theType, const std::shared_ptr& thePoint); /// Selects sub-shape by weak naming index MODEL_EXPORT virtual void selectSubShape(const std::string& theType, - const std::string& theContextName, const int theIndex); + const std::wstring& theContextName, const int theIndex); /// Returns true if attribute was initialized by some value MODEL_EXPORT virtual bool isInitialized(); @@ -126,11 +126,11 @@ public: // Implementation of the name generator method from the Selector package // This method returns the context name by the label of the sub-selected shape - MODEL_EXPORT virtual std::string contextName(const TDF_Label theSelectionLab) override; + MODEL_EXPORT virtual std::wstring contextName(const TDF_Label theSelectionLab) override; /// This method restores by the context and value name the context label and /// sub-label where the value is. Returns true if it is valid. - MODEL_EXPORT virtual bool restoreContext(std::string theName, + MODEL_EXPORT virtual bool restoreContext(std::wstring theName, TDF_Label& theContext, TDF_Label& theValue) override; /// Returns true if the first result is newer than the second one in the tree of features @@ -138,7 +138,7 @@ public: const override; /// Returns the name by context. Adds the part name if the context is located in other document - MODEL_EXPORT virtual std::string contextName(const ResultPtr& theContext) const; + MODEL_EXPORT virtual std::wstring contextName(const ResultPtr& theContext) const; /// Makes the current local selection becomes all sub-shapes with same base geometry. MODEL_EXPORT virtual void combineGeometrical(); diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 95a17e9d2..6de1b2356 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -88,7 +88,7 @@ void Model_AttributeSelectionList::append( } void Model_AttributeSelectionList::append( - const std::string& theNamingName, const std::string& theType) + const std::wstring& theNamingName, const std::string& theType) { int aNewTag = mySize->Get() + 1; TDF_Label aNewLab = mySize->Label().FindChild(aNewTag); @@ -123,7 +123,7 @@ void Model_AttributeSelectionList::append(const GeomPointPtr& thePoint, const st } void Model_AttributeSelectionList::append(const std::string& theType, - const std::string& theContextName, const int theIndex) + const std::wstring& theContextName, const int theIndex) { int aNewTag = mySize->Get() + 1; TDF_Label aNewLab = mySize->Label().FindChild(aNewTag); diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index 2db50d9b4..ea93c155c 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -56,14 +56,14 @@ public: /// Adds the new reference to the end of the list by the naming name of the selected shape /// The type of shape is taken from the current selection type if the given is empty - MODEL_EXPORT virtual void append(const std::string& theNamingName, const std::string& theType=""); + MODEL_EXPORT virtual void append(const std::wstring& theNamingName, const std::string& theType=""); /// Adds the new reference to the end of the list by inner point on the selected shape MODEL_EXPORT virtual void append(const std::shared_ptr& thePoint, const std::string& theType); /// Adds the new reference to the end of the list by weak naming index - MODEL_EXPORT virtual void append(const std::string& theType, const std::string& theContextName, + MODEL_EXPORT virtual void append(const std::string& theType, const std::wstring& theContextName, const int theIndex); /// Copy the selection list to the destination attribute diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 9aa0b983b..fa9fc4468 100644 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -202,7 +202,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::string aName (TCollection_AsciiString(anAttr->Get()).ToCString()); + std::wstring aName ((wchar_t*)anAttr->Get().ToExtString()); if(!aName.empty()) { std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); @@ -255,7 +255,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::string aName (TCollection_AsciiString(anAttr->Get()).ToCString()); + std::wstring aName((wchar_t*)anAttr->Get().ToExtString()); if(!aName.empty()) { std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); @@ -347,7 +347,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::string aName (TCollection_AsciiString(anAttr->Get()).ToCString()); + std::wstring aName ((wchar_t*)anAttr->Get().ToExtString()); if(!aName.empty()) { std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 41f9980b3..dea65b8a5 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -106,22 +106,23 @@ void Model_Data::setLabel(TDF_Label theLab) } } -std::string Model_Data::name() +std::wstring Model_Data::name() { Handle(TDataStd_Name) aName; if (shapeLab().FindAttribute(TDataStd_Name::GetID(), aName)) { #ifdef DEBUG_NAMES myObject->myName = TCollection_AsciiString(aName->Get()).ToCString(); #endif - return std::string(TCollection_AsciiString(aName->Get()).ToCString()); + return std::wstring((wchar_t*)aName->Get().ToExtString()); + //return std::wstring(TCollection_AsciiString(aName->Get()).ToCString()); } - return ""; // not defined + return L""; // not defined } -void Model_Data::setName(const std::string& theName) +void Model_Data::setName(const std::wstring& theName) { bool isModified = false; - std::string anOldName = name(); + std::wstring anOldName = name(); Handle(TDataStd_Name) aName; if (!shapeLab().FindAttribute(TDataStd_Name::GetID(), aName)) { TDataStd_Name::Set(shapeLab(), theName.c_str()); @@ -136,7 +137,7 @@ void Model_Data::setName(const std::string& theName) bool isUserDefined = true; ResultPtr aResult = std::dynamic_pointer_cast(myObject); if (aResult) { - std::string aDefaultName = ModelAPI_Tools::getDefaultName(aResult, false).first; + std::wstring aDefaultName = ModelAPI_Tools::getDefaultName(aResult, false).first; isUserDefined = aDefaultName != theName; } if (isUserDefined) { diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index fa833bdd3..17e8feb74 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -102,9 +102,9 @@ class Model_Data : public ModelAPI_Data /// The simplest constructor. "setLabel" must be called just after to initialize correctly. Model_Data(); /// Returns the name of the feature visible by the user in the object browser - MODEL_EXPORT virtual std::string name(); + MODEL_EXPORT virtual std::wstring name(); /// Defines the name of the feature visible by the user in the object browser - MODEL_EXPORT virtual void setName(const std::string& theName); + MODEL_EXPORT virtual void setName(const std::wstring& theName); /// Return \c true if the object has been renamed by the user MODEL_EXPORT virtual bool hasUserDefinedName() const; /// Returns version of the feature (empty string if not applicable) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 87e7e2f96..a1babc015 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -522,7 +522,7 @@ bool Model_Document::save( ResultPartPtr aPart = std::dynamic_pointer_cast(*aPartRes); if (!aPart->isActivated()) { // copy not-activated document that is not in the memory - std::string aDocName = aPart->data()->name(); + std::string aDocName = ModelAPI_Tools::toString(aPart->data()->name()); if (!aDocName.empty()) { // just copy file TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName)); @@ -539,8 +539,9 @@ bool Model_Document::save( } } } else { // simply save opened document + std::string aDocName = ModelAPI_Tools::toString(aPart->data()->name()); isDone = std::dynamic_pointer_cast(aPart->partDoc())-> - save(theDirName, aPart->data()->name().c_str(), theResults); + save(theDirName, aDocName.c_str(), theResults); } } } @@ -1327,7 +1328,7 @@ ObjectPtr Model_Document::object(const std::string& theGroupID, } std::shared_ptr Model_Document::objectByName( - const std::string& theGroupID, const std::string& theName) + const std::string& theGroupID, const std::wstring& theName) { return myObjs->objectByName(theGroupID, theName); } @@ -1652,9 +1653,9 @@ ResultPtr Model_Document::resultByLab(const TDF_Label& theLab) return ResultPtr(); // not found } -void Model_Document::addNamingName(const TDF_Label theLabel, std::string theName) +void Model_Document::addNamingName(const TDF_Label theLabel, std::wstring theName) { - std::map >::iterator aFind = myNamingNames.find(theName); + std::map >::iterator aFind = myNamingNames.find(theName); if (aFind != myNamingNames.end()) { // to avoid duplicate-labels // to keep correct order in spite of history line management @@ -1686,11 +1687,11 @@ void Model_Document::addNamingName(const TDF_Label theLabel, std::string theName myNamingNames[theName].push_back(theLabel); } -void Model_Document::changeNamingName(const std::string theOldName, - const std::string theNewName, +void Model_Document::changeNamingName(const std::wstring theOldName, + const std::wstring theNewName, const TDF_Label& theLabel) { - std::map >::iterator aFind = myNamingNames.find(theOldName); + std::map >::iterator aFind = myNamingNames.find(theOldName); if (aFind != myNamingNames.end()) { std::list::iterator aLabIter = aFind->second.begin(); for(; aLabIter != aFind->second.end(); aLabIter++) { @@ -1705,9 +1706,9 @@ void Model_Document::changeNamingName(const std::string theOldName, TDF_ChildIDIterator aChild(theLabel, TDataStd_Name::GetID()); for(; aChild.More(); aChild.Next()) { Handle(TDataStd_Name) aSubName = Handle(TDataStd_Name)::DownCast(aChild.Value()); - std::string aName = TCollection_AsciiString(aSubName->Get()).ToCString(); + std::wstring aName = (wchar_t*)aSubName->Get().ToExtString(); if (aName.find(theOldName) == 0) { // started from parent name - std::string aNewSubName = theNewName + aName.substr(theOldName.size()); + std::wstring aNewSubName = theNewName + aName.substr(theOldName.size()); changeNamingName(aName, aNewSubName, aSubName->Label()); aSubName->Set(aNewSubName.c_str()); } @@ -1764,9 +1765,9 @@ static bool IsExchangedName(const TCollection_ExtendedString& theName1, return true; } -TDF_Label Model_Document::findNamingName(std::string theName, ResultPtr theContext) +TDF_Label Model_Document::findNamingName(std::wstring theName, ResultPtr theContext) { - std::map >::iterator aFind = myNamingNames.find(theName); + std::map >::iterator aFind = myNamingNames.find(theName); if (aFind != myNamingNames.end()) { std::list::reverse_iterator aLabIter = aFind->second.rbegin(); for(; aLabIter != aFind->second.rend(); aLabIter++) { @@ -1781,7 +1782,7 @@ TDF_Label Model_Document::findNamingName(std::string theName, ResultPtr theConte // not found exact name, try to find by sub-components std::string::size_type aSlash = theName.rfind('/'); if (aSlash != std::string::npos) { - std::string anObjName = theName.substr(0, aSlash); + std::wstring anObjName = theName.substr(0, aSlash); aFind = myNamingNames.find(anObjName); if (aFind != myNamingNames.end()) { TCollection_ExtendedString aSubName(theName.substr(aSlash + 1).c_str()); @@ -1877,7 +1878,7 @@ bool Model_Document::isLaterByDep(FeaturePtr theThis, FeaturePtr theOther) { int Model_Document::numberOfNameInHistory( const ObjectPtr& theNameObject, const TDF_Label& theStartFrom) { - std::map >::iterator aFind = + std::map >::iterator aFind = myNamingNames.find(theNameObject->data()->name()); if (aFind == myNamingNames.end() || aFind->second.size() < 2) { return 1; // no need to specify the name by additional identifiers @@ -1915,10 +1916,10 @@ int Model_Document::numberOfNameInHistory( } ResultPtr Model_Document::findByName( - std::string& theName, std::string& theSubShapeName, bool& theUniqueContext) + std::wstring& theName, std::wstring& theSubShapeName, bool& theUniqueContext) { int aNumInHistory = 0; - std::string aName = theName; + std::wstring aName = theName; ResultPtr aRes = myObjs->findByName(aName); theUniqueContext = !(aRes.get() && myNamingNames.find(aName) != myNamingNames.end()); while(!aRes.get() && aName[0] == '_') { // this may be theContext with the history index @@ -1927,7 +1928,7 @@ ResultPtr Model_Document::findByName( aRes = myObjs->findByName(aName); } if (aNumInHistory) { - std::map >::iterator aFind = myNamingNames.find(aName); + std::map >::iterator aFind = myNamingNames.find(aName); if (aFind != myNamingNames.end() && aFind->second.size() > aNumInHistory) { std::list::reverse_iterator aLibIt = aFind->second.rbegin(); for(; aNumInHistory != 0; aNumInHistory--) @@ -2072,7 +2073,7 @@ AttributeSelectionListPtr Model_Document::selectionInPartFeature() aData->setObject(mySelectionFeature); mySelectionFeature->setDoc(myObjs->owner()); mySelectionFeature->setData(aData); - std::string aName = id() + "_Part"; + std::wstring aName = id() + L"_Part"; mySelectionFeature->data()->setName(aName); mySelectionFeature->setDoc(myObjs->owner()); mySelectionFeature->initAttributes(); diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 277c822ba..5239524e1 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -135,7 +135,7 @@ class Model_Document : public ModelAPI_Document //! \param theName name of the object to search //! \returns null if such object is not found MODEL_EXPORT virtual std::shared_ptr objectByName( - const std::string& theGroupID, const std::string& theName); + const std::string& theGroupID, const std::wstring& theName); //! Returns the object index in the group. Object must be visible. Otherwise returns -1. //! \param theObject object of this document @@ -273,18 +273,18 @@ class Model_Document : public ModelAPI_Document void setExecuteFeatures(const bool theFlag); //! Registers the name of the shape for the topological naming needs - void addNamingName(const TDF_Label theLabel, std::string theName); + void addNamingName(const TDF_Label theLabel, std::wstring theName); //! Updates the name of some object - void changeNamingName(std::string theOldName, const std::string theNewName, + void changeNamingName(std::wstring theOldName, const std::wstring theNewName, const TDF_Label& theLabel); //! Returns the label, keeper of the name for the topological naming needs - TDF_Label findNamingName(std::string theName, ResultPtr theContext); + TDF_Label findNamingName(std::wstring theName, ResultPtr theContext); //! Returns the number of the name in the history relatively to the given object (by label). //! Start from 1 (this object). int numberOfNameInHistory(const ObjectPtr& theNameObject, const TDF_Label& theStartFrom); //! Returns the result by name of the result (names of results must be unique, used for naming //! selection by name. - ResultPtr findByName(std::string& theName, std::string& theSubShapeName, bool& theUniqueContext); + ResultPtr findByName(std::wstring& theName, std::wstring& theSubShapeName, bool& theUniqueContext); ///! Returns all features of the document including the hidden features which are not in ///! history. Not very fast method, for calling once, not in big cycles. @@ -450,7 +450,7 @@ class Model_Document : public ModelAPI_Document //! Optimization for finding the shape-label by topological naming names //! The name -> list of labels where this name is appeared (the last created name is last here) - std::map > myNamingNames; + std::map > myNamingNames; //! If it is true, features are not executed on update (on abort, undo, redo) bool myExecuteFeatures; diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 6d40674d3..ef4d72a52 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -626,7 +626,7 @@ ObjectPtr Model_Objects::object(const std::string& theGroupID, } std::shared_ptr Model_Objects::objectByName( - const std::string& theGroupID, const std::string& theName) + const std::string& theGroupID, const std::wstring& theName) { createHistory(theGroupID); if (theGroupID == ModelAPI_Feature::group()) { // searching among features (in history or not) @@ -730,22 +730,22 @@ TDF_Label Model_Objects::featuresLabel() const return myMain.FindChild(TAG_OBJECTS); } -static std::string composeName(const std::string& theFeatureKind, const int theIndex) +static std::wstring composeName(const std::string& theFeatureKind, const int theIndex) { std::stringstream aNameStream; aNameStream << theFeatureKind << "_" << theIndex; - return aNameStream.str(); + return ModelAPI_Tools::toWString(aNameStream.str()); } void Model_Objects::setUniqueName(FeaturePtr theFeature) { if (!theFeature->data()->name().empty()) return; // not needed, name is already defined - std::string aName; // result + std::wstring aName; // result // first count all features of such kind to start with index = count + 1 int aNumObjects = -1; // this feature is already in this map NCollection_DataMap::Iterator aFIter(myFeatures); - std::set allNames; + std::set allNames; for (; aFIter.More(); aFIter.Next()) { if (aFIter.Value()->getKind() == theFeature->getKind()) aNumObjects++; @@ -766,7 +766,7 @@ void Model_Objects::setUniqueName(FolderPtr theFolder) return; // name is already defined int aNbFolders = myFolders.Size(); - std::string aName = composeName(ModelAPI_Folder::ID(), aNbFolders); + std::wstring aName = composeName(ModelAPI_Folder::ID(), aNbFolders); // check the uniqueness of the name NCollection_DataMap::Iterator anIt(myFolders); @@ -1189,7 +1189,7 @@ TDF_Label Model_Objects::resultLabel( bool Model_Objects::hasCustomName(DataPtr theFeatureData, ResultPtr theResult, int theResultIndex, - std::string& theParentName) const + std::wstring& theParentName) const { ResultBodyPtr aBodyRes = std::dynamic_pointer_cast(theFeatureData->owner()); if (aBodyRes) { @@ -1200,7 +1200,7 @@ bool Model_Objects::hasCustomName(DataPtr theFeatureData, // result of boolean operation 'Boolean_1' is a CompSolid which is renamed to 'MyBOOL', // however, sub-elements of 'MyBOOL' should be named 'Boolean_1_1', 'Boolean_1_2' etc.) if (std::dynamic_pointer_cast(aBodyRes->data())->label().Depth() == 6) { - std::ostringstream aDefaultName; + std::wostringstream aDefaultName; // compute default name of CompSolid (name of feature + index of CompSolid's result) int aBodyResultIndex = 0; const std::list& aResults = anOwner->results(); @@ -1217,7 +1217,7 @@ bool Model_Objects::hasCustomName(DataPtr theFeatureData, return false; } - std::pair aName = ModelAPI_Tools::getDefaultName(theResult); + std::pair aName = ModelAPI_Tools::getDefaultName(theResult); if (aName.second) theParentName = aName.first; return aName.second; @@ -1232,13 +1232,13 @@ void Model_Objects::storeResult(std::shared_ptr theFeatureData, initData(theResult, resultLabel(theFeatureData, theResultIndex), TAG_FEATURE_ARGUMENTS); if (theResult->data()->name().empty()) { // if was not initialized, generate event and set a name - std::string aNewName = theFeatureData->name(); + std::wstring aNewName = theFeatureData->name(); if (hasCustomName(theFeatureData, theResult, theResultIndex, aNewName)) { // if the name of result is user-defined, then, at first time, assign name of the result // by empty string to be sure that corresponding flag in the data model is set - theResult->data()->setName(""); + theResult->data()->setName(L""); } else { - std::stringstream aName; + std::wstringstream aName; aName << aNewName; // if there are several results (issue #899: any number of result), // add unique prefix starting from second @@ -1937,7 +1937,7 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set& t } } -ResultPtr Model_Objects::findByName(const std::string theName) +ResultPtr Model_Objects::findByName(const std::wstring theName) { ResultPtr aResult; FeaturePtr aResFeature; // keep feature to return the latest one diff --git a/src/Model/Model_Objects.h b/src/Model/Model_Objects.h index b9b8d7f18..4fe736b39 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -84,10 +84,10 @@ class Model_Objects //! \param theName name of the object to search //! \returns null if such object is not found std::shared_ptr objectByName( - const std::string& theGroupID, const std::string& theName); + const std::string& theGroupID, const std::wstring& theName); //! Returns the result by the result name - ResultPtr findByName(const std::string theName); + ResultPtr findByName(const std::wstring theName); //! Returns the object index in the group. Object must be visible. Otherwise returns -1. @@ -291,7 +291,7 @@ class Model_Objects bool hasCustomName(DataPtr theFeatureData, ResultPtr theResult, int theResultIndex, - std::string& theParentName) const; + std::wstring& theParentName) const; /// Return object representing a folder or empty pointer const ObjectPtr& folder(TDF_Label theLabel) const; diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index 997eeab61..18acf89ee 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -59,7 +59,7 @@ static void indexingSketchEdges( const CompositeFeaturePtr& theComposite, NCollection_DataMap& theCurvesIndices, NCollection_DataMap& theEdgesIndices, - std::map& theEdgesNames); + std::map& theEdgesNames); /// Convert each face to the list of indices of its edges /// \param[in] theFaces list of faces to proceed @@ -82,13 +82,13 @@ static void faceToEdgeIndices( /// \param theEdgesNames named of edges static void storeFacesOnLabel(std::shared_ptr& theDocument, TDF_Label& theShapeLabel, - const std::string& theName, + const std::wstring& theName, const TopoDS_Shape& theShape, NCollection_DataMap& theFacesOrder, NCollection_List& theUnorderedFaces, const MapFaceToEdgeIndices& theFaceEdges, const NCollection_DataMap& theEdgesIndices, - const std::map& theEdgesNames); + const std::map& theEdgesNames); // identifier of the infinite result @@ -121,18 +121,18 @@ std::shared_ptr Model_ResultConstruction::shape() return myShape; } -static std::string shortName( +static std::wstring shortName( std::shared_ptr& theConstr) { - std::string aName = theConstr->data()->name(); + std::wstring aName = theConstr->data()->name(); // remove "-", "/" and "&" command-symbols aName.erase(std::remove(aName.begin(), aName.end(), '-'), aName.end()); aName.erase(std::remove(aName.begin(), aName.end(), '/'), aName.end()); aName.erase(std::remove(aName.begin(), aName.end(), '&'), aName.end()); // remove the last 's', 'e', 'f' and 'r' symbols: // they are used as markers of start/end/forward/reversed indicators - static const std::string aSyms("sefr"); - std::string::iterator aSuffix = aName.end() - 1; + static const std::wstring aSyms(L"sefr"); + std::wstring::iterator aSuffix = aName.end() - 1; while(aSyms.find(*aSuffix) != std::string::npos) { --aSuffix; } @@ -270,7 +270,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData && aData->isValid()) { - std::string aMyName = data()->name(); + std::wstring aMyName = data()->name(); TDF_Label aShapeLab = aData->shapeLab(); if (!theShape.get() || theShape->isNull()) { aShapeLab.ForgetAllAttributes(); @@ -296,7 +296,8 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap TDF_Label aSubLab = aShapeLab.FindChild(anIndex); TNaming_Builder aBuilder(aSubLab); aBuilder.Generated(anExp.Current()); - std::string aVertexName = aMyName + "_" + (anIndex == 1 ? "StartVertex" : "EndVertex"); + std::wstring aVertexName = aMyName + L"_" + + (anIndex == 1 ? L"StartVertex" : L"EndVertex"); TDataStd_Name::Set(aSubLab, aVertexName.c_str()); aMyDoc->addNamingName(aSubLab, aVertexName); } @@ -316,7 +317,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap // collect indices of curves of current composite NCollection_DataMap aCurvesIndices; NCollection_DataMap anEdgeIndices; - std::map aComponentsNames; // names of components that lay on index + std::map aComponentsNames; // names of components that lay on index indexingSketchEdges(aComposite, aCurvesIndices, anEdgeIndices, aComponentsNames); GeomAlgoAPI_SketchBuilder aSketchBuilder(aWirePtr->origin(), aWirePtr->dirX(), @@ -379,7 +380,7 @@ void Model_ResultConstruction::setFacesOrder(const std::list& theFa { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData && aData->isValid()) { - std::string aMyName = data()->name(); + std::wstring aMyName = data()->name(); TDF_Label aShapeLab = aData->shapeLab(); GeomShapePtr aResShape = shape(); if (!aResShape.get() || aResShape->isNull()) { @@ -400,7 +401,7 @@ void Model_ResultConstruction::setFacesOrder(const std::list& theFa // collect indices of curves of current composite NCollection_DataMap aCurvesIndices; NCollection_DataMap anEdgeIndices; - std::map aComponentsNames; // names of components that lay on index + std::map aComponentsNames; // names of components that lay on index indexingSketchEdges(aComposite, aCurvesIndices, anEdgeIndices, aComponentsNames); ListOfShape aFaces; @@ -426,13 +427,13 @@ void Model_ResultConstruction::setFacesOrder(const std::list& theFa void storeFacesOnLabel(std::shared_ptr& theDocument, TDF_Label& theShapeLabel, - const std::string& theName, + const std::wstring& theName, const TopoDS_Shape& theShape, NCollection_DataMap& theFacesOrder, NCollection_List& theUnorderedFaces, const MapFaceToEdgeIndices& theFaceEdges, const NCollection_DataMap& theEdgesIndices, - const std::map& theEdgesNames) + const std::map& theEdgesNames) { theShapeLabel.ForgetAllAttributes(); // clear all previously stored TDataStd_Name::Set(theShapeLabel, theName.c_str()); // restore name forgotten @@ -466,7 +467,7 @@ void storeFacesOnLabel(std::shared_ptr& theDocument, // store also indices of the new face edges Handle(TDataStd_IntPackedMap) aNewMap = TDataStd_IntPackedMap::Set(aLab); const TColStd_ListOfInteger& aNewInd = theFaceEdges.FindFromKey(aFaceToPut); - std::stringstream aName; + std::wstringstream aName; aName<<"Face"; TopExp_Explorer aPutEdges(aFaceToPut, TopAbs_EDGE); TNaming_Builder *anEdgesBuilder = 0, *aVerticesBuilder = 0; @@ -525,8 +526,8 @@ void storeFacesOnLabel(std::shared_ptr& theDocument, TDF_Label aWireLab = aLab.FindChild(aWireTag); TNaming_Builder aWireBuilder(aWireLab); aWireBuilder.Generated(aWires.Current()); - std::ostringstream aWireName; - aWireName< 3) aWireName<<"_"<& theDocument, void indexingSketchEdges(const CompositeFeaturePtr& theComposite, NCollection_DataMap& theCurvesIndices, NCollection_DataMap& theEdgesIndices, - std::map& theEdgesNames) + std::map& theEdgesNames) { const int aSubNum = theComposite->numberOfSubs(); for (int a = 0; a < aSubNum; a++) { diff --git a/src/Model/Model_ResultField.cpp b/src/Model/Model_ResultField.cpp index 56a18c43e..ed6f3bece 100644 --- a/src/Model/Model_ResultField.cpp +++ b/src/Model/Model_ResultField.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -152,10 +153,10 @@ std::shared_ptr Model_ResultField::ste return NULL; } -std::string Model_ResultField::Model_FieldStep::name() { - std::ostringstream aStream; +std::wstring Model_ResultField::Model_FieldStep::name() { + std::wostringstream aStream; aStream<data()->name()<textLine(myId); + aStream<<"Step "<<(myId + 1)<<" "<< ModelAPI_Tools::toWString(myParent->textLine(myId)); return aStream.str(); } // LCOV_EXCL_STOP diff --git a/src/Model/Model_ResultField.h b/src/Model/Model_ResultField.h index cbaa3efec..80dfef1cb 100644 --- a/src/Model/Model_ResultField.h +++ b/src/Model/Model_ResultField.h @@ -52,7 +52,7 @@ public: virtual std::shared_ptr document() const { return myParent->document(); } /// Returns a GUI name of this step - virtual std::string name(); + virtual std::wstring name(); private: ModelAPI_ResultField* myParent; diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index fd752bc72..e6dc45453 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -90,7 +91,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 " + data()->name(); + std::string aMsg = "Activation " + ModelAPI_Tools::toString(data()->name()); aMgr->startOperation(aMsg); isNewTransaction = true; } @@ -253,7 +254,7 @@ static bool IsEqualTrsf(gp_Trsf& theT1, gp_Trsf theT2) { return true; } -std::string Model_ResultPart::nameInPart(const std::shared_ptr& theShape, +std::wstring Model_ResultPart::nameInPart(const std::shared_ptr& theShape, int& theIndex) { theIndex = 0; // not initialized @@ -279,21 +280,21 @@ std::string Model_ResultPart::nameInPart(const std::shared_ptr& t } } // something is not right - return ""; + return L""; } TopoDS_Shape aShape = theShape->impl(); if (aShape.IsNull()) - return ""; + return L""; // getting an access to the document of part std::shared_ptr aDoc = std::dynamic_pointer_cast(partDoc()); if (!aDoc.get()) // the part document is not presented for the moment - return ""; + return L""; TDF_Label anAccessLabel = aDoc->generalLabel(); // make the selection attribute anyway: // otherwise just by name it is not stable to search the result - std::string aName; + std::wstring aName; // for this the context result is needed ResultPtr aContext; const std::string& aBodyGroup = ModelAPI_ResultBody::group(); @@ -342,7 +343,7 @@ gp_Trsf Model_ResultPart::sumTrsf() { return aResult; } -bool Model_ResultPart::combineGeometrical(const int theIndex, std::string& theNewName) +bool Model_ResultPart::combineGeometrical(const int theIndex, std::wstring& theNewName) { std::shared_ptr aDoc = std::dynamic_pointer_cast(partDoc()); if (aDoc.get()) { @@ -361,7 +362,7 @@ bool Model_ResultPart::combineGeometrical(const int theIndex, std::string& theNe } std::shared_ptr Model_ResultPart::shapeInPart( - const std::string& theName, const std::string& theType, int& theIndex) + const std::wstring& theName, const std::string& theType, int& theIndex) { theIndex = 0; // not found yet std::shared_ptr aResult; diff --git a/src/Model/Model_ResultPart.h b/src/Model/Model_ResultPart.h index 0f27e9c58..8fc6ea062 100644 --- a/src/Model/Model_ResultPart.h +++ b/src/Model/Model_ResultPart.h @@ -70,16 +70,16 @@ class Model_ResultPart : public ModelAPI_ResultPart /// \param theShape selected shape in this document /// \param theIndex is returned as one-based index if selection was required, "0" otherwise /// \returns empty name is selection is not correct - MODEL_EXPORT virtual std::string nameInPart(const std::shared_ptr& theShape, + MODEL_EXPORT virtual std::wstring nameInPart(const std::shared_ptr& theShape, int& theIndex); /// Updates the selection inside of the part by the selection index MODEL_EXPORT virtual bool updateInPart(const int theIndex); /// Returns the shape by the name in the part MODEL_EXPORT virtual std::shared_ptr shapeInPart( - const std::string& theName, const std::string& theType, int& theIndex); + const std::wstring& theName, const std::string& theType, int& theIndex); /// Updates the selection inside of the part as a geometrical selection - MODEL_EXPORT virtual bool combineGeometrical(const int theIndex, std::string& theNewName); + MODEL_EXPORT virtual bool combineGeometrical(const int theIndex, std::wstring& theNewName); /// Updates the shape-result of the part (called on Part feature execution) MODEL_EXPORT virtual void updateShape(); /// Applies the additional transformation of the part diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 89f90ee4a..40251ca30 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -362,7 +362,7 @@ std::list > Model_Session::allOpenedDocuments return aResult; } -bool Model_Session::isLoadByDemand(const std::string theDocID, const int theDocIndex) +bool Model_Session::isLoadByDemand(const std::wstring theDocID, const int theDocIndex) { return Model_Application::getApplication()->isLoadByDemand(theDocID, theDocIndex); } diff --git a/src/Model/Model_Session.h b/src/Model/Model_Session.h index b480a67e9..fedd75ef5 100644 --- a/src/Model/Model_Session.h +++ b/src/Model/Model_Session.h @@ -116,7 +116,7 @@ class Model_Session : public ModelAPI_Session, public Events_Listener MODEL_EXPORT virtual std::list > allOpenedDocuments(); /// Returns true if document is not loaded yet - MODEL_EXPORT virtual bool isLoadByDemand(const std::string theDocID, const int theDocIndex); + MODEL_EXPORT virtual bool isLoadByDemand(const std::wstring theDocID, const int theDocIndex); /// Registers the plugin that creates features. /// It is obligatory for each plugin to call this function on loading to be found by diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index 5652538b0..6bb6eeff4 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -32,6 +32,8 @@ // fix for SWIG v2.0.4 #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj)) + + #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj)) %} // import other modules @@ -42,8 +44,6 @@ #define MODELAPI_EXPORT // standard definitions -%include "typemaps.i" -%include "std_string.i" %include "std_list.i" %include "std_shared_ptr.i" %include "std_set.i" diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index 119485dc4..148dd53e0 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -92,13 +92,13 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// Returns a textual string of the selection /// \param theDefaultValue a value, which is used if the naming name can not be obtained - virtual std::string namingName(const std::string& theDefaultValue = "") = 0; + virtual std::wstring namingName(const std::wstring& theDefaultValue = L"") = 0; /// Defines an id of the selection virtual void setId(int theID) = 0; /// Selects sub-shape by the textual Name - virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName) = 0; + virtual void selectSubShape(const std::string& theType, const std::wstring& theSubShapeName) = 0; /// Selects sub-shape by its inner point virtual void selectSubShape(const std::string& theType, @@ -106,7 +106,7 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// Selects sub-shape by weak naming index virtual void selectSubShape(const std::string& theType, - const std::string& theContextName, const int theIndex) = 0; + const std::wstring& theContextName, const int theIndex) = 0; /// Returns true if recompute of selection become impossible virtual bool isInvalid() = 0; @@ -118,7 +118,7 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection(); /// Returns the name by context. Adds the part name if the context is located in other document - MODELAPI_EXPORT virtual std::string contextName(const ResultPtr& theContext) const = 0; + MODELAPI_EXPORT virtual std::wstring contextName(const ResultPtr& theContext) const = 0; /// Makes the current local selection becomes all sub-shapes with same base geometry. MODELAPI_EXPORT virtual void combineGeometrical() = 0; diff --git a/src/ModelAPI/ModelAPI_AttributeSelectionList.h b/src/ModelAPI/ModelAPI_AttributeSelectionList.h index 16cd5f979..57ce5c8bc 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelectionList.h +++ b/src/ModelAPI/ModelAPI_AttributeSelectionList.h @@ -54,14 +54,14 @@ public: /// Adds the new reference to the end of the list by the naming name of the selected shape /// The type of shape is taken from the current selection type if the given is empty - virtual void append(const std::string& theNamingName, const std::string& theType = "") = 0; + virtual void append(const std::wstring& theNamingName, const std::string& theType = "") = 0; /// Adds the new reference to the end of the list by inner point on the selected shape virtual void append(const std::shared_ptr& thePoint, const std::string& theType) = 0; /// Adds the new reference to the end of the list by weak naming index - virtual void append(const std::string& theType, const std::string& theContextName, + virtual void append(const std::string& theType, const std::wstring& theContextName, const int theIndex) = 0; /// Copy the selection list to the destination attribute diff --git a/src/ModelAPI/ModelAPI_Data.h b/src/ModelAPI/ModelAPI_Data.h index bed7201ac..7743af0ac 100644 --- a/src/ModelAPI/ModelAPI_Data.h +++ b/src/ModelAPI/ModelAPI_Data.h @@ -72,9 +72,9 @@ class MODELAPI_EXPORT ModelAPI_Data public: /// Returns the name of the feature visible by the user in the object browser - virtual std::string name() = 0; + virtual std::wstring name() = 0; /// Defines the name of the feature visible by the user in the object browser - virtual void setName(const std::string& theName) = 0; + virtual void setName(const std::wstring& theName) = 0; /// Return \c true if the object has been renamed by the user virtual bool hasUserDefinedName() const = 0; diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 602c4e803..a07a8e801 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -100,7 +100,7 @@ public: //! \param theName name of the object to search //! \returns null if such object is not found virtual std::shared_ptr objectByName(const std::string& theGroupID, - const std::string& theName) = 0; + const std::wstring& theName) = 0; //! Returns the object index in the group. Object must be visible. Otherwise returns -1. //! \param theObject object of this document diff --git a/src/ModelAPI/ModelAPI_Events.cpp b/src/ModelAPI/ModelAPI_Events.cpp index 29658fd69..b7fd861ef 100644 --- a/src/ModelAPI/ModelAPI_Events.cpp +++ b/src/ModelAPI/ModelAPI_Events.cpp @@ -234,8 +234,8 @@ ModelAPI_ObjectRenamedMessage::~ModelAPI_ObjectRenamedMessage() {} void ModelAPI_ObjectRenamedMessage::send(ObjectPtr theObject, - const std::string& theOldName, - const std::string& theNewName, + const std::wstring& theOldName, + const std::wstring& theNewName, const void* theSender) { std::shared_ptr aMessage( @@ -256,22 +256,22 @@ void ModelAPI_ObjectRenamedMessage::setObject(ObjectPtr theObject) myObject = theObject; } -std::string ModelAPI_ObjectRenamedMessage::oldName() const +std::wstring ModelAPI_ObjectRenamedMessage::oldName() const { return myOldName; } -void ModelAPI_ObjectRenamedMessage::setOldName(const std::string& theOldName) +void ModelAPI_ObjectRenamedMessage::setOldName(const std::wstring& theOldName) { myOldName = theOldName; } -std::string ModelAPI_ObjectRenamedMessage::newName() const +std::wstring ModelAPI_ObjectRenamedMessage::newName() const { return myNewName; } -void ModelAPI_ObjectRenamedMessage::setNewName(const std::string& theNewName) +void ModelAPI_ObjectRenamedMessage::setNewName(const std::wstring& theNewName) { myNewName = theNewName; } diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index d951211eb..c0aa61ef8 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -393,8 +393,8 @@ public: class ModelAPI_ObjectRenamedMessage : public Events_Message { ObjectPtr myObject; - std::string myOldName; - std::string myNewName; + std::wstring myOldName; + std::wstring myNewName; public: /// Static. Returns EventID of the message. @@ -407,8 +407,8 @@ class ModelAPI_ObjectRenamedMessage : public Events_Message /// Useful method that creates and sends the AttributeEvalMessage event MODELAPI_EXPORT static void send(ObjectPtr theObject, - const std::string& theOldName, - const std::string& theNewName, + const std::wstring& theOldName, + const std::wstring& theNewName, const void* theSender); /// Creates an empty message @@ -421,13 +421,13 @@ class ModelAPI_ObjectRenamedMessage : public Events_Message /// Sets an object MODELAPI_EXPORT void setObject(ObjectPtr theObject); /// Returns an old name - MODELAPI_EXPORT std::string oldName() const; + MODELAPI_EXPORT std::wstring oldName() const; /// Sets an old name - MODELAPI_EXPORT void setOldName(const std::string& theOldName); + MODELAPI_EXPORT void setOldName(const std::wstring& theOldName); /// Returns a new name - MODELAPI_EXPORT std::string newName() const; + MODELAPI_EXPORT std::wstring newName() const; /// Sets a new name - MODELAPI_EXPORT void setNewName(const std::string& theNewName); + MODELAPI_EXPORT void setNewName(const std::wstring& theNewName); }; /// Message that the parameter should be replaced with its value diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 77cd55b96..ee9deb3fd 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -164,7 +164,7 @@ class ModelAPI_Feature : public ModelAPI_Object // Helper methods, aliases for data()->method() // ----------------------------------------------------------------------------------------------- /// Returns the name stored in the attribute - inline std::string name() + inline std::wstring name() { return data()->name(); } diff --git a/src/ModelAPI/ModelAPI_Folder.h b/src/ModelAPI/ModelAPI_Folder.h index 1fd19958e..fba630266 100644 --- a/src/ModelAPI/ModelAPI_Folder.h +++ b/src/ModelAPI/ModelAPI_Folder.h @@ -82,7 +82,7 @@ public: // Helper methods, aliases for data()->method() // ----------------------------------------------------------------------------------------------- /// Returns the name stored in the attribute - inline std::string name() + inline std::wstring name() { return data()->name(); } diff --git a/src/ModelAPI/ModelAPI_ResultField.h b/src/ModelAPI/ModelAPI_ResultField.h index 4e2be6a40..d53f18661 100644 --- a/src/ModelAPI/ModelAPI_ResultField.h +++ b/src/ModelAPI/ModelAPI_ResultField.h @@ -68,7 +68,7 @@ public: MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay); /// Returns a GUI name of this step - MODELAPI_EXPORT virtual std::string name() = 0; + MODELAPI_EXPORT virtual std::wstring name() = 0; protected: /// This method is called just after creation of the object: it must initialize diff --git a/src/ModelAPI/ModelAPI_ResultPart.h b/src/ModelAPI/ModelAPI_ResultPart.h index 0ceb08652..5991895cc 100644 --- a/src/ModelAPI/ModelAPI_ResultPart.h +++ b/src/ModelAPI/ModelAPI_ResultPart.h @@ -73,7 +73,7 @@ class ModelAPI_ResultPart : public ModelAPI_Result virtual bool isActivated() = 0; /// Returns the name of the shape inside of the part - virtual std::string nameInPart(const std::shared_ptr& theShape, + virtual std::wstring nameInPart(const std::shared_ptr& theShape, int& theIndex) = 0; /// Updates the selection inside of the part by the selection index virtual bool updateInPart(const int theIndex) = 0; @@ -87,10 +87,10 @@ class ModelAPI_ResultPart : public ModelAPI_Result /// Returns the shape by the name in the part virtual std::shared_ptr shapeInPart( - const std::string& theName, const std::string& theType, int& theIndex) = 0; + const std::wstring& theName, const std::string& theType, int& theIndex) = 0; /// Updates the selection inside of the part as a geometrical selection - virtual bool combineGeometrical(const int theIndex, std::string& theNewName) = 0; + virtual bool combineGeometrical(const int theIndex, std::wstring& theNewName) = 0; /// Returns the shape selected in the selection index virtual std::shared_ptr selectionValue(const int theIndex) = 0; diff --git a/src/ModelAPI/ModelAPI_Session.h b/src/ModelAPI/ModelAPI_Session.h index 84a925aa2..fae2a9e97 100644 --- a/src/ModelAPI/ModelAPI_Session.h +++ b/src/ModelAPI/ModelAPI_Session.h @@ -112,7 +112,7 @@ class MODELAPI_EXPORT ModelAPI_Session virtual std::list > allOpenedDocuments() = 0; /// Returns true if document is not loaded yet - virtual bool isLoadByDemand(const std::string theDocID, const int theDocIndex) = 0; + virtual bool isLoadByDemand(const std::wstring theDocID, const int theDocIndex) = 0; /// Copies the document to the new one with the given id virtual std::shared_ptr copy( diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 8a19702d6..7cbdd8089 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -172,9 +173,10 @@ std::string getFeatureError(const FeaturePtr& theFeature) ObjectPtr objectByName(const DocumentPtr& theDocument, const std::string& theGroup, const std::string& theName) { + std::wstring aName = toWString(theName); for (int anIndex = 0; anIndex < theDocument->size(theGroup); ++anIndex) { ObjectPtr anObject = theDocument->object(theGroup, anIndex); - if (anObject->data()->name() == theName) + if (anObject->data()->name() == aName) return anObject; } // not found @@ -338,9 +340,9 @@ void allResults(const FeaturePtr& theFeature, std::list& theResults) } //****************************************************************** -bool allDocumentsActivated(std::string& theNotActivatedNames) +bool allDocumentsActivated(std::wstring& theNotActivatedNames) { - theNotActivatedNames = ""; + theNotActivatedNames = L""; bool anAllPartActivated = true; DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); @@ -351,7 +353,7 @@ bool allDocumentsActivated(std::string& theNotActivatedNames) if (!aPart->isActivated()) { anAllPartActivated = false; if (!theNotActivatedNames.empty()) - theNotActivatedNames += ", "; + theNotActivatedNames += L", "; theNotActivatedNames += aObject->data()->name().c_str(); } } @@ -615,7 +617,7 @@ void getConcealedResults(const FeaturePtr& theFeature, } } -std::pair getDefaultName(const std::shared_ptr& theResult, +std::pair getDefaultName(const std::shared_ptr& theResult, const bool theInherited) { typedef std::list< std::pair < std::string, std::list > > ListOfReferences; @@ -627,10 +629,10 @@ std::pair getDefaultName(const std::shared_ptr(aDefaultName.str(), false); + return std::pair(aDefaultName.str(), false); } FeaturePtr anOwner = ModelAPI_Feature::feature(theResult->data()->owner()); @@ -706,7 +708,7 @@ std::pair getDefaultName(const std::shared_ptrdata()->hasUserDefinedName()) { - std::stringstream aName; + std::wstringstream aName; aName << anObjRes->data()->name(); std::map::iterator aFound = aNbRefToObject.find(anObjRes); if (aFound != aNbRefToObject.end()) { @@ -714,19 +716,19 @@ std::pair getDefaultName(const std::shared_ptrsecond + 1; } - return std::pair(aName.str(), true); + return std::pair(aName.str(), true); } } } // compose default name by the name of the feature and the index of result - std::stringstream aDefaultName; + std::wstringstream aDefaultName; aDefaultName << anOwner->name(); // if there are several results (issue #899: any number of result), // add unique prefix starting from second if (anIndexInOwner > 0 || theResult->groupName() == ModelAPI_ResultBody::group()) aDefaultName << "_" << anIndexInOwner + 1; - return std::pair(aDefaultName.str(), false); + return std::pair(aDefaultName.str(), false); } std::set getParents(const FeaturePtr& theFeature) @@ -1103,5 +1105,21 @@ std::list referencedFeatures( } // LCOV_EXCL_STOP +std::string toString(const std::wstring& theWStr) +{ + static std::wstring_convert > aConvertor; + return aConvertor.to_bytes(theWStr); +} + +/*! Converts a byte string to an extended string +* \param theStr a byte string +*/ +std::wstring toWString(const std::string& theStr) +{ + static std::wstring_convert > aConvertor; + return aConvertor.from_bytes(theStr); +} + + } // namespace ModelAPI_Tools diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h index a90cd60fa..f927a67c7 100644 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -140,7 +140,7 @@ MODELAPI_EXPORT void allResults(const std::shared_ptr& theFeat \param theNotActivatedNames out string which contains not activated names \return a boolean value */ -MODELAPI_EXPORT bool allDocumentsActivated(std::string& theNotActivatedNames); +MODELAPI_EXPORT bool allDocumentsActivated(std::wstring& theNotActivatedNames); /*! Removes features from the document * \param theFeatures a list of features to be removed @@ -199,7 +199,7 @@ MODELAPI_EXPORT void getConcealedResults(const std::shared_ptr * Return also whether the name is get from the concealing result of parent object * (means that concealing result has user-defined name). */ -MODELAPI_EXPORT std::pair getDefaultName( +MODELAPI_EXPORT std::pair getDefaultName( const std::shared_ptr& theResult, const bool theInherited = true); /*! Collect all parents for the given feature, including the Part @@ -300,6 +300,16 @@ MODELAPI_EXPORT std::list > referencedFeatures std::shared_ptr 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 diff --git a/src/ModelHighAPI/ModelHighAPI.i b/src/ModelHighAPI/ModelHighAPI.i index 9fea6cc19..28dd80021 100644 --- a/src/ModelHighAPI/ModelHighAPI.i +++ b/src/ModelHighAPI/ModelHighAPI.i @@ -32,6 +32,8 @@ // fix for SWIG v2.0.4 #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj)) + + #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj)) %} %include "doxyhelp.i" @@ -45,11 +47,7 @@ #define MODELHIGHAPI_EXPORT // standard definitions -%include "typemaps.i" -%include "std_list.i" %include "std_pair.i" -%include "std_string.i" -%include "std_shared_ptr.i" // directors %feature("director") ModelHighAPI_Dumper; diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index cf359fc65..ea695b89c 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -314,8 +314,8 @@ void ModelHighAPI_Dumper::DumpStorage::write(const AttributeSelectionPtr& theAtt getShapeAndContext(theAttrSelect, aShape, aContext); if (aShape.get()) { - myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \"" - << theAttrSelect->namingName() << "\""; + //TODO: vsv myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \"" + // << theAttrSelect->namingName() << "\""; } myDumpBuffer << ")"; @@ -495,8 +495,8 @@ void ModelHighAPI_Dumper::DumpStorageWeak::write(const AttributeSelectionPtr& th GeomAlgoAPI_NExplode aNExplode(aContext->shape(), aShape->shapeType()); int anIndex = aNExplode.index(aShape); if (anIndex != 0) { // found a week-naming index, so, export it - myDumpBuffer << "model.selection(\"" << aShape->shapeTypeStr() << "\", \"" - << theAttrSelect->contextName(aContext) << "\", " << anIndex << ")"; + //TODO: vsv myDumpBuffer << "model.selection(\"" << aShape->shapeTypeStr() << "\", \"" + // << theAttrSelect->contextName(aContext) << "\", " << anIndex << ")"; aStandardDump = false; } } @@ -580,18 +580,19 @@ const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity, return aFound->second.myCurrentName; } // entity is not found, store it - std::string aName, aKind; + std::string aName; + std::string aKind; bool isDefaultName = false; bool isSaveNotDumped = theSaveNotDumped; std::ostringstream aDefaultName; FeaturePtr aFeature = std::dynamic_pointer_cast(theEntity); if (aFeature) { - aName = aFeature->name(); + aName = ModelAPI_Tools::toString(aFeature->name()); aKind = aFeature->getKind(); } else { FolderPtr aFolder = std::dynamic_pointer_cast(theEntity); if (aFolder) { - aName = aFolder->data()->name(); + aName = ModelAPI_Tools::toString(aFolder->data()->name()); aKind = ModelAPI_Folder::ID(); isSaveNotDumped = false; } @@ -684,9 +685,9 @@ void ModelHighAPI_Dumper::saveResultNames(const FeaturePtr& theFeature) std::list allRes; ModelAPI_Tools::allResults(theFeature, allRes); for(std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) { - std::pair aName = ModelAPI_Tools::getDefaultName(*aRes); - std::string aDefaultName = aName.first; - std::string aResName = (*aRes)->data()->name(); + std::pair aName = ModelAPI_Tools::getDefaultName(*aRes); + std::string aDefaultName = ModelAPI_Tools::toString(aName.first); + std::string aResName = ModelAPI_Tools::toString((*aRes)->data()->name()); bool isUserDefined = !(isFeatureDefaultName && aDefaultName == aResName); myNames[*aRes] = EntityName(aResName, (isUserDefined ? aResName : std::string()), !isUserDefined); @@ -870,14 +871,15 @@ void ModelHighAPI_Dumper::dumpSubFeatureNameAndColor(const std::string theSubFea const FeaturePtr& theSubFeature) { name(theSubFeature, false); - myNames[theSubFeature] = EntityName(theSubFeatureGet, theSubFeature->name(), false); + myNames[theSubFeature] = + EntityName(theSubFeatureGet, ModelAPI_Tools::toString(theSubFeature->name()), false); // store results if they have user-defined names or colors std::list aResultsWithNameOrColor; const std::list& aResults = theSubFeature->results(); std::list::const_iterator aResIt = aResults.begin(); for (; aResIt != aResults.end(); ++aResIt) { - std::string aResName = (*aResIt)->data()->name(); + std::string aResName = ModelAPI_Tools::toString((*aResIt)->data()->name()); myNames[*aResIt] = EntityName(aResName, aResName, false); aResultsWithNameOrColor.push_back(*aResIt); } @@ -1088,6 +1090,12 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::string& theStrin return *this; } +ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::wstring& theString) +{ + *myDumpStorage << ModelAPI_Tools::toString(theString); + return *this; +} + ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const bool theValue) { *myDumpStorage << (theValue ? "True" : "False"); diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.h b/src/ModelHighAPI/ModelHighAPI_Dumper.h index aceab1465..0e3f56816 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.h +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.h @@ -228,6 +228,9 @@ public: /// Dump string MODELHIGHAPI_EXPORT ModelHighAPI_Dumper& operator<<(const std::string& theString); + /// Dump wstring + MODELHIGHAPI_EXPORT + ModelHighAPI_Dumper& operator<<(const std::wstring& theString); /// Dump boolean MODELHIGHAPI_EXPORT ModelHighAPI_Dumper& operator<<(const bool theValue); diff --git a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp index 63ba58607..6bbc96cec 100644 --- a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp +++ b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp @@ -75,7 +75,8 @@ 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 '" + theObject->data()->name() + "' differ:" + anError; + return "Features '" + ModelAPI_Tools::toString(theObject->data()->name()) + + "' differ:" + anError; } FeaturePtr aFeature = std::dynamic_pointer_cast(theObject); @@ -87,11 +88,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 '" + aFeature->name() + "' '" + (*aRes)->data()->name() + + return "Results of feature '" + ModelAPI_Tools::toString(aFeature->name()) + + "' '" + ModelAPI_Tools::toString((*aRes)->data()->name()) + "' differ:" + anError; } if (aRes != allResults.end()) { - return "Current model has more results '" + (*aRes)->data()->name() + "'"; + return "Current model has more results '" + + ModelAPI_Tools::toString((*aRes)->data()->name()) + "'"; } if (aResIter != myRes.end()) { return "Original model had more results '" + (*aResIter)["__name__"] + "'"; @@ -104,7 +107,7 @@ void ModelHighAPI_FeatureStore::storeData(std::shared_ptr theData std::map& theAttrs) { // store name to keep also this information and output if needed - theAttrs["__name__"] = theData->name(); + theAttrs["__name__"] = ModelAPI_Tools::toString(theData->name()); std::list > allAttrs = theData->attributes(""); std::list >::iterator anAttr = allAttrs.begin(); for(; anAttr != allAttrs.end(); anAttr++) { @@ -189,7 +192,8 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { if (anAttr->value() != aDoc) { ResultPtr aRes = ModelAPI_Tools::findPartResult(aDoc, anAttr->value()); if (aRes.get()) { - aResult<data()->name(); // Part result name (the same as saved file name) + // Part result name (the same as saved file name) + aResult<< ModelAPI_Tools::toString(aRes->data()->name()); } } else { aResult<kind(); // PartSet @@ -243,7 +247,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { AttributeReferencePtr anAttr = std::dynamic_pointer_cast(theAttr); if (anAttr->value().get()) { - aResult<value()->data()->name(); + aResult<< ModelAPI_Tools::toString(anAttr->value()->data()->name()); } else { aResult<<"__empty__"; } @@ -251,7 +255,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { AttributeSelectionPtr anAttr = std::dynamic_pointer_cast(theAttr); if (anAttr->context().get()) - aResult<namingName(); + aResult<< ModelAPI_Tools::toString(anAttr->namingName()); else aResult<<"__notinitialized__"; } else if (aType == ModelAPI_AttributeSelectionList::typeId()) { @@ -260,14 +264,14 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { for(int a = 0; a < anAttr->size(); a++) { if (a != 0) aResult<<" "; - aResult<value(a)->namingName(); + aResult<< ModelAPI_Tools::toString(anAttr->value(a)->namingName()); } } else if (aType == ModelAPI_AttributeRefAttr::typeId()) { AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast(theAttr); ObjectPtr anObj = anAttr->isObject() ? anAttr->object() : anAttr->attr()->owner(); if (anObj.get()) { - aResult<data()->name(); + aResult<< ModelAPI_Tools::toString(anObj->data()->name()); if (!anAttr->isObject()) { aResult<<" "<attr()->id(); } @@ -293,7 +297,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { if (aStr == "SketchConstraint") continue; // no need to dump and check constraints } - aResList.push_back((*aL)->data()->name()); + aResList.push_back(ModelAPI_Tools::toString((*aL)->data()->name())); } else if (!isSketchFeatures) { aResList.push_back("__empty__"); } @@ -313,7 +317,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { aResult<<" "; ObjectPtr anObj = aL->second.get() ? aL->second->owner() : aL->first; if (anObj.get()) { - aResult<data()->name(); + aResult<< ModelAPI_Tools::toString(anObj->data()->name()); if (aL->second.get()) { aResult<<" "<second->id(); } diff --git a/src/ModelHighAPI/ModelHighAPI_Folder.cpp b/src/ModelHighAPI/ModelHighAPI_Folder.cpp index b47d4b48d..18ac4e6e2 100644 --- a/src/ModelHighAPI/ModelHighAPI_Folder.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Folder.cpp @@ -59,13 +59,13 @@ bool ModelHighAPI_Folder::initialize() return true; } -void ModelHighAPI_Folder::setName(const std::string& theName) +void ModelHighAPI_Folder::setName(const std::wstring& theName) { if (myFolder && myFolder->data() && myFolder->data()->isValid()) myFolder->data()->setName(theName); } -std::string ModelHighAPI_Folder::name() const +std::wstring ModelHighAPI_Folder::name() const { return myFolder->data()->name(); } diff --git a/src/ModelHighAPI/ModelHighAPI_Folder.h b/src/ModelHighAPI/ModelHighAPI_Folder.h index 2f99aabf8..ea0232c74 100644 --- a/src/ModelHighAPI/ModelHighAPI_Folder.h +++ b/src/ModelHighAPI/ModelHighAPI_Folder.h @@ -58,11 +58,11 @@ public: /// Shortcut for data()->setName() MODELHIGHAPI_EXPORT - void setName(const std::string& theName); + void setName(const std::wstring& theName); /// Shortcut for data()->name() MODELHIGHAPI_EXPORT - std::string name() const; + std::wstring name() const; /// To update the folder state /// \param isForce start execution of feature instead of sending events diff --git a/src/ModelHighAPI/ModelHighAPI_Interface.cpp b/src/ModelHighAPI/ModelHighAPI_Interface.cpp index cb0373bfa..5fd4de052 100644 --- a/src/ModelHighAPI/ModelHighAPI_Interface.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Interface.cpp @@ -86,13 +86,13 @@ void ModelHighAPI_Interface::execute(bool isForce) //aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); } -void ModelHighAPI_Interface::setName(const std::string& theName) +void ModelHighAPI_Interface::setName(const std::wstring& theName) { if (feature().get()) feature()->data()->setName(theName); } -std::string ModelHighAPI_Interface::name() const +std::wstring ModelHighAPI_Interface::name() const { return feature()->data()->name(); } diff --git a/src/ModelHighAPI/ModelHighAPI_Interface.h b/src/ModelHighAPI/ModelHighAPI_Interface.h index 8675bb66c..a00435922 100644 --- a/src/ModelHighAPI/ModelHighAPI_Interface.h +++ b/src/ModelHighAPI/ModelHighAPI_Interface.h @@ -68,11 +68,11 @@ public: /// Shortcut for feature()->data()->setName() MODELHIGHAPI_EXPORT - void setName(const std::string& theName); + void setName(const std::wstring& theName); /// Shortcut for feature()->data()->name() MODELHIGHAPI_EXPORT - std::string name() const; + std::wstring name() const; /// Return firts object of the feature MODELHIGHAPI_EXPORT diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index 30f92c222..33f98418b 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -44,7 +44,7 @@ ModelHighAPI_Selection::ModelHighAPI_Selection(const std::shared_ptr(theContextName, theIndex)) + const std::wstring& theContextName, const int theIndex) + : myVariantType(VT_WeakNamingPair), + myWeakNamingPair(theType, std::pair(theContextName, theIndex)) { } @@ -184,7 +184,7 @@ std::string ModelHighAPI_Selection::shapeType() const } //================================================================================================== -void ModelHighAPI_Selection::setName(const std::string& theName) +void ModelHighAPI_Selection::setName(const std::wstring& theName) { if (myVariantType == VT_ResultSubShapePair) { std::shared_ptr aResult = myResultSubShapePair.first; @@ -195,14 +195,14 @@ void ModelHighAPI_Selection::setName(const std::string& theName) } } -std::string ModelHighAPI_Selection::name() const +std::wstring ModelHighAPI_Selection::name() const { if (myVariantType == VT_ResultSubShapePair) { std::shared_ptr aResult = myResultSubShapePair.first; if (aResult.get()) return aResult->data()->name(); } - return std::string(); + return std::wstring(); } void ModelHighAPI_Selection::setColor(int theRed, int theGreen, int theBlue) diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.h b/src/ModelHighAPI/ModelHighAPI_Selection.h index 3ef133dd9..3bf6d3851 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.h +++ b/src/ModelHighAPI/ModelHighAPI_Selection.h @@ -37,9 +37,9 @@ class ModelAPI_Result; //-------------------------------------------------------------------------------------- typedef std::pair, std::shared_ptr > ResultSubShapePair; -typedef std::pair TypeSubShapeNamePair; +typedef std::pair TypeSubShapeNamePair; typedef std::pair > TypeInnerPointPair; -typedef std::pair > TypeWeakNamingPair; +typedef std::pair > TypeWeakNamingPair; //-------------------------------------------------------------------------------------- /**\class ModelHighAPI_Selection * \ingroup CPPHighAPI @@ -70,7 +70,7 @@ public: /// Constructor for sub-shape by the textual Name MODELHIGHAPI_EXPORT ModelHighAPI_Selection(const std::string& theType, - const std::string& theSubShapeName); + const std::wstring& theSubShapeName); /// Constructor for sub-shape by inner point coordinates MODELHIGHAPI_EXPORT @@ -86,7 +86,7 @@ public: /// Constructor for sub-shape by weak naming identifier MODELHIGHAPI_EXPORT ModelHighAPI_Selection(const std::string& theType, - const std::string& theContextName, const int theIndex); + const std::wstring& theContextName, const int theIndex); /// Destructor MODELHIGHAPI_EXPORT @@ -126,11 +126,11 @@ public: /// Shortcut for result()->data()->setName() MODELHIGHAPI_EXPORT - void setName(const std::string& theName); + void setName(const std::wstring& theName); /// Shortcut for result()->data()->name() MODELHIGHAPI_EXPORT - std::string name() const; + std::wstring name() const; /// Change result's color MODELHIGHAPI_EXPORT diff --git a/src/ModelHighAPI/ModelHighAPI_Services.cpp b/src/ModelHighAPI/ModelHighAPI_Services.cpp index 4bcd182fd..9cb451d7e 100644 --- a/src/ModelHighAPI/ModelHighAPI_Services.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Services.cpp @@ -42,17 +42,17 @@ std::shared_ptr activeDocument() } //-------------------------------------------------------------------------------------- -std::shared_ptr defaultPlane( const std::string& theName ) +std::shared_ptr defaultPlane( const std::wstring& theName ) { std::shared_ptr o(new GeomAPI_Pnt(0, 0, 0)); std::shared_ptr n, x; - if (theName == "XOY") { + if (theName == L"XOY") { n.reset(new GeomAPI_Dir(0, 0, 1)); x.reset(new GeomAPI_Dir(1, 0, 0)); - } else if (theName == "XOZ") { + } else if (theName == L"XOZ") { n.reset(new GeomAPI_Dir(0, -1, 0)); x.reset(new GeomAPI_Dir(1, 0, 0)); - } else if (theName == "YOZ") { + } else if (theName == L"YOZ") { n.reset(new GeomAPI_Dir(1, 0, 0)); x.reset(new GeomAPI_Dir(0, 1, 0)); } @@ -60,35 +60,35 @@ std::shared_ptr defaultPlane( const std::string& theName ) return std::shared_ptr(new GeomAPI_Ax3(o, x, n)); } -std::string defaultPlane(const std::shared_ptr& theOrigin, +std::wstring defaultPlane(const std::shared_ptr& theOrigin, const std::shared_ptr& theNormal, const std::shared_ptr& theDirX) { static const double aTol = 1.e-10; if (fabs(theOrigin->x()) > aTol || fabs(theOrigin->y()) > aTol || fabs(theOrigin->z()) > aTol) - return std::string(); + return std::wstring(); // XOY or XOZ if (fabs(theNormal->x()) < aTol && fabs(theDirX->x() - 1.0) < aTol && fabs(theDirX->y()) < aTol && fabs(theDirX->z()) < aTol) { // XOY if (fabs(theNormal->y()) < aTol && fabs(theNormal->z() - 1.0) < aTol) - return std::string("XOY"); + return std::wstring(L"XOY"); else if (fabs(theNormal->y() + 1.0) < aTol && fabs(theNormal->z()) < aTol) - return std::string("XOZ"); + return std::wstring(L"XOZ"); } // YOZ else if (fabs(theNormal->x() - 1.0) < aTol && fabs(theNormal->y()) < aTol && fabs(theNormal->z()) < aTol && fabs(theDirX->x()) < aTol && fabs(theDirX->y() - 1.0) < aTol && fabs(theDirX->z()) < aTol) - return std::string("YOZ"); + return std::wstring(L"YOZ"); - return std::string(); + return std::wstring(); } -std::shared_ptr standardPlane(const std::string & theName){ +std::shared_ptr standardPlane(const std::wstring & theName){ DocumentPtr aPartSet = ModelAPI_Session::get()->moduleDocument(); // searching for the construction element return std::dynamic_pointer_cast( diff --git a/src/ModelHighAPI/ModelHighAPI_Services.h b/src/ModelHighAPI/ModelHighAPI_Services.h index bb73976be..00b9f66f1 100644 --- a/src/ModelHighAPI/ModelHighAPI_Services.h +++ b/src/ModelHighAPI/ModelHighAPI_Services.h @@ -49,11 +49,11 @@ std::shared_ptr activeDocument(); * These planes are respectively referred to by name "XOY" (Z=0), "XOZ" (Y=0) or "YOZ" (X=0). */ MODELHIGHAPI_EXPORT -std::shared_ptr defaultPlane(const std::string & theName); +std::shared_ptr defaultPlane(const std::wstring & theName); /// Return name of coordinate plane ("XOY", "XOZ" or "YOZ") or empty string for other planes. MODELHIGHAPI_EXPORT -std::string defaultPlane(const std::shared_ptr& theOrigin, +std::wstring defaultPlane(const std::shared_ptr& theOrigin, const std::shared_ptr& theNormal, const std::shared_ptr& theDirX); @@ -62,7 +62,7 @@ std::string defaultPlane(const std::shared_ptr& theOrigin, * These planes are respectively referred to by name "XOY" (Z=0), "XOZ" (Y=0) or "YOZ" (X=0). */ MODELHIGHAPI_EXPORT -std::shared_ptr standardPlane(const std::string & theName); +std::shared_ptr standardPlane(const std::wstring & theName); /** Start a data structure transaction. * diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index 936775e47..0eed22d58 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -407,20 +407,20 @@ std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType) } /// stores the features information, recursively stores sub-documents features -std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, - std::map >& theStore, +std::string storeFeatures(const std::wstring& theDocName, DocumentPtr theDoc, + std::map >& theStore, const bool theCompare) // if false => store { - std::map >::iterator aDocFind; + std::map >::iterator aDocFind; if (theCompare) { aDocFind = theStore.find(theDocName); if (aDocFind == theStore.end()) { - return "Document '" + theDocName + "' not found"; + return "Document '" + ModelAPI_Tools::toString(theDocName) + "' not found"; } } // store the model features information: iterate all features int anObjectsCount = 0; // stores the number of compared features for this document to compare - std::set aProcessed; // processed features names (that are in the current document) + std::set aProcessed; // processed features names (that are in the current document) // process all objects (features and folders) std::list allObjects = theDoc->allObjects(); @@ -436,14 +436,15 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, continue; // no need to dump and check constraints } if (theCompare) { - std::map::iterator + std::map::iterator anObjFind = aDocFind->second.find(anObject->data()->name()); if (anObjFind == aDocFind->second.end()) { - return "Document '" + theDocName + "' feature '" + anObject->data()->name() + "' not found"; + return "Document '" + ModelAPI_Tools::toString(theDocName) + + "' feature '" + ModelAPI_Tools::toString(anObject->data()->name()) + "' not found"; } std::string anError = anObjFind->second.compare(anObject); if (!anError.empty()) { - anError = "Document " + theDocName + " " + anError; + anError = "Document " + ModelAPI_Tools::toString(theDocName) + " " + anError; return anError; } anObjectsCount++; @@ -475,22 +476,23 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, if (theCompare) { if (aDocFind->second.size() != anObjectsCount) { // search for disappeared feature - std::string aLostName; - std::map::iterator aLostIter; + std::wstring aLostName; + std::map::iterator aLostIter; for(aLostIter = aDocFind->second.begin(); aLostIter != aDocFind->second.end(); aLostIter++) { if (aProcessed.find(aLostIter->first) == aProcessed.end()) { aLostName = aLostIter->first; } } - return "For document '" + theDocName + - "' the number of features is decreased, there is no feature '" + aLostName + "'"; + return "For document '" + ModelAPI_Tools::toString(theDocName) + + "' the number of features is decreased, there is no feature '" + + ModelAPI_Tools::toString(aLostName) + "'"; } } return ""; // ok } //================================================================================================== -typedef std::map > Storage; +typedef std::map > Storage; static bool dumpToPython(SessionPtr theSession, const std::string& theFilename, @@ -536,8 +538,9 @@ static bool checkDump(SessionPtr theSession, PyGILState_Release(gstate); /* release python thread */ // compare with the stored data - std::string anError = storeFeatures( - theSession->moduleDocument()->kind(), theSession->moduleDocument(), theStorage, true); + std::string anError = + storeFeatures(ModelAPI_Tools::toWString(theSession->moduleDocument()->kind()), + theSession->moduleDocument(), theStorage, true); if (!anError.empty()) { std::cout << anError << std::endl; Events_InfoMessage anErrorMsg(theErrorMsgContext, anError); @@ -575,9 +578,10 @@ bool checkPyDump(const std::string& theFilenameNaming, return false; // map from document name to feature name to feature data - std::map > aStore; - std::string anError = storeFeatures( - aSession->moduleDocument()->kind(), aSession->moduleDocument(), aStore, false); + std::map > aStore; + std::string anError = + storeFeatures(ModelAPI_Tools::toWString(aSession->moduleDocument()->kind()), + aSession->moduleDocument(), aStore, false); if (!anError.empty()) { Events_InfoMessage anErrorMsg(std::string("checkPythonDump"), anError); anErrorMsg.send(); diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index 74749fd5e..76ea42c68 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -413,7 +413,7 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a Handle(SelectMgr_SensitiveEntity) anEntity = anIt.Value(); Handle(SelectBasics_EntityOwner) aBasicsOwner = anEntity->BaseSensitive()->OwnerId(); if (!aBasicsOwner.IsNull()) - aBasicsOwner->Set(aBasicsOwner->Priority() + myAdditionalSelectionPriority); + aBasicsOwner->SetPriority(aBasicsOwner->Priority() + myAdditionalSelectionPriority); } } } @@ -441,10 +441,8 @@ bool ModuleBase_ResultPrs::appendVertexSelection(const Handle(SelectMgr_Selectio anIt.More(); anIt.Next()) { Handle(SelectMgr_SensitiveEntity) anEntity = anIt.Value(); - Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner) - ::DownCast(anEntity->BaseSensitive()->OwnerId()); - anOwner->Set(this); + Handle(SelectMgr_EntityOwner) anOwner = anEntity->BaseSensitive()->OwnerId(); + anOwner->SetSelectable(this); } return true; diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index a9f463969..ed9717c10 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -305,7 +305,7 @@ QString objectName(const ObjectPtr& theObj) if (!theObj.get()) return ""; - return theObj->data()->name().c_str(); + return QString::fromStdWString(theObj->data()->name()); } QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo) @@ -336,8 +336,8 @@ QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo) if (aFeature.get()) { aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str()); if (aFeature->data()->isValid()) { - aFeatureStr.append(QString(", name=%1").arg(theObj->data()->name().c_str()).toStdString() - .c_str()); + aFeatureStr.append(QString(", name=%1") + .arg(QString::fromStdWString(theObj->data()->name())).toStdString().c_str()); } if (isUseAttributesInfo) { std::set > anAttributes; @@ -564,8 +564,8 @@ void getParameters(QStringList& theParameters) int aSize = aDocument->size(aGroupId); for (int i = 0; i < aSize; i++) { ObjectPtr anObject = aDocument->object(aGroupId, i); - std::string aParameterName = anObject->data()->name(); - theParameters.append(aParameterName.c_str()); + std::wstring aParameterName = anObject->data()->name(); + theParameters.append(QString::fromStdWString(aParameterName)); } } } @@ -941,12 +941,12 @@ bool askToDelete(const std::set theFeatures, const std::string& thePrefixInfo) { QString aNotActivatedDocWrn; - std::string aNotActivatedNames; + std::wstring aNotActivatedNames; if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) { if (ModuleBase_Tools::hasModuleDocumentFeature(theFeatures)) aNotActivatedDocWrn = QObject::tr("Selected objects can be used in Part documents which are not loaded: %1.\n") - .arg(aNotActivatedNames.c_str()); + .arg(QString::fromStdWString(aNotActivatedNames)); } std::set aFeaturesRefsTo; @@ -962,7 +962,7 @@ bool askToDelete(const std::set theFeatures, continue; if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group())) - aPartFeatureNames.append(aFeature->name().c_str()); + aPartFeatureNames.append(QString::fromStdWString(aFeature->name())); std::set aRefFeatures; std::set aRefList = theReferences.at(aFeature); @@ -992,7 +992,7 @@ bool askToDelete(const std::set theFeatures, FeaturePtr aFeature = *anIt; if (theReferencesToDelete.find(aFeature) == theReferencesToDelete.end()) { aFeaturesRefsToParameterOnly.insert(aFeature); - aParamFeatureNames.append(aFeature->name().c_str()); + aParamFeatureNames.append(QString::fromStdWString(aFeature->name())); } } aParamFeatureNames.sort(); @@ -1004,9 +1004,9 @@ bool askToDelete(const std::set theFeatures, if (aFeature->getKind() == "RemoveResults") continue; // skip the remove results feature mentioning: result will be removed anyway if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group())) - aPartFeatureNames.append(aFeature->name().c_str()); + aPartFeatureNames.append(QString::fromStdWString(aFeature->name())); else - anOtherFeatureNames.append(aFeature->name().c_str()); + anOtherFeatureNames.append(QString::fromStdWString(aFeature->name())); } aPartFeatureNames.sort(); anOtherFeatureNames.sort(); @@ -1252,7 +1252,7 @@ bool isNameExist(const QString& theName, FeaturePtr theIgnoreParameter) std::shared_ptr aDoc = aMgr->activeDocument(); FeaturePtr aParamFeature; int aNbFeatures = aDoc->numInternalFeatures(); - std::string aName = theName.toStdString(); + std::wstring aName = theName.toStdWString(); for (int i = 0; i < aNbFeatures; i++) { aParamFeature = aDoc->internalFeature(i); if (aParamFeature && aParamFeature->getKind() == "Parameter") { @@ -1269,7 +1269,7 @@ FeaturePtr findParameter(const QString& theName) std::shared_ptr aDoc = aMgr->activeDocument(); FeaturePtr aParamFeature; int aNbFeatures = aDoc->numInternalFeatures(); - std::string aName = theName.toStdString(); + std::wstring aName = theName.toStdWString(); for (int i = 0; i < aNbFeatures; i++) { aParamFeature = aDoc->internalFeature(i); if (aParamFeature && aParamFeature->getKind() == "Parameter") { @@ -1282,10 +1282,10 @@ FeaturePtr findParameter(const QString& theName) //******************************************************************** -std::string generateName(const AttributePtr& theAttribute, +std::wstring generateName(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop) { - std::string aName; + std::wstring aName; if (theAttribute.get() != NULL) { ModuleBase_Operation* anOperation = theWorkshop->currentOperation(); @@ -1298,7 +1298,7 @@ std::string generateName(const AttributePtr& theAttribute, std::string anAttributeTitle; aFactory.getAttributeTitle(theAttribute->id(), anAttributeTitle); - std::stringstream aStreamName; + std::wstringstream aStreamName; aStreamName << theAttribute->owner()->data()->name() << "/" << anAttributeTitle.c_str(); aName = aStreamName.str(); } diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 2d1ad9227..6343bef97 100644 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -401,7 +401,7 @@ bool MODULEBASE_EXPORT isSameShape(const TopoDS_Shape& theShape1, const TopoDS_S /// \param theAttribute a model attribute /// \param theWorkshop a workshop class instance /// \return string value -std::string MODULEBASE_EXPORT generateName(const AttributePtr& theAttribute, +std::wstring MODULEBASE_EXPORT generateName(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop); /// Returns pixel ratio of a screen where main window is displayed diff --git a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp index d3d2a45b8..08ebd471e 100644 --- a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp +++ b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp @@ -163,7 +163,8 @@ void ModuleBase_WidgetConcealedObjects::addViewRow( aVisibilityBtn->setChecked(false); myView->setCellWidget(anId, 0, aVisibilityWdg); - myView->setItem(anId, 1, new QTableWidgetItem(theResult->data()->name().c_str())); + myView->setItem(anId, 1, + new QTableWidgetItem(QString::fromStdWString(theResult->data()->name()))); if (anId == 1) { myView->setColumnWidth(0, myView->verticalHeader()->defaultSectionSize()); diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureSelector.cpp b/src/ModuleBase/ModuleBase_WidgetFeatureSelector.cpp index c9685bbf0..b1191bee9 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeatureSelector.cpp @@ -184,8 +184,8 @@ void ModuleBase_WidgetFeatureSelector::updateSelectionName() ObjectPtr anObject = ModuleBase_Tools::getObject(myFeature->attribute(attributeID())); if (anObject.get() != NULL) { - std::string aName = anObject->data()->name(); - myTextLine->setText(QString::fromStdString(aName)); + std::wstring aName = anObject->data()->name(); + myTextLine->setText(QString::fromStdWString(aName)); } else { myTextLine->clear(); } diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 5404dcf02..a6acbc519 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -801,7 +801,7 @@ void ModuleBase_WidgetMultiSelector::updateSelectionList() AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID()); for (int i = 0; i < aSelectionListAttr->size(); i++) { AttributeSelectionPtr aAttr = aSelectionListAttr->value(i); - myListView->addItem(aAttr->namingName().c_str(), i); + myListView->addItem(QString::fromStdWString(aAttr->namingName()), i); } } else if (aType == ModelAPI_AttributeRefList::typeId()) { @@ -809,7 +809,7 @@ void ModuleBase_WidgetMultiSelector::updateSelectionList() for (int i = 0; i < aRefListAttr->size(); i++) { ObjectPtr anObject = aRefListAttr->object(i); if (anObject.get()) { - myListView->addItem(anObject->data()->name().c_str(), i); + myListView->addItem(QString::fromStdWString(anObject->data()->name()), i); } } } @@ -819,13 +819,13 @@ void ModuleBase_WidgetMultiSelector::updateSelectionList() AttributePtr anAttribute = aRefAttrListAttr->attribute(i); QString aName; if (anAttribute.get()) { - std::string anAttrName = ModuleBase_Tools::generateName(anAttribute, myWorkshop); - aName = QString::fromStdString(anAttrName); + std::wstring anAttrName = ModuleBase_Tools::generateName(anAttribute, myWorkshop); + aName = QString::fromStdWString(anAttrName); } else { ObjectPtr anObject = aRefAttrListAttr->object(i); if (anObject.get()) { - aName = anObject->data()->name().c_str(); + aName = QString::fromStdWString(anObject->data()->name()); } } myListView->addItem(aName, i); diff --git a/src/ModuleBase/ModuleBase_WidgetNameEdit.cpp b/src/ModuleBase/ModuleBase_WidgetNameEdit.cpp index 7ee2e2cd1..92324ff3c 100644 --- a/src/ModuleBase/ModuleBase_WidgetNameEdit.cpp +++ b/src/ModuleBase/ModuleBase_WidgetNameEdit.cpp @@ -30,7 +30,7 @@ bool ModuleBase_WidgetNameEdit::storeValueCustom() return false; QString aValue = myLineEdit->text(); - std::string aName = aValue.toStdString(); + std::wstring aName = aValue.toStdWString(); myFeature->data()->setName(aName); ResultPtr aRes = myFeature->firstResult(); if (aRes.get()) @@ -45,7 +45,7 @@ bool ModuleBase_WidgetNameEdit::restoreValueCustom() return false; bool isBlocked = myLineEdit->blockSignals(true); - myLineEdit->setText(QString::fromStdString(myFeature->data()->name())); + myLineEdit->setText(QString::fromStdWString(myFeature->data()->name())); myLineEdit->blockSignals(isBlocked); return true; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 127c7621e..e50f0d714 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -216,21 +216,21 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName() bool isNameUpdated = false; AttributeSelectionPtr aSelect = aData->selection(attributeID()); if (aSelect) { - std::string aDefault = translate(getDefaultValue()).toStdString(); - myTextLine->setText(QString::fromStdString(aSelect->namingName(aDefault))); + std::wstring aDefault = translate(getDefaultValue()).toStdWString(); + myTextLine->setText(QString::fromStdWString(aSelect->namingName(aDefault))); isNameUpdated = true; } if (!isNameUpdated) { ObjectPtr anObject = ModuleBase_Tools::getObject(myFeature->attribute(attributeID())); if (anObject.get() != NULL) { - std::string aName = anObject->data()->name(); - myTextLine->setText(QString::fromStdString(aName)); + std::wstring aName = anObject->data()->name(); + myTextLine->setText(QString::fromStdWString(aName)); } else { AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); if (aRefAttr && aRefAttr->attr().get() != NULL) { //myIsObject = aRefAttr->isObject(); - std::string anAttrName = ModuleBase_Tools::generateName(aRefAttr->attr(), myWorkshop); - myTextLine->setText(QString::fromStdString(anAttrName)); + std::wstring anAttrName = ModuleBase_Tools::generateName(aRefAttr->attr(), myWorkshop); + myTextLine->setText(QString::fromStdWString(anAttrName)); } else { myTextLine->setText(translate(getDefaultValue())); diff --git a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp index 718fa3f43..dec451209 100644 --- a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp +++ b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp @@ -244,16 +244,16 @@ bool isValidAttribute(const AttributePtr& theAttribute) void setParameterName(ResultParameterPtr theResultParameter, const std::string& theName) { bool aWasBlocked = theResultParameter->data()->blockSendAttributeUpdated(true); - theResultParameter->data()->setName(theName); + theResultParameter->data()->setName(ModelAPI_Tools::toWString(theName)); theResultParameter->data()->blockSendAttributeUpdated(aWasBlocked, false); std::shared_ptr aParameter = std::dynamic_pointer_cast( ModelAPI_Feature::feature(theResultParameter)); - std::string anOldName = aParameter->name(); + std::string anOldName = ModelAPI_Tools::toString(aParameter->name()); aWasBlocked = aParameter->data()->blockSendAttributeUpdated(true); - aParameter->data()->setName(theName); + aParameter->data()->setName(ModelAPI_Tools::toWString(theName)); aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID())->setValue(theName); aParameter->data()->blockSendAttributeUpdated(aWasBlocked); } @@ -282,7 +282,7 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent( if (!aParameter.get()) return; - std::string aNotActivatedNames; + std::wstring aNotActivatedNames; if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) { static const std::string aMsgContext("ParametersPlugin"); static const std::string aMsgText = @@ -295,28 +295,28 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent( ModuleBase_Tools::translate(aMsg), QMessageBox::No | QMessageBox::Yes, QMessageBox::No); if (aRes != QMessageBox::Yes) { - setParameterName(aResultParameter, aMessage->oldName()); + setParameterName(aResultParameter, ModelAPI_Tools::toString(aMessage->oldName())); return; } } // try to update the parameter feature according the new name - setParameterName(aResultParameter, aMessage->newName()); + setParameterName(aResultParameter, ModelAPI_Tools::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()] = aMessage->oldName(); + myOldNames[aParameter.get()] = ModelAPI_Tools::toString(aMessage->oldName()); return; } - std::string anOldName = aMessage->oldName(); + std::string anOldName = ModelAPI_Tools::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, aMessage->newName()); + renameInDependents(aResultParameter, anOldName, ModelAPI_Tools::toString(aMessage->newName())); } void ParametersPlugin_EvalListener::processReplaceParameterEvent( @@ -341,5 +341,6 @@ void ParametersPlugin_EvalListener::processReplaceParameterEvent( double aRealValue = aResultParameter->data()->real(ModelAPI_ResultParameter::VALUE())->value(); std::string aValue = toStdString(aRealValue); - renameInDependents(aResultParameter, aResultParameter->data()->name(), aValue); + renameInDependents(aResultParameter, ModelAPI_Tools::toString(aResultParameter->data()->name()), + aValue); } diff --git a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp index 2c793535e..b49507bef 100644 --- a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp @@ -74,11 +74,11 @@ void ParametersPlugin_Parameter::attributeChanged(const std::string& theID) void ParametersPlugin_Parameter::updateName() { std::string aName = string(VARIABLE_ID())->value(); - data()->setName(aName); + data()->setName(ModelAPI_Tools::toWString(aName)); ResultParameterPtr aParam = document()->createParameter(data()); - std::string anOldName = aParam->data()->name(); - aParam->data()->setName(aName); + std::string anOldName = ModelAPI_Tools::toString(aParam->data()->name()); + aParam->data()->setName(ModelAPI_Tools::toWString(aName)); setResult(aParam); diff --git a/src/ParametersPlugin/ParametersPlugin_Validators.cpp b/src/ParametersPlugin/ParametersPlugin_Validators.cpp index 1b47e66b6..47b5ac0b2 100644 --- a/src/ParametersPlugin/ParametersPlugin_Validators.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Validators.cpp @@ -71,7 +71,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 (aParamObj->data()->name() != theString) + if (ModelAPI_Tools::toString(aParamObj->data()->name()) != theString) continue; ResultParameterPtr aParam = std::dynamic_pointer_cast(aParamObj); if (!aParam.get()) diff --git a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp index 959969785..fa31070fa 100644 --- a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp +++ b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp @@ -385,7 +385,7 @@ QList ParametersPlugin_WidgetParamsMgr:: } else { if (!theFeatureList.contains(aReferenced)) { QStringList aValNames; - aValNames << aReferenced->data()->name().c_str(); + aValNames << QString::fromStdWString(aReferenced->data()->name()); std::string aId = aAttr->attributeType(); if (aId == ModelAPI_AttributeDouble::typeId()) { @@ -769,7 +769,7 @@ bool ParametersPlugin_WidgetParamsMgr::hasName(const QString& theName) const int aCurrent = myDelegate->editIndex().row(); int i = 0; foreach(FeaturePtr aFeature, myParametersList) { - if ((i != aCurrent) && (aFeature->data()->name() == theName.toStdString())) + if ((i != aCurrent) && (aFeature->data()->name() == theName.toStdWString())) return true; i++; } diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index 7ec0f7e81..7eca18749 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -193,7 +193,7 @@ bool PartSet_MenuMgr::addViewerMenu(const QMap& theStdActions QAction* aAction; int i = 0; foreach (FeaturePtr aCoins, myCoinsideLines) { - QString anItemText = aCoins->data()->name().c_str(); + QString anItemText = QString::fromStdWString(aCoins->data()->name()); #ifdef _DEBUG if (anIsAttributes[i]) anItemText += " [attribute]"; @@ -320,7 +320,7 @@ void PartSet_MenuMgr::onLineDetach(QAction* theAction) ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation(); ModuleBase_Operation* anOpAction = - new ModuleBase_Operation(tr("Detach %1").arg(aLine->data()->name().c_str()), myModule); + new ModuleBase_Operation(tr("Detach %1").arg(QString::fromStdWString(aLine->data()->name())), myModule); bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation); XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr(); // the active nested sketch operation should be aborted unconditionally diff --git a/src/PartSet/PartSet_OverconstraintListener.cpp b/src/PartSet/PartSet_OverconstraintListener.cpp index f94b11213..69cc7c3fa 100644 --- a/src/PartSet/PartSet_OverconstraintListener.cpp +++ b/src/PartSet/PartSet_OverconstraintListener.cpp @@ -94,7 +94,6 @@ void PartSet_OverconstraintListener::getCustomColor(const ObjectPtr& theObject, return; FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); - std::string aFeatureName = aFeature->data()->name(); if (myConflictingObjects.find(theObject) != myConflictingObjects.end()) { theColor = Config_PropManager::color("Visualization", "sketch_overconstraint_color"); @@ -202,7 +201,7 @@ void PartSet_OverconstraintListener::processEvent( // This Line's message should not be processed, as the reentrant operation is not for Line // It is not enoght of kind, the name should be used, e.g. restarted Lines on auxiliary // cirlce sometimes causes previous line change, kind the same, but feature line is different - std::string aCurrentFeatureName; + std::wstring aCurrentFeatureName; ModuleBase_Operation* anOperation = XGUI_Tools::workshop(myWorkshop)->operationMgr()->currentOperation(); if (anOperation) { diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 1a3f78e58..48ba4156b 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -1141,7 +1141,7 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) for (; anIt != aLast; anIt++) { FeaturePtr aFeature = *anIt; if (aFeature.get()) - anInvalidFeatureNames.append(aFeature->name().c_str()); + anInvalidFeatureNames.append(QString::fromStdWString(aFeature->name())); } std::string aPrefixInfo = QString("Invalid features of the sketch will be deleted: %1.\n\n"). arg(anInvalidFeatureNames.join(", ")).toStdString().c_str(); diff --git a/src/PartSet/PartSet_TreeNodes.cpp b/src/PartSet/PartSet_TreeNodes.cpp index ac694b1ab..384e05b2f 100644 --- a/src/PartSet/PartSet_TreeNodes.cpp +++ b/src/PartSet/PartSet_TreeNodes.cpp @@ -104,10 +104,10 @@ QVariant PartSet_ObjectNode::data(int theColumn, int theRole) const AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); QString aVal = QString::number(aValueAttribute->value()); - QString aTitle = QString(myObject->data()->name().c_str()); + QString aTitle = QString::fromStdWString(myObject->data()->name()); return aTitle + " = " + aVal; } - return myObject->data()->name().c_str(); + return QString::fromStdWString(myObject->data()->name()); } break; case Qt::DecorationRole: @@ -974,9 +974,9 @@ QVariant PartSet_PartRootNode::data(int theColumn, int theRole) const ResultPartPtr aPartRes = getPartResult(myObject); if (aPartRes.get()) { if (aPartRes->partDoc().get() == NULL) - return QString(myObject->data()->name().c_str()) + " (Not loaded)"; + return QString::fromStdWString(myObject->data()->name()) + " (Not loaded)"; } - return QString(myObject->data()->name().c_str()); + return QString::fromStdWString(myObject->data()->name()); } case Qt::DecorationRole: return ModuleBase_IconFactory::get()->getIcon(myObject); diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 2f4d1a82b..76c8e6156 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -435,8 +435,9 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute continue; if (isObject) { if (aRef->object() == anObject) { - theError = errorMessage(EqualObjects, anObject.get() ? anObject->data()->name() : "", - theAttribute->id(), aRef->id()); + theError = errorMessage(EqualObjects, + anObject.get() ? ModelAPI_Tools::toString(anObject->data()->name()) : "", + theAttribute->id(), aRef->id()); return false; } } @@ -512,8 +513,9 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute std::dynamic_pointer_cast(*anAttr); // check the object is already presented if (aRef->value() == anObject) { - theError = errorMessage(EqualObjects, anObject.get() ? anObject->data()->name() : "", - theAttribute->id(), aRef->id()); + theError = errorMessage(EqualObjects, + anObject.get() ? ModelAPI_Tools::toString(anObject->data()->name()) : "", + theAttribute->id(), aRef->id()); return false; } } @@ -608,8 +610,9 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute for (int j = 0; j < aRefSelList->size(); j++) { if (aCurSelObject == aRefSelList->object(j)) { theError = errorMessage(EqualObjects, - aCurSelObject.get() ? aCurSelObject->data()->name() : "", - theAttribute->id(), aCurSelList->id()); + aCurSelObject.get()? + ModelAPI_Tools::toString(aCurSelObject->data()->name()) : "", + theAttribute->id(), aCurSelList->id()); return false; } } diff --git a/src/PrimitivesAPI/PrimitivesAPI_Cone.cpp b/src/PrimitivesAPI/PrimitivesAPI_Cone.cpp index e4525734c..63d2acf64 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Cone.cpp +++ b/src/PrimitivesAPI/PrimitivesAPI_Cone.cpp @@ -114,8 +114,8 @@ ConePtr addCone(const std::shared_ptr& thePart, const ModelHighAPI_Double& theTopRadius, const ModelHighAPI_Double& theHeight) { - ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin"); - ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ"); + ModelHighAPI_Selection aBasePoint("VERTEX", L"PartSet/Origin"); + ModelHighAPI_Selection anAxis("EDGE", L"PartSet/OZ"); std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID()); return ConePtr(new PrimitivesAPI_Cone(aFeature, aBasePoint, anAxis, theBaseRadius, theTopRadius, theHeight)); diff --git a/src/PrimitivesAPI/PrimitivesAPI_Cylinder.cpp b/src/PrimitivesAPI/PrimitivesAPI_Cylinder.cpp index f64f8ed84..02ff703bb 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Cylinder.cpp +++ b/src/PrimitivesAPI/PrimitivesAPI_Cylinder.cpp @@ -137,8 +137,8 @@ CylinderPtr addCylinder(const std::shared_ptr& thePart, const ModelHighAPI_Double& theRadius, const ModelHighAPI_Double& theHeight) { - ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin"); - ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ"); + ModelHighAPI_Selection aBasePoint("VERTEX", L"PartSet/Origin"); + ModelHighAPI_Selection anAxis("EDGE", L"PartSet/OZ"); std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID()); return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis, theRadius, theHeight)); @@ -150,8 +150,8 @@ CylinderPtr addCylinder(const std::shared_ptr& thePart, const ModelHighAPI_Double& theHeight, const ModelHighAPI_Double& theAngle) { - ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin"); - ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ"); + ModelHighAPI_Selection aBasePoint("VERTEX", L"PartSet/Origin"); + ModelHighAPI_Selection anAxis("EDGE", L"PartSet/OZ"); std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID()); return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis, theRadius, theHeight, theAngle)); diff --git a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp index 13a8b1916..e2f6b7e9b 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp +++ b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp @@ -94,7 +94,7 @@ SpherePtr addSphere(const std::shared_ptr& thePart, SpherePtr addSphere(const std::shared_ptr& thePart, const ModelHighAPI_Double& theRadius) { - ModelHighAPI_Selection aCenterPoint("VERTEX", "PartSet/Origin"); + ModelHighAPI_Selection aCenterPoint("VERTEX", L"PartSet/Origin"); std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID()); return SpherePtr(new PrimitivesAPI_Sphere(aFeature, aCenterPoint, theRadius)); } diff --git a/src/PrimitivesAPI/PrimitivesAPI_Torus.cpp b/src/PrimitivesAPI/PrimitivesAPI_Torus.cpp index 0af0baf33..9308d1e57 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Torus.cpp +++ b/src/PrimitivesAPI/PrimitivesAPI_Torus.cpp @@ -101,8 +101,8 @@ TorusPtr addTorus(const std::shared_ptr& thePart, const ModelHighAPI_Double& theRadius, const ModelHighAPI_Double& theRingRadius) { - ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin"); - ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ"); + ModelHighAPI_Selection aBasePoint("VERTEX", L"PartSet/Origin"); + ModelHighAPI_Selection anAxis("EDGE", L"PartSet/OZ"); std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Torus::ID()); return TorusPtr(new PrimitivesAPI_Torus(aFeature, aBasePoint, anAxis, theRadius, theRingRadius)); } diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp index e3c4d57e2..d31a92423 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp @@ -63,7 +63,7 @@ void PrimitivesPlugin_Cone::initAttributes() data()->selection(PrimitivesPlugin_Cone::BASE_POINT_ID()); if (!aCenterPoint->isInitialized()) { ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument() - ->objectByName(ModelAPI_ResultConstruction::group(), "Origin"); + ->objectByName(ModelAPI_ResultConstruction::group(), L"Origin"); if (aPointObj.get()) { ResultPtr aPointRes = std::dynamic_pointer_cast(aPointObj); aCenterPoint->setValue(aPointRes, std::shared_ptr()); @@ -74,7 +74,7 @@ void PrimitivesPlugin_Cone::initAttributes() AttributeSelectionPtr anAxis = data()->selection(PrimitivesPlugin_Cone::AXIS_ID()); if (!anAxis->isInitialized()) { ObjectPtr anAxisObj = ModelAPI_Session::get()->moduleDocument() - ->objectByName(ModelAPI_ResultConstruction::group(), "OZ"); + ->objectByName(ModelAPI_ResultConstruction::group(), L"OZ"); if (anAxisObj.get()) { ResultPtr anAxisRes = std::dynamic_pointer_cast(anAxisObj); anAxis->setValue(anAxisRes, std::shared_ptr()); diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp index 9b5e544ac..22185dbb5 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp @@ -60,7 +60,7 @@ void PrimitivesPlugin_Cylinder::initAttributes() AttributeSelectionPtr aBasePoint = data()->selection(BASE_POINT_ID()); if (!aBasePoint->isInitialized()) { ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument() - ->objectByName(ModelAPI_ResultConstruction::group(), "Origin"); + ->objectByName(ModelAPI_ResultConstruction::group(), L"Origin"); if (aPointObj.get()) { ResultPtr aPointRes = std::dynamic_pointer_cast(aPointObj); aBasePoint->setValue(aPointRes, std::shared_ptr()); @@ -71,7 +71,7 @@ void PrimitivesPlugin_Cylinder::initAttributes() AttributeSelectionPtr anAxis = data()->selection(AXIS_ID()); if (!anAxis->isInitialized()) { ObjectPtr anAxisObj = ModelAPI_Session::get()->moduleDocument() - ->objectByName(ModelAPI_ResultConstruction::group(), "OZ"); + ->objectByName(ModelAPI_ResultConstruction::group(), L"OZ"); if (anAxisObj.get()) { ResultPtr anAxisRes = std::dynamic_pointer_cast(anAxisObj); anAxis->setValue(anAxisRes, std::shared_ptr()); diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp index c9c43d750..416cec986 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp @@ -54,7 +54,7 @@ void PrimitivesPlugin_Sphere::initAttributes() data()->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID()); if (!aCenterPoint->isInitialized()) { ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument() - ->objectByName(ModelAPI_ResultConstruction::group(), "Origin"); + ->objectByName(ModelAPI_ResultConstruction::group(), L"Origin"); if (aPointObj.get()) { ResultPtr aPointRes = std::dynamic_pointer_cast(aPointObj); aCenterPoint->setValue(aPointRes, std::shared_ptr()); diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp index fef286d79..8404df801 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp @@ -61,7 +61,7 @@ void PrimitivesPlugin_Torus::initAttributes() data()->selection(PrimitivesPlugin_Torus::BASE_POINT_ID()); if (!aCenterPoint->isInitialized()) { ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument() - ->objectByName(ModelAPI_ResultConstruction::group(), "Origin"); + ->objectByName(ModelAPI_ResultConstruction::group(), L"Origin"); if (aPointObj.get()) { ResultPtr aPointRes = std::dynamic_pointer_cast(aPointObj); aCenterPoint->setValue(aPointRes, std::shared_ptr()); @@ -72,7 +72,7 @@ void PrimitivesPlugin_Torus::initAttributes() AttributeSelectionPtr anAxis = data()->selection(PrimitivesPlugin_Torus::AXIS_ID()); if (!anAxis->isInitialized()) { ObjectPtr anAxisObj = ModelAPI_Session::get()->moduleDocument() - ->objectByName(ModelAPI_ResultConstruction::group(), "OZ"); + ->objectByName(ModelAPI_ResultConstruction::group(), L"OZ"); if (anAxisObj.get()) { ResultPtr anAxisRes = std::dynamic_pointer_cast(anAxisObj); anAxis->setValue(anAxisRes, std::shared_ptr()); diff --git a/src/Selector/Selector_Algo.cpp b/src/Selector/Selector_Algo.cpp index f6035dc72..94ce16124 100644 --- a/src/Selector/Selector_Algo.cpp +++ b/src/Selector/Selector_Algo.cpp @@ -410,7 +410,7 @@ Selector_Algo* Selector_Algo::restoreByLab(TDF_Label theLab, TDF_Label theBaseDo } Selector_Algo* Selector_Algo::restoreByName(TDF_Label theLab, TDF_Label theBaseDocLab, - std::string theName, const TopAbs_ShapeEnum theShapeType, const bool theGeomNaming, + std::wstring theName, const TopAbs_ShapeEnum theShapeType, const bool theGeomNaming, Selector_NameGenerator* theNameGenerator, TDF_Label& theContextLab) { Selector_Algo* aResult = NULL; diff --git a/src/Selector/Selector_Algo.h b/src/Selector/Selector_Algo.h index ad512aad9..162f0cc24 100644 --- a/src/Selector/Selector_Algo.h +++ b/src/Selector/Selector_Algo.h @@ -82,14 +82,14 @@ public: /// Restores the selected shape by the topological name string. /// Returns not empty label of the context. - SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) = 0; /// Updates the current shape by the stored topological name SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) = 0; /// Returns the naming name of the selection - SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) = 0; + SELECTOR_EXPORT virtual std::wstring name(Selector_NameGenerator* theNameGenerator) = 0; /// Returns the current sub-shape value (null if can not resolve) SELECTOR_EXPORT TopoDS_Shape value(); /// Restores sub-algorithm of a given type by the storage-label @@ -97,7 +97,7 @@ public: /// Restores the selected sub-algorithm by the naming name. /// Returns not empty label of the context. SELECTOR_EXPORT static Selector_Algo* restoreByName( - TDF_Label theLab, TDF_Label theBaseDocLab, std::string theName, + TDF_Label theLab, TDF_Label theBaseDocLab, std::wstring theName, const TopAbs_ShapeEnum theShapeType, const bool theGeomNaming, Selector_NameGenerator* theNameGenerator, TDF_Label& theContextLab); @@ -149,15 +149,15 @@ protected: return kSHAPE_TYPE; } /// string identifier of the weak name in modification or intersection types of algorithm - static const std::string& weakNameID() + static const std::wstring& weakNameID() { - static const std::string kWEAK_NAME_IDENTIFIER = "weak_name_"; + static const std::wstring kWEAK_NAME_IDENTIFIER = L"weak_name_"; return kWEAK_NAME_IDENTIFIER; } /// string identifier of the pure weak name - static const std::string& pureWeakNameID() + static const std::wstring& pureWeakNameID() { - static const std::string kPURE_WEAK_NAME_IDENTIFIER = "_weak_name_"; + static const std::wstring kPURE_WEAK_NAME_IDENTIFIER = L"_weak_name_"; return kPURE_WEAK_NAME_IDENTIFIER; } /// Stores the type of an algorithm in the data tree (in myLab) diff --git a/src/Selector/Selector_Container.cpp b/src/Selector/Selector_Container.cpp index 44d1b1e92..05f8fa2ea 100644 --- a/src/Selector/Selector_Container.cpp +++ b/src/Selector/Selector_Container.cpp @@ -80,7 +80,7 @@ bool Selector_Container::restore() return true; } -TDF_Label Selector_Container::restoreByName(std::string theName, +TDF_Label Selector_Container::restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) { myShapeType = theShapeType; @@ -99,7 +99,7 @@ TDF_Label Selector_Container::restoreByName(std::string theName, } if (anEndPos == std::string::npos) return TDF_Label(); // invalid parentheses - std::string aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1); + std::wstring aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1); TopAbs_ShapeEnum aSubShapeType = TopAbs_FACE; switch (myShapeType) { case TopAbs_COMPSOLID: aSubShapeType = TopAbs_SOLID; break; @@ -177,9 +177,9 @@ bool Selector_Container::solve(const TopoDS_Shape& theContext) return false; } -std::string Selector_Container::name(Selector_NameGenerator* theNameGenerator) +std::wstring Selector_Container::name(Selector_NameGenerator* theNameGenerator) { - std::string aResult; + std::wstring aResult; // add names of sub-components one by one in "[]" std::list::const_iterator aSubSel = list().cbegin(); for(; aSubSel != list().cend(); aSubSel++) { diff --git a/src/Selector/Selector_Container.h b/src/Selector/Selector_Container.h index e163ea23e..b29cd5f96 100644 --- a/src/Selector/Selector_Container.h +++ b/src/Selector/Selector_Container.h @@ -45,14 +45,14 @@ public: /// Restores the selected shape by the topological name string. /// Returns not empty label of the context. - SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) override; /// Updates the current shape by the stored topological name SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) override; /// Returns the naming name of the selection - SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) override; + SELECTOR_EXPORT virtual std::wstring name(Selector_NameGenerator* theNameGenerator) override; private: /// Initializes selector Selector_Container(); diff --git a/src/Selector/Selector_FilterByNeighbors.cpp b/src/Selector/Selector_FilterByNeighbors.cpp index 7a741402b..075036400 100644 --- a/src/Selector/Selector_FilterByNeighbors.cpp +++ b/src/Selector/Selector_FilterByNeighbors.cpp @@ -294,17 +294,17 @@ bool Selector_FilterByNeighbors::restore() return myNBLevel.size() == list().size() && !myNBLevel.empty(); } -TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName, +TDF_Label Selector_FilterByNeighbors::restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) { myShapeType = theShapeType; TDF_Label aContext; - std::string aLastLevel; // last level string (after '(' ) to check the context name in the end + std::wstring aLastLevel; // last level string (after '(' ) to check the context name in the end for (size_t aStart = 0; aStart != std::string::npos; aStart = theName.find('(', aStart + 1)) { size_t anEndPos = theName.find(')', aStart + 1); if (anEndPos != std::string::npos) { - std::string aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1); + std::wstring aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1); TDF_Label aSubContext; Selector_Algo* aSubSel = Selector_Algo::restoreByName(newSubLabel(), baseDocument(), aSubStr, myShapeType, @@ -327,7 +327,7 @@ TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName, // aContext = theNameGenerator->newestContext(aContext); // searching for the level index - std::string aLevel; + std::wstring aLevel; for (anEndPos++; anEndPos != std::string::npos && theName[anEndPos] != '(' && theName[anEndPos] != 0; anEndPos++) { @@ -337,7 +337,7 @@ TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName, if (aLevel.empty() || aLevel[0] == '_') myNBLevel.push_back(1); // by default it is 1 else { - int aNum = atoi(aLevel.c_str()); + int aNum = std::stoi(aLevel.c_str()); if (aNum > 0) myNBLevel.push_back(aNum); else @@ -347,9 +347,9 @@ TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName, return TDF_Label(); // invalid parentheses } if (!aLastLevel.empty()) { // get the context - size_t aLinePos = aLastLevel.find("_"); + size_t aLinePos = aLastLevel.find(L"_"); if (aLinePos != std::string::npos) { - std::string aContextName = aLastLevel.substr(aLinePos + 1); + std::wstring aContextName = aLastLevel.substr(aLinePos + 1); if (!aContextName.empty()) { TDF_Label aThisContext, aValue; if (theNameGenerator->restoreContext(aContextName, aThisContext, aValue)) { @@ -387,23 +387,23 @@ bool Selector_FilterByNeighbors::solve(const TopoDS_Shape& theContext) return false; } -std::string Selector_FilterByNeighbors::name(Selector_NameGenerator* theNameGenerator) +std::wstring Selector_FilterByNeighbors::name(Selector_NameGenerator* theNameGenerator) { // (nb1)level_if_more_than_1(nb2)level_if_more_than_1(nb3)level_if_more_than_1 bool aThisContextNameNeeded = !myContext.IsNull(); - std::string aContextName; + std::wstring aContextName; if (aThisContextNameNeeded) aContextName = theNameGenerator->contextName(myContext); - std::string aResult; + std::wstring aResult; std::list::iterator aLevel = myNBLevel.begin(); std::list::const_iterator aSubSel = list().cbegin(); for(; aSubSel != list().cend(); aSubSel++, aLevel++) { if (!*aSubSel) continue; - std::string aSubName = (*aSubSel)->name(theNameGenerator); - aResult += "(" + aSubName + ")"; + std::wstring aSubName = (*aSubSel)->name(theNameGenerator); + aResult += L"(" + aSubName + L")"; if (*aLevel > 1) { - std::ostringstream aLevelStr; + std::wostringstream aLevelStr; aLevelStr<<*aLevel; aResult += aLevelStr.str(); } @@ -413,7 +413,7 @@ std::string Selector_FilterByNeighbors::name(Selector_NameGenerator* theNameGene aThisContextNameNeeded = false; } if (aThisContextNameNeeded) { - aResult = aResult + "_" + aContextName; + aResult = aResult + L"_" + aContextName; } return aResult; } diff --git a/src/Selector/Selector_FilterByNeighbors.h b/src/Selector/Selector_FilterByNeighbors.h index 527f4d810..6cc9364d3 100644 --- a/src/Selector/Selector_FilterByNeighbors.h +++ b/src/Selector/Selector_FilterByNeighbors.h @@ -49,14 +49,14 @@ public: /// Restores the selected shape by the topological name string. /// Returns not empty label of the context. - SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) override; /// Updates the current shape by the stored topological name SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) override; /// Returns the naming name of the selection - SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) override; + SELECTOR_EXPORT virtual std::wstring name(Selector_NameGenerator* theNameGenerator) override; private: /// Initializes selector Selector_FilterByNeighbors(); diff --git a/src/Selector/Selector_Intersect.cpp b/src/Selector/Selector_Intersect.cpp index 81e54b80a..07671e2f6 100644 --- a/src/Selector/Selector_Intersect.cpp +++ b/src/Selector/Selector_Intersect.cpp @@ -181,7 +181,7 @@ bool Selector_Intersect::restore() return true; } -TDF_Label Selector_Intersect::restoreByName(std::string theName, +TDF_Label Selector_Intersect::restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) { myShapeType = theShapeType; @@ -189,15 +189,15 @@ TDF_Label Selector_Intersect::restoreByName(std::string theName, for(size_t aStart = 0; aStart != std::string::npos; aStart = theName.find('[', aStart + 1)) { size_t anEndPos = theName.find(']', aStart + 1); if (anEndPos != std::string::npos) { - std::string aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1); + std::wstring aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1); if (aSubStr.find(weakNameID()) == 0) { // weak name identifier - std::string aWeakIndex = aSubStr.substr(weakNameID().size()); - myWeakIndex = atoi(aWeakIndex.c_str()); + std::wstring aWeakIndex = aSubStr.substr(weakNameID().size()); + myWeakIndex = stoi(aWeakIndex); continue; } TopAbs_ShapeEnum aSubShapeType = TopAbs_FACE; if (anEndPos != std::string::npos && anEndPos + 1 < theName.size()) { - char aShapeChar = theName[anEndPos + 1]; + wchar_t aShapeChar = theName[anEndPos + 1]; if (theName[anEndPos + 1] != '[') { switch(aShapeChar) { case 'e': aSubShapeType = TopAbs_EDGE; break; @@ -277,9 +277,9 @@ bool Selector_Intersect::solve(const TopoDS_Shape& theContext) return false; } -std::string Selector_Intersect::name(Selector_NameGenerator* theNameGenerator) +std::wstring Selector_Intersect::name(Selector_NameGenerator* theNameGenerator) { - std::string aResult; + std::wstring aResult; // add names of sub-components one by one in "[]" +optionally [weak_name_1] std::list::const_iterator aSubSel = list().cbegin(); for(; aSubSel != list().cend(); aSubSel++) { @@ -291,15 +291,15 @@ std::string Selector_Intersect::name(Selector_NameGenerator* theNameGenerator) TopAbs_ShapeEnum aSubType = aSubVal.ShapeType(); if (aSubType != TopAbs_FACE) { // in case the sub shape type must be stored switch(aSubType) { - case TopAbs_EDGE: aResult += "e"; break; - case TopAbs_VERTEX: aResult += "v"; break; + case TopAbs_EDGE: aResult += L"e"; break; + case TopAbs_VERTEX: aResult += L"v"; break; default:; } } } } if (myWeakIndex != -1) { - std::ostringstream aWeakStr; + std::wostringstream aWeakStr; aWeakStr<<"["<contextName(myFinal) + "/" + - std::string(TCollection_AsciiString(aName->Get()).ToCString()); + return L""; + aResult += theNameGenerator->contextName(myFinal) + L"/"; + aResult += (wchar_t*)aName->Get().ToExtString(); for(TDF_LabelList::iterator aBase = myBases.begin(); aBase != myBases.end(); aBase++) { if (!aBase->FindAttribute(TDataStd_Name::GetID(), aName)) - return ""; - aResult += "&"; - aResult += theNameGenerator->contextName(*aBase) + "/" + - std::string(TCollection_AsciiString(aName->Get()).ToCString()); + return L""; + aResult += L"&"; + aResult += theNameGenerator->contextName(*aBase) + L"/"; + aResult += (wchar_t*)aName->Get().ToExtString(); } if (myWeakIndex != -1) { - std::ostringstream aWeakStr; + std::wostringstream aWeakStr; aWeakStr<<"&"<contextName(myFinal); - if (!aResult.empty()) - aResult += "/" + std::string(TCollection_AsciiString(aName->Get()).ToCString()); + return L""; + std::wstring aResult = theNameGenerator->contextName(myFinal); + if (!aResult.empty()) { + aResult += L"/"; + aResult += ((wchar_t*)aName->Get().ToExtString()); + } return aResult; } diff --git a/src/Selector/Selector_Primitive.h b/src/Selector/Selector_Primitive.h index b9d02aba0..deee6d4bd 100644 --- a/src/Selector/Selector_Primitive.h +++ b/src/Selector/Selector_Primitive.h @@ -43,14 +43,14 @@ public: /// Restores the selected shape by the topological name string. /// Returns not empty label of the context. - SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) override; /// Updates the current shape by the stored topological name SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) override; /// Returns the naming name of the selection - SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) override; + SELECTOR_EXPORT virtual std::wstring name(Selector_NameGenerator* theNameGenerator) override; private: /// Initializes selector Selector_Primitive(); diff --git a/src/Selector/Selector_Selector.cpp b/src/Selector/Selector_Selector.cpp index f10a0d082..e0d0f4c3d 100644 --- a/src/Selector/Selector_Selector.cpp +++ b/src/Selector/Selector_Selector.cpp @@ -73,12 +73,12 @@ TopoDS_Shape Selector_Selector::value() return TopoDS_Shape(); // empty, error shape } -std::string Selector_Selector::name(Selector_NameGenerator* theNameGenerator) { +std::wstring Selector_Selector::name(Selector_NameGenerator* theNameGenerator) { return myAlgo->name(theNameGenerator); } TDF_Label Selector_Selector::restoreByName( - std::string theName, const TopAbs_ShapeEnum theShapeType, + std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator, const bool theGeometricalNaming) { TDF_Label aResult; diff --git a/src/Selector/Selector_Selector.h b/src/Selector/Selector_Selector.h index bb84365c0..52af8af84 100644 --- a/src/Selector/Selector_Selector.h +++ b/src/Selector/Selector_Selector.h @@ -66,14 +66,14 @@ public: /// Restores the selected shape by the topological name string. /// Returns not empty label of the context. SELECTOR_EXPORT TDF_Label restoreByName( - std::string theName, const TopAbs_ShapeEnum theShapeType, + std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator, const bool theGeometricalNaming = false); /// Returns the current sub-shape value (null if can not resolve) SELECTOR_EXPORT TopoDS_Shape value(); /// Returns the naming name of the selection - SELECTOR_EXPORT std::string name(Selector_NameGenerator* theNameGenerator); + SELECTOR_EXPORT std::wstring name(Selector_NameGenerator* theNameGenerator); /// Makes the current local selection becomes all sub-shapes with same base geometry. SELECTOR_EXPORT void combineGeometrical(const TopoDS_Shape theContext); diff --git a/src/Selector/Selector_WeakName.cpp b/src/Selector/Selector_WeakName.cpp index ff74df585..6d3ad0455 100644 --- a/src/Selector/Selector_WeakName.cpp +++ b/src/Selector/Selector_WeakName.cpp @@ -85,16 +85,16 @@ bool Selector_WeakName::restore() return restoreBaseArray(anEmptyRefList, myContext); } -TDF_Label Selector_WeakName::restoreByName(std::string theName, +TDF_Label Selector_WeakName::restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) { - std::string aWeakIndex = theName.substr(pureWeakNameID().size()); - std::size_t aContextPosition = aWeakIndex.find("_"); - myWeakIndex = atoi(aWeakIndex.c_str()); + std::wstring aWeakIndex = theName.substr(pureWeakNameID().size()); + std::size_t aContextPosition = aWeakIndex.find(L"_"); + myWeakIndex = std::stoi(aWeakIndex.c_str()); myShapeType = theShapeType; TDF_Label aContext; - if (aContextPosition != std::string::npos) { // context is also defined - std::string aContextName = aWeakIndex.substr(aContextPosition + 1); + if (aContextPosition != std::wstring::npos) { // context is also defined + std::wstring aContextName = aWeakIndex.substr(aContextPosition + 1); if (theNameGenerator->restoreContext(aContextName, aContext, myContext)) { if (myContext.IsNull()) aContext.Nullify(); @@ -126,13 +126,13 @@ bool Selector_WeakName::solve(const TopoDS_Shape& theContext) return false; } -std::string Selector_WeakName::name(Selector_NameGenerator* theNameGenerator) +std::wstring Selector_WeakName::name(Selector_NameGenerator* theNameGenerator) { // _weak_naming_1_Context - std::ostringstream aWeakStr; + std::wostringstream aWeakStr; aWeakStr<contextName(myContext); + aResult += L"_" + theNameGenerator->contextName(myContext); return aResult; } diff --git a/src/Selector/Selector_WeakName.h b/src/Selector/Selector_WeakName.h index aadf4d187..2ce456e0e 100644 --- a/src/Selector/Selector_WeakName.h +++ b/src/Selector/Selector_WeakName.h @@ -45,14 +45,14 @@ public: /// Restores the selected shape by the topological name string. /// Returns not empty label of the context. - SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) override; /// Updates the current shape by the stored topological name SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) override; /// Returns the naming name of the selection - SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) override; + SELECTOR_EXPORT virtual std::wstring name(Selector_NameGenerator* theNameGenerator) override; private: /// Initializes selector Selector_WeakName(); diff --git a/src/SketchAPI/SketchAPI.i b/src/SketchAPI/SketchAPI.i index 2ee3108cd..e022d8f2d 100644 --- a/src/SketchAPI/SketchAPI.i +++ b/src/SketchAPI/SketchAPI.i @@ -27,6 +27,8 @@ // fix for SWIG v2.0.4 #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj)) + + #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj)) %} %include "doxyhelp.i" @@ -40,10 +42,7 @@ #define SKETCHAPI_EXPORT // standard definitions -%include "typemaps.i" -%include "std_list.i" %include "std_pair.i" -%include "std_shared_ptr.i" // function with named parameters %feature("kwargs") SketchAPI_BSpline::controlPoles; diff --git a/src/SketchAPI/SketchAPI_Arc.cpp b/src/SketchAPI/SketchAPI_Arc.cpp index d71722b83..5dd2ca951 100644 --- a/src/SketchAPI/SketchAPI_Arc.cpp +++ b/src/SketchAPI/SketchAPI_Arc.cpp @@ -75,7 +75,7 @@ SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr& theFeature //================================================================================================ SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr& theFeature, - const std::string& theExternalName) + const std::wstring& theExternalName) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { @@ -126,7 +126,7 @@ void SketchAPI_Arc::setByExternal(const ModelHighAPI_Selection & theExternal) } //=============================================================================================== -void SketchAPI_Arc::setByExternalName(const std::string & theExternalName) +void SketchAPI_Arc::setByExternalName(const std::wstring & theExternalName) { fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external()); diff --git a/src/SketchAPI/SketchAPI_Arc.h b/src/SketchAPI/SketchAPI_Arc.h index 69e724dcb..8e3ec4477 100644 --- a/src/SketchAPI/SketchAPI_Arc.h +++ b/src/SketchAPI/SketchAPI_Arc.h @@ -64,7 +64,7 @@ public: /// Constructor with values. SKETCHAPI_EXPORT SketchAPI_Arc(const std::shared_ptr& theFeature, - const std::string& theExternalName); + const std::wstring& theExternalName); /// Destructor. SKETCHAPI_EXPORT @@ -106,7 +106,7 @@ public: /// Set by external name. SKETCHAPI_EXPORT - void setByExternalName(const std::string& theExternalName); + void setByExternalName(const std::wstring& theExternalName); /// Dump wrapped feature SKETCHAPI_EXPORT diff --git a/src/SketchAPI/SketchAPI_BSpline.cpp b/src/SketchAPI/SketchAPI_BSpline.cpp index c89abac78..2280396c1 100644 --- a/src/SketchAPI/SketchAPI_BSpline.cpp +++ b/src/SketchAPI/SketchAPI_BSpline.cpp @@ -30,6 +30,8 @@ #include #include +#include + #include #include #include @@ -152,8 +154,8 @@ static void createPole(const CompositeFeaturePtr& theSketch, aPointFeature->reference(SketchPlugin_Point::PARENT_ID())->setValue(theBSpline); aPointFeature->execute(); - std::ostringstream aName; - aName << theBSpline->name() << "_" << thePoles->id() << "_" << thePoleIndex; + std::wostringstream aName; + aName << theBSpline->name() << "_" << ModelAPI_Tools::toWString(thePoles->id()) << "_" << thePoleIndex; aPointFeature->data()->setName(aName.str()); aPointFeature->lastResult()->data()->setName(aName.str()); @@ -185,7 +187,7 @@ static void createSegment(const CompositeFeaturePtr& theSketch, aLineFeature->reference(SketchPlugin_Point::PARENT_ID())->setValue(theBSpline); aLineFeature->execute(); - std::ostringstream aName; + std::wostringstream aName; aName << theBSpline->name() << "_segment_" << theStartPoleIndex << "_" << aEndPoleIndex; aLineFeature->data()->setName(aName.str()); aLineFeature->lastResult()->data()->setName(aName.str()); diff --git a/src/SketchAPI/SketchAPI_Circle.cpp b/src/SketchAPI/SketchAPI_Circle.cpp index c4cd7db15..378e5be4b 100644 --- a/src/SketchAPI/SketchAPI_Circle.cpp +++ b/src/SketchAPI/SketchAPI_Circle.cpp @@ -68,7 +68,7 @@ SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr& theF //================================================================================================== SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr& theFeature, - const std::string& theExternalName) + const std::wstring& theExternalName) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { @@ -110,7 +110,7 @@ void SketchAPI_Circle::setByExternal(const ModelHighAPI_Selection & theExternal) } //================================================================================================== -void SketchAPI_Circle::setByExternalName(const std::string & theExternalName) +void SketchAPI_Circle::setByExternalName(const std::wstring & theExternalName) { fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external()); diff --git a/src/SketchAPI/SketchAPI_Circle.h b/src/SketchAPI/SketchAPI_Circle.h index 839c1e58f..c2d59d127 100644 --- a/src/SketchAPI/SketchAPI_Circle.h +++ b/src/SketchAPI/SketchAPI_Circle.h @@ -58,7 +58,7 @@ public: /// Constructor with values. SKETCHAPI_EXPORT SketchAPI_Circle(const std::shared_ptr& theFeature, - const std::string& theExternalName); + const std::wstring& theExternalName); /// Destructor. SKETCHAPI_EXPORT @@ -86,7 +86,7 @@ public: /// Set by external name. SKETCHAPI_EXPORT - void setByExternalName(const std::string& theExternalName); + void setByExternalName(const std::wstring& theExternalName); /// Set center. SKETCHAPI_EXPORT diff --git a/src/SketchAPI/SketchAPI_Ellipse.cpp b/src/SketchAPI/SketchAPI_Ellipse.cpp index 19de091d4..d05222b9f 100644 --- a/src/SketchAPI/SketchAPI_Ellipse.cpp +++ b/src/SketchAPI/SketchAPI_Ellipse.cpp @@ -25,11 +25,13 @@ #include #include +#include + #include #include #include -static const std::string AUXILIARY_VALUE = "aux"; +static const std::wstring AUXILIARY_VALUE = L"aux"; static const std::string MAJOR_AXIS_ID = "majorAxis"; static const std::string MINOR_AXIS_ID = "minorAxis"; @@ -71,7 +73,7 @@ SketchAPI_Ellipse::SketchAPI_Ellipse(const std::shared_ptr& th } SketchAPI_Ellipse::SketchAPI_Ellipse(const std::shared_ptr& theFeature, - const std::string& theExternalName) + const std::wstring& theExternalName) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { @@ -111,7 +113,7 @@ void SketchAPI_Ellipse::setByExternal(const ModelHighAPI_Selection & theExternal execute(); } -void SketchAPI_Ellipse::setByExternalName(const std::string & theExternalName) +void SketchAPI_Ellipse::setByExternalName(const std::wstring & theExternalName) { fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external()); execute(); @@ -191,7 +193,7 @@ static void createInternalConstraint(const CompositeFeaturePtr& theSketch, static void createPoint(const CompositeFeaturePtr& theSketch, const FeaturePtr& theEllipse, const std::string& theCoincident, - const std::string& theAuxOrName, + const std::wstring& theAuxOrName, std::list& theEntities) { if (theAuxOrName.empty()) @@ -207,7 +209,7 @@ static void createPoint(const CompositeFeaturePtr& theSketch, aPointFeature->reference(SketchPlugin_Point::PARENT_ID())->setValue(theEllipse); aPointFeature->execute(); - std::string aName = theEllipse->name() + "_" + theCoincident; + std::wstring aName = theEllipse->name() + L"_" + ModelAPI_Tools::toWString(theCoincident); aPointFeature->data()->setName(aName); aPointFeature->lastResult()->data()->setName(aName); @@ -227,7 +229,7 @@ static void createAxis(const CompositeFeaturePtr& theSketch, const FeaturePtr& theEllipse, const std::string& theCoincidentStart, const std::string& theCoincidentEnd, - const std::string& theAuxOrName, + const std::wstring& theAuxOrName, std::list& theEntities) { if (theAuxOrName.empty()) @@ -248,9 +250,9 @@ static void createAxis(const CompositeFeaturePtr& theSketch, aLineFeature->reference(SketchPlugin_Point::PARENT_ID())->setValue(theEllipse); aLineFeature->execute(); - std::string aName = theEllipse->name() + "_" + + std::wstring aName = theEllipse->name() + L"_" + (theCoincidentStart == SketchPlugin_Ellipse::MAJOR_AXIS_START_ID() ? - "major_axis" : "minor_axis"); + L"major_axis" : L"minor_axis"); aLineFeature->data()->setName(aName); aLineFeature->lastResult()->data()->setName(aName); @@ -268,15 +270,15 @@ static void createAxis(const CompositeFeaturePtr& theSketch, } std::list > SketchAPI_Ellipse::construction( - const std::string& center, - const std::string& firstFocus, - const std::string& secondFocus, - const std::string& majorAxisStart, - const std::string& majorAxisEnd, - const std::string& minorAxisStart, - const std::string& minorAxisEnd, - const std::string& majorAxis, - const std::string& minorAxis) const + const std::wstring& center, + const std::wstring& firstFocus, + const std::wstring& secondFocus, + const std::wstring& majorAxisStart, + const std::wstring& majorAxisEnd, + const std::wstring& minorAxisStart, + const std::wstring& minorAxisEnd, + const std::wstring& majorAxis, + const std::wstring& minorAxis) const { FeaturePtr anEllipse = feature(); @@ -294,15 +296,15 @@ std::list > SketchAPI_Ellipse::construct std::list > SketchAPI_Ellipse::buildConstructionEntities( const FeaturePtr& theEllipse, const std::list& theAttributes, - const std::string& theCenter, - const std::string& theFirstFocus, - const std::string& theSecondFocus, - const std::string& theMajorAxisStart, - const std::string& theMajorAxisEnd, - const std::string& theMinorAxisStart, - const std::string& theMinorAxisEnd, - const std::string& theMajorAxis, - const std::string& theMinorAxis) + const std::wstring& theCenter, + const std::wstring& theFirstFocus, + const std::wstring& theSecondFocus, + const std::wstring& theMajorAxisStart, + const std::wstring& theMajorAxisEnd, + const std::wstring& theMinorAxisStart, + const std::wstring& theMinorAxisEnd, + const std::wstring& theMajorAxis, + const std::wstring& theMinorAxis) { CompositeFeaturePtr aSketch = sketchForFeature(theEllipse); diff --git a/src/SketchAPI/SketchAPI_Ellipse.h b/src/SketchAPI/SketchAPI_Ellipse.h index 598d41356..3b726ddb8 100644 --- a/src/SketchAPI/SketchAPI_Ellipse.h +++ b/src/SketchAPI/SketchAPI_Ellipse.h @@ -61,7 +61,7 @@ public: /// Constructor with external. SKETCHAPI_EXPORT SketchAPI_Ellipse(const std::shared_ptr& theFeature, - const std::string& theExternalName); + const std::wstring& theExternalName); /// Destructor. SKETCHAPI_EXPORT @@ -107,7 +107,7 @@ public: /// Set by external name. SKETCHAPI_EXPORT - void setByExternalName(const std::string& theExternalName); + void setByExternalName(const std::wstring& theExternalName); /// Set center. SKETCHAPI_EXPORT @@ -135,15 +135,15 @@ public: /// And the name of the feature shows that it is a regular feature. SKETCHAPI_EXPORT std::list > construction( - const std::string& center = std::string(), - const std::string& firstFocus = std::string(), - const std::string& secondFocus = std::string(), - const std::string& majorAxisStart = std::string(), - const std::string& majorAxisEnd = std::string(), - const std::string& minorAxisStart = std::string(), - const std::string& minorAxisEnd = std::string(), - const std::string& majorAxis = std::string(), - const std::string& minorAxis = std::string()) const; + const std::wstring& center = std::wstring(), + const std::wstring& firstFocus = std::wstring(), + const std::wstring& secondFocus = std::wstring(), + const std::wstring& majorAxisStart = std::wstring(), + const std::wstring& majorAxisEnd = std::wstring(), + const std::wstring& minorAxisStart = std::wstring(), + const std::wstring& minorAxisEnd = std::wstring(), + const std::wstring& majorAxis = std::wstring(), + const std::wstring& minorAxis = std::wstring()) const; /// Dump wrapped feature SKETCHAPI_EXPORT @@ -175,15 +175,15 @@ private: static std::list > buildConstructionEntities( const FeaturePtr& theEllipse, const std::list& theAttributes, - const std::string& theCenter, - const std::string& theFirstFocus, - const std::string& theSecondFocus, - const std::string& theMajorAxisStart, - const std::string& theMajorAxisEnd, - const std::string& theMinorAxisStart, - const std::string& theMinorAxisEnd, - const std::string& theMajorAxis, - const std::string& theMinorAxis); + const std::wstring& theCenter, + const std::wstring& theFirstFocus, + const std::wstring& theSecondFocus, + const std::wstring& theMajorAxisStart, + const std::wstring& theMajorAxisEnd, + const std::wstring& theMinorAxisStart, + const std::wstring& theMinorAxisEnd, + const std::wstring& theMajorAxis, + const std::wstring& theMinorAxis); friend class SketchAPI_EllipticArc; }; diff --git a/src/SketchAPI/SketchAPI_EllipticArc.cpp b/src/SketchAPI/SketchAPI_EllipticArc.cpp index a3e39a2b6..ad85ec056 100644 --- a/src/SketchAPI/SketchAPI_EllipticArc.cpp +++ b/src/SketchAPI/SketchAPI_EllipticArc.cpp @@ -74,7 +74,7 @@ SketchAPI_EllipticArc::SketchAPI_EllipticArc(const std::shared_ptr& theFeature, - const std::string& theExternalName) + const std::wstring& theExternalName) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { @@ -125,7 +125,7 @@ void SketchAPI_EllipticArc::setByExternal(const ModelHighAPI_Selection & theExte execute(); } -void SketchAPI_EllipticArc::setByExternalName(const std::string & theExternalName) +void SketchAPI_EllipticArc::setByExternalName(const std::wstring & theExternalName) { fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external()); execute(); @@ -178,15 +178,15 @@ static const std::list& ellipticArcAttrAndDumpNames() } std::list > SketchAPI_EllipticArc::construction( - const std::string& center, - const std::string& firstFocus, - const std::string& secondFocus, - const std::string& majorAxisStart, - const std::string& majorAxisEnd, - const std::string& minorAxisStart, - const std::string& minorAxisEnd, - const std::string& majorAxis, - const std::string& minorAxis) const + const std::wstring& center, + const std::wstring& firstFocus, + const std::wstring& secondFocus, + const std::wstring& majorAxisStart, + const std::wstring& majorAxisEnd, + const std::wstring& minorAxisStart, + const std::wstring& minorAxisEnd, + const std::wstring& majorAxis, + const std::wstring& minorAxis) const { FeaturePtr anEllipse = feature(); diff --git a/src/SketchAPI/SketchAPI_EllipticArc.h b/src/SketchAPI/SketchAPI_EllipticArc.h index dea054449..3749936b6 100644 --- a/src/SketchAPI/SketchAPI_EllipticArc.h +++ b/src/SketchAPI/SketchAPI_EllipticArc.h @@ -63,7 +63,7 @@ public: /// Constructor with external. SKETCHAPI_EXPORT SketchAPI_EllipticArc(const std::shared_ptr& theFeature, - const std::string& theExternalName); + const std::wstring& theExternalName); /// Destructor. SKETCHAPI_EXPORT @@ -119,7 +119,7 @@ public: /// Set by external name. SKETCHAPI_EXPORT - void setByExternalName(const std::string& theExternalName); + void setByExternalName(const std::wstring& theExternalName); /// Set center. SKETCHAPI_EXPORT @@ -143,15 +143,15 @@ public: /// And the name of the feature shows that it is a regular feature. SKETCHAPI_EXPORT std::list > construction( - const std::string& center = std::string(), - const std::string& firstFocus = std::string(), - const std::string& secondFocus = std::string(), - const std::string& majorAxisStart = std::string(), - const std::string& majorAxisEnd = std::string(), - const std::string& minorAxisStart = std::string(), - const std::string& minorAxisEnd = std::string(), - const std::string& majorAxis = std::string(), - const std::string& minorAxis = std::string()) const; + const std::wstring& center = std::wstring(), + const std::wstring& firstFocus = std::wstring(), + const std::wstring& secondFocus = std::wstring(), + const std::wstring& majorAxisStart = std::wstring(), + const std::wstring& majorAxisEnd = std::wstring(), + const std::wstring& minorAxisStart = std::wstring(), + const std::wstring& minorAxisEnd = std::wstring(), + const std::wstring& majorAxis = std::wstring(), + const std::wstring& minorAxis = std::wstring()) const; /// Dump wrapped feature SKETCHAPI_EXPORT diff --git a/src/SketchAPI/SketchAPI_IntersectionPoint.cpp b/src/SketchAPI/SketchAPI_IntersectionPoint.cpp index e4732fbda..0faeee6ba 100644 --- a/src/SketchAPI/SketchAPI_IntersectionPoint.cpp +++ b/src/SketchAPI/SketchAPI_IntersectionPoint.cpp @@ -47,7 +47,7 @@ SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint( SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint( const std::shared_ptr & theFeature, - const std::string & theExternalName ) + const std::wstring & theExternalName ) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { @@ -68,7 +68,7 @@ void SketchAPI_IntersectionPoint::setByExternalEdge(const ModelHighAPI_Selection execute(); } -void SketchAPI_IntersectionPoint::setByExternalEdgeName(const std::string & theExternalLineName) +void SketchAPI_IntersectionPoint::setByExternalEdgeName(const std::wstring & theExternalLineName) { fillAttribute(ModelHighAPI_Selection("EDGE", theExternalLineName), externalFeature()); diff --git a/src/SketchAPI/SketchAPI_IntersectionPoint.h b/src/SketchAPI/SketchAPI_IntersectionPoint.h index c85c8a24f..970bd8af4 100644 --- a/src/SketchAPI/SketchAPI_IntersectionPoint.h +++ b/src/SketchAPI/SketchAPI_IntersectionPoint.h @@ -46,7 +46,7 @@ public: /// Constructor with values SKETCHAPI_EXPORT SketchAPI_IntersectionPoint(const std::shared_ptr & theFeature, - const std::string & theExternalName); + const std::wstring & theExternalName); /// Destructor SKETCHAPI_EXPORT virtual ~SketchAPI_IntersectionPoint(); @@ -66,7 +66,7 @@ public: /// Set by external name SKETCHAPI_EXPORT - void setByExternalEdgeName(const std::string & theExternalEdgeName); + void setByExternalEdgeName(const std::wstring & theExternalEdgeName); /// Set flag to include projection to result or not SKETCHAPI_EXPORT diff --git a/src/SketchAPI/SketchAPI_Line.cpp b/src/SketchAPI/SketchAPI_Line.cpp index 9afa4cce3..fbfdece72 100644 --- a/src/SketchAPI/SketchAPI_Line.cpp +++ b/src/SketchAPI/SketchAPI_Line.cpp @@ -65,7 +65,7 @@ SketchAPI_Line::SketchAPI_Line( SketchAPI_Line::SketchAPI_Line( const std::shared_ptr & theFeature, - const std::string & theExternalName ) + const std::wstring & theExternalName ) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { @@ -105,7 +105,7 @@ void SketchAPI_Line::setByExternal(const ModelHighAPI_Selection & theExternal) execute(); } -void SketchAPI_Line::setByExternalName(const std::string & theExternalName) +void SketchAPI_Line::setByExternalName(const std::wstring & theExternalName) { fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external()); diff --git a/src/SketchAPI/SketchAPI_Line.h b/src/SketchAPI/SketchAPI_Line.h index c34db1b74..0d0afda1e 100644 --- a/src/SketchAPI/SketchAPI_Line.h +++ b/src/SketchAPI/SketchAPI_Line.h @@ -57,7 +57,7 @@ public: /// Constructor with values SKETCHAPI_EXPORT SketchAPI_Line(const std::shared_ptr & theFeature, - const std::string & theExternalName); + const std::wstring & theExternalName); /// Destructor SKETCHAPI_EXPORT virtual ~SketchAPI_Line(); @@ -86,7 +86,7 @@ public: /// Set by external name SKETCHAPI_EXPORT - void setByExternalName(const std::string & theExternalName); + void setByExternalName(const std::wstring & theExternalName); /// Set start point SKETCHAPI_EXPORT diff --git a/src/SketchAPI/SketchAPI_Point.cpp b/src/SketchAPI/SketchAPI_Point.cpp index 2a5344db5..ee4e3ec44 100644 --- a/src/SketchAPI/SketchAPI_Point.cpp +++ b/src/SketchAPI/SketchAPI_Point.cpp @@ -64,7 +64,7 @@ SketchAPI_Point::SketchAPI_Point( SketchAPI_Point::SketchAPI_Point( const std::shared_ptr & theFeature, - const std::string & theExternalName ) + const std::wstring & theExternalName ) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { @@ -101,7 +101,7 @@ void SketchAPI_Point::setByExternal(const ModelHighAPI_Selection & theExternal) execute(); } -void SketchAPI_Point::setByExternalName(const std::string & theExternalName) +void SketchAPI_Point::setByExternalName(const std::wstring & theExternalName) { fillAttribute(ModelHighAPI_Selection("VERTEX", theExternalName), external()); diff --git a/src/SketchAPI/SketchAPI_Point.h b/src/SketchAPI/SketchAPI_Point.h index e9940ac74..b1cac1407 100644 --- a/src/SketchAPI/SketchAPI_Point.h +++ b/src/SketchAPI/SketchAPI_Point.h @@ -56,7 +56,7 @@ public: /// Constructor with values SKETCHAPI_EXPORT SketchAPI_Point(const std::shared_ptr & theFeature, - const std::string & theExternalName); + const std::wstring & theExternalName); /// Destructor SKETCHAPI_EXPORT virtual ~SketchAPI_Point(); @@ -82,7 +82,7 @@ public: /// Set by external name SKETCHAPI_EXPORT - void setByExternalName(const std::string & theExternalName); + void setByExternalName(const std::wstring & theExternalName); /// Dump wrapped feature SKETCHAPI_EXPORT diff --git a/src/SketchAPI/SketchAPI_Projection.cpp b/src/SketchAPI/SketchAPI_Projection.cpp index aa94fa895..06c36fa66 100644 --- a/src/SketchAPI/SketchAPI_Projection.cpp +++ b/src/SketchAPI/SketchAPI_Projection.cpp @@ -58,7 +58,7 @@ SketchAPI_Projection::SketchAPI_Projection( SketchAPI_Projection::SketchAPI_Projection( const std::shared_ptr & theFeature, - const std::string & theExternalName) + const std::wstring & theExternalName) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { @@ -79,7 +79,7 @@ void SketchAPI_Projection::setExternalFeature(const ModelHighAPI_Selection & the execute(true); } -void SketchAPI_Projection::setByExternalName(const std::string& theExternalName) +void SketchAPI_Projection::setByExternalName(const std::wstring& theExternalName) { setExternalFeature(ModelHighAPI_Selection("EDGE", theExternalName)); } diff --git a/src/SketchAPI/SketchAPI_Projection.h b/src/SketchAPI/SketchAPI_Projection.h index 02fb43f7e..3a16dbc4a 100644 --- a/src/SketchAPI/SketchAPI_Projection.h +++ b/src/SketchAPI/SketchAPI_Projection.h @@ -46,7 +46,7 @@ public: /// Constructor with values SKETCHAPI_EXPORT SketchAPI_Projection(const std::shared_ptr & theFeature, - const std::string & theExternalName); + const std::wstring & theExternalName); /// Destructor SKETCHAPI_EXPORT virtual ~SketchAPI_Projection(); @@ -68,7 +68,7 @@ public: /// Set by external name SKETCHAPI_EXPORT - void setByExternalName(const std::string & theExternalName); + void setByExternalName(const std::wstring & theExternalName); /// Set flag to include projection to result or not SKETCHAPI_EXPORT diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index a3efd9ef5..69462b8cc 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -223,7 +223,7 @@ SketchPtr addSketch(const std::shared_ptr & thePart, } SketchPtr addSketch(const std::shared_ptr & thePart, - const std::string & theExternalName) + const std::wstring & theExternalName) { std::shared_ptr aFeature = thePart->addFeature(SketchAPI_Sketch::ID()); return SketchPtr( @@ -349,7 +349,7 @@ std::shared_ptr compositeFeature()->addFeature(SketchPlugin_Point::ID()); return PointPtr(new SketchAPI_Point(aFeature, theExternal)); } -std::shared_ptr SketchAPI_Sketch::addPoint(const std::string & theExternalName) +std::shared_ptr SketchAPI_Sketch::addPoint(const std::wstring & theExternalName) { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID()); @@ -368,7 +368,7 @@ std::shared_ptr SketchAPI_Sketch::addIntersectionPo return anIntersection; } std::shared_ptr SketchAPI_Sketch::addIntersectionPoint( - const std::string & theExternalName, + const std::wstring & theExternalName, bool theKeepResult) { std::shared_ptr aFeature = @@ -401,7 +401,7 @@ std::shared_ptr compositeFeature()->addFeature(SketchPlugin_Line::ID()); return LinePtr(new SketchAPI_Line(aFeature, theExternal)); } -std::shared_ptr SketchAPI_Sketch::addLine(const std::string & theExternalName) +std::shared_ptr SketchAPI_Sketch::addLine(const std::wstring & theExternalName) { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID()); @@ -493,7 +493,7 @@ std::shared_ptr return CirclePtr(new SketchAPI_Circle(aFeature, theExternal)); } -std::shared_ptr SketchAPI_Sketch::addCircle(const std::string & theExternalName) +std::shared_ptr SketchAPI_Sketch::addCircle(const std::wstring & theExternalName) { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID()); @@ -587,7 +587,7 @@ std::shared_ptr SketchAPI_Sketch::addArc(const ModelHighAPI_Selec return ArcPtr(new SketchAPI_Arc(aFeature, theExternal)); } -std::shared_ptr SketchAPI_Sketch::addArc(const std::string & theExternalName) +std::shared_ptr SketchAPI_Sketch::addArc(const std::wstring & theExternalName) { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID()); @@ -662,7 +662,7 @@ std::shared_ptr SketchAPI_Sketch::addEllipse( } std::shared_ptr SketchAPI_Sketch::addEllipse( - const std::string & theExternalName) + const std::wstring & theExternalName) { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_Ellipse::ID()); @@ -713,7 +713,7 @@ std::shared_ptr SketchAPI_Sketch::addEllipticArc( } std::shared_ptr SketchAPI_Sketch::addEllipticArc( - const std::string & theExternalName) + const std::wstring & theExternalName) { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_EllipticArc::ID()); @@ -871,7 +871,7 @@ std::shared_ptr SketchAPI_Sketch::addProjection( } std::shared_ptr SketchAPI_Sketch::addProjection( - const std::string & theExternalName, + const std::wstring & theExternalName, bool theKeepResult) { std::shared_ptr aFeature = @@ -1548,7 +1548,7 @@ void SketchAPI_Sketch::dump(ModelHighAPI_Dumper& theDumper) const aBase->attribute(SketchPlugin_Sketch::DIRX_ID()))->dir(); // Check the plane is coordinate plane - std::string aPlaneName = defaultPlane(anOrigin, aNormal, aDirX); + std::wstring aPlaneName = defaultPlane(anOrigin, aNormal, aDirX); if(anExternal->context()) { // checking for selected planes if (!aPlaneName.empty() && anExternal->context()->data() diff --git a/src/SketchAPI/SketchAPI_Sketch.h b/src/SketchAPI/SketchAPI_Sketch.h index 3115cadf5..9e6a2dc20 100644 --- a/src/SketchAPI/SketchAPI_Sketch.h +++ b/src/SketchAPI/SketchAPI_Sketch.h @@ -140,7 +140,7 @@ public: std::shared_ptr addPoint(const ModelHighAPI_Selection & theExternal); /// Add point SKETCHAPI_EXPORT - std::shared_ptr addPoint(const std::string & theExternalName); + std::shared_ptr addPoint(const std::wstring & theExternalName); /// Add intersection point SKETCHAPI_EXPORT @@ -150,7 +150,7 @@ public: /// Add point SKETCHAPI_EXPORT std::shared_ptr - addIntersectionPoint(const std::string & theExternalName, + addIntersectionPoint(const std::wstring & theExternalName, bool theKeepResult = false); /// Add line @@ -167,7 +167,7 @@ public: std::shared_ptr addLine(const ModelHighAPI_Selection & theExternal); /// Add line SKETCHAPI_EXPORT - std::shared_ptr addLine(const std::string & theExternalName); + std::shared_ptr addLine(const std::wstring & theExternalName); /// Add rectangle SKETCHAPI_EXPORT @@ -216,7 +216,7 @@ public: std::shared_ptr addCircle(const ModelHighAPI_Selection & theExternal); /// Add circle SKETCHAPI_EXPORT - std::shared_ptr addCircle(const std::string & theExternalName); + std::shared_ptr addCircle(const std::wstring & theExternalName); /// Add arc SKETCHAPI_EXPORT @@ -270,7 +270,7 @@ public: /// Add arc SKETCHAPI_EXPORT - std::shared_ptr addArc(const std::string & theExternalName); + std::shared_ptr addArc(const std::wstring & theExternalName); /// Add ellipse SKETCHAPI_EXPORT @@ -303,7 +303,7 @@ public: std::shared_ptr addEllipse(const ModelHighAPI_Selection & theExternal); /// Add ellipse SKETCHAPI_EXPORT - std::shared_ptr addEllipse(const std::string & theExternalName); + std::shared_ptr addEllipse(const std::wstring & theExternalName); /// Add elliptic arc SKETCHAPI_EXPORT @@ -326,7 +326,7 @@ public: std::shared_ptr addEllipticArc(const ModelHighAPI_Selection & theExternal); /// Add elliptic arc SKETCHAPI_EXPORT - std::shared_ptr addEllipticArc(const std::string & theExternalName); + std::shared_ptr addEllipticArc(const std::wstring & theExternalName); /// Add B-spline SKETCHAPI_EXPORT @@ -362,7 +362,7 @@ public: /// Add projection SKETCHAPI_EXPORT - std::shared_ptr addProjection(const std::string & theExternalName, + std::shared_ptr addProjection(const std::wstring & theExternalName, bool theKeepResult = false); /// Add mirror @@ -604,7 +604,7 @@ SketchPtr addSketch(const std::shared_ptr & thePart, */ SKETCHAPI_EXPORT SketchPtr addSketch(const std::shared_ptr & thePart, - const std::string & theExternalName); + const std::wstring & theExternalName); /**\ingroup CPPHighAPI * \brief Create Sketch feature diff --git a/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp b/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp index 3d3ab4c53..4aa8f5418 100644 --- a/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -266,10 +267,10 @@ void SketchPlugin_MacroBSpline::assignDefaultNameForAux(FeaturePtr theAuxFeature { FeaturePtr aBSpline = ModelAPI_Feature::feature(theBSplinePoles->owner()); - std::ostringstream aName; + std::wostringstream aName; aName << aBSpline->name(); if (theAuxFeature->getKind() == SketchPlugin_Point::ID()) - aName << "_" << theBSplinePoles->id() << "_" << thePoleIndex1; + aName << "_" << ModelAPI_Tools::toWString(theBSplinePoles->id()) << "_" << thePoleIndex1; else aName << "_segment_" << thePoleIndex1 << "_" << thePoleIndex2; diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 839d3d961..3f313b162 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -413,7 +413,7 @@ FeaturePtr SketchPlugin_Sketch::addUniqueNamedCopiedFeature(FeaturePtr theFeatur { FeaturePtr aNewFeature = theSketch->addFeature(theFeature->getKind()); // addFeature generates a unique name for the feature, it caches the name - std::string aUniqueFeatureName = aNewFeature->data()->name(); + std::wstring aUniqueFeatureName = aNewFeature->data()->name(); // all attribute values are copied\pasted to the new feature, name is not an exception theFeature->data()->copyTo(aNewFeature->data()); // external state should not be copied as a new object is an object of the current sketch @@ -582,9 +582,9 @@ void SketchPlugin_Sketch::updateCoordinateAxis(ObjectPtr theSub, GeomAx3Ptr the return; DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - ObjectPtr anOX = aRootDoc->objectByName(ModelAPI_ResultConstruction::group(), "OX"); - ObjectPtr anOY = aRootDoc->objectByName(ModelAPI_ResultConstruction::group(), "OY"); - ObjectPtr anOZ = aRootDoc->objectByName(ModelAPI_ResultConstruction::group(), "OZ"); + ObjectPtr anOX = aRootDoc->objectByName(ModelAPI_ResultConstruction::group(), L"OX"); + ObjectPtr anOY = aRootDoc->objectByName(ModelAPI_ResultConstruction::group(), L"OY"); + ObjectPtr anOZ = aRootDoc->objectByName(ModelAPI_ResultConstruction::group(), L"OZ"); AttributeSelectionPtr anExtFeature; if (aFeature->getKind() == SketchPlugin_Projection::ID()) diff --git a/src/SketchPlugin/SketchPlugin_SketchCopy.cpp b/src/SketchPlugin/SketchPlugin_SketchCopy.cpp index 24ce8f582..43246f9a6 100644 --- a/src/SketchPlugin/SketchPlugin_SketchCopy.cpp +++ b/src/SketchPlugin/SketchPlugin_SketchCopy.cpp @@ -228,8 +228,8 @@ static void renameByParent(FeaturePtr theOld, FeaturePtr theNew) AttributeReferencePtr aNewParentRef = theNew->reference(SketchPlugin_SketchEntity::PARENT_ID()); - std::string anOldName = anOldParentRef->value()->data()->name(); - std::string aNewName = aNewParentRef->value()->data()->name(); + std::wstring anOldName = anOldParentRef->value()->data()->name(); + std::wstring aNewName = aNewParentRef->value()->data()->name(); // substitute name of old parent by the new one theNew->data()->setName(theOld->name()); @@ -282,14 +282,14 @@ static void copyFeature(const FeaturePtr theFeature, renameByParent(theFeature, aNewFeature); } -static int index(const std::string& theName, const std::string& thePrefix) +static int index(const std::wstring& theName, const std::wstring& thePrefix) { int anIndex = -1; if (theName.find(thePrefix) == 0) { anIndex = 0; if (theName[thePrefix.size()] == '_') { - std::string anIndexStr = theName.substr(thePrefix.size() + 1); - anIndex = std::atoi(anIndexStr.c_str()); + std::wstring anIndexStr = theName.substr(thePrefix.size() + 1); + anIndex = std::stoi(anIndexStr); } } return anIndex; @@ -326,8 +326,8 @@ void SketchPlugin_SketchCopy::execute() aNewSketch->execute(); // check number of copies of the selected sketch before name the new sketch - static const std::string SKETCH_NAME_SUFFIX("_Copy"); - std::string aSketchName = aBaseSketch->name() + SKETCH_NAME_SUFFIX; + static const std::wstring SKETCH_NAME_SUFFIX(L"_Copy"); + std::wstring aSketchName = aBaseSketch->name() + SKETCH_NAME_SUFFIX; int aNewSketchIndex = 0; std::list aFeatures = document()->allFeatures(); for (std::list::iterator aFIt = aFeatures.begin(); aFIt != aFeatures.end(); ++aFIt) { @@ -340,7 +340,7 @@ void SketchPlugin_SketchCopy::execute() if (anIndex >= aNewSketchIndex) aNewSketchIndex = anIndex + 1; } - std::ostringstream aNameStream; + std::wostringstream aNameStream; aNameStream << aSketchName; if (aNewSketchIndex > 0) aNameStream << '_' << aNewSketchIndex; diff --git a/src/SketchPlugin/SketchPlugin_Split.cpp b/src/SketchPlugin/SketchPlugin_Split.cpp index 62dad8c5f..f6b5b88ec 100644 --- a/src/SketchPlugin/SketchPlugin_Split.cpp +++ b/src/SketchPlugin/SketchPlugin_Split.cpp @@ -1389,7 +1389,7 @@ std::string SketchPlugin_Split::getFeatureInfo(const std::shared_ptrdata()->isValid()) - anInfo.append(theFeature->data()->name().c_str()); + anInfo.append(ModelAPI_Tools::toString(theFeature->data()->name())); if (isUseAttributesInfo) { std::string aPointsInfo = ModelGeomAlgo_Point2D::getPontAttributesInfo(theFeature, diff --git a/src/SketchPlugin/SketchPlugin_Tools.cpp b/src/SketchPlugin/SketchPlugin_Tools.cpp index 874d05e8e..fe22b3a8b 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.cpp +++ b/src/SketchPlugin/SketchPlugin_Tools.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -260,7 +261,8 @@ private: std::set aCoincToRes = SketchPlugin_Tools::findCoincidentConstraints(theFeature->lastResult()); aCoincidences.insert(aCoincToRes.begin(), aCoincToRes.end()); - } std::set::const_iterator aCIt = aCoincidences.begin(); + } + std::set::const_iterator aCIt = aCoincidences.begin(); for (; aCIt != aCoincidences.end(); ++aCIt) { if (theCoincidences.find(*aCIt) != theCoincidences.end()) @@ -525,7 +527,8 @@ void createAuxiliaryPointOnEllipse(const FeaturePtr& theEllipseFeature, aCoord->setValue(anElPoint->x(), anElPoint->y()); aPointFeature->execute(); - std::string aName = theEllipseFeature->name() + "_" + theEllipsePoint; + std::wstring aName = theEllipseFeature->name() + L"_" + + ModelAPI_Tools::toWString(theEllipsePoint); aPointFeature->data()->setName(aName); aPointFeature->lastResult()->data()->setName(aName); @@ -558,8 +561,8 @@ void createAuxiliaryAxisOfEllipse(const FeaturePtr& theEllipseFeature, aLineEnd->setValue(aEndPoint->x(), aEndPoint->y()); aLineFeature->execute(); - std::string aName = theEllipseFeature->name() + "_" + - (theStartPoint == SketchPlugin_Ellipse::MAJOR_AXIS_START_ID() ? "major_axis" : "minor_axis"); + std::wstring aName = theEllipseFeature->name() + L"_" + + (theStartPoint == SketchPlugin_Ellipse::MAJOR_AXIS_START_ID() ? L"major_axis" : L"minor_axis"); aLineFeature->data()->setName(aName); aLineFeature->lastResult()->data()->setName(aName); @@ -626,13 +629,13 @@ void setDimensionColor(const AISObjectPtr& theDimPrs) theDimPrs->setColor(aColor[0], aColor[1], aColor[2]); } -void replaceInName(ObjectPtr theObject, const std::string& theSource, const std::string& theDest) +void replaceInName(ObjectPtr theObject, const std::wstring& theSource, const std::wstring& theDest) { - std::string aName = theObject->data()->name(); + std::wstring aName = theObject->data()->name(); size_t aPos = aName.find(theSource); if (aPos != std::string::npos) { - std::string aNewName = aName.substr(0, aPos) + theDest - + aName.substr(aPos + theSource.size()); + std::wstring aNewName = aName.substr(0, aPos) + theDest + + aName.substr(aPos + theSource.size()); theObject->data()->setName(aNewName); } } diff --git a/src/SketchPlugin/SketchPlugin_Tools.h b/src/SketchPlugin/SketchPlugin_Tools.h index 11aa5a1ac..d7550bd0b 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.h +++ b/src/SketchPlugin/SketchPlugin_Tools.h @@ -155,7 +155,7 @@ void customizeFeaturePrs(const AISObjectPtr& thePrs, bool isAxiliary); void setDimensionColor(const AISObjectPtr& theDimPrs); /// Replace string in the name of object -void replaceInName(ObjectPtr theObject, const std::string& theSource, const std::string& theDest); +void replaceInName(ObjectPtr theObject, const std::wstring& theSource, const std::wstring& theDest); }; // namespace SketchPlugin_Tools diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 320315bd2..50d14b6a4 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -320,7 +320,7 @@ bool SketchPlugin_NotFixedValidator::isValid(const AttributePtr& theAttribute, if (aRefAttr->isObject()) { if (aRefAttr->object() == aRAttr->object()) { ObjectPtr anObject = aRefAttr->object(); - std::string aName = anObject.get() ? anObject->data()->name() : ""; + std::wstring aName = anObject.get() ? anObject->data()->name() : L""; theError = "The object %1 has been already fixed."; theError.arg(aName); return false; @@ -328,7 +328,7 @@ bool SketchPlugin_NotFixedValidator::isValid(const AttributePtr& theAttribute, } else if (aRefAttr->attr() == aRAttr->attr()) { AttributePtr anAttribute = aRefAttr->attr(); - std::string aName = anAttribute.get() ? anAttribute->id() : ""; + std::wstring aName = anAttribute.get() ? ModelAPI_Tools::toWString(anAttribute->id()) : L""; theError = "The attribute %1 has been already fixed."; theError.arg(aName); return false; @@ -425,7 +425,7 @@ bool SketchPlugin_MirrorAttrValidator::isValid(const AttributePtr& theAttribute, return false; } - std::string aName = aSelObject.get() ? aSelObject->data()->name() : ""; + std::wstring aName = aSelObject.get() ? aSelObject->data()->name() : L""; std::list::iterator aMirIter = aMirroredObjects.begin(); for (; aMirIter != aMirroredObjects.end(); aMirIter++) if (aSelObject == *aMirIter) { @@ -544,7 +544,7 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, anObjIter = aCopiedObjects.begin(); for (; anObjIter != aCopiedObjects.end(); anObjIter++) if (aSelObject == *anObjIter) { - std::string aName = aSelObject.get() ? aSelObject->data()->name() : ""; + std::wstring aName = aSelObject.get() ? aSelObject->data()->name() : L""; theError = "The object %1 is a result of copy"; theError.arg(aName); return false; diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 7e690a0f1..6629f95c1 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -206,7 +206,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, int aDispMode = isShading? Shading : Wireframe; anAISIO->SetDisplayMode(aDispMode); - aContext->Display(anAISIO, aDispMode, 0, false, true, AIS_DS_Displayed); + aContext->Display(anAISIO, aDispMode, 0, false, AIS_DS_Displayed); #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(anAISIO); #endif @@ -703,7 +703,7 @@ bool XGUI_Displayer::displayAIS(AISObjectPtr theAIS, const bool toActivateInSele Handle(AIS_InteractiveContext) aContext = AISContext(); Handle(AIS_InteractiveObject) anAISIO = theAIS->impl(); if (!aContext.IsNull() && !anAISIO.IsNull()) { - aContext->Display(anAISIO, theDisplayMode, 0, false/*update viewer*/, true, AIS_DS_Displayed); + aContext->Display(anAISIO, theDisplayMode, 0, false/*update viewer*/, AIS_DS_Displayed); #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(anAISIO); #endif @@ -1058,7 +1058,6 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const 0 /*wireframe*/, -1 /* selection mode */, Standard_True /* update viewer*/, - Standard_False /* allow decomposition */, AIS_DS_Displayed /* xdisplay status */); #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(aTrihedron); @@ -1098,7 +1097,7 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th /// OCCT: to write about the problem that active owners method returns one owner several times QList aSelectedIds; // Remember of selected address in order to avoid duplicates for (; anOwnersIt.More(); anOwnersIt.Next()) { - anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value()); + anOwner = anOwnersIt.Value(); if (aSelectedIds.contains((size_t)anOwner.get())) continue; aSelectedIds.append((size_t)anOwner.get()); diff --git a/src/XGUI/XGUI_FacesPanel.cpp b/src/XGUI/XGUI_FacesPanel.cpp index e623a7e90..891ed7e4f 100644 --- a/src/XGUI/XGUI_FacesPanel.cpp +++ b/src/XGUI/XGUI_FacesPanel.cpp @@ -379,7 +379,7 @@ void XGUI_FacesPanel::processSelection() } QString aItemName = aResGroup.get()? - aResGroup->data()->name().c_str() : XGUI_Tools::generateName(aPrs); + QString::fromStdWString(aResGroup->data()->name()) : XGUI_Tools::generateName(aPrs); if (myListView->hasItem(aItemName)) continue; diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 754034d3a..738b11aee 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -73,7 +73,7 @@ public: XGUI_DataModel* aModel = myTreedView->dataModel(); ObjectPtr aObj = aModel->object(index); if (aObj.get() != NULL) { - aEditor->setText(aObj->data()->name().c_str()); + aEditor->setText(QString::fromStdWString(aObj->data()->name())); return; } } @@ -131,7 +131,8 @@ void XGUI_DataTree::commitData(QWidget* theEditor) if (XGUI_Tools::canRename(aObj, aName)) { SessionPtr aMgr = ModelAPI_Session::get(); aMgr->startOperation("Rename"); - aObj->data()->setName(aName.toStdString()); + std::wstring aaa = aName.toStdWString(); + aObj->data()->setName(aName.toStdWString()); aMgr->finishOperation(); } } diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index b74c923ed..acfa828b2 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -297,12 +297,12 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrsPtr& thePrs, Handle(AIS_TrihedronOwner) aTrihedronOwner = Handle(AIS_TrihedronOwner)::DownCast(theOwner); if (!aTrihedronOwner.IsNull()) { const Prs3d_DatumParts& aPart = aTrihedronOwner->DatumPart(); - std::string aName; + std::wstring aName; switch (aPart) { - case Prs3d_DP_Origin: aName = "Origin"; break; - case Prs3d_DP_XAxis: aName = "OX"; break; - case Prs3d_DP_YAxis: aName = "OY"; break; - case Prs3d_DP_ZAxis: aName = "OZ"; break; + case Prs3d_DP_Origin: aName = L"Origin"; break; + case Prs3d_DP_XAxis: aName = L"OX"; break; + case Prs3d_DP_YAxis: aName = L"OY"; break; + case Prs3d_DP_ZAxis: aName = L"OZ"; break; default: break; } if (aName.length() > 0) { @@ -453,8 +453,7 @@ void XGUI_Selection::entityOwners(const Handle(AIS_InteractiveObject)& theObject Handle(SelectMgr_SensitiveEntity) anEntity = anIt.Value(); if (anEntity.IsNull()) continue; - Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast(anEntity->BaseSensitive()->OwnerId()); + Handle(SelectMgr_EntityOwner) anOwner = anEntity->BaseSensitive()->OwnerId(); if (!anOwner.IsNull()) theOwners.Add(anOwner); } diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index 49bcdcbd3..104b0c1b7 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -173,7 +173,7 @@ void XGUI_SelectionMgr::deselectPresentation(const Handle(AIS_InteractiveObject) NCollection_List::Iterator anOwnersIt (aResultOwners); Handle(SelectMgr_EntityOwner) anOwner; for (; anOwnersIt.More(); anOwnersIt.Next()) { - anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value()); + anOwner = anOwnersIt.Value(); if (!anOwner.IsNull()) aContext->AddOrRemoveSelected(anOwner, false); } diff --git a/src/XGUI/XGUI_Tools.cpp b/src/XGUI/XGUI_Tools.cpp index ae2bb8984..898d7b739 100644 --- a/src/XGUI/XGUI_Tools.cpp +++ b/src/XGUI/XGUI_Tools.cpp @@ -105,7 +105,7 @@ QString unionOfObjectNames(const QObjectPtrList& theObjects, const QString& theS QStringList aObjectNames; foreach (ObjectPtr aObj, theObjects) { if (aObj->data()->isValid()) - aObjectNames << QString::fromStdString(aObj->data()->name()); + aObjectNames << QString::fromStdWString(aObj->data()->name()); } if (aObjectNames.count() == 0) return QString(); @@ -145,14 +145,14 @@ std::string featureInfo(FeaturePtr theFeature) bool canRemoveOrRename(QWidget* theParent, const std::set& theFeatures) { bool aResult = true; - std::string aNotActivatedNames; + std::wstring aNotActivatedNames; if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) { bool aFoundPartSetObject = ModuleBase_Tools::hasModuleDocumentFeature(theFeatures); if (aFoundPartSetObject) { const char* aKeyStr = "Selected objects can be used in Part documents which are not loaded: " "%1. Whould you like to continue?"; QMessageBox::StandardButton aRes = QMessageBox::warning(theParent, QObject::tr("Warning"), - QObject::tr(aKeyStr).arg(aNotActivatedNames.c_str()), + QObject::tr(aKeyStr).arg(QString::fromStdWString(aNotActivatedNames)), QMessageBox::No | QMessageBox::Yes, QMessageBox::No); aResult = aRes == QMessageBox::Yes; } @@ -207,7 +207,7 @@ bool canRename(const ObjectPtr& theObject, const QString& theName) else { DocumentPtr aDoc = theObject->document(); ObjectPtr aObj = - aDoc->objectByName(aType, theName.toStdString()); + aDoc->objectByName(aType, theName.toStdWString()); if (aObj.get() && theObject != aObj) { QString aErrMsg(QObject::tr("Name %2 already exists in %1."). @@ -246,7 +246,7 @@ QString generateName(const ModuleBase_ViewerPrsPtr& thePrs) // TODO if there is this case } - QString aName = anObject->data()->name().c_str(); + QString aName = QString::fromStdWString(anObject->data()->name()); if (aContext.get()) { GeomShapePtr aSubShape(new GeomAPI_Shape()); TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(thePrs); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index f5aba9c79..5353baea5 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1897,7 +1897,7 @@ bool XGUI_Workshop::prepareForDisplay(const std::set& theObjects) con if (!facesPanel()->isObjectHiddenByPanel(*anObjectsIt)) continue; aHiddenObjects.insert(*anObjectsIt); - aHiddenObjectNames.append((*anObjectsIt)->data()->name().c_str()); + aHiddenObjectNames.append(QString::fromStdWString((*anObjectsIt)->data()->name())); } if (aHiddenObjects.empty()) // in parameter objects there are no hidden objects in hide face return true; @@ -2103,7 +2103,7 @@ void XGUI_Workshop::cleanHistory() if (!anUnusedObjects.empty()) { QStringList aNames; foreach (const FeaturePtr& aFeature, anUnusedObjects) { - aNames.append(aFeature->name().c_str()); + aNames.append(QString::fromStdWString(aFeature->name())); } aNames.sort(); QString anUnusedNames = aNames.join(", "); @@ -2766,7 +2766,7 @@ void XGUI_Workshop::updateColorScaleVisibility() aPrs->dataRange(aMin, aMax); myViewerProxy->setColorScaleRange(aMin, aMax); } - myViewerProxy->setColorScaleTitle(aStep->name().c_str()); + myViewerProxy->setColorScaleTitle(QString::fromStdWString(aStep->name())); myViewerProxy->setColorScaleShown(true); } }