ADD_DEFINITIONS( -DMAKE_TRANSLATION )
ADD_SUBDIRECTORY (src/Config)
+ADD_SUBDIRECTORY (src/Locale)
ADD_SUBDIRECTORY (src/Events)
ADD_SUBDIRECTORY (src/Selector)
ADD_SUBDIRECTORY (src/Model)
- **Sketch auxiliary entity color** selects default color for sketch auxiliary objects;
- **Sketch overconstraint color** selects default color for a sketch with redundant constraints;
- **Sketch fully constraint color** selects default color for a sketch with zero degrees of freedom.
+- **Zoom trihedron arrows** if this control is checked then arrows of a view trihedron will be scaled according to current view scale
+- **Axis arrow size** relative size of trihedron arrows. It has effect only in case if **Zoom trihedron arrows** is On.
To redefine any color click on the corresponding line to access **Select color** dialog box
}
// 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()));
}
}
}
Events_InfoMessage.cpp
)
+SET(PROJECT_LIBRARIES
+ Locale
+)
+
ADD_DEFINITIONS(-DEVENTS_EXPORTS)
ADD_LIBRARY(Events SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
SET_SOURCE_FILES_PROPERTIES(Events.i PROPERTIES SWIG_DEFINITIONS "-shadow")
INCLUDE_DIRECTORIES(
+ ../Locale
)
TARGET_LINK_LIBRARIES(Events ${PROJECT_LIBRARIES})
// 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 <Locale_Convert.h>
+#include <sstream>
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)
+{
+ addParameter(Locale::Convert::toString(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; }
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
${PROJECT_SOURCE_DIR}/src/Config
+ ${PROJECT_SOURCE_DIR}/src/Locale
${PROJECT_SOURCE_DIR}/src/ModelAPI
${PROJECT_SOURCE_DIR}/src/ModelHighAPI
${PROJECT_SOURCE_DIR}/src/GeomAPI
SET(PROJECT_LIBRARIES
Events
Config
+ Locale
ModelAPI
ModelHighAPI
GeomAPI
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_Trsf.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_AttributeStringArray.h>
if (aGeometryName.empty() && aResults.size() == 1) {
// get the name from the first result
ResultPtr aResultBody = *aResults.begin();
- aGeometryName = aResultBody->data()->name();
+ aGeometryName = Locale::Convert::toString(aResultBody->data()->name());
}
aXao.getGeometry()->setName(aGeometryName);
XAO::Dimension aGroupDimension = XAO::XaoUtils::stringToDimension(aDimensionString);
XAO::Group* aXaoGroup = aXao.addGroup(aGroupDimension,
- aResultGroup->data()->name());
+ Locale::Convert::toString(aResultGroup->data()->name()));
try {
GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType);
} catch (XAO::XAO_Exception& e) {
// LCOV_EXCL_START
std::string msg = "An error occurred while exporting group " +
- aResultGroup->data()->name();
+ Locale::Convert::toString(aResultGroup->data()->name());
msg += ".\n";
msg += e.what();
msg += "\n";
XAO::Type aFieldType = XAO::XaoUtils::stringToFieldType(aTypeString);
XAO::Field* aXaoField = aXao.addField(aFieldType, aFieldDimension, aTables->columns(),
- aResultField->data()->name());
+ Locale::Convert::toString(aResultField->data()->name()));
try {
} catch (XAO::XAO_Exception& e) {
// LCOV_EXCL_START
std::string msg = "An error occurred while exporting field " +
- aResultField->data()->name();
+ Locale::Convert::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 "ExchangePlugin_Import.h"
#include "ExchangePlugin_ImportFeature.h"
+#include <Locale_Convert.h>
+
#include <PartSetPlugin_Part.h>
#include <ModelAPI_AttributeString.h>
#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(),
+ Locale::Convert::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, Locale::Convert::toString(*anIt));
}
else {
// keep only the name of the current part
FeaturePtr aPartFeature = ModelAPI_Tools::findPartFeature(aSession->moduleDocument(), aDoc);
aPartsAttr->setSize(1);
- aPartsAttr->setValue(0, aPartFeature->name());
+ aPartsAttr->setValue(0, Locale::Convert::toString(aPartFeature->name()));
aTargetAttr->setValue(0);
}
}
#include <GeomAPI_Shape.h>
#include <GeomAPI_ShapeExplorer.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
#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(Locale::Convert::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(Locale::Convert::toWString(aBodyName));
ResultBodyPtr aResultBody = createResultBody(aGeomShape);
setResult(aResultBody);
// group name
if (!aXaoGroup->getName().empty())
- aGroupFeature->data()->setName(aXaoGroup->getName());
+ aGroupFeature->data()->setName(Locale::Convert::toWString(aXaoGroup->getName()));
// fill selection
AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
// group name
if (!aXaoField->getName().empty())
- aFieldFeature->data()->setName(aXaoField->getName());
+ aFieldFeature->data()->setName(Locale::Convert::toWString(aXaoField->getName()));
// fill selection
AttributeSelectionListPtr aSelectionList = aFieldFeature->selectionList("selected");
#include <ExchangePlugin_ImportPart.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_AttributeStringArray.h>
#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(Locale::Convert::toString((*aFIt)->name()));
}
if ((size_t)aPartsAttr->size() != anAcceptedValues.size())
FeaturePtr aPartFeature = ModelAPI_Tools::findPartFeature(aSession->moduleDocument(), aDoc);
aPartsAttr->setSize(1);
- aPartsAttr->setValue(0, aPartFeature->name());
+ aPartsAttr->setValue(0, Locale::Convert::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() &&
+ Locale::Convert::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;
+ bool isOk = aLastUndercore != std::wstring::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();
/// Performs the algorithm and stores results it in the data structure.
FEATURESPLUGIN_EXPORT virtual void executeCompositeBoolean();
+ const OperationType& operationType() const { return myOperationType; }
+
protected:
struct ResultBaseAlgo {
ResultBodyPtr resultBody;
// Initialize selection list.
if(theInitFlags & InitBaseObjectsList) {
data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
+ myCurrentSelectionType = selectionList(BASE_OBJECTS_ID())->selectionType();
}
}
}
}
}
+
+//=================================================================================================
+void FeaturesPlugin_CompositeSketch::attributeChanged(const std::string& theID)
+{
+ if (theID == BASE_OBJECTS_ID()) {
+ AttributeSelectionListPtr anObjects = selectionList(BASE_OBJECTS_ID());
+ if (anObjects->size() == 0 || anObjects->selectionType() != myCurrentSelectionType) {
+ myCurrentSelectionType = anObjects->selectionType();
+ removeResults(0); // clear the results
+ }
+ }
+}
/// structures of the owner (the remove from the document will be done outside just after).
FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
+ /// On change of attribute of the result update presentation of this result:
+ /// for the current moment there are only presentation attributes assigned to results
+ FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
protected:
enum InitFlags {
InitSketchLauncher = 1 << 0,
const ListOfShape& theShapes,
const std::string theName);
+private:
+ std::string myCurrentSelectionType; //< type of selection (vertex, edge or face)
};
#endif
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);
#include "FeaturesPlugin_BooleanFuse.h"
#include "FeaturesPlugin_BooleanCommon.h"
#include "FeaturesPlugin_BooleanSmash.h"
+#include "FeaturesPlugin_CompositeBoolean.h"
#include "FeaturesPlugin_Extrusion.h"
#include "FeaturesPlugin_Pipe.h"
#include "FeaturesPlugin_Union.h"
return true;
}
} else {
- // Shape on construction selected. Check that it is a face or wire.
- if(aShape->shapeType() == GeomAPI_Shape::WIRE ||
- aShape->shapeType() == GeomAPI_Shape::FACE) {
- return true;
+ // CUT operation supports only FACE or WIRE as a tool base
+ std::shared_ptr<FeaturesPlugin_CompositeBoolean> aComposite =
+ std::dynamic_pointer_cast<FeaturesPlugin_CompositeBoolean>(
+ ModelAPI_Feature::feature(theAttribute->owner()));
+ if (aComposite &&
+ aComposite->operationType() == FeaturesPlugin_CompositeBoolean::BOOL_CUT) {
+ return aShape->shapeType() == GeomAPI_Shape::WIRE ||
+ aShape->shapeType() == GeomAPI_Shape::FACE;
}
}
- return false;
}
if(aContextShape.get() && !aShape->isEqual(aContextShape)) {
1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br />
2. An existing sketch face or contour. Extrusion will be filled by it.<br />
3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it."
- shape_types="vertices edges wires faces shells solids compsolids compounds">
+ shape_types="Vertices Edges Faces"
+ type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
+ default_type = "2"
+ use_choice="true">
<validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="base,Sketch"/>
</sketch_launcher>
<multi_selector id="base"
label="Base objects:"
tooltip="Select a base objects"
- shape_types="vertices edges wires faces shells compounds"
+ shape_types="Vertices Edges Faces"
+ type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
+ default_type = "2"
+ use_choice="true"
concealment="true">
<validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face,shell,compound"/>
</multi_selector>
1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br />
2. An existing sketch face or contour. Extrusion will be filled by it.<br />
3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it."
- shape_types="vertices edges wires faces shells compounds">
+ shape_types="Vertices Edges Faces"
+ type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
+ default_type = "2"
+ use_choice="true">
<validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="base,Sketch"/>
</sketch_launcher>
<multi_selector id="base"
label="Select a sketch face"
icon="icons/Features/sketch.png"
tooltip="Select a sketch face"
- shape_types="vertices edges wires faces shells compounds"
+ shape_types="Vertices Edges Faces"
+ type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
+ default_type = "2"
+ use_choice="true"
concealment="true">
<validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face,shell,compound"/>
</multi_selector>
1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br />
2. An existing sketch face or contour. Extrusion will be filled by it.<br />
3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it."
- shape_types="vertices edges wires faces shells compounds">
+ shape_types="Vertices Edges Faces"
+ type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
+ default_type = "2"
+ use_choice="true">
<validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="base,Sketch"/>
</sketch_launcher>
<multi_selector id="base"
label="Base objects:"
tooltip="Select a base objects"
- shape_types="vertices edges wires faces shells compounds"
+ shape_types="Vertices Edges Faces"
+ type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
+ default_type = "2"
+ use_choice="true"
concealment="true">
<validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face,shell,compound"/>
</multi_selector>
1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br />
2. An existing sketch face or contour. Extrusion will be filled by it.<br />
3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it."
- shape_types="vertices edges wires faces shells compounds">
+ shape_types="Vertices Edges Faces"
+ type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
+ default_type = "2"
+ use_choice="true">
<validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="base,Sketch"/>
</sketch_launcher>
<multi_selector id="base"
label="Select a sketch face"
icon="icons/Features/sketch.png"
tooltip="Select a sketch face"
- shape_types="vertices edges wires faces shells compounds"
+ shape_types="Vertices Edges Faces"
+ type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png"
+ default_type = "2"
+ use_choice="true"
concealment="true">
<validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face,shell,compound"/>
</multi_selector>
if (aColor.IsEqual(aCurrentColor))
return false;
+ Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS);
if (!aDimAIS.IsNull()) {
aDimAIS->DimensionAspect()->SetCommonColor(aColor);
+ if (!aContext.IsNull())
+ aContext->Redisplay(aDimAIS, false);
+ }
+ else {
+ if (!aContext.IsNull())
+ aContext->SetColor(anAIS, aColor, false);
+ else
+ anAIS->SetColor(aColor);
}
- Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
- if (!aContext.IsNull())
- aContext->SetColor(anAIS, aColor, false);
- else
- anAIS->SetColor(aColor);
return true;
}
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
--- /dev/null
+# Copyright (C) 2020 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+INCLUDE(Common)
+INCLUDE(UnitTest)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${Boost_INCLUDE_DIR}
+)
+
+SET(PROJECT_HEADERS
+ Locale_def.h
+ Locale_Convert.h
+)
+
+SET(PROJECT_SOURCES
+ Locale_Convert.cpp
+)
+
+SET(PROJECT_LIBRARIES
+)
+
+ADD_DEFINITIONS(-DLOCALE_EXPORTS)
+ADD_LIBRARY(Locale SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(Locale ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS Locale DESTINATION ${SHAPER_INSTALL_BIN})
+
+ADD_UNIT_TESTS(
+ TestUTF8.py
+)
--- /dev/null
+// Copyright (C) 2020 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <Locale_Convert.h>
+
+#include <boost/locale/encoding_utf.hpp>
+
+namespace Locale
+{
+ std::string Convert::toString(const std::wstring& theWStr)
+ {
+ return boost::locale::conv::utf_to_utf<char>(theWStr);
+ }
+
+ std::string Convert::toString(const char16_t* theExtStr)
+ {
+ return boost::locale::conv::utf_to_utf<char>(theExtStr);
+ }
+
+ std::wstring Convert::toWString(const std::string& theStr)
+ {
+ return boost::locale::conv::utf_to_utf<wchar_t>(theStr);
+ }
+
+ std::wstring Convert::toWString(const char16_t* theExtStr)
+ {
+ return boost::locale::conv::utf_to_utf<wchar_t>(theExtStr);
+ }
+
+}
--- /dev/null
+// Copyright (C) 2020 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef LOCALE_CONVERT_H
+#define LOCALE_CONVERT_H
+
+#include <Locale_def.h>
+
+#include <string>
+
+namespace Locale
+{
+ /// Convert strings
+ namespace Convert
+ {
+ /// Converts a wide-string to a simple (byte) string
+ /// \param theWStr a wide-string
+ LOCALE_EXPORT std::string toString(const std::wstring& theWStr);
+
+ /// Converts an extended string to a simple (byte) string
+ /// \param theExtStr an extended string
+ LOCALE_EXPORT std::string toString(const char16_t* theExtStr);
+
+ /// Converts a byte string to a wide-string
+ /// \param theStr a byte string
+ LOCALE_EXPORT std::wstring toWString(const std::string& theStr);
+
+ /// Converts an extended string to a wide-string
+ /// \param theStr a byte string
+ LOCALE_EXPORT std::wstring toWString(const char16_t* theExtStr);
+
+ }
+}
+
+#endif // Locale_Convert_H
--- /dev/null
+// Copyright (C) 2020 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef LOCALE_DEF_H
+#define LOCALE_DEF_H
+
+#if defined WIN32
+# if defined LOCALE_EXPORTS
+# define LOCALE_EXPORT __declspec( dllexport )
+# else
+# define LOCALE_EXPORT __declspec( dllimport )
+# endif
+#else
+# define LOCALE_EXPORT
+#endif
+
+#endif
--- /dev/null
+# Copyright (C) 2020 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Box
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Box_1.setName("boîte")
+Box_1.result().setName("boîte")
+
+### Create Sphere
+Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10)
+Sphere_1.setName("sphère")
+Sphere_1.result().setName("sphère")
+
+### Create Shell
+Shell_1_objects = [model.selection("FACE", "boîte/Left"),
+ model.selection("FACE", "boîte/Back"),
+ model.selection("FACE", "boîte/Bottom")]
+Shell_1 = model.addShell(Part_1_doc, Shell_1_objects)
+
+### Create Cut
+Cut_1 = model.addCut(Part_1_doc, [model.selection("SHELL", "boîte")], [model.selection("COMPOUND", "all-in-sphère")], keepSubResults = True)
+Cut_1.result().subResult(0).setName("Cut_1_1_1")
+Cut_1.result().subResult(1).setName("Cut_1_1_2")
+Cut_1.result().subResult(2).setName("Cut_1_1_3")
+
+model.end()
+
+from GeomAPI import *
+
+model.testNbResults(Cut_1, 1)
+model.testNbSubResults(Cut_1, [3])
+model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [3])
+model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [9])
+model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [18])
+model.testResultsVolumes(Cut_1, [64.38055098])
+
+assert(model.checkPythonDump())
GeomData
GeomAPI
GeomAlgoAPI
+ Locale
ModelGeomAlgo
${OpenCASCADE_ApplicationFramework_LIBRARIES}
)
../GeomDataAPI
../GeomAlgoAPI
../GeomAPI
+ ../Locale
../ModelGeomAlgo
../ConstructionPlugin
${OpenCASCADE_INCLUDE_DIR}
#include <Model_Document.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_Tools.h>
+
+#include <Locale_Convert.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(), Locale::Convert::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
#include <GeomAlgoAPI_NExplode.h>
#include <Selector_Selector.h>
+#include <Locale_Convert.h>
+
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
#include <TNaming_Builder.hxx>
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
} else { // face with name is already in the data model, so try to take it by name
Handle(TDataStd_Name) aName;
if (aSelLab.FindAttribute(TDataStd_Name::GetID(), aName)) {
- std::string aSubShapeName(TCollection_AsciiString(aName->Get()).ToCString());
- std::size_t aPartEnd = aSubShapeName.find('/');
- if (aPartEnd != std::string::npos && aPartEnd != aSubShapeName.rfind('/')) {
- std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1);
+ std::wstring aSubShapeName = Locale::Convert::toWString(aName->Get().ToExtString());
+ std::size_t aPartEnd = aSubShapeName.find(L'/');
+ if (aPartEnd != std::wstring::npos && aPartEnd != aSubShapeName.rfind(L'/')) {
+ std::wstring aNameInPart = aSubShapeName.substr(aPartEnd + 1);
int anInd;
std::string aType; // to reuse already existing selection the type is not needed
return aPart->shapeInPart(aNameInPart, aType, anInd);
}
// 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::wstring aName;
if (aShape.get()) {
- aName = aShape->shapeTypeStr();
+ aName = Locale::Convert::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 += Locale::Convert::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);
- if (aFound != std::string::npos &&
+ if (aFound != std::wstring::npos &&
aFound == theShapeName.size() - aPrefixIter->second.size()) {
theShapeName = theShapeName.substr(0, aFound);
return aPrefixIter->first;
// 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
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(owner()->document());
// 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::size_t aPartEnd = aSubShapeName.find(L'/');
+ if (aPartEnd != std::wstring::npos) {
+ std::wstring aPartName = aSubShapeName.substr(0, aPartEnd);
DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- if (aPartName == aRootDoc->kind()) {
+ if (aPartName == Locale::Convert::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);
}
// the whole result selection check
- if (aSubShapeName.find('/') == std::string::npos) {
+ if (aSubShapeName.find(L'/') == std::wstring::npos) {
ObjectPtr aRes = aDoc->objectByName(ModelAPI_ResultConstruction::group(), aSubShapeName);
if (!aRes.get()) {
aRes = aDoc->objectByName(ModelAPI_ResultBody::group(), aSubShapeName);
}
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 = Locale::Convert::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 = Locale::Convert::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::string::size_type n = aName.find('/');
- if (n != std::string::npos) {
+ std::wstring aSubShapeName = aName;
+ std::wstring::size_type n = aName.find(L'/');
+ if (n != std::wstring::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(Locale::Convert::toWString(aDoc->kind())) == 0) {
+ // remove the document identifier from name if exists
aSubShapeName = theName.substr(aDoc->kind().size() + 1);
aName = aSubShapeName;
- n = aName.find('/');
- if (n != std::string::npos) {
+ n = aName.find(L'/');
+ if (n != std::wstring::npos) {
aName = aName.substr(0, n);
}
}
// sketch sub-component shape and name is located in separated feature label, try the sub-name
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::size_type aSlash = aSubShapeName.rfind(L'/');
+ if (aSlash != std::wstring::npos) {
+ 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
#include <Model_BodyBuilder.h>
+#include <Locale_Convert.h>
+
#include <Model_Data.h>
#include <Model_Document.h>
#include <ModelAPI_Session.h>
if(!aBuilder.NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
- std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
+ std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
if(!aBuilder->NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
- std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
+ std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
if(!aBuilder->NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
- std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
+ std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
#include <Events_Loop.h>
#include <Events_InfoMessage.h>
+#include <Locale_Convert.h>
+
#include <TDataStd_Name.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TDataStd_UAttribute.hxx>
}
}
-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();
+ myObject->myName = Locale::Convert::toWString(aName->Get().ToExtString());
#endif
- return std::string(TCollection_AsciiString(aName->Get()).ToCString());
+ return Locale::Convert::toWString(aName->Get().ToExtString());
}
- 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)
#include <Events_InfoMessage.h>
#include <GeomAPI_Tools.h>
+#include <Locale_Convert.h>
+
#include <TDataStd_Integer.hxx>
#include <TDataStd_Comment.hxx>
#include <TDF_ChildIDIterator.hxx>
ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aPartRes);
if (!aPart->isActivated()) {
// copy not-activated document that is not in the memory
- std::string aDocName = aPart->data()->name();
+ std::string aDocName = Locale::Convert::toString(aPart->data()->name());
if (!aDocName.empty()) {
// just copy file
TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName));
}
}
} else { // simply save opened document
+ std::string aDocName = Locale::Convert::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 = Locale::Convert::toWString(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++) {
return *(aFind->second.rbegin()); // no more variants, so, return the last
}
// 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::size_type aSlash = theName.rfind(L'/');
+ if (aSlash != std::wstring::npos) {
+ 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() && (int)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;
#include <Events_Loop.h>
#include <Events_InfoMessage.h>
+#include <Locale_Convert.h>
+
#include <TDataStd_Integer.hxx>
#include <TDataStd_Comment.hxx>
#include <TDF_ChildIDIterator.hxx>
}
std::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 Locale::Convert::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;
- while(aSyms.find(*aSuffix) != std::string::npos) {
+ static const std::wstring aSyms(L"sefr");
+ std::wstring::iterator aSuffix = aName.end() - 1;
+ while(aSyms.find(*aSuffix) != std::wstring::npos) {
--aSuffix;
}
aName.erase(aSuffix + 1, aName.end());
{
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 aSubBuilder(aSubLab);
aSubBuilder.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>
+#include <Locale_Convert.h>
+
#include <Config_PropManager.h>
Model_ResultField::Model_ResultField(std::shared_ptr<ModelAPI_Data> theOwnerData)
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)<<" "<< Locale::Convert::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>
+#include <Locale_Convert.h>
+
#include <TNaming_Tool.hxx>
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Name.hxx>
SessionPtr aMgr = ModelAPI_Session::get();
if (!aMgr->isOperation()) {
// open transaction even document is not created to set current docs in setActiveDocument
- std::string aMsg = "Activation " + data()->name();
+ std::string aMsg = "Activation " + Locale::Convert::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"";
MAYBE_UNUSED 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
Model_Update MY_UPDATER_INSTANCE; /// the only one instance initialized on load of the library
//#define DEB_UPDATE
+#ifdef DEB_UPDATE
+#include <Locale_Convert.h>
+#endif
+
Model_Update::Model_Update()
{
Events_Loop* aLoop = Events_Loop::loop();
else if (myProcessOnFinish.find(theFeature) == myProcessOnFinish.end())
myProcessOnFinish[theFeature] = std::set<std::shared_ptr<ModelAPI_Feature> >();
#ifdef DEB_UPDATE
- std::cout<<"*** Add process on finish "<<theFeature->name()<<std::endl;
+ std::wcout<<L"*** Add process on finish "<<theFeature->name()<<std::endl;
#endif
// keeps the currently updated features to avoid infinitive cycling here: where feature on
// "updateArguments" sends "updated" (in selection attribute) and goes here again
if (!(*anObjIter)->data()->isValid())
continue;
#ifdef DEB_UPDATE
- std::cout<<">>> in event updated "<<(*anObjIter)->groupName()<<
- " "<<(*anObjIter)->data()->name()<<std::endl;
+ std::wcout<<L">>> in event updated "<<Locale::Convert::toWString((*anObjIter)->groupName())
+ <<L" "<<(*anObjIter)->data()->name()<<std::endl;
#endif
if ((*anObjIter)->groupName() == ModelAPI_ResultParameter::group()) {
myIsParamUpdated = true;
}
#ifdef DEB_UPDATE
- std::cout<<"* Process feature "<<theFeature->name()<<std::endl;
+ std::wcout<<L"* Process feature "<<theFeature->name()<<std::endl;
#endif
// update the sketch plane before the sketch sub-elements are recomputed
// (otherwise sketch will update plane, modify subs, after executed, but with old subs edges)
if (aIsModified && theFeature->getKind() == "Sketch") {
#ifdef DEB_UPDATE
- std::cout << "****** Update sketch args " << theFeature->name() << std::endl;
+ std::wcout << L"****** Update sketch args " << theFeature->name() << std::endl;
#endif
AttributeSelectionPtr anExtSel = theFeature->selection("External");
if (anExtSel.get()) {
}
#ifdef DEB_UPDATE
- std::cout<<"Update args "<<theFeature->name()<<std::endl;
+ std::wcout<<L"Update args "<<theFeature->name()<<std::endl;
#endif
// TestImport.py : after arguments are updated, theFeature may be removed
if (!theFeature->data()->isValid())
// don't disable Part because it will make disabled all the features
// (performance and problems with the current feature)
#ifdef DEB_UPDATE
- std::cout<<"Invalid args "<<theFeature->name()<<std::endl;
+ std::wcout<<L"Invalid args "<<theFeature->name()<<std::endl;
#endif
theFeature->eraseResults(false);
redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
}
} else {
#ifdef DEB_UPDATE
- std::cout<<"Feature is not valid, erase results "<<theFeature->name()<<std::endl;
+ std::wcout<<L"Feature is not valid, erase results "<<theFeature->name()<<std::endl;
#endif
theFeature->eraseResults(false);
redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
void Model_Update::executeFeature(FeaturePtr theFeature)
{
#ifdef DEB_UPDATE
- std::cout<<"Execute Feature "<<theFeature->name()<<std::endl;
+ std::wcout<<L"Execute Feature "<<theFeature->name()<<std::endl;
#endif
// execute in try-catch to avoid internal problems of the feature
ModelAPI_ExecState aState = ModelAPI_StateDone;
SET(PROJECT_LIBRARIES
Config
GeomAPI
+ Locale
)
SET(CMAKE_SWIG_FLAGS -threads -w325,321,362,383,302,403,451,473)
ADD_DEFINITIONS(-DMODELAPI_EXPORTS)
${PROJECT_SOURCE_DIR}/src/Events
${PROJECT_SOURCE_DIR}/src/GeomAPI
${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
+ ${PROJECT_SOURCE_DIR}/src/Locale
)
// 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;
}
/// Event ID that 1D-fillet failed (comes with ModelAPI_ShapesFailedMessage)
-static const char * EVENT_OPERATION_SHAPES_FAILED = "OperationShapesFailed";
+MAYBE_UNUSED static const char * EVENT_OPERATION_SHAPES_FAILED = "OperationShapesFailed";
/// Message that feature was changed (used for Object Browser update): moved, updated and deleted
class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
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();
}
std::shared_ptr<ModelAPI_Document> myDoc; ///< document this object belongs to
public:
#ifdef DEBUG_NAMES
- std::string myName; // name of this object
+ std::wstring myName; // name of this object
#endif
/// By default object is displayed in the object browser.
MODELAPI_EXPORT virtual bool isInHistory();
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 <sstream>
#include <Events_Loop.h>
+#include <Locale_Convert.h>
#include <ModelAPI_Events.h>
#include <GeomAPI_ShapeHierarchy.h>
ObjectPtr objectByName(const DocumentPtr& theDocument, const std::string& theGroup,
const std::string& theName)
{
+ std::wstring aName = Locale::Convert::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)
\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
MODELAPI_EXPORT std::list<std::shared_ptr<ModelAPI_Feature> > referencedFeatures(
std::shared_ptr<ModelAPI_Result> theTarget, const std::string& theFeatureKind,
const bool theSortResults);
-
}
#endif
GeomAPI
GeomDataAPI
GeomAlgoAPI
+ Locale
ModelAPI
ModelGeomAlgo
)
${PROJECT_SOURCE_DIR}/src/GeomAPI
${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+ ${PROJECT_SOURCE_DIR}/src/Locale
${PROJECT_SOURCE_DIR}/src/ModelAPI
${PROJECT_SOURCE_DIR}/src/ModelGeomAlgo
${PROJECT_SOURCE_DIR}/src/PartSetPlugin
// 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;
// std::pair -> []
%template(ResultSubShapePair) std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >;
%template(StringsPair) std::pair<std::string, std::string>;
+%template(StringWStringPair) std::pair<std::string, std::wstring>;
// fix compilarion error: 'res*' was not declared in this scope
#include <GeomDataAPI_Point2D.h>
#include <GeomDataAPI_Point2DArray.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeBoolean.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeDoubleArray.h>
if (aShape.get()) {
myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \""
- << theAttrSelect->namingName() << "\"";
+ << Locale::Convert::toString(theAttrSelect->namingName()) << "\"";
}
myDumpBuffer << ")";
int anIndex = aNExplode.index(aShape);
if (anIndex != 0) { // found a week-naming index, so, export it
myDumpBuffer << "model.selection(\"" << aShape->shapeTypeStr() << "\", \""
- << theAttrSelect->contextName(aContext) << "\", " << anIndex << ")";
+ << Locale::Convert::toString(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 = Locale::Convert::toString(aFeature->name());
aKind = aFeature->getKind();
} else {
FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(theEntity);
if (aFolder) {
- aName = aFolder->data()->name();
+ aName = Locale::Convert::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 = Locale::Convert::toString(aName.first);
+ std::string aResName = Locale::Convert::toString((*aRes)->data()->name());
bool isUserDefined = !(isFeatureDefaultName && aDefaultName == aResName);
myNames[*aRes] =
EntityName(aResName, (isUserDefined ? aResName : std::string()), !isUserDefined);
const FeaturePtr& theSubFeature)
{
name(theSubFeature, false);
- myNames[theSubFeature] = EntityName(theSubFeatureGet, theSubFeature->name(), false);
+ myNames[theSubFeature] =
+ EntityName(theSubFeatureGet, Locale::Convert::toString(theSubFeature->name()), false);
// store results if they have user-defined names or colors
std::list<ResultPtr> aResultsWithNameOrColor;
const std::list<ResultPtr>& aResults = theSubFeature->results();
std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
for (; aResIt != aResults.end(); ++aResIt) {
- std::string aResName = (*aResIt)->data()->name();
+ std::string aResName = Locale::Convert::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 << Locale::Convert::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);
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAPI_Pnt.h>
+#include <Locale_Convert.h>
+
#include <TopoDS_Shape.hxx>
#include <TopExp_Explorer.hxx>
std::string ModelHighAPI_FeatureStore::compare(ObjectPtr theObject) {
std::string anError = compareData(theObject->data(), myAttrs);
if (!anError.empty()) {
- return "Features '" + theObject->data()->name() + "' differ:" + anError;
+ return "Features '" + Locale::Convert::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 '" + Locale::Convert::toString(aFeature->name()) +
+ "' '" + Locale::Convert::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 '" +
+ Locale::Convert::toString((*aRes)->data()->name()) + "'";
}
if (aResIter != myRes.end()) {
return "Original model had more results '" + (*aResIter)["__name__"] + "'";
std::map<std::string, std::string>& theAttrs)
{
// store name to keep also this information and output if needed
- theAttrs["__name__"] = theData->name();
+ theAttrs["__name__"] = Locale::Convert::toString(theData->name());
std::list<std::shared_ptr<ModelAPI_Attribute> > allAttrs = theData->attributes("");
std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = allAttrs.begin();
for(; anAttr != allAttrs.end(); anAttr++) {
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<< Locale::Convert::toString(aRes->data()->name());
}
} else {
aResult<<aDoc->kind(); // PartSet
AttributeReferencePtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttr);
if (anAttr->value().get()) {
- aResult<<anAttr->value()->data()->name();
+ aResult<< Locale::Convert::toString(anAttr->value()->data()->name());
} else {
aResult<<"__empty__";
}
AttributeSelectionPtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttr);
if (anAttr->context().get())
- aResult<<anAttr->namingName();
+ aResult<< Locale::Convert::toString(anAttr->namingName());
else
aResult<<"__notinitialized__";
} else if (aType == ModelAPI_AttributeSelectionList::typeId()) {
for(int a = 0; a < anAttr->size(); a++) {
if (a != 0)
aResult<<" ";
- aResult<<anAttr->value(a)->namingName();
+ aResult<< Locale::Convert::toString(anAttr->value(a)->namingName());
}
} else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
AttributeRefAttrPtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttr);
ObjectPtr anObj = anAttr->isObject() ? anAttr->object() : anAttr->attr()->owner();
if (anObj.get()) {
- aResult<<anObj->data()->name();
+ aResult<< Locale::Convert::toString(anObj->data()->name());
if (!anAttr->isObject()) {
aResult<<" "<<anAttr->attr()->id();
}
if (aStr == "SketchConstraint")
continue; // no need to dump and check constraints
}
- aResList.push_back((*aL)->data()->name());
+ aResList.push_back(Locale::Convert::toString((*aL)->data()->name()));
} else if (!isSketchFeatures) {
aResList.push_back("__empty__");
}
aResult<<" ";
ObjectPtr anObj = aL->second.get() ? aL->second->owner() : aL->first;
if (anObj.get()) {
- aResult<<anObj->data()->name();
+ aResult<< Locale::Convert::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()->isValid())
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.
*
#include <GeomDataAPI_Point2D.h>
#include <GeomDataAPI_Point2DArray.h>
//--------------------------------------------------------------------------------------
+#include <Locale_Convert.h>
+//--------------------------------------------------------------------------------------
#include <ModelAPI_AttributeBoolean.h>
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_AttributeDouble.h>
}
/// 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 '" + Locale::Convert::toString(theDocName) + "' not found";
}
}
// store the model features information: iterate all features
size_t 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 '" + Locale::Convert::toString(theDocName)
+ + "' feature '" + Locale::Convert::toString(anObject->data()->name()) + "' not found";
}
std::string anError = anObjFind->second.compare(anObject);
if (!anError.empty()) {
- anError = "Document " + theDocName + " " + anError;
+ anError = "Document " + Locale::Convert::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 '" + Locale::Convert::toString(theDocName) +
+ "' the number of features is decreased, there is no feature '" +
+ Locale::Convert::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(Locale::Convert::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(Locale::Convert::toWString(aSession->moduleDocument()->kind()),
+ aSession->moduleDocument(), aStore, false);
if (!anError.empty()) {
Events_InfoMessage anErrorMsg(std::string("checkPythonDump"), anError);
anErrorMsg.send();
/// \param theAIS a presentation object
virtual void onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS) {}
+ /// Called on transformation in current viewer
+ /// \param theTrsfType type of tranformation
+ virtual void onViewTransformed(int theTrsfType = 2) {}
+
protected slots:
/// Called on selection changed event
virtual void onSelectionChanged() {}
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) {
FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
if (aFeature.get()) {
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();
}
myMainLayout = new QVBoxLayout(this);
ModuleBase_Tools::adjustMargins(myMainLayout);
- QStringList aIconsList = getIconsList(myShapeTypes);
+
+ QStringList aIconsList;
+ std::string aIcons = theData->getProperty("type_icons");
+ if (aIcons.size() > 0)
+ aIconsList = QString(aIcons.c_str()).split(' ', QString::SkipEmptyParts);
+
+ if (aIconsList.size() != myShapeTypes.size())
+ aIconsList = getIconsList(myShapeTypes);
+
myTypeCtrl = new ModuleBase_ChoiceCtrl(this, myShapeTypes, aIconsList);
myTypeCtrl->setLabel(tr("Type"));
if (!myShapeTypes.empty()) {
- myTypeCtrl->setValue(0);
- myDefMode = myShapeTypes.first().toStdString();
+ std::string aDefType = theData->getProperty("default_type");
+ if (aDefType.size() > 0) {
+ bool aOk = false;
+ int aId = QString(aDefType.c_str()).toInt(&aOk);
+ if (aOk) {
+ myTypeCtrl->setValue(aId);
+ myDefMode = myShapeTypes.at(aId).toStdString();
+ }
+ }
+ if (myDefMode.size() == 0) {
+ myTypeCtrl->setValue(0);
+ myDefMode = myShapeTypes.first().toStdString();
+ }
}
myMainLayout->addWidget(myTypeCtrl);
QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
{
QList<QWidget*> result;
+ if (myTypeCtrl->isVisible())
+ result << myTypeCtrl;
result << myListView->getControl();
return result;
}
restoreValue();
myWorkshop->setSelected(getAttributeSelection());
// may be the feature's result is not displayed, but attributes should be
- myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments,
- true); /// hope that something is redisplayed by object updated
+ // hope that something is redisplayed by object updated
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments, false);
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeResults, true);
// clear history should follow after set selected to do not increase history by setSelected
clearSelectedHistory();
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 anAttr = aRefAttrListAttr->attribute(i);
QString aName;
if (anAttr.get()) {
- std::string anAttrName = ModuleBase_Tools::generateName(anAttr, myWorkshop);
- aName = QString::fromStdString(anAttrName);
+ std::wstring anAttrName = ModuleBase_Tools::generateName(anAttr, 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()));
<source>Replace</source>
<translation>Remplacer</translation>
</message>
+ <message>
+ <source>Trihedron arrows constant size</source>
+ <translation>Flèche trièdre de taille constante</translation>
+ </message>
+ <message>
+ <source>Keep trihedron arrows view size constant</source>
+ <translation>Maintenir la taille de la vue des flèches trièdres constante</translation>
+ </message>
</context>
</TS>
INCLUDE(UseQtExt)
# additional include directories
-INCLUDE_DIRECTORIES(${QT_INCLUDES})
+INCLUDE_DIRECTORIES(
+ ../Locale
+ ${QT_INCLUDES}
+)
# additional preprocessor / compiler flags
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET(PROJECT_LIBRARIES
Events
Config
+ Locale
ModelAPI
ModuleBase
${QT_LIBRARIES}
#include <Events_InfoMessage.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeRefList.h>
void setParameterName(ResultParameterPtr theResultParameter, const std::string& theName)
{
bool aWasBlocked = theResultParameter->data()->blockSendAttributeUpdated(true);
- theResultParameter->data()->setName(theName);
+ theResultParameter->data()->setName(Locale::Convert::toWString(theName));
theResultParameter->data()->blockSendAttributeUpdated(aWasBlocked, false);
std::shared_ptr<ParametersPlugin_Parameter> aParameter =
std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
ModelAPI_Feature::feature(theResultParameter));
- std::string anOldName = aParameter->name();
+ std::string anOldName = Locale::Convert::toString(aParameter->name());
aWasBlocked = aParameter->data()->blockSendAttributeUpdated(true);
- aParameter->data()->setName(theName);
+ aParameter->data()->setName(Locale::Convert::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, Locale::Convert::toString(aMessage->oldName()));
return;
}
}
// try to update the parameter feature according the new name
- setParameterName(aResultParameter, aMessage->newName());
+ setParameterName(aResultParameter, Locale::Convert::toString(aMessage->newName()));
if (!isValidAttribute(aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID()))) {
//setParameterName(aResultParameter, aMessage->oldName());
if (myOldNames.find(aParameter.get()) == myOldNames.end())
- myOldNames[aParameter.get()] = aMessage->oldName();
+ myOldNames[aParameter.get()] = Locale::Convert::toString(aMessage->oldName());
return;
}
- std::string anOldName = aMessage->oldName();
+ std::string anOldName = Locale::Convert::toString(aMessage->oldName());
if (myOldNames.find(aParameter.get()) != myOldNames.end()) {
anOldName = myOldNames[aParameter.get()];
myOldNames.erase(aParameter.get());
aParameter->execute(); // to enable result because of previously incorrect name
}
- renameInDependents(aResultParameter, anOldName, aMessage->newName());
+ renameInDependents(aResultParameter, anOldName,
+ Locale::Convert::toString(aMessage->newName()));
}
void ParametersPlugin_EvalListener::processReplaceParameterEvent(
double aRealValue = aResultParameter->data()->real(ModelAPI_ResultParameter::VALUE())->value();
std::string aValue = toStdString(aRealValue);
- renameInDependents(aResultParameter, aResultParameter->data()->name(), aValue);
+ renameInDependents(aResultParameter,
+ Locale::Convert::toString(aResultParameter->data()->name()),
+ aValue);
}
#include "ParametersPlugin_Parameter.h"
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_AttributeDouble.h>
void ParametersPlugin_Parameter::updateName()
{
std::string aName = string(VARIABLE_ID())->value();
- data()->setName(aName);
+ data()->setName(Locale::Convert::toWString(aName));
ResultParameterPtr aParam = document()->createParameter(data());
- std::string anOldName = aParam->data()->name();
- aParam->data()->setName(aName);
+ std::string anOldName = Locale::Convert::toString(aParam->data()->name());
+ aParam->data()->setName(Locale::Convert::toWString(aName));
setResult(aParam);
#include <Events_InfoMessage.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultParameter.h>
for (int anIndex = 0, aSize = aDocument->size(ModelAPI_ResultParameter::group());
anIndex < aSize; ++anIndex) {
ObjectPtr aParamObj = aDocument->object(ModelAPI_ResultParameter::group(), anIndex);
- if (aParamObj->data()->name() != theString)
+ if (Locale::Convert::toString(aParamObj->data()->name()) != theString)
continue;
ResultParameterPtr aParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aParamObj);
if (!aParam.get())
} 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++;
}
ModuleBase
ModelGeomAlgo
Config
+ Locale
GeomAPI
GeomDataAPI
SketcherPrs
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/XGUI
${PROJECT_SOURCE_DIR}/src/Config
${PROJECT_SOURCE_DIR}/src/Events
+ ${PROJECT_SOURCE_DIR}/src/Locale
${PROJECT_SOURCE_DIR}/src/ModuleBase
${PROJECT_SOURCE_DIR}/src/ModelAPI
${PROJECT_SOURCE_DIR}/src/ModelGeomAlgo
QAction* aAction;
int i = 0;
foreach (FeaturePtr aCoinsL, myCoinsideLines) {
- QString anItemText = aCoinsL->data()->name().c_str();
+ QString anItemText = QString::fromStdWString(aCoinsL->data()->name());
#ifdef _DEBUG
if (anIsAttributes[i])
anItemText += " [attribute]";
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
XGUI_Workshop* aWorkshop = aConnector->workshop();
- ModuleBase_Operation* anOpAction =
- new ModuleBase_Operation(tr("Detach %1").arg(aLine->data()->name().c_str()), myModule);
+ ModuleBase_Operation* anOpAction = new ModuleBase_Operation(tr("Detach %1").arg(
+ QString::fromStdWString(aLine->data()->name())), myModule);
XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
// the active nested sketch operation should be aborted unconditionally
// the Delete action should be additionally granted for the Sketch operation
"Hidden faces transparency",
Config_Prop::DblSpin,
"0.8");
+
std::ostringstream aStream;
aStream << SketcherPrs_Tools::getDefaultArrowSize();
Config_PropManager::registerProp("Visualization", "dimension_arrow_size",
"Feature items in Object Browser",
Config_Prop::Color, FEATURE_ITEM_COLOR);
+ Config_PropManager::registerProp("Visualization", "zoom_trihedron_arrows",
+ "Keep trihedron arrows view size constant", Config_Prop::Boolean, "false");
+
+ Config_PropManager::registerProp("Visualization", "axis_arrow_size",
+ "Trihedron arrows constant size", Config_Prop::IntSpin, "10");
+
Config_PropManager::registerProp("Shortcuts", "add_parameter_shortcut",
"Add parameter in parameters manager dialog",
Config_Prop::Shortcut, "Ctrl+A");
return;
bool isModified = false;
+ double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
if (aCurrentOperation &&
(PartSet_SketcherMgr::isSketchOperation(aCurrentOperation) ||
sketchMgr()->isNestedSketchOperation(aCurrentOperation) ||
(aCurrentOperation->id() == "Measurement")))
{
- double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
SketcherPrs_Tools::setArrowSize(aLen);
const double aCurScale = aViewer->activeView()->Camera()->Scale();
aViewer->SetScale(aViewer->activeView(), aCurScale);
isModified = true;
}
}
- if (isModified)
- aDisplayer->updateViewer();
}
+ // Manage trihedron arrows
+ if (Config_PropManager::boolean("Visualization", "zoom_trihedron_arrows")) {
+ Handle(AIS_Trihedron) aTrihedron = aViewer->trihedron();
+ if (!aTrihedron.IsNull()) {
+ double aAxLen =
+ aView->Convert(Config_PropManager::integer("Visualization", "axis_arrow_size"));
+ Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+ double aAxisLen = aDatumAspect->AxisLength(Prs3d_DP_XAxis);
+ aDatumAspect->SetAttribute(Prs3d_DP_ShadingConeLengthPercent, aAxLen / aAxisLen);
+ aTrihedron->Attributes()->SetDatumAspect(aDatumAspect);
+ aContext->Redisplay(aTrihedron, false);
+ isModified = true;
+ }
+ }
+ if (isModified)
+ aDisplayer->updateViewer();
}
//******************************************************
void PartSet_Module::enableCustomModes() {
myCustomPrs->enableCustomModes();
}
+
+//******************************************************
+void PartSet_Module::onConflictingConstraints()
+{
+ const std::set<ObjectPtr>& aConstraints = myOverconstraintListener->conflictingObjects();
+ QObjectPtrList aObjectsList;
+ std::set<ObjectPtr>::const_iterator aIt;
+ for (aIt = aConstraints.cbegin(); aIt != aConstraints.cend(); aIt++) {
+ if (mySketchReentrantMgr->isLastAutoConstraint(*aIt))
+ aObjectsList.append(*aIt);
+ }
+ if (aObjectsList.size() > 0) {
+ XGUI_Workshop* aWorkshop = getWorkshop();
+ QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
+ ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription);
+ XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
+
+ ModuleBase_Operation* anOp = anOpMgr->currentOperation();
+ if (sketchMgr()->isNestedSketchOperation(anOp))
+ anOp->abort();
+
+ anOpMgr->startOperation(anOpAction);
+ aWorkshop->deleteFeatures(aObjectsList);
+ anOpMgr->commitOperation();
+ ModuleBase_Tools::flushUpdated(sketchMgr()->activeSketch());
+ }
+}
/// Called on transformation in current viewer
/// \param theTrsfType type of tranformation
- void onViewTransformed(int theTrsfType = 2);
+ virtual void onViewTransformed(int theTrsfType = 2);
+
+ void onConflictingConstraints();
protected slots:
/// Called when previous operation is finished
#include "SketchPlugin_SketchEntity.h"
#include "SketchPlugin_MacroArcReentrantMessage.h"
#include "SketchPlugin_Sketch.h"
+#include "SketchPlugin_ConstraintHorizontal.h"
+#include "SketchPlugin_ConstraintVertical.h"
#include "Events_Loop.h"
#include <ModuleBase_Tools.h>
#include <QString>
+#include <QTimer>
//#define DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
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) {
// set error state for new objects and append them in the internal map of objects
std::set<ObjectPtr>::const_iterator
anIt = theConflictingObjects.begin(), aLast = theConflictingObjects.end();
+ FeaturePtr aFeature;
+ bool isHVConstraint = false;
for (; anIt != aLast; anIt++) {
ObjectPtr anObject = *anIt;
if (myConflictingObjects.find(anObject) == myConflictingObjects.end()) { // it is not found
aModifiedObjects.insert(anObject);
myConflictingObjects.insert(anObject);
}
+ if (!isHVConstraint) {
+ aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+ if (aFeature) {
+ std::string aType = aFeature->getKind();
+ isHVConstraint = (aType == SketchPlugin_ConstraintHorizontal::ID()) ||
+ (aType == SketchPlugin_ConstraintVertical::ID());
+ }
+ }
}
bool isUpdated = !aModifiedObjects.empty();
if (isUpdated)
redisplayObjects(aModifiedObjects);
+ // If the conflicting object is an automatic constraint caused the conflict
+ // then it has to be deleted
+ if (isHVConstraint) {
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ QTimer::singleShot(5, aModule, SLOT(onConflictingConstraints()));
+ }
+
return isUpdated;
}
ObjectPtr anObject = *anIt;
if (theConflictingObjects.find(anObject) != theConflictingObjects.end()) { // it is found
myConflictingObjects.erase(anObject);
-
aModifiedObjects.insert(anObject);
}
}
return (myConflictingObjects.find(theObject) != myConflictingObjects.end());
}
+ const std::set<ObjectPtr>& conflictingObjects() const
+ {
+ return myConflictingObjects;
+ }
+
bool isFullyConstrained() const { return myIsFullyConstrained; }
protected:
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();
myIsFlagsBlocked(false),
myIsInternalEditOperation(false),
myNoMoreWidgetsAttribute(""),
- myIsAutoConstraints(true)
+ myIsAutoConstraints(true),
+ myLastAutoConstraint(0)
{
}
double aTolerance = Config_PropManager::real(SKETCH_TAB_NAME, "angular_tolerance");
CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
FeaturePtr aFeature;
- if (aHorAngle < aTolerance)
+ if (aHorAngle < aTolerance) {
// Add horizontal constraint
aFeature = aSketch->addFeature(SketchPlugin_ConstraintHorizontal::ID());
- else if (aVertAngle < aTolerance)
+ }
+ else if (aVertAngle < aTolerance) {
// Add vertical constraint
aFeature = aSketch->addFeature(SketchPlugin_ConstraintVertical::ID());
-
+ }
if (aFeature.get()) {
aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())->setObject(
theFeature->firstResult());
+ myLastAutoConstraint = aFeature.get();
}
}
}
+
+
+bool PartSet_SketcherReentrantMgr::isLastAutoConstraint(const ObjectPtr& theObj) const
+{
+ return theObj.get() == myLastAutoConstraint;
+}
bool isAutoConstraints() const { return myIsAutoConstraints; }
+ bool isLastAutoConstraint(const ObjectPtr& theObj) const;
+
public slots:
/// The slot is called when user checks "Automatic constraints" button
/// \param isOn a state of the check box
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);
#include <SketchPlugin_Point.h>
#include <GeomAPI_Edge.h>
+#include <Locale_Convert.h>
+
#include <list>
#include <unordered_map>
#ifdef _DEBUG
continue;
if (isObject) {
if (aRef->object() == anObject) {
- theError = errorMessage(EqualObjects, anObject.get() ? anObject->data()->name() : "",
- theAttribute->id(), aRef->id());
+ theError = errorMessage(EqualObjects,
+ anObject.get() ? Locale::Convert::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() ? Locale::Convert::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()?
+ Locale::Convert::toString(aCurSelObject->data()->name()) : "",
+ theAttribute->id(), aCurSelList->id());
return false;
}
}
#include <ModuleBase_IPropertyPanel.h>
#include <ModuleBase_OperationFeature.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_ChoiceCtrl.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_ISelectionActivate.h>
#include <Config_WidgetAPI.h>
#define DEBUG_UNDO_INVALID_SKETCH
+
+
+QStringList getIconsList(const QStringList& theNames)
+{
+ QStringList aIcons;
+ foreach(QString aName, theNames) {
+ QString aUName = aName.toUpper();
+ if ((aUName == "VERTICES") || (aUName == "VERTEX"))
+ aIcons << ":pictures/vertex32.png";
+ else if ((aUName == "EDGES") || (aUName == "EDGE"))
+ aIcons << ":pictures/edge32.png";
+ else if ((aUName == "FACES") || (aUName == "FACE"))
+ aIcons << ":pictures/face32.png";
+ }
+ return aIcons;
+}
+
+
+
PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent,
PartSet_Module* theModule,
const Config_WidgetAPI* theData)
aLayout->addWidget(mySizeOfViewWidget);
aLayout->addWidget(myLabel);
- aLayout->addStretch(1);
std::string aTypes = theData->getProperty("shape_types");
myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts);
+ myIsUseChoice = theData->getBooleanAttribute("use_choice", false);
+
+ QStringList aIconsList;
+ std::string aIcons = theData->getProperty("type_icons");
+ if (aIcons.size() > 0)
+ aIconsList = QString(aIcons.c_str()).split(' ', QString::SkipEmptyParts);
+
+ if (aIconsList.size() != myShapeTypes.size())
+ aIconsList = getIconsList(myShapeTypes);
+
+ myTypeCtrl = new ModuleBase_ChoiceCtrl(this, myShapeTypes, aIconsList);
+ myTypeCtrl->setLabel(tr("Type"));
+ if (!myShapeTypes.empty()) {
+ std::string aDefType = theData->getProperty("default_type");
+ if (aDefType.size() > 0) {
+ bool aOk = false;
+ int aId = QString(aDefType.c_str()).toInt(&aOk);
+ if (aOk) {
+ myTypeCtrl->setValue(aId);
+ myDefMode = myShapeTypes.at(aId).toStdString();
+ }
+ }
+ if (myDefMode.size() == 0) {
+ myTypeCtrl->setValue(0);
+ myDefMode = myShapeTypes.first().toStdString();
+ }
+ }
+ aLayout->addWidget(myTypeCtrl);
+ // There is no sense to parameterize list of types while we can not parameterize selection mode
+ // if the xml definition contains one type, the controls to select a type should not be shown
+ if (myShapeTypes.size() <= 1 || !myIsUseChoice) {
+ myTypeCtrl->setVisible(false);
+ }
+ connect(myTypeCtrl, SIGNAL(valueChanged(int)), this, SLOT(onSelectionTypeChanged()));
+ aLayout->addStretch(1);
myPreviewPlanes = new PartSet_PreviewPlanes();
}
QIntList PartSet_WidgetSketchCreator::shapeTypes() const
{
QIntList aShapeTypes;
- foreach(QString aType, myShapeTypes) {
- aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
+ if (myShapeTypes.length() > 1 && myIsUseChoice) {
+ aShapeTypes.append(ModuleBase_Tools::shapeType(myTypeCtrl->textValue()));
+ }
+ else {
+ foreach(QString aType, myShapeTypes) {
+ aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
+ }
}
return aShapeTypes;
}
eachControl->setEnabled(theEnabled);
}
}
+
+void PartSet_WidgetSketchCreator::onSelectionTypeChanged()
+{
+ // Clear current selection in order to avoid updating of object browser with obsolete indexes
+ // which can appear because of results deletetion after changing a type of selection
+ QString aSelectionType = myTypeCtrl->textValue();
+ QList<ModuleBase_ViewerPrsPtr> aEmptyList;
+ myWorkshop->setSelected(aEmptyList);
+
+ updateSelectionModesAndFilters(true);
+ myWorkshop->selectionActivate()->updateSelectionModes();
+
+ if (!myFeature)
+ return;
+
+ if (aSelectionType != "Faces") {
+ setVisibleSelectionControl(false);
+ myWorkshop->propertyPanel()->activateNextWidget();
+ }
+
+ /// store the selected type
+ AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
+ anAttrList->setSelectionType(aSelectionType.toStdString());
+ anAttrList->clear();
+
+ // update object is necessary to flush update signal. It leads to objects references map update
+ // and the operation presentation will not contain deleted items visualized as parameters of
+ // the feature.
+ updateObject(myFeature);
+ myWorkshop->propertyPanel()->activeWidget()->restoreValue();
+ myWorkshop->setSelected(getAttributeSelection());
+ // may be the feature's result is not displayed, but attributes should be
+ // hope that something is redisplayed by object updated
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments, true);
+}
\ No newline at end of file
class ModuleBase_Operation;
class ModuleBase_IWorkshop;
class PartSet_PreviewPlanes;
+class ModuleBase_ChoiceCtrl;
/**
* \ingroup Modules
private slots:
void onResumed(ModuleBase_Operation* theOp);
+ /// Slot is called on selection type changed
+ void onSelectionTypeChanged();
+
private:
/// Append new Sketch, set the selected plane for the sketch and start Edit operation.
/// \param theValues a selection list
/// class to show/hide preview planes
PartSet_PreviewPlanes* myPreviewPlanes;
+
+ bool myIsUseChoice; ///< A flag to store use_choice parameter state
+
+ /// Control for types
+ ModuleBase_ChoiceCtrl* myTypeCtrl;
+ std::string myDefMode;
};
#endif
\ No newline at end of file
- <!DOCTYPE RCC><RCC version="1.0">
- <qresource>
- <file>icons/activate.png</file>
- <file>icons/angle_32x32.png</file>
- <file>icons/concealed_on.png</file>
- <file>icons/concealed_off.png</file>
- <file>icons/deactivate.png</file>
- <file>icons/edit.png</file>
- <file>icons/exec_state_failed.png</file>
- <file>icons/exec_state_invalid_parameters.png</file>
- <file>icons/hand_point.png</file>
- <file>icons/move_to_end.png</file>
- <file>icons/sketch_shape.png</file>
- <file>icons/expression.png</file>
- <file>icons/paper_roll.png</file>
-
- <file>icons/group_edge.png</file>
- <file>icons/group_face.png</file>
- <file>icons/group_solid.png</file>
- <file>icons/group_vertex.png</file>
- <file>icons/toWork.png</file>
- <file>icons/isFailed.png</file>
- <file>icons/hasWarning.png</file>
- </qresource>
- </RCC>
+<RCC>
+ <qresource prefix="/">
+ <file>icons/activate.png</file>
+ <file>icons/angle_32x32.png</file>
+ <file>icons/concealed_on.png</file>
+ <file>icons/concealed_off.png</file>
+ <file>icons/deactivate.png</file>
+ <file>icons/edit.png</file>
+ <file>icons/exec_state_failed.png</file>
+ <file>icons/exec_state_invalid_parameters.png</file>
+ <file>icons/hand_point.png</file>
+ <file>icons/move_to_end.png</file>
+ <file>icons/sketch_shape.png</file>
+ <file>icons/expression.png</file>
+ <file>icons/paper_roll.png</file>
+ <file>icons/group_edge.png</file>
+ <file>icons/group_face.png</file>
+ <file>icons/group_solid.png</file>
+ <file>icons/group_vertex.png</file>
+ <file>icons/toWork.png</file>
+ <file>icons/isFailed.png</file>
+ <file>icons/hasWarning.png</file>
+ <file>icons/extrusion_edge32.png</file>
+ <file>icons/extrusion_face32.png</file>
+ <file>icons/extrusion_vertex32.png</file>
+ </qresource>
+</RCC>
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>());
SHAPERGUI::SHAPERGUI()
: LightApp_Module("SHAPER"),
mySelector(0), myIsOpened(0), myPopupMgr(0), myIsInspectionVisible(false),
- myInspectionPanel(0), myIsFacesPanelVisible(false), myIsToolbarsModified(false)
+ myInspectionPanel(0), myIsFacesPanelVisible(false), myIsToolbarsModified(false),
+ myAxisArrowRate(-1)
{
myWorkshop = new XGUI_Workshop(this);
connect(myWorkshop, SIGNAL(commandStatusUpdated()),
XGUI_Displayer* aDisp = myWorkshop->displayer();
QObjectPtrList aObjList = aDisp->displayedObjects();
- //if (myHighlightPointAspect.IsNull()) {
- // Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron();
- // myHighlightPointAspect =
- // new Graphic3d_AspectMarker3d(aTrihedron->getHighlightPointAspect()->Aspect().operator*());
- //}
if (myOldSelectionColor.size() == 0)
myOldSelectionColor = aDisp->selectionColor();
}
// Delete selector because it has to be redefined on next activation
if (mySelector) {
- //if (!myHighlightPointAspect.IsNull()) {
- // Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron();
- // aTrihedron->getHighlightPointAspect()->SetAspect(myHighlightPointAspect);
- // myHighlightPointAspect.Nullify();
- //}
+ // Restore size of arrows of trihedron
+ if (myAxisArrowRate > 0) {
+ Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron();
+ Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+ aDatumAspect->SetAttribute(Prs3d_DP_ShadingConeLengthPercent, myAxisArrowRate);
+ Handle(AIS_InteractiveContext) aContext = mySelector->viewer()->getAISContext();
+ aContext->Redisplay(aTrihedron, false);
+ }
myWorkshop->displayer()->setSelectionColor(myOldSelectionColor);
myProxyViewer->setSelector(0);
if (theMgr->getType() == OCCViewer_Viewer::Type()) {
OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
- //if (myHighlightPointAspect.IsNull()) {
- // Handle(AIS_Trihedron) aTrihedron = aViewer->getTrihedron();
- // myHighlightPointAspect =
- // new Graphic3d_AspectMarker3d(aTrihedron->getHighlightPointAspect()->Aspect().operator*());
- //}
+ // Remember current length of arrow of axis
+ Handle(AIS_Trihedron) aTrihedron = aViewer->getTrihedron();
+ Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+ myAxisArrowRate = aDatumAspect->Attribute(Prs3d_DP_ShadingConeLengthPercent);
+
SHAPERGUI_OCCSelector* aSelector = new SHAPERGUI_OCCSelector(aViewer,
getApp()->selectionMgr());
#ifdef SALOME_PATCH_FOR_CTRL_WHEEL
std::vector<int> aColor = Config_PropManager::color("Visualization", "selection_color");
myWorkshop->displayer()->setSelectionColor(aColor);
+
+ // Cause scaling of arrows of axis and dimensions
+ myWorkshop->module()->onViewTransformed();
+
return aSelector;
}
return 0;
std::vector<int> myOldSelectionColor;
Handle(Graphic3d_AspectMarker3d) myHighlightPointAspect;
+
+ double myAxisArrowRate;
};
#endif
#include <QMouseEvent>
#include <QContextMenuEvent>
+#include <QTimer>
#if OCC_VERSION_HEX < 0x070400
#define SALOME_PATCH_FOR_CTRL_WHEEL
myWindowScale.insert(aView->getViewPort()->getView(),
aView->getViewPort()->getView()->Camera()->Scale());
- emit viewCreated(myView);
+ QTimer::singleShot(10, this, SLOT(onAfterViewCreated()));
+ emit viewCreated(myView);
+}
+//**********************************************
+void SHAPERGUI_SalomeViewer::onAfterViewCreated()
+{
+ // Update trihedron and dimension arrows
+ emit onViewTransformed(OCCViewer_ViewWindow::ZOOMVIEW);
}
+
//**********************************************
void SHAPERGUI_SalomeViewer::onActivated(SUIT_ViewManager* theMgr)
{
/// It is necessary to activate the viewer trihedron in the current selection mode
void onViewPortMapped();
+ /// Signal called in order to apdate viewer transformed objects
+ void onAfterViewCreated();
+
private:
SHAPERGUI_OCCSelector* mySelector;
SHAPERGUI_SalomeView* myView;
)
SET(PROJECT_LIBRARIES
+ Locale
${OpenCASCADE_ApplicationFramework_LIBRARIES}
GeomAPI
GeomAlgoAPI
)
SET(PROJECT_INCLUDES
+ ../Locale
${OpenCASCADE_INCLUDE_DIR}
../GeomAPI
../GeomAlgoAPI
}
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;
- if (theName[0] == '[') { // intersection or container
+ if (theName[0] == L'[') { // intersection or container
switch(theShapeType) {
case TopAbs_COMPOUND:
case TopAbs_COMPSOLID:
break;
default:;
}
- } else if (theName[0] == '(') { // filter by neighbors
+ } else if (theName[0] == L'(') { // filter by neighbors
aResult = new Selector_FilterByNeighbors;
} else if (theName.find(pureWeakNameID()) == 0 ||
theName.find(oldPureWeakNameID()) == 0) { // weak naming identifier
aResult = new Selector_WeakName;
- } else if (theName.find('&') != std::string::npos) { // modification
+ } else if (theName.find(L'&') != std::wstring::npos) { // modification
aResult = new Selector_Modify;
} else { // primitive
aResult = new Selector_Primitive;
/// 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;
}
/// old string identifier of the weak name in modification or intersection types of algorithm
- static const std::string& oldWeakNameID()
+ static const std::wstring& oldWeakNameID()
{
- static const std::string kWEAK_NAME_IDENTIFIER = "weak_name_";
+ static const std::wstring kWEAK_NAME_IDENTIFIER = L"weak_name_";
return kWEAK_NAME_IDENTIFIER;
}
/// old string identifier of the pure weak name
- static const std::string& oldPureWeakNameID()
+ static const std::wstring& oldPureWeakNameID()
{
- 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;
}
/// 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 = std::string("new_") + oldWeakNameID();
+ static const std::wstring kWEAK_NAME_IDENTIFIER = std::wstring(L"new_") + oldWeakNameID();
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 = std::string("_new") + oldPureWeakNameID();
+ static const std::wstring kPURE_WEAK_NAME_IDENTIFIER =
+ std::wstring(L"_new") + oldPureWeakNameID();
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;
TDF_Label aContext;
- 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) {
+ for(size_t aStart = 0; aStart != std::wstring::npos; aStart = theName.find('[', aStart + 1)) {
+ size_t anEndPos = theName.find(L']', aStart + 1);
+ if (anEndPos != std::wstring::npos) {
// there could be sub-intersections, so, [[...]] case; searching for other open-bracket
- size_t aNextStart = theName.find('[', aStart + 1);
- while(aNextStart != std::string::npos && aNextStart < anEndPos) {
- anEndPos = theName.find(']', anEndPos + 1);
- if (anEndPos == std::string::npos) {
+ size_t aNextStart = theName.find(L'[', aStart + 1);
+ while(aNextStart != std::wstring::npos && aNextStart < anEndPos) {
+ anEndPos = theName.find(L']', anEndPos + 1);
+ if (anEndPos == std::wstring::npos) {
return TDF_Label(); // invalid parentheses
}
- aNextStart = theName.find('[', aNextStart + 1);
+ aNextStart = theName.find(L'[', aNextStart + 1);
}
- if (anEndPos == std::string::npos)
+ if (anEndPos == std::wstring::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
- 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 aLastLevel; // last level string (after '(' ) to check the context name in the end
+ for (size_t aStart = 0; aStart != std::wstring::npos;
+ aStart = theName.find(L'(', aStart + 1)) {
+ size_t anEndPos = theName.find(L')', aStart + 1);
+ if (anEndPos != std::wstring::npos) {
+ 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;
- for (anEndPos++; anEndPos != std::string::npos &&
- theName[anEndPos] != '(' && theName[anEndPos] != 0;
+ std::wstring aLevel;
+ for (anEndPos++; anEndPos != std::wstring::npos &&
+ theName[anEndPos] != L'(' && theName[anEndPos] != 0;
anEndPos++) {
aLevel += theName[anEndPos];
}
aLastLevel = aLevel;
- if (aLevel.empty() || aLevel[0] == '_')
+ if (aLevel.empty() || aLevel[0] == L'_')
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("_");
- if (aLinePos != std::string::npos) {
- std::string aContextName = aLastLevel.substr(aLinePos + 1);
+ size_t aLinePos = aLastLevel.find(L"_");
+ if (aLinePos != std::wstring::npos) {
+ 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();
#include <Selector_NameGenerator.h>
#include <Selector_NExplode.h>
+#include <Locale_Convert.h>
+
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_Integer.hxx>
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;
TDF_Label aContext;
- 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);
+ for(size_t aStart = 0; aStart != std::wstring::npos; aStart = theName.find(L'[', aStart + 1)) {
+ size_t anEndPos = theName.find(L']', aStart + 1);
+ if (anEndPos != std::wstring::npos) {
+ std::wstring aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1);
size_t aFoundOldWeak = aSubStr.find(oldWeakNameID());
- size_t aFoundNewWeak = aFoundOldWeak != std::string::npos ?
+ size_t aFoundNewWeak = aFoundOldWeak != std::wstring::npos ?
aSubStr.find(weakNameID()) :
aFoundOldWeak;
if (aFoundOldWeak == 0 || aFoundNewWeak == 0) { // weak name identifier
- std::string aWeakIndex = aSubStr.substr(aFoundOldWeak + oldWeakNameID().size());
- myWeakIndex = atoi(aWeakIndex.c_str());
+ std::wstring aWeakIndex = aSubStr.substr(aFoundOldWeak + oldWeakNameID().size());
+ myWeakIndex = atoi(Locale::Convert::toString(aWeakIndex).c_str());
myRecomputeWeakIndex = aFoundOldWeak == 0;
continue;
}
TopAbs_ShapeEnum aSubShapeType = TopAbs_FACE;
- if (anEndPos != std::string::npos && anEndPos + 1 < theName.size()) {
- char aShapeChar = theName[anEndPos + 1];
- if (theName[anEndPos + 1] != '[') {
+ if (anEndPos != std::wstring::npos && anEndPos + 1 < theName.size()) {
+ wchar_t aShapeChar = theName[anEndPos + 1];
+ if (theName[anEndPos + 1] != L'[') {
switch(aShapeChar) {
case 'e': aSubShapeType = TopAbs_EDGE; break;
case 'v': aSubShapeType = TopAbs_VERTEX; 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();
#include <Selector_NameGenerator.h>
#include <Selector_NExplode.h>
+#include <Locale_Convert.h>
+
#include <TNaming_NamedShape.hxx>
#include <TNaming_Iterator.hxx>
#include <TNaming_SameShapeIterator.hxx>
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)
{
typedef NCollection_DataMap<TopoDS_Shape, bool, TopTools_ShapeMapHasher> MapOfCompsolids;
MapOfCompsolids aWrongSubsCompsolids;
TDF_Label aContext;
- for(size_t anEnd, aStart = 0; aStart != std::string::npos; aStart = anEnd) {
+ for(size_t anEnd, aStart = 0; aStart != std::wstring::npos; aStart = anEnd) {
if (aStart != 0)
aStart++;
- anEnd = theName.find('&', aStart);
- std::string aSubStr =
- theName.substr(aStart, anEnd == std::string::npos ? anEnd : anEnd - aStart);
+ anEnd = theName.find(L'&', aStart);
+ std::wstring aSubStr =
+ theName.substr(aStart, anEnd == std::wstring::npos ? anEnd : anEnd - aStart);
size_t aFoundOldWeak = aSubStr.find(oldWeakNameID());
- size_t aFoundNewWeak = aFoundOldWeak != std::string::npos ?
+ size_t aFoundNewWeak = aFoundOldWeak != std::wstring::npos ?
aSubStr.find(weakNameID()) :
aFoundOldWeak;
if (aFoundOldWeak == 0 || aFoundNewWeak == 0) { // weak name identifier
- std::string aWeakIndex = aSubStr.substr(aFoundOldWeak + oldWeakNameID().size());
- myWeakIndex = atoi(aWeakIndex.c_str());
+ std::wstring aWeakIndex = aSubStr.substr(aFoundOldWeak + oldWeakNameID().size());
+ myWeakIndex = atoi(Locale::Convert::toString(aWeakIndex).c_str());
myRecomputeWeakIndex = aFoundOldWeak == 0;
continue;
}
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 += Locale::Convert::toWString(aName->Get().ToExtString());
for(TDF_LabelList::iterator aBase = myBases.begin(); aBase != myBases.end(); aBase++) {
if (!aBase->FindAttribute(TDataStd_Name::GetID(), aName))
- return "";
- aResult += "&";
- aResult += theNameGenerator->contextName(*aBase) + "/" +
- std::string(TCollection_AsciiString(aName->Get()).ToCString());
+ return L"";
+ aResult += L"&";
+ aResult += theNameGenerator->contextName(*aBase) + L"/";
+ aResult += Locale::Convert::toWString(aName->Get().ToExtString());
}
if (myWeakIndex != -1) {
- std::ostringstream aWeakStr;
- aWeakStr<<"&"<<weakNameID()<<myWeakIndex;
+ std::wostringstream aWeakStr;
+ aWeakStr<<L"&"<<weakNameID()<<myWeakIndex;
aResult += aWeakStr.str();
}
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_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
#include <Selector_NameGenerator.h>
+#include <Locale_Convert.h>
+
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Name.hxx>
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 += Locale::Convert::toWString(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);
#include <Selector_NameGenerator.h>
#include <Selector_NExplode.h>
+#include <Locale_Convert.h>
+
#include <TNaming_Tool.hxx>
#include <TNaming_SameShapeIterator.hxx>
#include <TNaming_Iterator.hxx>
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)
{
size_t aFoundWeak = theName.find(oldPureWeakNameID());
- std::string aWeakIndex = theName.substr(aFoundWeak + oldPureWeakNameID().size());
- std::size_t aContextPosition = aWeakIndex.find("_");
- myWeakIndex = atoi(aWeakIndex.c_str());
+ std::wstring aWeakIndex = theName.substr(aFoundWeak + oldPureWeakNameID().size());
+ std::size_t aContextPosition = aWeakIndex.find(L"_");
+ myWeakIndex = atoi(Locale::Convert::toString(aWeakIndex).c_str());
myRecomputeWeakIndex = aFoundWeak == 0;
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();
SET(PROJECT_LIBRARIES
GeomAlgoAPI
+ Locale
ModelAPI
ModelHighAPI
SketcherPrs
# Plugin headers dependency
INCLUDE_DIRECTORIES(
- # TODO(spo): modify ConstructionPlugin headers to remove dependency on GeomAPI headers
${PROJECT_SOURCE_DIR}/src/Config
+ ${PROJECT_SOURCE_DIR}/src/Locale
${PROJECT_SOURCE_DIR}/src/GeomAPI
${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
${PROJECT_SOURCE_DIR}/src/SketchPlugin
// 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 <GeomAlgoAPI_EdgeBuilder.h>
+#include <Locale_Convert.h>
+
#include <ModelHighAPI_Double.h>
#include <ModelHighAPI_Dumper.h>
#include <ModelHighAPI_Integer.h>
#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() << "_" << Locale::Convert::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 <GeomAPI_Pnt2d.h>
+#include <Locale_Convert.h>
+
#include <ModelHighAPI_Dumper.h>
#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"_" + Locale::Convert::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
}
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());
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
*/
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
Config
GeomAPI
GeomAlgoAPI
+ GeomDataAPI
+ Locale
ModelAPI
ModelGeomAlgo
ModuleBase
SketcherPrs
- GeomDataAPI
)
SET(XML_RESOURCES
INCLUDE_DIRECTORIES(
../Config
../Events
+ ../Locale
../ModelAPI
../ModelGeomAlgo
../ModuleBase
#include <SketchPlugin_Tools.h>
#include <SketchPlugin_Sketch.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeDoubleArray.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeRefAttrList.h>
#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 << "_" << Locale::Convert::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;
#include <GeomDataAPI_Point2D.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeBoolean.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeRefAttr.h>
}
if (theFeature->data()->isValid())
- anInfo.append(theFeature->data()->name().c_str());
+ anInfo.append(Locale::Convert::toString(theFeature->data()->name()));
if (isUseAttributesInfo) {
std::string aPointsInfo = ModelGeomAlgo_Point2D::getPontAttributesInfo(theFeature,
#include <SketcherPrs_Tools.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_Tools.h>
#include <ModelGeomAlgo_Point2D.h>
#include <ModelGeomAlgo_Shape.h>
std::set<FeaturePtr> aCoincToRes =
SketchPlugin_Tools::findCoincidentConstraints(theFeature->lastResult());
aCoincidences.insert(aCoincToRes.begin(), aCoincToRes.end());
- }\r std::set<FeaturePtr>::const_iterator aCIt = aCoincidences.begin();
+ }
+ std::set<FeaturePtr>::const_iterator aCIt = aCoincidences.begin();
for (; aCIt != aCoincidences.end(); ++aCIt)
{
if (theCoincidences.find(*aCIt) != theCoincidences.end())
aCoord->setValue(anElPoint->x(), anElPoint->y());
aPointFeature->execute();
- std::string aName = theEllipseFeature->name() + "_" + theEllipsePoint;
+ std::wstring aName = theEllipseFeature->name() + L"_" +
+ Locale::Convert::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());
+ if (aPos != std::wstring::npos) {
+ 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
#include <Events_InfoMessage.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_Data.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_AttributeDouble.h>
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() ? Locale::Convert::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) {
bool isFound = aSelObject == *anObjIter;
if (!isFound) {
// check in the results of the feature
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anObjIter);
- if (aFeature) {
- const std::list<ResultPtr>& aResults = aFeature->results();
+ FeaturePtr aCurFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anObjIter);
+ if (aCurFeature) {
+ const std::list<ResultPtr>& aResults = aCurFeature->results();
for (std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
aResIt != aResults.end() && !isFound; ++aResIt) {
isFound = aSelObject == *aResIt;
}
}
if (isFound) {
- std::string aName = aSelObject.get() ? aSelObject->data()->name() : "";
+ std::string aName =
+ aSelObject.get() ? Locale::Convert::toString(aSelObject->data()->name()) : "";
theError = "The object %1 is a result of copy";
theError.arg(aName);
return false;
}
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) {
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);
myWorkshop->salomeConnector()->viewer()->setColorScaleTitle(theText);
#else
Handle(AIS_ColorScale) aColorScale = myWorkshop->mainWindow()->viewer()->colorScale();
- aColorScale->SetTitle(theText.toStdString().c_str());
+ aColorScale->SetTitle(theText.toStdWString().c_str());
#endif
}
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);
}
}