}
// returns name with suffix, not existing in the existing set
-static std::string findName(
- const std::string theOrigin, int& theSuffix, std::set<std::string>& theExisting)
+static std::wstring findName(
+ const std::wstring theOrigin, int& theSuffix, std::set<std::wstring>& theExisting)
{
- std::string aRes;
+ std::wstring aRes;
do {
- std::ostringstream aName;
+ std::wostringstream aName;
aName<<theOrigin<<"_"<<theSuffix;
aRes = aName.str();
theSuffix++;
if (theActionId == "split") {
DocumentPtr aDoc = document();
// collect all existing names of features to give unique names
- std::set<std::string> aFeatNames, aResNames;
+ std::set<std::wstring> aFeatNames, aResNames;
std::list<FeaturePtr> allFeat = aDoc->allFeatures();
std::list<FeaturePtr>::iterator allFeatIter = allFeat.begin();
for(; allFeatIter != allFeat.end(); allFeatIter++) {
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());
}
// 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) {
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();
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();
// 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()));
}
}
}
// standard definitions
%include "typemaps.i"
%include "std_string.i"
+%include "std_wstring.i"
// directors
%feature("director") Events_Listener;
//
#include "Events_InfoMessage.h"
-
-#ifdef WIN32
-#pragma warning(disable : 4996) // for sprintf
-#endif
+#include <sstream>
+#include <codecvt>
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()
std::shared_ptr<Events_Message> aMsg(new Events_InfoMessage(*this));
Events_Loop::loop()->send(aMsg);
}
+
+Events_InfoMessage& Events_InfoMessage::arg(const std::wstring& theParam)
+{
+ static std::wstring_convert<std::codecvt_utf8<wchar_t> > aConvertor;
+ addParameter(aConvertor.to_bytes(theParam));
+ return *this;
+}
/// Returns list of parameters
std::list<std::string> 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; }
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);
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);
} 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";
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 {
} 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";
std::list<FeaturePtr>& theExportedParts,
std::list<FeaturePtr>& theReferredParts);
// Collect names of features as a single string
-static std::string namesOfFeatures(const std::list<FeaturePtr>& theFeatures);
+static std::wstring namesOfFeatures(const std::list<FeaturePtr>& theFeatures);
ExchangePlugin_ExportPart::ExchangePlugin_ExportPart()
std::list<FeaturePtr> 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. "
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 "
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();
return theExternalReferences.empty() && theExportedParts.empty() && theReferredParts.empty();
}
-std::string namesOfFeatures(const std::list<FeaturePtr>& theFeatures)
+std::wstring namesOfFeatures(const std::list<FeaturePtr>& theFeatures)
{
- std::ostringstream aListOfFeatures;
+ std::wostringstream aListOfFeatures;
for (std::list<FeaturePtr>::const_iterator anIt = theFeatures.begin();
anIt != theFeatures.end(); ++anIt) {
if (anIt != theFeatures.begin())
#include <ModelAPI_Tools.h>
-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;
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());
DocumentPtr aDoc = document();
bool isPartSet = aDoc == aSession->moduleDocument();
if (isPartSet) {
- std::list<std::string> anAcceptedValues;
+ std::list<std::wstring> anAcceptedValues;
anAcceptedValues.push_back(THE_NEW_PART_STR);
// append names of all parts
aTargetAttr->setValue(0);
aPartsAttr->setSize((int)anAcceptedValues.size());
- std::list<std::string>::iterator anIt = anAcceptedValues.begin();
+ std::list<std::wstring>::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
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);
}
}
#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
#include <XAO_Xao.hxx>
#include <XAO_Group.hxx>
// 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));
}
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);
// 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");
// 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");
#include <map>
#include <sstream>
+#include <string>
static const std::string THE_NEW_PART_STR("New Part");
static const std::string THE_PART_SET_STR("PartSet");
for (std::list<FeaturePtr>::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())
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);
}
}
std::list<FeaturePtr> aSubFeatures = thePartSetDoc->allFeatures();
for (std::list<FeaturePtr>::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;
}
return aDoc;
}
-typedef std::map<std::string, std::map<std::string, std::set<int> > > ObjectNameMap;
+typedef std::map<std::string, std::map<std::wstring, std::set<int> > > 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);
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);
}
}
-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);
ObjectNameMap::iterator aFoundGroup = theExistingNames.find(aGroup);
bool isUnique = aFoundGroup == theExistingNames.end();
- std::map<std::string, std::set<int> >::iterator aFound;
+ std::map<std::wstring, std::set<int> >::iterator aFound;
if (!isUnique) {
aFound = aFoundGroup->second.find(aName);
isUnique = aFound == aFoundGroup->second.end();
if (anIndex != *aFoundIndex)
break;
// compose the new name
- std::ostringstream aNewName;
+ std::wostringstream aNewName;
aNewName << aName << "_" << anIndex;
aName = aNewName.str();
// add new index
for (std::list<FeaturePtr>::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<ResultPtr>& aResults = (*anIt)->results();
int aCopiesNum = integer(NUMBER())->value();
AttributeSelectionListPtr aList = selectionList(OBJECTS());
int aResultIndex = 0;
- std::set<std::string> anExistingNames; // to avoid names duplication
+ std::set<std::wstring> 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);
}
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));
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);
new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)));
Events_Loop::loop()->send(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.));
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);
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<ModelAPI_Feature> aPoint = theDoc->addFeature("Point");
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);
/// \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
#include <Model_Document.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_Tools.h>
#include <BinDrivers_DocumentRetrievalDriver.hxx>
#include <BinDrivers_DocumentStorageDriver.hxx>
}
//=======================================================================
-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<Model_Document> aNew(new Model_Document(theDocID, thePartKind));
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;
}
//=======================================================================
-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;
for(aResult = int(myDocs.size()); true; aResult++) {
if (myDocs.find(aResult) == myDocs.end()) {
bool aFound = false;
- std::map<std::string, int>::iterator aLBDIter = myLoadedByDemand.begin();
+ std::map<std::wstring, int>::iterator aLBDIter = myLoadedByDemand.begin();
for(; aLBDIter != myLoadedByDemand.end(); aLBDIter++) {
if (aLBDIter->second == aResult) {
aFound = true;
//! \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();
/// 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<std::string, int> myLoadedByDemand;
+ std::map<std::wstring, int> myLoadedByDemand;
};
#endif
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
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);
}
}
}
}
// 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<TopoDS_Shape>();
} else {
aShape = theSubShape->impl<TopoDS_Shape>();
int anIndex;
- aName += "/" + aPart->nameInPart(theSubShape, anIndex);
+ aName += L"/" + aPart->nameInPart(theSubShape, anIndex);
TDataStd_Integer::Set(selectionLabel(), anIndex);
}
TNaming_Builder aBuilder(selectionLabel());
}
/// prefixes of the shape names with centers defined
-static std::map<ModelAPI_AttributeSelection::CenterType, std::string> kCENTERS_PREFIX;
+static std::map<ModelAPI_AttributeSelection::CenterType, std::wstring> kCENTERS_PREFIX;
/// returns the map that contains all possible prefixes of the center-names
-static std::map<ModelAPI_AttributeSelection::CenterType, std::string>& centersMap()
+static std::map<ModelAPI_AttributeSelection::CenterType, std::wstring>& 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;
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;
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
if (aCont->groupName() == ModelAPI_ResultPart::group()) {
ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(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;
}
Selector_Selector aSelector(aSelLab, baseDocumentLab());
- std::string aResult;
+ std::wstring aResult;
if (aCont->shape().get() && aSelector.restore(aCont->shape()->impl<TopoDS_Shape>()))
aResult = aSelector.name(this);
if (aCenterType != NOT_CENTER) {
}
// 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<ModelAPI_AttributeSelection::CenterType, std::string>::iterator aPrefixIter =
+ std::map<ModelAPI_AttributeSelection::CenterType, std::wstring>::iterator aPrefixIter =
centersMap().begin();
for(; aPrefixIter != centersMap().end(); aPrefixIter++) {
std::size_t aFound = theShapeName.find(aPrefixIter->second);
// 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
// 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<Model_Document>(aRootDoc);
aSubShapeName = aSubShapeName.substr(aPartEnd + 1);
}
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<ModelAPI_ResultPart>(aFound);
- std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1);
+ std::wstring aNameInPart = aSubShapeName.substr(aPartEnd + 1);
if (aNameInPart.empty()) { // whole part
setValue(aPart, anEmptyShape);
return;
// 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);
}
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);
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"/";
}
}
}
myParent = theParent;
}
-std::string Model_AttributeSelection::contextName(const TDF_Label theSelectionLab)
+std::wstring Model_AttributeSelection::contextName(const TDF_Label theSelectionLab)
{
std::shared_ptr<Model_Document> aDoc = myRestoreDocument.get() ? myRestoreDocument :
std::dynamic_pointer_cast<Model_Document>(owner()->document());
}
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)
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<Model_Document> aDoc = myRestoreDocument.get() ? myRestoreDocument :
std::dynamic_pointer_cast<Model_Document>(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);
// name in PartSet?
aDoc = std::dynamic_pointer_cast<Model_Document>(
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('/');
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<ModelAPI_CompositeFeature>(aDoc->feature(aCont));
if (aComposite.get() && aComposite->numberOfSubs()) {
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());
}
/// 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<GeomAPI_Pnt>& 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();
// 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
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();
}
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);
}
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);
/// 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<GeomAPI_Pnt>& 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
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<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
if(!aBuilder->NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
- std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
+ std::wstring aName((wchar_t*)anAttr->Get().ToExtString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
if(!aBuilder->NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
- std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
+ std::wstring aName ((wchar_t*)anAttr->Get().ToExtString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
}
}
-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());
bool isUserDefined = true;
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(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) {
/// 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)
ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aPartRes);
if (!aPart->isActivated()) {
// copy not-activated document that is not in the memory
- std::string aDocName = 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));
}
}
} else { // simply save opened document
+ std::string aDocName = ModelAPI_Tools::toString(aPart->data()->name());
isDone = std::dynamic_pointer_cast<Model_Document>(aPart->partDoc())->
- save(theDirName, aPart->data()->name().c_str(), theResults);
+ save(theDirName, aDocName.c_str(), theResults);
}
}
}
}
std::shared_ptr<ModelAPI_Object> Model_Document::objectByName(
- const std::string& theGroupID, const std::string& theName)
+ const std::string& theGroupID, const std::wstring& theName)
{
return myObjs->objectByName(theGroupID, theName);
}
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<std::string, std::list<TDF_Label> >::iterator aFind = myNamingNames.find(theName);
+ std::map<std::wstring, std::list<TDF_Label> >::iterator aFind = myNamingNames.find(theName);
if (aFind != myNamingNames.end()) { // to avoid duplicate-labels
// to keep correct order in spite of history line management
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<std::string, std::list<TDF_Label> >::iterator aFind = myNamingNames.find(theOldName);
+ std::map<std::wstring, std::list<TDF_Label> >::iterator aFind = myNamingNames.find(theOldName);
if (aFind != myNamingNames.end()) {
std::list<TDF_Label>::iterator aLabIter = aFind->second.begin();
for(; aLabIter != aFind->second.end(); aLabIter++) {
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());
}
return true;
}
-TDF_Label Model_Document::findNamingName(std::string theName, ResultPtr theContext)
+TDF_Label Model_Document::findNamingName(std::wstring theName, ResultPtr theContext)
{
- std::map<std::string, std::list<TDF_Label> >::iterator aFind = myNamingNames.find(theName);
+ std::map<std::wstring, std::list<TDF_Label> >::iterator aFind = myNamingNames.find(theName);
if (aFind != myNamingNames.end()) {
std::list<TDF_Label>::reverse_iterator aLabIter = aFind->second.rbegin();
for(; aLabIter != aFind->second.rend(); aLabIter++) {
// 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());
int Model_Document::numberOfNameInHistory(
const ObjectPtr& theNameObject, const TDF_Label& theStartFrom)
{
- std::map<std::string, std::list<TDF_Label> >::iterator aFind =
+ std::map<std::wstring, std::list<TDF_Label> >::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
}
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
aRes = myObjs->findByName(aName);
}
if (aNumInHistory) {
- std::map<std::string, std::list<TDF_Label> >::iterator aFind = myNamingNames.find(aName);
+ std::map<std::wstring, std::list<TDF_Label> >::iterator aFind = myNamingNames.find(aName);
if (aFind != myNamingNames.end() && aFind->second.size() > aNumInHistory) {
std::list<TDF_Label>::reverse_iterator aLibIt = aFind->second.rbegin();
for(; aNumInHistory != 0; aNumInHistory--)
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();
//! \param theName name of the object to search
//! \returns null if such object is not found
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Object> 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
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.
//! 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<std::string, std::list<TDF_Label> > myNamingNames;
+ std::map<std::wstring, std::list<TDF_Label> > myNamingNames;
//! If it is true, features are not executed on update (on abort, undo, redo)
bool myExecuteFeatures;
}
std::shared_ptr<ModelAPI_Object> 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)
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<TDF_Label, FeaturePtr>::Iterator aFIter(myFeatures);
- std::set<std::string> allNames;
+ std::set<std::wstring> allNames;
for (; aFIter.More(); aFIter.Next()) {
if (aFIter.Value()->getKind() == theFeature->getKind())
aNumObjects++;
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<TDF_Label, ObjectPtr>::Iterator anIt(myFolders);
bool Model_Objects::hasCustomName(DataPtr theFeatureData,
ResultPtr theResult,
int theResultIndex,
- std::string& theParentName) const
+ std::wstring& theParentName) const
{
ResultBodyPtr aBodyRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theFeatureData->owner());
if (aBodyRes) {
// 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<Model_Data>(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<ResultPtr>& aResults = anOwner->results();
return false;
}
- std::pair<std::string, bool> aName = ModelAPI_Tools::getDefaultName(theResult);
+ std::pair<std::wstring, bool> aName = ModelAPI_Tools::getDefaultName(theResult);
if (aName.second)
theParentName = aName.first;
return aName.second;
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
}
}
-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
//! \param theName name of the object to search
//! \returns null if such object is not found
std::shared_ptr<ModelAPI_Object> 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.
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;
const CompositeFeaturePtr& theComposite,
NCollection_DataMap<Handle(Geom_Curve), int>& theCurvesIndices,
NCollection_DataMap<int, TopoDS_Edge>& theEdgesIndices,
- std::map<int, std::string>& theEdgesNames);
+ std::map<int, std::wstring>& theEdgesNames);
/// Convert each face to the list of indices of its edges
/// \param[in] theFaces list of faces to proceed
/// \param theEdgesNames named of edges
static void storeFacesOnLabel(std::shared_ptr<Model_Document>& theDocument,
TDF_Label& theShapeLabel,
- const std::string& theName,
+ const std::wstring& theName,
const TopoDS_Shape& theShape,
NCollection_DataMap<int, TopoDS_Face>& theFacesOrder,
NCollection_List<TopoDS_Face>& theUnorderedFaces,
const MapFaceToEdgeIndices& theFaceEdges,
const NCollection_DataMap<int, TopoDS_Edge>& theEdgesIndices,
- const std::map<int, std::string>& theEdgesNames);
+ const std::map<int, std::wstring>& theEdgesNames);
// identifier of the infinite result
return myShape;
}
-static std::string shortName(
+static std::wstring shortName(
std::shared_ptr<ModelAPI_ResultConstruction>& 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;
}
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(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();
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);
}
// collect indices of curves of current composite
NCollection_DataMap<Handle(Geom_Curve), int> aCurvesIndices;
NCollection_DataMap<int, TopoDS_Edge> anEdgeIndices;
- std::map<int, std::string> aComponentsNames; // names of components that lay on index
+ std::map<int, std::wstring> aComponentsNames; // names of components that lay on index
indexingSketchEdges(aComposite, aCurvesIndices, anEdgeIndices, aComponentsNames);
GeomAlgoAPI_SketchBuilder aSketchBuilder(aWirePtr->origin(), aWirePtr->dirX(),
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(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()) {
// collect indices of curves of current composite
NCollection_DataMap<Handle(Geom_Curve), int> aCurvesIndices;
NCollection_DataMap<int, TopoDS_Edge> anEdgeIndices;
- std::map<int, std::string> aComponentsNames; // names of components that lay on index
+ std::map<int, std::wstring> aComponentsNames; // names of components that lay on index
indexingSketchEdges(aComposite, aCurvesIndices, anEdgeIndices, aComponentsNames);
ListOfShape aFaces;
void storeFacesOnLabel(std::shared_ptr<Model_Document>& theDocument,
TDF_Label& theShapeLabel,
- const std::string& theName,
+ const std::wstring& theName,
const TopoDS_Shape& theShape,
NCollection_DataMap<int, TopoDS_Face>& theFacesOrder,
NCollection_List<TopoDS_Face>& theUnorderedFaces,
const MapFaceToEdgeIndices& theFaceEdges,
const NCollection_DataMap<int, TopoDS_Edge>& theEdgesIndices,
- const std::map<int, std::string>& theEdgesNames)
+ const std::map<int, std::wstring>& theEdgesNames)
{
theShapeLabel.ForgetAllAttributes(); // clear all previously stored
TDataStd_Name::Set(theShapeLabel, theName.c_str()); // restore name forgotten
// 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;
TDF_Label aWireLab = aLab.FindChild(aWireTag);
TNaming_Builder aWireBuilder(aWireLab);
aWireBuilder.Generated(aWires.Current());
- std::ostringstream aWireName;
- aWireName<<aName.str()<<"_wire";
+ std::wostringstream aWireName;
+ aWireName<<aName.str()<<L"_wire";
if (aWireTag > 3)
aWireName<<"_"<<aWireTag - 2;
TDataStd_Name::Set(aWireLab, aWireName.str().c_str());
void indexingSketchEdges(const CompositeFeaturePtr& theComposite,
NCollection_DataMap<Handle(Geom_Curve), int>& theCurvesIndices,
NCollection_DataMap<int, TopoDS_Edge>& theEdgesIndices,
- std::map<int, std::string>& theEdgesNames)
+ std::map<int, std::wstring>& theEdgesNames)
{
const int aSubNum = theComposite->numberOfSubs();
for (int a = 0; a < aSubNum; a++) {
#include <ModelAPI_Feature.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
return NULL;
}
-std::string Model_ResultField::Model_FieldStep::name() {
- std::ostringstream aStream;
+std::wstring Model_ResultField::Model_FieldStep::name() {
+ std::wostringstream aStream;
aStream<<myParent->data()->name()<<std::endl;
- aStream<<"Step "<<(myId + 1)<<" "<<myParent->textLine(myId);
+ aStream<<"Step "<<(myId + 1)<<" "<< ModelAPI_Tools::toWString(myParent->textLine(myId));
return aStream.str();
}
// LCOV_EXCL_STOP
virtual std::shared_ptr<ModelAPI_Document> document() const { return myParent->document(); }
/// Returns a GUI name of this step
- virtual std::string name();
+ virtual std::wstring name();
private:
ModelAPI_ResultField* myParent;
#include <Model_Application.h>
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_Tools.h>
#include <GeomAPI_Trsf.h>
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;
}
return true;
}
-std::string Model_ResultPart::nameInPart(const std::shared_ptr<GeomAPI_Shape>& theShape,
+std::wstring Model_ResultPart::nameInPart(const std::shared_ptr<GeomAPI_Shape>& theShape,
int& theIndex)
{
theIndex = 0; // not initialized
}
}
// something is not right
- return "";
+ return L"";
}
TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
if (aShape.IsNull())
- return "";
+ return L"";
// getting an access to the document of part
std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(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();
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<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(partDoc());
if (aDoc.get()) {
}
std::shared_ptr<GeomAPI_Shape> 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<GeomAPI_Shape> aResult;
/// \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<GeomAPI_Shape>& theShape,
+ MODEL_EXPORT virtual std::wstring nameInPart(const std::shared_ptr<GeomAPI_Shape>& 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<GeomAPI_Shape> 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
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);
}
MODEL_EXPORT virtual std::list<std::shared_ptr<ModelAPI_Document> > 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
// fix for SWIG v2.0.4
#define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
+
+ #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj))
%}
// import other modules
#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"
/// 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,
/// 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;
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;
/// 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<GeomAPI_Pnt>& 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
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;
//! \param theName name of the object to search
//! \returns null if such object is not found
virtual std::shared_ptr<ModelAPI_Object> 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
{}
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<ModelAPI_ObjectRenamedMessage> aMessage(
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;
}
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.
/// 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
/// 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
// Helper methods, aliases for data()->method()
// -----------------------------------------------------------------------------------------------
/// Returns the name stored in the attribute
- inline std::string name()
+ inline std::wstring name()
{
return data()->name();
}
// Helper methods, aliases for data()->method()
// -----------------------------------------------------------------------------------------------
/// Returns the name stored in the attribute
- inline std::string name()
+ inline std::wstring name()
{
return data()->name();
}
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
virtual bool isActivated() = 0;
/// Returns the name of the shape inside of the part
- virtual std::string nameInPart(const std::shared_ptr<GeomAPI_Shape>& theShape,
+ virtual std::wstring nameInPart(const std::shared_ptr<GeomAPI_Shape>& theShape,
int& theIndex) = 0;
/// Updates the selection inside of the part by the selection index
virtual bool updateInPart(const int theIndex) = 0;
/// Returns the shape by the name in the part
virtual std::shared_ptr<GeomAPI_Shape> 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<GeomAPI_Shape> selectionValue(const int theIndex) = 0;
virtual std::list<std::shared_ptr<ModelAPI_Document> > 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<ModelAPI_Document> copy(
#include <map>
#include <iostream>
#include <sstream>
+#include <codecvt>
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
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
}
//******************************************************************
-bool allDocumentsActivated(std::string& theNotActivatedNames)
+bool allDocumentsActivated(std::wstring& theNotActivatedNames)
{
- theNotActivatedNames = "";
+ theNotActivatedNames = L"";
bool anAllPartActivated = true;
DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
if (!aPart->isActivated()) {
anAllPartActivated = false;
if (!theNotActivatedNames.empty())
- theNotActivatedNames += ", ";
+ theNotActivatedNames += L", ";
theNotActivatedNames += aObject->data()->name().c_str();
}
}
}
}
-std::pair<std::string, bool> getDefaultName(const std::shared_ptr<ModelAPI_Result>& theResult,
+std::pair<std::wstring, bool> getDefaultName(const std::shared_ptr<ModelAPI_Result>& theResult,
const bool theInherited)
{
typedef std::list< std::pair < std::string, std::list<ObjectPtr> > > ListOfReferences;
// names of sub-solids in CompSolid should be default (for example,
// result of boolean operation 'Boolean_1_1' is a CompSolid which is renamed to 'MyBOOL',
// however, sub-elements of 'MyBOOL' should be named 'Boolean_1_1_1', 'Boolean_1_1_2' etc.)
- std::ostringstream aDefaultName;
+ std::wostringstream aDefaultName;
aDefaultName << getDefaultName(anOwnerRes).first;
aDefaultName << "_" << (bodyIndex(theResult) + 1);
- return std::pair<std::string, bool>(aDefaultName.str(), false);
+ return std::pair<std::wstring, bool>(aDefaultName.str(), false);
}
FeaturePtr anOwner = ModelAPI_Feature::feature(theResult->data()->owner());
// return name of reference result only if it has been renamed by the user,
// in other case compose a default name
if (anObjRes->data()->hasUserDefinedName()) {
- std::stringstream aName;
+ std::wstringstream aName;
aName << anObjRes->data()->name();
std::map<ResultPtr, int>::iterator aFound = aNbRefToObject.find(anObjRes);
if (aFound != aNbRefToObject.end()) {
// referring to the same shape
aName << "_" << aFound->second + 1;
}
- return std::pair<std::string, bool>(aName.str(), true);
+ return std::pair<std::wstring, bool>(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<std::string, bool>(aDefaultName.str(), false);
+ return std::pair<std::wstring, bool>(aDefaultName.str(), false);
}
std::set<FeaturePtr> getParents(const FeaturePtr& theFeature)
}
// LCOV_EXCL_STOP
+std::string toString(const std::wstring& theWStr)
+{
+ static std::wstring_convert<std::codecvt_utf8<wchar_t> > 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<std::codecvt_utf8<wchar_t> > aConvertor;
+ return aConvertor.from_bytes(theStr);
+}
+
+
} // namespace ModelAPI_Tools
\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
* 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<std::string, bool> getDefaultName(
+MODELAPI_EXPORT std::pair<std::wstring, bool> getDefaultName(
const std::shared_ptr<ModelAPI_Result>& theResult, const bool theInherited = true);
/*! Collect all parents for the given feature, including the Part
std::shared_ptr<ModelAPI_Result> theTarget, const std::string& theFeatureKind,
const bool theSortResults);
+/*! Converts an extended string to a simple (byte) string
+* \param theWStr an extended string
+*/
+MODELAPI_EXPORT std::string toString(const std::wstring& theWStr);
+
+/*! Converts a byte string to an extended string
+* \param theStr a byte string
+*/
+MODELAPI_EXPORT std::wstring toWString(const std::string& theStr);
+
}
#endif
// fix for SWIG v2.0.4
#define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
+
+ #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj))
%}
%include "doxyhelp.i"
#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;
getShapeAndContext(theAttrSelect, aShape, aContext);
if (aShape.get()) {
- myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \""
- << theAttrSelect->namingName() << "\"";
+ //TODO: vsv myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \""
+ // << theAttrSelect->namingName() << "\"";
}
myDumpBuffer << ")";
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;
}
}
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<ModelAPI_Feature>(theEntity);
if (aFeature) {
- aName = aFeature->name();
+ aName = ModelAPI_Tools::toString(aFeature->name());
aKind = aFeature->getKind();
} else {
FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(theEntity);
if (aFolder) {
- aName = aFolder->data()->name();
+ aName = ModelAPI_Tools::toString(aFolder->data()->name());
aKind = ModelAPI_Folder::ID();
isSaveNotDumped = false;
}
std::list<ResultPtr> allRes;
ModelAPI_Tools::allResults(theFeature, allRes);
for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
- std::pair<std::string, bool> aName = ModelAPI_Tools::getDefaultName(*aRes);
- std::string aDefaultName = aName.first;
- std::string aResName = (*aRes)->data()->name();
+ std::pair<std::wstring, bool> aName = ModelAPI_Tools::getDefaultName(*aRes);
+ std::string aDefaultName = ModelAPI_Tools::toString(aName.first);
+ std::string aResName = ModelAPI_Tools::toString((*aRes)->data()->name());
bool isUserDefined = !(isFeatureDefaultName && aDefaultName == aResName);
myNames[*aRes] =
EntityName(aResName, (isUserDefined ? aResName : std::string()), !isUserDefined);
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<ResultPtr> aResultsWithNameOrColor;
const std::list<ResultPtr>& aResults = theSubFeature->results();
std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
for (; aResIt != aResults.end(); ++aResIt) {
- std::string aResName = (*aResIt)->data()->name();
+ std::string aResName = ModelAPI_Tools::toString((*aResIt)->data()->name());
myNames[*aResIt] = EntityName(aResName, aResName, false);
aResultsWithNameOrColor.push_back(*aResIt);
}
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");
/// 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);
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<ModelAPI_Feature>(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__"] + "'";
std::map<std::string, std::string>& 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<std::shared_ptr<ModelAPI_Attribute> > allAttrs = theData->attributes("");
std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = allAttrs.begin();
for(; anAttr != allAttrs.end(); anAttr++) {
if (anAttr->value() != aDoc) {
ResultPtr aRes = ModelAPI_Tools::findPartResult(aDoc, anAttr->value());
if (aRes.get()) {
- aResult<<aRes->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<<aDoc->kind(); // PartSet
AttributeReferencePtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttr);
if (anAttr->value().get()) {
- aResult<<anAttr->value()->data()->name();
+ aResult<< ModelAPI_Tools::toString(anAttr->value()->data()->name());
} else {
aResult<<"__empty__";
}
AttributeSelectionPtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttr);
if (anAttr->context().get())
- aResult<<anAttr->namingName();
+ aResult<< ModelAPI_Tools::toString(anAttr->namingName());
else
aResult<<"__notinitialized__";
} else if (aType == ModelAPI_AttributeSelectionList::typeId()) {
for(int a = 0; a < anAttr->size(); a++) {
if (a != 0)
aResult<<" ";
- aResult<<anAttr->value(a)->namingName();
+ aResult<< ModelAPI_Tools::toString(anAttr->value(a)->namingName());
}
} else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
AttributeRefAttrPtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttr);
ObjectPtr anObj = anAttr->isObject() ? anAttr->object() : anAttr->attr()->owner();
if (anObj.get()) {
- aResult<<anObj->data()->name();
+ aResult<< ModelAPI_Tools::toString(anObj->data()->name());
if (!anAttr->isObject()) {
aResult<<" "<<anAttr->attr()->id();
}
if (aStr == "SketchConstraint")
continue; // no need to dump and check constraints
}
- aResList.push_back((*aL)->data()->name());
+ aResList.push_back(ModelAPI_Tools::toString((*aL)->data()->name()));
} else if (!isSketchFeatures) {
aResList.push_back("__empty__");
}
aResult<<" ";
ObjectPtr anObj = aL->second.get() ? aL->second->owner() : aL->first;
if (anObj.get()) {
- aResult<<anObj->data()->name();
+ aResult<< ModelAPI_Tools::toString(anObj->data()->name());
if (aL->second.get()) {
aResult<<" "<<aL->second->id();
}
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();
}
/// 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
//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();
}
/// 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
}
ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType,
- const std::string& theSubShapeName)
+ const std::wstring& theSubShapeName)
: myVariantType(VT_TypeSubShapeNamePair)
, myTypeSubShapeNamePair(theType, theSubShapeName)
{
}
ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType,
- const std::string& theContextName, const int theIndex)
- : myVariantType(VT_WeakNamingPair)
- , myWeakNamingPair(theType, std::pair<std::string, int>(theContextName, theIndex))
+ const std::wstring& theContextName, const int theIndex)
+ : myVariantType(VT_WeakNamingPair),
+ myWeakNamingPair(theType, std::pair<std::wstring, int>(theContextName, theIndex))
{
}
}
//==================================================================================================
-void ModelHighAPI_Selection::setName(const std::string& theName)
+void ModelHighAPI_Selection::setName(const std::wstring& theName)
{
if (myVariantType == VT_ResultSubShapePair) {
std::shared_ptr<ModelAPI_Result> aResult = myResultSubShapePair.first;
}
}
-std::string ModelHighAPI_Selection::name() const
+std::wstring ModelHighAPI_Selection::name() const
{
if (myVariantType == VT_ResultSubShapePair) {
std::shared_ptr<ModelAPI_Result> 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)
//--------------------------------------------------------------------------------------
typedef std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >
ResultSubShapePair;
-typedef std::pair<std::string, std::string> TypeSubShapeNamePair;
+typedef std::pair<std::string, std::wstring> TypeSubShapeNamePair;
typedef std::pair<std::string, std::shared_ptr<GeomAPI_Pnt> > TypeInnerPointPair;
-typedef std::pair<std::string, std::pair<std::string, int> > TypeWeakNamingPair;
+typedef std::pair<std::string, std::pair<std::wstring, int> > TypeWeakNamingPair;
//--------------------------------------------------------------------------------------
/**\class ModelHighAPI_Selection
* \ingroup CPPHighAPI
/// 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
/// 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
/// 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
}
//--------------------------------------------------------------------------------------
-std::shared_ptr<GeomAPI_Ax3> defaultPlane( const std::string& theName )
+std::shared_ptr<GeomAPI_Ax3> defaultPlane( const std::wstring& theName )
{
std::shared_ptr<GeomAPI_Pnt> o(new GeomAPI_Pnt(0, 0, 0));
std::shared_ptr<GeomAPI_Dir> 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));
}
return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(o, x, n));
}
-std::string defaultPlane(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
+std::wstring defaultPlane(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
const std::shared_ptr<GeomAPI_Dir>& theNormal,
const std::shared_ptr<GeomAPI_Dir>& 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<ModelAPI_Result> standardPlane(const std::string & theName){
+std::shared_ptr<ModelAPI_Result> standardPlane(const std::wstring & theName){
DocumentPtr aPartSet = ModelAPI_Session::get()->moduleDocument();
// searching for the construction element
return std::dynamic_pointer_cast<ModelAPI_Result>(
* These planes are respectively referred to by name "XOY" (Z=0), "XOZ" (Y=0) or "YOZ" (X=0).
*/
MODELHIGHAPI_EXPORT
-std::shared_ptr<GeomAPI_Ax3> defaultPlane(const std::string & theName);
+std::shared_ptr<GeomAPI_Ax3> 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<GeomAPI_Pnt>& theOrigin,
+std::wstring defaultPlane(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
const std::shared_ptr<GeomAPI_Dir>& theNormal,
const std::shared_ptr<GeomAPI_Dir>& theDirX);
* These planes are respectively referred to by name "XOY" (Z=0), "XOZ" (Y=0) or "YOZ" (X=0).
*/
MODELHIGHAPI_EXPORT
-std::shared_ptr<ModelAPI_Result> standardPlane(const std::string & theName);
+std::shared_ptr<ModelAPI_Result> standardPlane(const std::wstring & theName);
/** Start a data structure transaction.
*
}
/// stores the features information, recursively stores sub-documents features
-std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc,
- std::map<std::string, std::map<std::string, ModelHighAPI_FeatureStore> >& theStore,
+std::string storeFeatures(const std::wstring& theDocName, DocumentPtr theDoc,
+ std::map<std::wstring, std::map<std::wstring, ModelHighAPI_FeatureStore> >& theStore,
const bool theCompare) // if false => store
{
- std::map<std::string, std::map<std::string, ModelHighAPI_FeatureStore> >::iterator aDocFind;
+ std::map<std::wstring, std::map<std::wstring, ModelHighAPI_FeatureStore> >::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<std::string> aProcessed; // processed features names (that are in the current document)
+ std::set<std::wstring> aProcessed; // processed features names (that are in the current document)
// process all objects (features and folders)
std::list<ObjectPtr> allObjects = theDoc->allObjects();
continue; // no need to dump and check constraints
}
if (theCompare) {
- std::map<std::string, ModelHighAPI_FeatureStore>::iterator
+ std::map<std::wstring, ModelHighAPI_FeatureStore>::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++;
if (theCompare) {
if (aDocFind->second.size() != anObjectsCount) {
// search for disappeared feature
- std::string aLostName;
- std::map<std::string, ModelHighAPI_FeatureStore>::iterator aLostIter;
+ std::wstring aLostName;
+ std::map<std::wstring, ModelHighAPI_FeatureStore>::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<std::string, std::map<std::string, ModelHighAPI_FeatureStore> > Storage;
+typedef std::map<std::wstring, std::map<std::wstring, ModelHighAPI_FeatureStore> > Storage;
static bool dumpToPython(SessionPtr theSession,
const std::string& theFilename,
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);
return false;
// map from document name to feature name to feature data
- std::map<std::string, std::map<std::string, ModelHighAPI_FeatureStore> > aStore;
- std::string anError = storeFeatures(
- aSession->moduleDocument()->kind(), aSession->moduleDocument(), aStore, false);
+ std::map<std::wstring, std::map<std::wstring, ModelHighAPI_FeatureStore> > 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();
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);
}
}
}
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;
if (!theObj.get())
return "";
- return theObj->data()->name().c_str();
+ return QString::fromStdWString(theObj->data()->name());
}
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<std::shared_ptr<ModelAPI_Attribute> > anAttributes;
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));
}
}
}
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<FeaturePtr> aFeaturesRefsTo;
continue;
if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group()))
- aPartFeatureNames.append(aFeature->name().c_str());
+ aPartFeatureNames.append(QString::fromStdWString(aFeature->name()));
std::set<FeaturePtr> aRefFeatures;
std::set<FeaturePtr> aRefList = theReferences.at(aFeature);
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();
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();
std::shared_ptr<ModelAPI_Document> 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") {
std::shared_ptr<ModelAPI_Document> 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") {
//********************************************************************
-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();
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();
}
/// \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
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());
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();
}
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()) {
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);
}
}
}
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);
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())
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;
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()));
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<ParametersPlugin_Parameter> aParameter =
std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
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);
}
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 =
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(
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);
}
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);
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<ModelAPI_ResultParameter>(aParamObj);
if (!aParam.get())
} 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()) {
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++;
}
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]";
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
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");
// 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) {
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();
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:
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);
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;
}
}
std::dynamic_pointer_cast<ModelAPI_AttributeReference>(*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;
}
}
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;
}
}
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<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID());
return ConePtr(new PrimitivesAPI_Cone(aFeature, aBasePoint, anAxis, theBaseRadius,
theTopRadius, theHeight));
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<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis,
theRadius, theHeight));
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<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis,
theRadius, theHeight, theAngle));
SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Double& theRadius)
{
- ModelHighAPI_Selection aCenterPoint("VERTEX", "PartSet/Origin");
+ ModelHighAPI_Selection aCenterPoint("VERTEX", L"PartSet/Origin");
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
return SpherePtr(new PrimitivesAPI_Sphere(aFeature, aCenterPoint, theRadius));
}
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<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Torus::ID());
return TorusPtr(new PrimitivesAPI_Torus(aFeature, aBasePoint, anAxis, theRadius, theRingRadius));
}
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<ModelAPI_Result>(aPointObj);
aCenterPoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
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<ModelAPI_Result>(anAxisObj);
anAxis->setValue(anAxisRes, std::shared_ptr<GeomAPI_Shape>());
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<ModelAPI_Result>(aPointObj);
aBasePoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
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<ModelAPI_Result>(anAxisObj);
anAxis->setValue(anAxisRes, std::shared_ptr<GeomAPI_Shape>());
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<ModelAPI_Result>(aPointObj);
aCenterPoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
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<ModelAPI_Result>(aPointObj);
aCenterPoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
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<ModelAPI_Result>(anAxisObj);
anAxis->setValue(anAxisRes, std::shared_ptr<GeomAPI_Shape>());
}
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;
/// 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
/// 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);
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)
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;
}
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;
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<Selector_Algo*>::const_iterator aSubSel = list().cbegin();
for(; aSubSel != list().cend(); aSubSel++) {
/// 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();
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,
// 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++) {
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
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)) {
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<int>::iterator aLevel = myNBLevel.begin();
std::list<Selector_Algo*>::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();
}
aThisContextNameNeeded = false;
}
if (aThisContextNameNeeded) {
- aResult = aResult + "_" + aContextName;
+ aResult = aResult + L"_" + aContextName;
}
return aResult;
}
/// 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();
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;
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;
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<Selector_Algo*>::const_iterator aSubSel = list().cbegin();
for(; aSubSel != list().cend(); aSubSel++) {
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<<"["<<weakNameID()<<myWeakIndex<<"]";
aResult += aWeakStr.str();
}
/// 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_Intersect();
return false;
}
-TDF_Label Selector_Modify::restoreByName(std::string theName,
+TDF_Label Selector_Modify::restoreByName(std::wstring theName,
const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator)
{
TDF_Label aContext;
if (aStart != 0)
aStart++;
anEnd = theName.find('&', aStart);
- std::string aSubStr =
+ std::wstring aSubStr =
theName.substr(aStart, anEnd == std::string::npos ? anEnd : anEnd - aStart);
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 = std::stoi(aWeakIndex.c_str());
continue;
}
TDF_Label aSubContext, aValue;
return false;
}
-std::string Selector_Modify::name(Selector_NameGenerator* theNameGenerator)
+std::wstring Selector_Modify::name(Selector_NameGenerator* theNameGenerator)
{
// final&base1&base2 +optionally: [weak_name_1]
- std::string aResult;
+ std::wstring aResult;
Handle(TDataStd_Name) aName;
if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName))
- return "";
- aResult += theNameGenerator->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<<"&"<<weakNameID()<<myWeakIndex;
aResult += aWeakStr.str();
}
/// 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_NameGenerator() {};
/// This method returns the context name by the label of the sub-selected shape
- virtual std::string contextName(const TDF_Label theSelectionLab) = 0;
+ virtual std::wstring contextName(const TDF_Label theSelectionLab) = 0;
/// 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.
- virtual bool restoreContext(std::string theName,
+ virtual bool restoreContext(std::wstring theName,
TDF_Label& theContext, TDF_Label& theValue) = 0;
/// Returns true if the first result is older than the second one in the tree of features
return restoreBaseArray(anEmptyRefList, myFinal);
}
-TDF_Label Selector_Primitive::restoreByName(std::string theName,
+TDF_Label Selector_Primitive::restoreByName(std::wstring theName,
const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator)
{
TDF_Label aContext;
return false;
}
-std::string Selector_Primitive::name(Selector_NameGenerator* theNameGenerator)
+std::wstring Selector_Primitive::name(Selector_NameGenerator* theNameGenerator)
{
Handle(TDataStd_Name) aName;
if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName))
- return "";
- std::string aResult = theNameGenerator->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;
}
/// 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();
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;
/// 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);
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();
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<<pureWeakNameID()<<myWeakIndex;
- std::string aResult = aWeakStr.str();
+ std::wstring aResult = aWeakStr.str();
if (!myContext.IsNull())
- aResult += "_" + theNameGenerator->contextName(myContext);
+ aResult += L"_" + theNameGenerator->contextName(myContext);
return aResult;
}
/// 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();
// fix for SWIG v2.0.4
#define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
+
+ #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj))
%}
%include "doxyhelp.i"
#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;
//================================================================================================
SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::string& theExternalName)
+ const std::wstring& theExternalName)
: SketchAPI_SketchEntity(theFeature)
{
if (initialize()) {
}
//===============================================================================================
-void SketchAPI_Arc::setByExternalName(const std::string & theExternalName)
+void SketchAPI_Arc::setByExternalName(const std::wstring & theExternalName)
{
fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
/// Constructor with values.
SKETCHAPI_EXPORT
SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::string& theExternalName);
+ const std::wstring& theExternalName);
/// Destructor.
SKETCHAPI_EXPORT
/// Set by external name.
SKETCHAPI_EXPORT
- void setByExternalName(const std::string& theExternalName);
+ void setByExternalName(const std::wstring& theExternalName);
/// Dump wrapped feature
SKETCHAPI_EXPORT
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
+#include <ModelAPI_Tools.h>
+
#include <SketchPlugin_ConstraintCoincidenceInternal.h>
#include <SketchPlugin_Line.h>
#include <SketchPlugin_Point.h>
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());
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());
//==================================================================================================
SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::string& theExternalName)
+ const std::wstring& theExternalName)
: SketchAPI_SketchEntity(theFeature)
{
if (initialize()) {
}
//==================================================================================================
-void SketchAPI_Circle::setByExternalName(const std::string & theExternalName)
+void SketchAPI_Circle::setByExternalName(const std::wstring & theExternalName)
{
fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
/// Constructor with values.
SKETCHAPI_EXPORT
SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::string& theExternalName);
+ const std::wstring& theExternalName);
/// Destructor.
SKETCHAPI_EXPORT
/// Set by external name.
SKETCHAPI_EXPORT
- void setByExternalName(const std::string& theExternalName);
+ void setByExternalName(const std::wstring& theExternalName);
/// Set center.
SKETCHAPI_EXPORT
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
+#include <ModelAPI_Tools.h>
+
#include <SketchPlugin_ConstraintCoincidenceInternal.h>
#include <SketchPlugin_Line.h>
#include <SketchPlugin_Point.h>
-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";
}
SketchAPI_Ellipse::SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::string& theExternalName)
+ const std::wstring& theExternalName)
: SketchAPI_SketchEntity(theFeature)
{
if (initialize()) {
execute();
}
-void SketchAPI_Ellipse::setByExternalName(const std::string & theExternalName)
+void SketchAPI_Ellipse::setByExternalName(const std::wstring & theExternalName)
{
fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
execute();
static void createPoint(const CompositeFeaturePtr& theSketch,
const FeaturePtr& theEllipse,
const std::string& theCoincident,
- const std::string& theAuxOrName,
+ const std::wstring& theAuxOrName,
std::list<FeaturePtr>& theEntities)
{
if (theAuxOrName.empty())
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);
const FeaturePtr& theEllipse,
const std::string& theCoincidentStart,
const std::string& theCoincidentEnd,
- const std::string& theAuxOrName,
+ const std::wstring& theAuxOrName,
std::list<FeaturePtr>& theEntities)
{
if (theAuxOrName.empty())
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);
}
std::list<std::shared_ptr<SketchAPI_SketchEntity> > 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();
std::list<std::shared_ptr<SketchAPI_SketchEntity> > SketchAPI_Ellipse::buildConstructionEntities(
const FeaturePtr& theEllipse,
const std::list<PairOfStrings>& 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);
/// Constructor with external.
SKETCHAPI_EXPORT
SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::string& theExternalName);
+ const std::wstring& theExternalName);
/// Destructor.
SKETCHAPI_EXPORT
/// Set by external name.
SKETCHAPI_EXPORT
- void setByExternalName(const std::string& theExternalName);
+ void setByExternalName(const std::wstring& theExternalName);
/// Set center.
SKETCHAPI_EXPORT
/// And the name of the feature shows that it is a regular feature.
SKETCHAPI_EXPORT
std::list<std::shared_ptr<SketchAPI_SketchEntity> > 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
static std::list<std::shared_ptr<SketchAPI_SketchEntity> > buildConstructionEntities(
const FeaturePtr& theEllipse,
const std::list<PairOfStrings>& 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;
};
}
SketchAPI_EllipticArc::SketchAPI_EllipticArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::string& theExternalName)
+ const std::wstring& theExternalName)
: SketchAPI_SketchEntity(theFeature)
{
if (initialize()) {
execute();
}
-void SketchAPI_EllipticArc::setByExternalName(const std::string & theExternalName)
+void SketchAPI_EllipticArc::setByExternalName(const std::wstring & theExternalName)
{
fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
execute();
}
std::list<std::shared_ptr<SketchAPI_SketchEntity> > 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();
/// Constructor with external.
SKETCHAPI_EXPORT
SketchAPI_EllipticArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::string& theExternalName);
+ const std::wstring& theExternalName);
/// Destructor.
SKETCHAPI_EXPORT
/// Set by external name.
SKETCHAPI_EXPORT
- void setByExternalName(const std::string& theExternalName);
+ void setByExternalName(const std::wstring& theExternalName);
/// Set center.
SKETCHAPI_EXPORT
/// And the name of the feature shows that it is a regular feature.
SKETCHAPI_EXPORT
std::list<std::shared_ptr<SketchAPI_SketchEntity> > 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
SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint(
const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const std::string & theExternalName )
+ const std::wstring & theExternalName )
: SketchAPI_SketchEntity(theFeature)
{
if (initialize()) {
execute();
}
-void SketchAPI_IntersectionPoint::setByExternalEdgeName(const std::string & theExternalLineName)
+void SketchAPI_IntersectionPoint::setByExternalEdgeName(const std::wstring & theExternalLineName)
{
fillAttribute(ModelHighAPI_Selection("EDGE", theExternalLineName), externalFeature());
/// Constructor with values
SKETCHAPI_EXPORT
SketchAPI_IntersectionPoint(const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const std::string & theExternalName);
+ const std::wstring & theExternalName);
/// Destructor
SKETCHAPI_EXPORT
virtual ~SketchAPI_IntersectionPoint();
/// 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
SketchAPI_Line::SketchAPI_Line(
const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const std::string & theExternalName )
+ const std::wstring & theExternalName )
: SketchAPI_SketchEntity(theFeature)
{
if (initialize()) {
execute();
}
-void SketchAPI_Line::setByExternalName(const std::string & theExternalName)
+void SketchAPI_Line::setByExternalName(const std::wstring & theExternalName)
{
fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
/// Constructor with values
SKETCHAPI_EXPORT
SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const std::string & theExternalName);
+ const std::wstring & theExternalName);
/// Destructor
SKETCHAPI_EXPORT
virtual ~SketchAPI_Line();
/// Set by external name
SKETCHAPI_EXPORT
- void setByExternalName(const std::string & theExternalName);
+ void setByExternalName(const std::wstring & theExternalName);
/// Set start point
SKETCHAPI_EXPORT
SketchAPI_Point::SketchAPI_Point(
const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const std::string & theExternalName )
+ const std::wstring & theExternalName )
: SketchAPI_SketchEntity(theFeature)
{
if (initialize()) {
execute();
}
-void SketchAPI_Point::setByExternalName(const std::string & theExternalName)
+void SketchAPI_Point::setByExternalName(const std::wstring & theExternalName)
{
fillAttribute(ModelHighAPI_Selection("VERTEX", theExternalName), external());
/// Constructor with values
SKETCHAPI_EXPORT
SketchAPI_Point(const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const std::string & theExternalName);
+ const std::wstring & theExternalName);
/// Destructor
SKETCHAPI_EXPORT
virtual ~SketchAPI_Point();
/// Set by external name
SKETCHAPI_EXPORT
- void setByExternalName(const std::string & theExternalName);
+ void setByExternalName(const std::wstring & theExternalName);
/// Dump wrapped feature
SKETCHAPI_EXPORT
SketchAPI_Projection::SketchAPI_Projection(
const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const std::string & theExternalName)
+ const std::wstring & theExternalName)
: SketchAPI_SketchEntity(theFeature)
{
if (initialize()) {
execute(true);
}
-void SketchAPI_Projection::setByExternalName(const std::string& theExternalName)
+void SketchAPI_Projection::setByExternalName(const std::wstring& theExternalName)
{
setExternalFeature(ModelHighAPI_Selection("EDGE", theExternalName));
}
/// Constructor with values
SKETCHAPI_EXPORT
SketchAPI_Projection(const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const std::string & theExternalName);
+ const std::wstring & theExternalName);
/// Destructor
SKETCHAPI_EXPORT
virtual ~SketchAPI_Projection();
/// 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
}
SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
- const std::string & theExternalName)
+ const std::wstring & theExternalName)
{
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
return SketchPtr(
compositeFeature()->addFeature(SketchPlugin_Point::ID());
return PointPtr(new SketchAPI_Point(aFeature, theExternal));
}
-std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(const std::string & theExternalName)
+std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(const std::wstring & theExternalName)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Point::ID());
return anIntersection;
}
std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
- const std::string & theExternalName,
+ const std::wstring & theExternalName,
bool theKeepResult)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Line::ID());
return LinePtr(new SketchAPI_Line(aFeature, theExternal));
}
-std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const std::string & theExternalName)
+std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const std::wstring & theExternalName)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Line::ID());
return CirclePtr(new SketchAPI_Circle(aFeature, theExternal));
}
-std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::string & theExternalName)
+std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::wstring & theExternalName)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Circle::ID());
return ArcPtr(new SketchAPI_Arc(aFeature, theExternal));
}
-std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::string & theExternalName)
+std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::wstring & theExternalName)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Arc::ID());
}
std::shared_ptr<SketchAPI_Ellipse> SketchAPI_Sketch::addEllipse(
- const std::string & theExternalName)
+ const std::wstring & theExternalName)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Ellipse::ID());
}
std::shared_ptr<SketchAPI_EllipticArc> SketchAPI_Sketch::addEllipticArc(
- const std::string & theExternalName)
+ const std::wstring & theExternalName)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_EllipticArc::ID());
}
std::shared_ptr<SketchAPI_Projection> SketchAPI_Sketch::addProjection(
- const std::string & theExternalName,
+ const std::wstring & theExternalName,
bool theKeepResult)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
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()
std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
/// Add point
SKETCHAPI_EXPORT
- std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
+ std::shared_ptr<SketchAPI_Point> addPoint(const std::wstring & theExternalName);
/// Add intersection point
SKETCHAPI_EXPORT
/// Add point
SKETCHAPI_EXPORT
std::shared_ptr<SketchAPI_IntersectionPoint>
- addIntersectionPoint(const std::string & theExternalName,
+ addIntersectionPoint(const std::wstring & theExternalName,
bool theKeepResult = false);
/// Add line
std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
/// Add line
SKETCHAPI_EXPORT
- std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
+ std::shared_ptr<SketchAPI_Line> addLine(const std::wstring & theExternalName);
/// Add rectangle
SKETCHAPI_EXPORT
std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
/// Add circle
SKETCHAPI_EXPORT
- std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
+ std::shared_ptr<SketchAPI_Circle> addCircle(const std::wstring & theExternalName);
/// Add arc
SKETCHAPI_EXPORT
/// Add arc
SKETCHAPI_EXPORT
- std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
+ std::shared_ptr<SketchAPI_Arc> addArc(const std::wstring & theExternalName);
/// Add ellipse
SKETCHAPI_EXPORT
std::shared_ptr<SketchAPI_Ellipse> addEllipse(const ModelHighAPI_Selection & theExternal);
/// Add ellipse
SKETCHAPI_EXPORT
- std::shared_ptr<SketchAPI_Ellipse> addEllipse(const std::string & theExternalName);
+ std::shared_ptr<SketchAPI_Ellipse> addEllipse(const std::wstring & theExternalName);
/// Add elliptic arc
SKETCHAPI_EXPORT
std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(const ModelHighAPI_Selection & theExternal);
/// Add elliptic arc
SKETCHAPI_EXPORT
- std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(const std::string & theExternalName);
+ std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(const std::wstring & theExternalName);
/// Add B-spline
SKETCHAPI_EXPORT
/// Add projection
SKETCHAPI_EXPORT
- std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
+ std::shared_ptr<SketchAPI_Projection> addProjection(const std::wstring & theExternalName,
bool theKeepResult = false);
/// Add mirror
*/
SKETCHAPI_EXPORT
SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
- const std::string & theExternalName);
+ const std::wstring & theExternalName);
/**\ingroup CPPHighAPI
* \brief Create Sketch feature
#include <ModelAPI_Events.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
#include <GeomDataAPI_Point2DArray.h>
{
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;
{
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
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())
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());
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;
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<FeaturePtr> aFeatures = document()->allFeatures();
for (std::list<FeaturePtr>::iterator aFIt = aFeatures.begin(); aFIt != aFeatures.end(); ++aFIt) {
if (anIndex >= aNewSketchIndex)
aNewSketchIndex = anIndex + 1;
}
- std::ostringstream aNameStream;
+ std::wostringstream aNameStream;
aNameStream << aSketchName;
if (aNewSketchIndex > 0)
aNameStream << '_' << aNewSketchIndex;
}
if (theFeature->data()->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,
#include <SketcherPrs_Tools.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Tools.h>
#include <ModelGeomAlgo_Point2D.h>
#include <ModelGeomAlgo_Shape.h>
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);
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);
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);
}
}
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
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;
}
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;
return false;
}
- std::string aName = aSelObject.get() ? aSelObject->data()->name() : "";
+ std::wstring aName = aSelObject.get() ? aSelObject->data()->name() : L"";
std::list<ObjectPtr>::iterator aMirIter = aMirroredObjects.begin();
for (; aMirIter != aMirroredObjects.end(); aMirIter++)
if (aSelObject == *aMirIter) {
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;
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
Handle(AIS_InteractiveContext) aContext = AISContext();
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
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
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);
/// OCCT: to write about the problem that active owners method returns one owner several times
QList<size_t> 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());
}
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;
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;
}
}
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();
}
}
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) {
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);
}
NCollection_List<Handle(SelectBasics_EntityOwner)>::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);
}
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();
bool canRemoveOrRename(QWidget* theParent, const std::set<FeaturePtr>& 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;
}
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.").
// 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);
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;
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(", ");
aPrs->dataRange(aMin, aMax);
myViewerProxy->setColorScaleRange(aMin, aMax);
}
- myViewerProxy->setColorScaleTitle(aStep->name().c_str());
+ myViewerProxy->setColorScaleTitle(QString::fromStdWString(aStep->name()));
myViewerProxy->setColorScaleShown(true);
}
}