]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[bos #26444] [EDF] (2021) SHAPER: Improve treatment of parameters
authorAlexey Kondratyev <alexey.kondratyev@opencascade.com>
Mon, 11 Oct 2021 07:47:07 +0000 (10:47 +0300)
committerAlexey Kondratyev <alexey.kondratyev@opencascade.com>
Fri, 29 Oct 2021 06:46:00 +0000 (09:46 +0300)
Update "addParameters" to use French and Russian chars in comments.

Update "importParameters" to import French and Russian chars in comments from file.

Update parameter manager to use French and Russian chars in comments.

src/ModelHighAPI/ModelHighAPI_Tools.cpp
src/ModelHighAPI/ModelHighAPI_Tools.h
src/ParametersAPI/ParametersAPI.i
src/ParametersAPI/ParametersAPI_Parameter.cpp
src/ParametersAPI/ParametersAPI_Parameter.h
src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp
src/PythonAPI/Test/TestInsertParameter.py
src/PythonAPI/model/parameter/import_parameter.py

index 8208eba768f06f201a0e2b8913e94a15c7161aff..14ab9887894f1c487822341e04a9d81b46a10bc9 100644 (file)
@@ -224,6 +224,13 @@ void fillAttribute(const std::string & theValue,
   theAttribute->setValue(theValue);
 }
 
+//--------------------------------------------------------------------------------------
+void fillAttribute(const std::wstring & theValue,
+  const std::shared_ptr<ModelAPI_AttributeString> & theAttribute)
+{
+  theAttribute->setValue(theValue);
+}
+
 //--------------------------------------------------------------------------------------
 void fillAttribute(const char * theValue,
                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute)
index 7f0e1c8962d7bbcc248a7e8a4092a0135525162c..a476721a65141b860ef62b879bf094dab566ae4a 100644 (file)
@@ -136,6 +136,11 @@ void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
 MODELHIGHAPI_EXPORT
 void fillAttribute(const std::string & theValue,
                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
+
+MODELHIGHAPI_EXPORT
+void fillAttribute(const std::wstring & theValue,
+  const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
+
 MODELHIGHAPI_EXPORT
 void fillAttribute(const char * theValue,
                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
index 6922c1f968a0db3e3ddc936a71bf4273927f762e..8d8a59c74318f9de31f70cc14cd8121bebd0b5d2 100644 (file)
 
 %{
   #include "ParametersAPI_swig.h"
+
+  // fix for SWIG v2.0.4
+  #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
+
+  #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj))
 %}
 
 %include "doxyhelp.i"
index 27c687ad349886bdd3f3e85b985d1a851cb3dffb..9079094a40eeb6cde3a10f4fbcb77c93c0ff2888 100644 (file)
@@ -35,7 +35,7 @@ ParametersAPI_Parameter::ParametersAPI_Parameter(
     const std::shared_ptr<ModelAPI_Feature> & theFeature,
     const std::string & theName,
     const std::string & theExpression,
-    const std::string & theComment)
+    const std::wstring & theComment)
 : ModelHighAPI_Interface(theFeature)
 {
   if (initialize()) {
@@ -87,7 +87,7 @@ void ParametersAPI_Parameter::dump(ModelHighAPI_Dumper& theDumper) const
 ParameterPtr addParameter(const std::shared_ptr<ModelAPI_Document> & thePart,
                           const std::string & theName,
                           const std::string & theExpression,
-                          const std::string & theComment)
+                          const std::wstring & theComment)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ParametersAPI_Parameter::ID());
   return ParameterPtr(new ParametersAPI_Parameter(aFeature, theName, theExpression, theComment));
index 50bb1d3b8f4f2eb279959a83fdb2298581d186b5..8295db3ccf47e0d0f7d0b7365923ca1c735b70d4 100644 (file)
@@ -45,7 +45,7 @@ public:
   explicit ParametersAPI_Parameter(const  std::shared_ptr<ModelAPI_Feature> & theFeature,
                                    const std::string & theName,
                                    const std::string & theExpression,
-                                   const std::string & theComment = std::string());
+                                   const std::wstring & theComment = std::wstring());
   /// Destructor
   PARAMETERSAPI_EXPORT
   virtual ~ParametersAPI_Parameter();
@@ -80,7 +80,7 @@ PARAMETERSAPI_EXPORT
 ParameterPtr addParameter(const std::shared_ptr<ModelAPI_Document> & thePart,
                           const std::string & theName,
                           const std::string & theExpression,
-                          const std::string & theComment = std::string());
+                          const std::wstring & theComment = std::wstring());
 
 /**\ingroup CPPHighAPI
  * \brief Remove Parameter feature and substitute it by the value in referred features
index b2ca352114e3cfbdbf70fbb304f4497857e81e3f..3f3385ec927f45c053b8a91c679b55ad9adbd552 100644 (file)
@@ -526,7 +526,7 @@ void ParametersPlugin_WidgetParamsMgr::onCloseEditor(QWidget* theEditor,
   case Col_Comment:
     {
       AttributeStringPtr aStringAttr = aFeature->string(ParametersPlugin_Parameter::COMMENT_ID());
-      aStringAttr->setValue(aText.toStdString());
+      aStringAttr->setValue(aText.toStdWString());
       isModified = true;
     }
     break;
index 246a07a0e9e5b21c2a536d5e193926eb4aaaec49..97b7e13f5d95b3d05c117c73925866d76e4efb14 100644 (file)
@@ -31,10 +31,10 @@ nameFile = "PythonAPI_test_parametres1.txt"
 
 aDir = os.path.join(data_dir, nameFile)
 
-aFile = open(nameFile, 'w')
+aFile = open(nameFile, 'w', encoding = "utf_8")
 
-aFile.write("Longueur  36. # \"Comment\"\n")
-aFile.write("Largeur  24.  # Comment\n")
+aFile.write("Longueur  36. # \"Longueur de la pièce\"\n")
+aFile.write("Largeur  24.  # Largeur de la pièce\n")
 aFile.write("Hauteur  Longueur*Largeur\n")
 aFile.write("\n")
 aFile.write(" \n")
index d75275dfca4442501c5c1020c578e9b0063b9f3c..cc5b21427ca4774016d4e4ac2d77246cf5a4ce06 100644 (file)
 #
 
 from salome.shaper import model
+import codecs
 
 def importParameters(theDocument, theFileName):
 
     aResult = []
     try:
-        aFile = open(theFileName, 'r')
+        aFile = codecs.open(theFileName, 'r', encoding = 'utf_8_sig')
     except IOError:
         return aResult
 
@@ -36,7 +37,7 @@ def importParameters(theDocument, theFileName):
         isComment = False
         aFirstText = aLine.split(" ")[0]
 
-        aName = aFirstText.split("#")[0]
+        aName = aFirstText.split("#")[0].strip()
 
         aLine = aLine.lstrip(aName)
 
@@ -48,7 +49,7 @@ def importParameters(theDocument, theFileName):
         aComment = aLine
 
         if(len(aName) > 0):
-            aResult.append(model.addParameter(theDocument, aName.strip(), aParameter.strip(), aComment.strip()))
+            aResult.append(model.addParameter(theDocument, aName, aParameter.strip(), aComment.strip()))
 
     aFile.close()
     return aResult