X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Tools.cpp;h=119a0a1ebe7419fde56a05551a71a9065197b255;hb=2054879244f3323c305222c79c57d2db6a487538;hp=76b914b19ab3d0ba9d588e5426da67e674612f29;hpb=423c10234142d14d0d5de89383f2f96a4ec5930f;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index 76b914b19..119a0a1eb 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -194,12 +195,36 @@ void fillAttribute(const std::string & theValue, { theAttribute->setValue(theValue); } + +//-------------------------------------------------------------------------------------- void fillAttribute(const char * theValue, const std::shared_ptr & theAttribute) { theAttribute->setValue(theValue); } +//-------------------------------------------------------------------------------------- +void fillAttribute(const std::list & theValue, + const std::shared_ptr & theAttribute) +{ + theAttribute->setSize(int(theValue.size())); + + int anIndex = 0; + for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex) + theAttribute->setValue(anIndex, *it); +} + +//-------------------------------------------------------------------------------------- +void fillAttribute(const std::list & theValue, + const std::shared_ptr & theAttribute) +{ + theAttribute->setSize(int(theValue.size())); + + int anIndex = 0; + for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex) + theAttribute->setValue(anIndex, it->intValue()); // use only values, no text support in array +} + //================================================================================================== GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr) { @@ -260,6 +285,32 @@ GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection return aShapeType; } +//-------------------------------------------------------------------------------------- +ModelAPI_AttributeTables::ValueType valueTypeByStr(const std::string& theValueTypeStr) +{ + std::string aType = theValueTypeStr; + std::transform(aType.begin(), aType.end(), aType.begin(), ::tolower); + if (aType == "boolean") + return ModelAPI_AttributeTables::BOOLEAN; + else if (aType == "integer") + return ModelAPI_AttributeTables::INTEGER; + else if (aType == "string") + return ModelAPI_AttributeTables::STRING; + return ModelAPI_AttributeTables::DOUBLE; // default +} + +//-------------------------------------------------------------------------------------- +std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType) +{ + switch(theType) { + case ModelAPI_AttributeTables::BOOLEAN: return "BOOLEAN"; + case ModelAPI_AttributeTables::INTEGER: return "INTEGER"; + case ModelAPI_AttributeTables::DOUBLE: return "DOUBLE"; + case ModelAPI_AttributeTables::STRING: return "STRING"; + } + return ""; // bad case +} + /// stores the features information, recoursively stores sub-documetns features std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, std::map >& theStore,