int aPartitionVersion = version();
if (aPartitionVersion < THE_PARTITION_VERSION_1) {
- // default behaviours of Partition
+ // default behaviors of Partition
if(aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) {
for(GeomAPI_ShapeIterator anIt(aResultShape); anIt.more(); anIt.next()) {
storeResult(aBaseObjects, aPlanes, anIt.current(), aMakeShapeList, aResultIndex);
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
+#include <TDataStd_UAttribute.hxx>
#include <Standard_TypeDef.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <string>
+// on myLabel if the Unicode string was stored
+static const Standard_GUID kUVALUE_IDENTIFIER("04cac509-b2fc-4887-b442-d2a86f2fd7bd");
+
void Model_AttributeString::setValue(const std::string& theValue)
{
TCollection_ExtendedString aValue(theValue.c_str());
if (myString.IsNull())
myString = TDataStd_Name::Set(myLab, TCollection_ExtendedString());
myString->Set(aValue);
+ myLab.ForgetAttribute(kUVALUE_IDENTIFIER);
owner()->data()->sendAttributeUpdated(this);
}
}
if (myString.IsNull())
myString = TDataStd_Name::Set(myLab, TCollection_ExtendedString());
myString->Set(aValue);
+ TDataStd_UAttribute::Set(myLab, kUVALUE_IDENTIFIER);
owner()->data()->sendAttributeUpdated(this);
}
}
return ""; // not initialized
return TCollection_AsciiString(myString->Get()).ToCString();
}
+
char16_t* Model_AttributeString::valueU()
{
if (myString.IsNull()) { // not initialized
return (char16_t*)(myString->Get().ToExtString());
}
+bool Model_AttributeString::isUValue() const {
+ return !myLab.IsNull() && myLab.IsAttribute(kUVALUE_IDENTIFIER);
+}
+
Model_AttributeString::Model_AttributeString(TDF_Label& theLabel)
{
myLab = theLabel;
MODEL_EXPORT virtual std::string value();
/// Returns a pointer to Unicode string
MODEL_EXPORT virtual char16_t* valueU();
+ /// Returns true if Unicode string was stored
+ MODEL_EXPORT virtual bool isUValue() const;
protected:
/// Initializes attributes
MODELAPI_EXPORT virtual std::string value() = 0;
/// Returns a pointer to Unicode string
MODELAPI_EXPORT virtual char16_t* valueU() = 0;
+ MODELAPI_EXPORT virtual bool isUValue() const = 0;
/// Returns the type of this class of attributes
MODELAPI_EXPORT static std::string typeId()
#include <ModuleBase_Tools.h>
#include <ModelAPI_AttributeString.h>
+#include <Config_Translator.h>
+#include <QTextCodec>
#include <QLabel>
#include <QVBoxLayout>
DataPtr aData = myFeature->data();
AttributeStringPtr aStrAttr = aData->string(attributeID());
if (aStrAttr.get()) {
- std::string aMsg;
+ QString aText;
if (aStrAttr.get()) {
- aMsg = aStrAttr->value();
+ if (aStrAttr->isUValue()) { // already translated text
+ char16_t* aStr = aStrAttr->valueU();
+ std::wstring aWStr((wchar_t*)aStr);
+ static const int aBufSize = 1000;
+ static char aMBStr[aBufSize];
+ size_t aLen = wcstombs(aMBStr, aWStr.c_str(), aBufSize);
+ std::string aCodec = Config_Translator::codec("");
+ aText = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aMBStr);
+ } else {
+ std::string aMsg = aStrAttr->value();
+ aText = ModuleBase_Tools::translate(myFeature->getKind(), aMsg);
+ }
}
- QString aText = ModuleBase_Tools::translate(myFeature->getKind(), aMsg);
myLabel->setText(aText);
}
return true;
CompositeFeaturePtr aSketch = aModule->sketchMgr()->activeSketch();
if (aSketch.get()) {
std::string aDOFMessage = aSketch->string(SketchPlugin_Sketch::SOLVER_DOF())->value();
- myIsFullyConstrained = QString(aDOFMessage.c_str()).contains("DoF = 0");
+ myIsFullyConstrained = QString(aDOFMessage.c_str()).contains(" = 0");
}
}
}
// ============================================================================
void SketchSolver_Group::computeDoF()
{
- std::ostringstream aDoFMsg;
+ std::string aDoFMsg;
static const std::string aMsgContext("Sketch");
int aDoF = mySketchSolver->dof();
/// "DoF = 0" content of string value is used in PartSet by Sketch edit
/// If it is changed, it should be corrected also there
if (aDoF == 0) {
static const std::string aMsgDoF("Sketch is fully fixed (DoF = 0)");
- aDoFMsg << Config_Translator::translate(aMsgContext, aMsgDoF).c_str();
+ aDoFMsg = Config_Translator::translate(aMsgContext, aMsgDoF);
} else {
static const std::string aMsgDoF("DoF (degrees of freedom) = %1");
Events_InfoMessage aMsg(aMsgContext, aMsgDoF);
- aMsg.arg(aDoF);
- aDoFMsg << Config_Translator::translate(aMsg).c_str();
+ aMsg.addParameter(aDoF);
+ aDoFMsg = Config_Translator::translate(aMsg);
}
- mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aDoFMsg.str());
+ // store Unicode value for translated message about DoF
+ size_t aLen = aDoFMsg.size();
+ std::wstring aWStr(aLen, L'#');
+ mbstowcs(&aWStr[0], aDoFMsg.c_str(), aLen);
+ mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aWStr);
if (aDoF > 0 && myDOF <= 0)
sendMessage(EVENT_SKETCH_UNDER_CONSTRAINED, mySketch, aDoF);